Пример #1
0
function add_exp_for_craft($user_id, $prof_id, $times = 1)
{
    $exp = exp_for_craft($prof_id);
    if ($exp > 0) {
        save_exp($user_id, $exp * $times, 16);
    }
}
Пример #2
0
 private function nachisl_exp_gp_def($user_id, $exp = 0, $gp = 0, $k = 0)
 {
     if ($exp == 0 and $gp == 0) {
         $check = myquery("SELECT exp,gp FROM combat_users_exp WHERE combat_id=" . $this->combat['combat_id'] . " AND user_id = {$user_id} AND prot_id={$user_id} AND (exp>0 OR gp>0)");
         if (mysql_num_rows($check) > 0) {
             list($exp, $gp) = mysql_fetch_array($check);
             //Проверим - были ли такие бои уже
             $k = $this->get_combat_koef();
         }
     }
     if ($exp > 0 or $gp > 0) {
         $exp = max(1, $exp * $k);
         $gp = max(1, $gp * $k);
         save_gp($user_id, $gp, 109);
         save_exp($user_id, $exp, 18);
         $mes = '    За лечебные/защитные действия ты получаешь ';
         $mes .= '<b><font color="#FF0000">' . $exp . '</font></b> очков опыта и <b><font color="#FF0000">' . $gp . '</font></b> монет';
         $mes .= '</font><br>';
     }
 }
