9
3

Bot.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. #include "Bot.h"
  2. #include "BotBrain.h"
  3. #include "../Trade.h"
  4. #include "../../common/Log.h"
  5. #include "../WorldDatabase.h"
  6. #include "../classes.h"
  7. #include "../SpellProcess.h"
  8. extern WorldDatabase database;
  9. extern MasterSpellList master_spell_list;
  10. extern World world;
  11. extern Classes classes;
  12. Bot::Bot() : NPC() {
  13. SetBrain(new BotBrain(this));
  14. BotID = 0;
  15. ShowHelm = true;
  16. ShowCloak = true;
  17. CanTaunt = false;
  18. combat_target = 0;
  19. main_tank = 0;
  20. //AddPrimaryEntityCommand("hail", 10000, "hail", "", 0, 0);
  21. AddSecondaryEntityCommand("invite bot", 10000, "invite", "", 0, 0);
  22. AddSecondaryEntityCommand("bot inventory", 10000, "bot inv list", "", 0, 0);
  23. InfoStruct* info = GetInfoStruct();
  24. info->set_str_base(50);
  25. info->set_sta_base(20);
  26. info->set_wis_base(20);
  27. info->set_intel_base(20);
  28. info->set_agi_base(20);
  29. }
  30. Bot::~Bot() {
  31. }
  32. void Bot::GiveItem(int32 item_id) {
  33. Item* master_item = master_item_list.GetItem(item_id);
  34. Item* item = 0;
  35. if (master_item)
  36. item = new Item(master_item);
  37. if (item) {
  38. int8 slot = GetEquipmentList()->GetFreeSlot(item);
  39. if (slot != 255) {
  40. GetEquipmentList()->AddItem(slot, item);
  41. SetEquipment(item, slot);
  42. database.SaveBotItem(BotID, item_id, slot);
  43. if (slot == 0) {
  44. ChangePrimaryWeapon();
  45. if (IsBot())
  46. LogWrite(PLAYER__ERROR, 0, "Bot", "Changing bot primary weapon.");
  47. }
  48. CalculateBonuses();
  49. }
  50. }
  51. }
  52. void Bot::GiveItem(Item* item) {
  53. if (item) {
  54. int8 slot = GetEquipmentList()->GetFreeSlot(item);
  55. if (slot != 255) {
  56. GetEquipmentList()->AddItem(slot, item);
  57. SetEquipment(item, slot);
  58. database.SaveBotItem(BotID, item->details.item_id, slot);
  59. if (slot == 0) {
  60. ChangePrimaryWeapon();
  61. if (IsBot())
  62. LogWrite(PLAYER__ERROR, 0, "Bot", "Changing bot primary weapon.");
  63. }
  64. CalculateBonuses();
  65. }
  66. }
  67. }
  68. void Bot::RemoveItem(Item* item) {
  69. int8 slot = GetEquipmentList()->GetSlotByItem(item);
  70. if (slot != 255) {
  71. GetEquipmentList()->RemoveItem(slot, true);
  72. SetEquipment(0, slot);
  73. }
  74. }
  75. void Bot::TradeItemAdded(Item* item) {
  76. int8 slot = GetEquipmentList()->GetFreeSlot(item);
  77. if (slot == 255 && item->slot_data.size() > 0) {
  78. slot = item->slot_data[0];
  79. AddItemToTrade(slot);
  80. }
  81. }
  82. void Bot::AddItemToTrade(int8 slot) {
  83. Item* item = GetEquipmentList()->GetItem(slot);
  84. if (trading_slots.count(slot) == 0 && item && trade) {
  85. trade->AddItemToTrade(this, item, 1, 255);
  86. trading_slots.insert(slot);
  87. }
  88. }
  89. bool Bot::CheckTradeItems(map<int8, TradeItemInfo>* list) {
  90. if (!list) {
  91. LogWrite(PLAYER__ERROR, 0, "Bot", "CheckTradeItems did not recieve a valid list of items");
  92. return false;
  93. }
  94. bool ret = true;
  95. map<int8, TradeItemInfo>::iterator itr;
  96. for (itr = list->begin(); itr != list->end(); itr++) {
  97. Item* item = itr->second.item;
  98. if (item) {
  99. if (!CanEquipItem(item)) {
  100. // No slots means not equipable so reject the trade
  101. ret = false;
  102. break;
  103. }
  104. }
  105. }
  106. return ret;
  107. }
  108. void Bot::FinishTrade() {
  109. trading_slots.clear();
  110. }
  111. bool Bot::CanEquipItem(Item* item) {
  112. if (item) {
  113. if (item->IsArmor() || item->IsWeapon() || item->IsFood() || item->IsRanged() || item->IsShield() || item->IsBauble() || item->IsAmmo() || item->IsThrown()) {
  114. int16 override_level = item->GetOverrideLevel(GetAdventureClass(), GetTradeskillClass());
  115. if (override_level > 0 && override_level <= GetLevel()) {
  116. LogWrite(PLAYER__ERROR, 0, "Bot", "Passed in override_level check");
  117. return true;
  118. }
  119. if (item->CheckClass(GetAdventureClass(), GetTradeskillClass()))
  120. if (item->CheckLevel(GetAdventureClass(), GetTradeskillClass(), GetLevel())) {
  121. LogWrite(PLAYER__ERROR, 0, "Bot", "Passed in normal check");
  122. return true;
  123. }
  124. }
  125. }
  126. return false;
  127. }
  128. void Bot::MessageGroup(string msg) {
  129. GroupMemberInfo* gmi = GetGroupMemberInfo();
  130. if (gmi)
  131. world.GetGroupManager()->GroupChatMessage(gmi->group_id, this, 0, msg.c_str());
  132. }
  133. void Bot::GetNewSpells() {
  134. vector<Spell*> spells;
  135. vector<Spell*>* spells1 = master_spell_list.GetSpellListByAdventureClass(GetAdventureClass(), GetLevel(), 1);
  136. vector<Spell*>* spells2 = master_spell_list.GetSpellListByAdventureClass(classes.GetBaseClass(GetAdventureClass()), GetLevel(), 1);
  137. vector<Spell*>* spells3 = master_spell_list.GetSpellListByAdventureClass(classes.GetSecondaryBaseClass(GetAdventureClass()), GetLevel(), 1);
  138. spells.insert(spells.end(), spells1->begin(), spells1->end());
  139. spells.insert(spells.end(), spells2->begin(), spells2->end());
  140. spells.insert(spells.end(), spells3->begin(), spells3->end());
  141. vector<Spell*>::iterator itr;
  142. map<int32, int8>* spell_list = 0;
  143. for (itr = spells.begin(); itr != spells.end(); itr++) {
  144. switch ((*itr)->GetSpellData()->spell_type) {
  145. case SPELL_TYPE_DD:
  146. spell_list = &dd_spells;
  147. break;
  148. case SPELL_TYPE_DOT:
  149. spell_list = &dot_spells;
  150. break;
  151. case SPELL_TYPE_HEAL:
  152. spell_list = &heal_spells;
  153. break;
  154. case SPELL_TYPE_HOT_WARD:
  155. spell_list = &hot_ward_spells;
  156. break;
  157. case SPELL_TYPE_DEBUFF:
  158. spell_list = &debuff_spells;
  159. break;
  160. case SPELL_TYPE_BUFF:
  161. spell_list = &buff_spells;
  162. break;
  163. case SPELL_TYPE_COMBATBUFF:
  164. spell_list = &combat_buff_spells;
  165. break;
  166. case SPELL_TYPE_TAUNT:
  167. spell_list = &taunt_spells;
  168. break;
  169. case SPELL_TYPE_DETAUNT:
  170. spell_list = &detaunt_spells;
  171. break;
  172. case SPELL_TYPE_REZ:
  173. LogWrite(PLAYER__ERROR, 0, "Bot", "Adding rez spell.");
  174. spell_list = &rez_spells;
  175. break;
  176. case SPELL_TYPE_CURE:
  177. spell_list = &cure_spells;
  178. break;
  179. default:
  180. spell_list = 0;
  181. break;
  182. }
  183. if (spell_list && spell_list->count((*itr)->GetSpellID()) == 0)
  184. (*spell_list)[(*itr)->GetSpellID()] = 1;
  185. }
  186. safe_delete(spells1);
  187. safe_delete(spells2);
  188. safe_delete(spells3);
  189. }
  190. Entity* Bot::GetCombatTarget() {
  191. Spawn* target = GetZone()->GetSpawnByID(combat_target);
  192. if (target && target->IsEntity())
  193. return (Entity*)target;
  194. combat_target = 0;
  195. return 0;
  196. }
  197. Spell* Bot::SelectSpellToCast(float distance) {
  198. Spell* spell = 0;
  199. map<int32, int8>::iterator itr;
  200. // Heal
  201. spell = GetHealSpell();
  202. if (spell)
  203. return spell;
  204. // Taunt
  205. spell = GetTauntSpell();
  206. if (spell)
  207. return spell;
  208. // Detaunt
  209. spell = GetDetauntSpell();
  210. if (spell)
  211. return spell;
  212. // Hot/Ward
  213. spell = GetHoTWardSpell();
  214. if (spell)
  215. return spell;
  216. // Debuff
  217. spell = GetDebuffSpell();
  218. if (spell)
  219. return spell;
  220. // Combat Buff
  221. spell = GetCombatBuffSpell();
  222. if (spell)
  223. return spell;
  224. // DoT
  225. spell = GetDoTSpell();
  226. if (spell)
  227. return spell;
  228. // DD
  229. spell = GetDDSpell();
  230. if (spell)
  231. return spell;
  232. return 0;
  233. }
  234. void Bot::SetRecast(Spell* spell, int32 time) {
  235. recast_times[spell->GetSpellID()] = time;
  236. }
  237. bool Bot::IsSpellReady(Spell* spell) {
  238. if (recast_times.count(spell->GetSpellID()) > 0) {
  239. if (recast_times[spell->GetSpellID()] > Timer::GetCurrentTime2())
  240. return false;
  241. }
  242. return true;
  243. }
  244. Spell* Bot::GetDDSpell() {
  245. if (dd_spells.size() == 0)
  246. return 0;
  247. Spell* spell = 0;
  248. map<int32, int8>::iterator itr;
  249. for (itr = dd_spells.begin(); itr != dd_spells.end(); itr++) {
  250. spell = master_spell_list.GetSpell(itr->first, itr->second);
  251. if (spell && IsSpellReady(spell)) {
  252. return spell;
  253. }
  254. }
  255. return 0;
  256. }
  257. Spell* Bot::GetHealSpell() {
  258. if (heal_spells.size() == 0)
  259. return 0;
  260. // Get an available heal spell
  261. Spell* spell = 0;
  262. map<int32, int8>::iterator itr;
  263. for (itr = heal_spells.begin(); itr != heal_spells.end(); itr++) {
  264. spell = master_spell_list.GetSpell(itr->first, itr->second);
  265. if (spell && IsSpellReady(spell)) {
  266. break;
  267. }
  268. }
  269. // No heal available, return out
  270. if (!spell)
  271. return 0;
  272. // There was a heal spell so find a group member that needs healing
  273. int8 threshold = GetHealThreshold();
  274. GroupMemberInfo* gmi = GetGroupMemberInfo();
  275. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  276. if (group)
  277. {
  278. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  279. deque<GroupMemberInfo*>* members = group->GetMembers();
  280. for (int8 i = 0; i < members->size(); i++) {
  281. Entity* member = members->at(i)->member;
  282. if(!member)
  283. continue;
  284. if (!member->Alive())
  285. continue;
  286. int8 percent = (int8)(((float)member->GetHP() / member->GetTotalHP()) * 100);
  287. if (percent <= threshold) {
  288. if (spell) {
  289. SetTarget(member);
  290. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  291. return spell;
  292. }
  293. }
  294. }
  295. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  296. }
  297. return 0;
  298. }
  299. Spell* Bot::GetTauntSpell() {
  300. if (taunt_spells.size() == 0)
  301. return 0;
  302. // If not the main tank and taunts are turned off return out
  303. if (main_tank != this && !CanTaunt)
  304. return 0;
  305. Spell* spell = 0;
  306. map<int32, int8>::iterator itr;
  307. for (itr = taunt_spells.begin(); itr != taunt_spells.end(); itr++) {
  308. spell = master_spell_list.GetSpell(itr->first, itr->second);
  309. if (spell && IsSpellReady(spell)) {
  310. return spell;
  311. }
  312. }
  313. return 0;
  314. }
  315. Spell* Bot::GetDetauntSpell() {
  316. if (detaunt_spells.size() == 0)
  317. return 0;
  318. if (!GetTarget() || !GetTarget()->IsNPC())
  319. return 0;
  320. NPC* target = (NPC*)GetTarget();
  321. Entity* hated = target->Brain()->GetMostHated();
  322. if (hated == this) {
  323. Spell* spell = 0;
  324. map<int32, int8>::iterator itr;
  325. for (itr = detaunt_spells.begin(); itr != detaunt_spells.end(); itr++) {
  326. spell = master_spell_list.GetSpell(itr->first, itr->second);
  327. if (spell && IsSpellReady(spell)) {
  328. return spell;
  329. }
  330. }
  331. }
  332. return 0;
  333. }
  334. Spell* Bot::GetHoTWardSpell() {
  335. if (hot_ward_spells.size() == 0)
  336. return 0;
  337. // Get an available spell
  338. Spell* spell = 0;
  339. map<int32, int8>::iterator itr;
  340. for (itr = hot_ward_spells.begin(); itr != hot_ward_spells.end(); itr++) {
  341. spell = master_spell_list.GetSpell(itr->first, itr->second);
  342. if (spell && IsSpellReady(spell)) {
  343. break;
  344. }
  345. }
  346. // No spell available, return out
  347. if (!spell)
  348. return 0;
  349. // There was a spell so find a group member that needs healing
  350. int8 threshold = GetHealThreshold();
  351. GroupMemberInfo* gmi = GetGroupMemberInfo();
  352. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  353. if (group)
  354. {
  355. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  356. deque<GroupMemberInfo*>* members = group->GetMembers();
  357. for (int8 i = 0; i < members->size(); i++) {
  358. Entity* member = members->at(i)->member;
  359. if(!member)
  360. continue;
  361. int8 percent = 0;
  362. if (member->GetHP() > 0)
  363. percent = (int8)(((float)member->GetHP() / member->GetTotalHP()) * 100);
  364. if (percent <= 99 && percent > threshold) {
  365. if (spell) {
  366. SetTarget(member);
  367. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  368. return spell;
  369. }
  370. }
  371. }
  372. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  373. }
  374. return 0;
  375. }
  376. Spell* Bot::GetDebuffSpell() {
  377. if (debuff_spells.size() == 0)
  378. return 0;
  379. Spell* spell = 0;
  380. map<int32, int8>::iterator itr;
  381. for (itr = debuff_spells.begin(); itr != debuff_spells.end(); itr++) {
  382. spell = master_spell_list.GetSpell(itr->first, itr->second);
  383. if (spell && IsSpellReady(spell)) {
  384. // If target already has this effect on them then continue to the next spell
  385. if (((Entity*)GetTarget())->GetSpellEffect(itr->first))
  386. continue;
  387. return spell;
  388. }
  389. }
  390. return 0;
  391. }
  392. Spell* Bot::GetCombatBuffSpell() {
  393. return 0;
  394. }
  395. Spell* Bot::GetDoTSpell() {
  396. if (dot_spells.size() == 0)
  397. return 0;
  398. Spell* spell = 0;
  399. map<int32, int8>::iterator itr;
  400. for (itr = dot_spells.begin(); itr != dot_spells.end(); itr++) {
  401. spell = master_spell_list.GetSpell(itr->first, itr->second);
  402. if (spell && IsSpellReady(spell)) {
  403. // If target already has this effect on them then continue to the next spell
  404. if (((Entity*)GetTarget())->GetSpellEffect(itr->first))
  405. continue;
  406. return spell;
  407. }
  408. }
  409. return 0;
  410. }
  411. Spell* Bot::GetBuffSpell() {
  412. if (buff_spells.size() == 0)
  413. return 0;
  414. Spell* spell = 0;
  415. Entity* target = 0;
  416. map<int32, int8>::iterator itr;
  417. for (itr = buff_spells.begin(); itr != buff_spells.end(); itr++) {
  418. spell = master_spell_list.GetSpell(itr->first, itr->second);
  419. if (spell && IsSpellReady(spell)) {
  420. target = 0;
  421. if (spell->GetSpellData()->target_type == SPELL_TARGET_SELF)
  422. target = this;
  423. if (spell->GetSpellData()->target_type == SPELL_TARGET_GROUP_AE)
  424. target = this;
  425. if (spell->GetSpellData()->target_type == SPELL_TARGET_ENEMY && spell->GetSpellData()->friendly_spell == 1)
  426. target = (main_tank != NULL) ? main_tank : GetOwner();
  427. if (!target)
  428. continue;
  429. if (!target->Alive())
  430. continue;
  431. // If target already has this effect on them then continue to the next spell
  432. if (target->GetSpellEffect(itr->first))
  433. continue;
  434. SetTarget(target);
  435. return spell;
  436. }
  437. }
  438. return 0;
  439. }
  440. Spell* Bot::GetRezSpell() {
  441. if (rez_spells.size() == 0)
  442. return 0;
  443. GroupMemberInfo* gmi = GetGroupMemberInfo();
  444. if (!gmi)
  445. return 0;
  446. Entity* target = 0;
  447. PlayerGroup* group = world.GetGroupManager()->GetGroup(gmi->group_id);
  448. if (group)
  449. {
  450. group->MGroupMembers.readlock(__FUNCTION__, __LINE__);
  451. deque<GroupMemberInfo*>* members = group->GetMembers();
  452. for (int8 i = 0; i < members->size(); i++) {
  453. Entity* member = members->at(i)->member;
  454. if (member && !member->Alive() && member->IsPlayer()) {
  455. PendingResurrection* rez = members->at(i)->client->GetCurrentRez();
  456. if (rez->active)
  457. continue;
  458. target = member;
  459. break;
  460. }
  461. }
  462. group->MGroupMembers.releasereadlock(__FUNCTION__, __LINE__);
  463. }
  464. if (!target)
  465. return 0;
  466. Spell* spell = 0;
  467. map<int32, int8>::iterator itr;
  468. for (itr = rez_spells.begin(); itr != rez_spells.end(); itr++) {
  469. spell = master_spell_list.GetSpell(itr->first, itr->second);
  470. if (spell && IsSpellReady(spell)) {
  471. SetTarget(target);
  472. return spell;
  473. }
  474. }
  475. return 0;
  476. }
  477. Spell* Bot::GetCureSpell() {
  478. return 0;
  479. }
  480. int8 Bot::GetHealThreshold() {
  481. int8 ret = 0;
  482. switch (GetAdventureClass()) {
  483. case PRIEST:
  484. case CLERIC:
  485. case TEMPLAR:
  486. case INQUISITOR:
  487. case DRUID:
  488. case WARDEN:
  489. case FURY:
  490. case SHAMAN:
  491. case MYSTIC:
  492. case DEFILER:
  493. ret = 70;
  494. break;
  495. default:
  496. ret = 30;
  497. break;
  498. }
  499. return ret;
  500. }
  501. bool Bot::ShouldMelee() {
  502. bool ret = true;
  503. switch (GetAdventureClass()) {
  504. case PRIEST:
  505. case CLERIC:
  506. case TEMPLAR:
  507. case INQUISITOR:
  508. case DRUID:
  509. case WARDEN:
  510. case FURY:
  511. case SHAMAN:
  512. case MYSTIC:
  513. case DEFILER:
  514. case MAGE:
  515. case SORCERER:
  516. case WIZARD:
  517. case WARLOCK:
  518. case ENCHANTER:
  519. case ILLUSIONIST:
  520. case COERCER:
  521. case SUMMONER:
  522. case CONJUROR:
  523. case NECROMANCER:
  524. ret = false;
  525. break;
  526. default:
  527. ret = true;
  528. break;
  529. }
  530. if (GetTarget() == GetOwner())
  531. ret = false;
  532. return ret;
  533. }
  534. void Bot::Camp(bool immediate) {
  535. // Copy from COMMAND_GROUP_LEAVE
  536. GroupMemberInfo* gmi = GetGroupMemberInfo();
  537. if (gmi) {
  538. int32 group_id = gmi->group_id;
  539. world.GetGroupManager()->RemoveGroupMember(group_id, this);
  540. if (!world.GetGroupManager()->IsGroupIDValid(group_id)) {
  541. // leader->Message(CHANNEL_COLOR_GROUP, "%s has left the group.", client->GetPlayer()->GetName());
  542. }
  543. else {
  544. world.GetGroupManager()->GroupMessage(group_id, "%s has left the group.", GetName());
  545. }
  546. }
  547. if(!immediate)
  548. {
  549. GetZone()->PlayAnimation(this, 538);
  550. SetVisualState(540);
  551. GetZone()->Despawn(this, 5000);
  552. }
  553. if (!GetOwner())
  554. return;
  555. Client* client = GetZone()->GetClientBySpawn(GetOwner());
  556. if (client)
  557. client->GetPlayer()->SpawnedBots.erase(BotIndex);
  558. }
  559. void Bot::ChangeLevel(int16 old_level, int16 new_level) {
  560. if (new_level < 1)
  561. return;
  562. if (GetLevel() != new_level) {
  563. SetLevel(new_level);
  564. if (GetGroupMemberInfo()) {
  565. UpdateGroupMemberInfo();
  566. world.GetGroupManager()->SendGroupUpdate(GetGroupMemberInfo()->group_id);
  567. }
  568. }
  569. if (GetPet()) {
  570. NPC* pet = (NPC*)GetPet();
  571. if (pet->GetMaxPetLevel() == 0 || new_level <= pet->GetMaxPetLevel()) {
  572. pet->SetLevel(new_level);
  573. GetZone()->PlayAnimation(pet, 1753);
  574. }
  575. }
  576. // level up animation
  577. GetZone()->PlayAnimation(this, 1753);
  578. //player->GetSkills()->IncreaseAllSkillCaps(5 * (new_level - old_level));
  579. GetNewSpells();
  580. //SendNewSpells(player->GetAdventureClass());
  581. //SendNewSpells(classes.GetBaseClass(player->GetAdventureClass()));
  582. //SendNewSpells(classes.GetSecondaryBaseClass(player->GetAdventureClass()));
  583. ChangePrimaryWeapon();
  584. ChangeSecondaryWeapon();
  585. ChangeRangedWeapon();
  586. GetInfoStruct()->set_level(new_level);
  587. // GetPlayer()->SetLevel(new_level);
  588. LogWrite(MISC__TODO, 1, "TODO", "Get new HP/POWER/stat based on default values from DB\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
  589. SetTotalHPBase(new_level*new_level * 2 + 40);
  590. SetTotalPowerBase((sint32)(new_level*new_level*2.1 + 45));
  591. CalculateBonuses();
  592. SetHP(GetTotalHP());
  593. SetPower(GetTotalPower());
  594. GetInfoStruct()->set_agi_base(new_level * 2 + 15);
  595. GetInfoStruct()->set_intel_base(new_level * 2 + 15);
  596. GetInfoStruct()->set_wis_base(new_level * 2 + 15);
  597. GetInfoStruct()->set_str_base(new_level * 2 + 15);
  598. GetInfoStruct()->set_sta_base(new_level * 2 + 15);
  599. GetInfoStruct()->set_cold_base((int16)(new_level*1.5 + 10));
  600. GetInfoStruct()->set_heat_base((int16)(new_level*1.5 + 10));
  601. GetInfoStruct()->set_disease_base((int16)(new_level*1.5 + 10));
  602. GetInfoStruct()->set_mental_base((int16)(new_level*1.5 + 10));
  603. GetInfoStruct()->set_magic_base((int16)(new_level*1.5 + 10));
  604. GetInfoStruct()->set_divine_base((int16)(new_level*1.5 + 10));
  605. GetInfoStruct()->set_poison_base((int16)(new_level*1.5 + 10));
  606. /*UpdateTimeStampFlag(LEVEL_UPDATE_FLAG);
  607. GetPlayer()->SetCharSheetChanged(true);
  608. Message(CHANNEL_COLOR_EXP, "You are now level %i!", new_level);
  609. LogWrite(WORLD__DEBUG, 0, "World", "Player: %s leveled from %u to %u", GetPlayer()->GetName(), old_level, new_level);
  610. GetPlayer()->GetSkills()->SetSkillCapsByType(1, 5 * new_level);
  611. GetPlayer()->GetSkills()->SetSkillCapsByType(3, 5 * new_level);
  612. GetPlayer()->GetSkills()->SetSkillCapsByType(6, 5 * new_level);
  613. GetPlayer()->GetSkills()->SetSkillCapsByType(13, 5 * new_level);
  614. */
  615. }