Пример #3
0
 public function use_item($id = 0)
 {
     global $char;
     if ($id > 0) {
         $this->init_item($id);
     }
     //можно использовать только эликсиры
     if ($this->fact['type'] == 13) {
         if ($this->item['user_id'] == $this->char['user_id']) {
             if ($this->item['priznak'] == 0) {
                 list($dlit) = mysql_fetch_array(myquery("SELECT dlit FROM game_eliksir_dlit WHERE elik_id=" . $this->fact['id'] . ""));
                 //эликсиры продолжительного действия
                 if ($dlit > 0) {
                     if ($this->fact['id'] == eliksir_bodrosti_item_id) {
                         //зелье бодрости
                         myquery("DELETE FROM game_obelisk_users WHERE user_id=" . $this->char['user_id'] . " AND type=3");
                         myquery("INSERT INTO game_obelisk_users (user_id,time_end,type) VALUES (" . $this->char['user_id'] . "," . (time() + $dlit) . ",3)");
                         $this->message = $this->message . '<b><font color=red>Ты ' . echo_sex('выпил', 'выпила') . ' зелье "' . $this->fact['name'] . '"</font></b><br>';
                     } elseif ($this->fact['id'] == eliksir_zorkosti_item_id) {
                         //зелье зоркости
                         myquery("DELETE FROM game_obelisk_users WHERE user_id=" . $this->char['user_id'] . " AND type=4");
                         myquery("INSERT INTO game_obelisk_users (user_id,time_end,type) VALUES (" . $this->char['user_id'] . "," . (time() + $dlit) . ",4)");
                         $this->message = $this->message . '<b><font color=red>Ты ' . echo_sex('выпил', 'выпила') . ' зелье "' . $this->fact['name'] . '"</font></b><br>';
                     } elseif ($this->fact['id'] == eliksir_nevidimka_item_id) {
                         //зелье невидимости
                         myquery("DELETE FROM game_obelisk_users WHERE user_id=" . $this->char['user_id'] . " AND type=5");
                         myquery("INSERT INTO game_obelisk_users (user_id,time_end,type) VALUES (" . $this->char['user_id'] . "," . (time() + $dlit) . ",5)");
                         $this->message = $this->message . '<b><font color=red>Ты ' . echo_sex('выпил', 'выпила') . ' зелье "' . $this->fact['name'] . '"</font></b><br>';
                     } elseif ($this->fact['id'] == eliksir_mogushestva_item_id) {
                         //зелье движения
                         //проверка на наличие действующего эликсира
                         $check = myquery("SELECT * FROM game_obelisk_users WHERE user_id=" . $this->char['user_id'] . " AND type=2 AND harka='PR' AND time_end>" . time() . "");
                         $effect = 50;
                         if (mysql_num_rows($check) > 0) {
                             myquery("UPDATE game_obelisk_users SET time_end=time_end+" . $dlit . " WHERE user_id=" . $this->char['user_id'] . " AND type=2 AND (harka='PR' or harka='PR_MAX') AND time_end>" . time() . "");
                         } else {
                             myquery("UPDATE game_users SET PR=PR+" . $effect . ", PR_MAX=PR_MAX+" . $effect . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'PR',2," . (time() + $dlit) . "," . $effect . "), (" . $this->char['user_id'] . ",'PR_MAX',2," . (time() + $dlit) . "," . $effect . ") ");
                         }
                         $this->message = $this->message . '<b><font color=red>Ты ' . echo_sex('выпил', 'выпила') . ' зелье "' . $this->fact['name'] . '"</font></b><br>';
                     } elseif ($this->fact['name'] == "Эликсир Барда") {
                         $r = mt_rand(1, 7);
                         $har2 = "";
                         switch ($r) {
                             case 1:
                                 $har_sql = "LUCKY=LUCKY+1";
                                 $har1 = "LUCKY";
                                 $har_name = "Удача";
                                 break;
                             case 2:
                                 $har_sql = "STR=STR+1";
                                 $har1 = "STR";
                                 $har_name = "Сила";
                                 break;
                             case 3:
                                 $har_sql = "SPD=SPD+1";
                                 $har1 = "SPD";
                                 $har_name = "Мудрость";
                                 break;
                             case 4:
                                 $har_sql = "NTL=NTL+1, MP_MAX=MP_MAX+15";
                                 $har1 = "NTL";
                                 $har2 = "MP_MAX";
                                 $har_name = "Интеллект";
                                 break;
                             case 5:
                                 $har_sql = "PIE=PIE+1, STM_MAX=STM_MAX+15";
                                 $har1 = "PIE";
                                 $har2 = "STM_MAX";
                                 $har_name = "Ловкость";
                                 break;
                             case 6:
                                 $har_sql = "VIT=VIT+1";
                                 $har1 = "VIT";
                                 $har_name = "Защита";
                                 break;
                             case 7:
                                 $har_sql = "DEX=DEX+1, HP_MAX=HP_MAX+15";
                                 $har1 = "DEX";
                                 $har2 = "HP_MAX";
                                 $har_name = "Выносливость";
                                 break;
                         }
                         myquery("UPDATE game_users SET " . $har_sql . " WHERE user_id=" . $this->char['user_id'] . "");
                         myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'" . $har1 . "',2," . (time() + $dlit) . ",1)");
                         if ($har2 != "") {
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'" . $har2 . "',2," . (time() + $dlit) . ",15)");
                         }
                         $this->message = $this->message . '<b><font color=red>Ты ' . echo_sex('выпил', 'выпила') . ' зелье "' . $this->fact['name'] . '".<br>Характеристика "' . $har_name . '" увеличена.</font></b><br>';
                     } else {
                         // Повышение харок
                         if ($this->fact['hp_p'] > 0) {
                             myquery("UPDATE game_users SET HP_MAX=HP_MAX+" . $this->fact['hp_p'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'HP_MAX',2," . (time() + $dlit) . "," . $this->fact['hp_p'] . ")");
                         }
                         if ($this->fact['mp_p'] > 0) {
                             myquery("UPDATE game_users SET MP_MAX=MP_MAX+" . $this->fact['mp_p'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'MP_MAX',2," . (time() + $dlit) . "," . $this->fact['mp_p'] . ")");
                         }
                         if ($this->fact['stm_p'] > 0) {
                             myquery("UPDATE game_users SET STM_MAX=STM_MAX+" . $this->fact['stm_p'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'STM_MAX',2," . (time() + $dlit) . "," . $this->fact['stm_p'] . ")");
                         }
                         if ($this->fact['pr_p'] > 0) {
                             myquery("UPDATE game_users SET PR_MAX=PR_MAX+" . $this->fact['pr_p'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'PR_MAX',2," . (time() + $dlit) . "," . $this->fact['pr_p'] . ")");
                         }
                         if ($this->fact['dstr'] > 0) {
                             myquery("UPDATE game_users SET STR=STR+" . $this->fact['dstr'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'STR',2," . (time() + $dlit) . "," . $this->fact['dstr'] . ")");
                         }
                         if ($this->fact['dspd'] > 0) {
                             myquery("UPDATE game_users SET SPD=SPD+" . $this->fact['dspd'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'SPD',2," . (time() + $dlit) . "," . $this->fact['dspd'] . ")");
                         }
                         if ($this->fact['dntl'] > 0) {
                             myquery("UPDATE game_users SET NTL=NTL+" . $this->fact['dntl'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'NTL',2," . (time() + $dlit) . "," . $this->fact['dntl'] . ")");
                         }
                         if ($this->fact['dpie'] > 0) {
                             myquery("UPDATE game_users SET PIE=PIE+" . $this->fact['dpie'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'PIE',2," . (time() + $dlit) . "," . $this->fact['dpie'] . ")");
                         }
                         if ($this->fact['dvit'] > 0) {
                             myquery("UPDATE game_users SET VIT=VIT+" . $this->fact['dvit'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'VIT',2," . (time() + $dlit) . "," . $this->fact['dvit'] . ")");
                         }
                         if ($this->fact['ddex'] > 0) {
                             myquery("UPDATE game_users SET DEX=DEX+" . $this->fact['ddex'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'DEX',2," . (time() + $dlit) . "," . $this->fact['ddex'] . ")");
                         }
                         if ($this->fact['cc_p'] > 0) {
                             myquery("UPDATE game_users SET CC=CC+" . $this->fact['cc_p'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'CC',2," . (time() + $dlit) . "," . $this->fact['cc_p'] . ")");
                         }
                         if ($this->fact['dlucky'] > 0) {
                             myquery("UPDATE game_users SET LUCKY=LUCKY+" . $this->fact['dlucky'] . " WHERE user_id=" . $this->char['user_id'] . "");
                             myquery("INSERT INTO game_obelisk_users (user_id,harka,type,time_end,value) VALUES (" . $this->char['user_id'] . ",'LUCKY',2," . (time() + $dlit) . "," . $this->fact['dlucky'] . ")");
                         }
                         $this->message = $this->message . '<b><font color=red>Ты ' . echo_sex('выпил', 'выпила') . ' зелье "' . $this->fact['name'] . '"</font></b><br>';
                     }
                 } elseif ($dlit == 0) {
                     if ($this->fact['hp_p'] > 0 or $this->fact['mp_p'] > 0 or $this->fact['stm_p'] > 0 or $this->fact['pr_p'] > 0) {
                         $new_HP = min($this->char['HP_MAX'], $this->char['HP'] + $this->fact['hp_p']);
                         $new_MP = min($this->char['MP_MAX'], $this->char['MP'] + $this->fact['mp_p']);
                         $new_STM = min($this->char['STM_MAX'], $this->char['STM'] + $this->fact['stm_p']);
                         $new_PR = min($this->char['PR_MAX'], $this->char['PR'] + $this->fact['stm_p']);
                         myquery("UPDATE game_users SET HP=" . $new_HP . ",MP=" . $new_MP . ",STM=" . $new_STM . ",PR=" . $new_PR . " WHERE user_id=" . $this->char['user_id'] . "");
                         $char['HP'] = $new_HP;
                         $char['MP'] = $new_MP;
                         $char['STM'] = $new_STM;
                         $char['PR'] = $new_PR;
                         $this->message = $this->message . '<b><font color=red>Ты ' . echo_sex('выпил', 'выпила') . ' зелье "' . $this->fact['name'] . '"</font></b><br>';
                     }
                 }
             }
         }
     } else {
         if ($this->item['user_id'] == $this->char['user_id']) {
             if ($this->item['priznak'] == 0) {
                 if ($this->fact['id'] == shamp_item_id) {
                     myquery("INSERT INTO game_log (FROMm,message,date,color) VALUES ('" . $this->char['user_id'] . "','" . iconv("Windows-1251", "UTF-8//IGNORE", "<img src=mag/shamp.gif border=0>&nbsp;[b]" . echo_sex('открыл', 'открыла') . " бутылку шампанского[/b]") . "','" . time() . "','yellow')");
                 } elseif ($this->fact['id'] == hlop_item_id) {
                     myquery("INSERT INTO game_log (FROMm,message,date,color) VALUES ('" . $this->char['user_id'] . "','" . iconv("Windows-1251", "UTF-8//IGNORE", "<img src=mag/hlop.gif border=0>&nbsp;[b]громко " . echo_sex('выстрелил', 'выстрелила') . " хлопушкой[/b]") . "','" . time() . "','#47F8EF')");
                 } elseif ($this->fact['id'] == beer_td_item_id) {
                     myquery("INSERT INTO game_log (FROMm,message,date,color) VALUES ('" . $this->char['user_id'] . "','" . iconv("Windows-1251", "UTF-8//IGNORE", "<img src=mag/p_temn_beer_dwarf.jpg border=0>&nbsp;[b]  " . echo_sex('выпил', 'выпила') . " кружку темного дварфийского пива[/b]") . "','" . time() . "','#47F8EF')");
                 } elseif ($this->fact['id'] == beer_t_item_id) {
                     myquery("INSERT INTO game_log (FROMm,message,date,color) VALUES ('" . $this->char['user_id'] . "','" . iconv("Windows-1251", "UTF-8//IGNORE", "<img src=mag/p_temn_beer.jpg border=0>&nbsp;[b]  " . echo_sex('выпил', 'выпила') . " кружку темного пива[/b]") . "','" . time() . "','#47F8EF')");
                 } elseif ($this->fact['id'] == beer_s_item_id) {
                     myquery("INSERT INTO game_log (FROMm,message,date,color) VALUES ('" . $this->char['user_id'] . "','" . iconv("Windows-1251", "UTF-8//IGNORE", "<img src=mag/p_svet_beer.jpg border=0>&nbsp;[b]  " . echo_sex('выпил', 'выпила') . " кружку светлого пива[/b]") . "','" . time() . "','#47F8EF')");
                 } elseif ($this->fact['id'] == ell_item_id) {
                     myquery("INSERT INTO game_log (FROMm,message,date,color) VALUES ('" . $this->char['user_id'] . "','" . iconv("Windows-1251", "UTF-8//IGNORE", "<img src=mag/p_ell.jpg border=0>&nbsp;[b]  " . echo_sex('выпил', 'выпила') . " эль[/b]") . "','" . time() . "','#47F8EF')");
                 } elseif ($this->fact['id'] == berez_item_id) {
                     myquery("INSERT INTO game_log (FROMm,message,date,color) VALUES ('" . $this->char['user_id'] . "','" . iconv("Windows-1251", "UTF-8//IGNORE", "<img src=mag/p_berez_sok.jpg border=0>&nbsp;[b]  " . echo_sex('выпил', 'выпила') . " полную кружку березового сока[/b]") . "','" . time() . "','#47F8EF')");
                 } elseif ($this->fact['name'] == "Железная шкатулка") {
                     $bonus = 100;
                     $r = mt_rand(1, 2);
                     $item_name = 'Эликсир Барда';
                     $Item = new Item();
                     list($elik_id) = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE name like '" . $item_name . "'"));
                     $ar = $Item->add_user($elik_id, $this->char['user_id'], 0, 0, 0, $r);
                     save_exp($this->char['user_id'], $bonus, 14);
                     $this->message = $this->message . '<b><font color=red>Вы открыли предмет "' . $this->fact['name'] . '".<br>Ваш опыт увеличен на ' . $bonus . ' единиц.<br>Вы получили предмет ' . $item_name . ' (' . $r . ' шт.)</font></b><br>';
                 } elseif ($this->fact['name'] == "Медная шкатулка") {
                     $bonus = 300;
                     $r = mt_rand(1, 3);
                     $item_name = 'Эликсир Барда';
                     $Item = new Item();
                     list($elik_id) = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE name like '" . $item_name . "'"));
                     $ar = $Item->add_user($elik_id, $this->char['user_id'], 0, 0, 0, $r);
                     save_exp($this->char['user_id'], $bonus, 14);
                     $this->message = $this->message . '<b><font color=red>Вы открыли предмет "' . $this->fact['name'] . '".<br>Ваш опыт увеличен на ' . $bonus . ' единиц.<br>Вы получили предмет ' . $item_name . ' (' . $r . ' шт.)</font></b><br>';
                 } elseif ($this->fact['name'] == "Серебряная шкатулка") {
                     $bonus = 1000;
                     $r = mt_rand(1, 4);
                     $item_name = 'Эликсир Барда';
                     $Item = new Item();
                     list($elik_id) = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE name like '" . $item_name . "'"));
                     $ar = $Item->add_user($elik_id, $this->char['user_id'], 0, 0, 0, $r);
                     save_exp($this->char['user_id'], $bonus, 14);
                     $this->message = $this->message . '<b><font color=red>Вы открыли предмет "' . $this->fact['name'] . '".<br>Ваш опыт увеличен на ' . $bonus . ' единиц.<br>Вы получили предмет ' . $item_name . ' (' . $r . ' шт.)</font></b><br>';
                 } elseif ($this->fact['name'] == "Золотая шкатулка") {
                     $bonus = 2000;
                     $r = mt_rand(1, 5);
                     $item_name = 'Эликсир Барда';
                     $Item = new Item();
                     list($elik_id) = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE name like '" . $item_name . "'"));
                     $ar = $Item->add_user($elik_id, $this->char['user_id'], 0, 0, 0, $r);
                     save_exp($this->char['user_id'], $bonus, 14);
                 } elseif ($this->fact['name'] == "Мифриловая шкатулка") {
                     $bonus = 5000;
                     $r = mt_rand(2, 5);
                     $item_name = 'Эликсир Барда';
                     $Item = new Item();
                     list($elik_id) = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE name like '" . $item_name . "'"));
                     $ar = $Item->add_user($elik_id, $this->char['user_id'], 0, 0, 0, $r);
                     save_exp($this->char['user_id'], $bonus, 14);
                     $this->message = $this->message . '<b><font color=red>Вы открыли предмет "' . $this->fact['name'] . '".<br>Ваш опыт увеличен на "' . $bonus . '" единиц.<br>Вы получили предмет "' . $item_name . '" ("' . $r . '" шт.)</font></b><br>';
                 }
             }
         }
     }
     $this->admindelete(0, 1, 4);
 }