Advertisement
Kobiesan

Player.cpp - Twinkcraft

Jun 4th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.54 KB | None | 0 0
  1. static uint32 copseReclaimDelay[MAX_DEATH_COUNT] = { 30, 60, 120 };
  2.  
  3. // For Player::GiveLevel remove shaman weapon enchants on prestige
  4. static uint32 weaponEnchantsToRemove[5] = {1, 4, 5, 6, 29};
  5. static uint32 weaponEnchantsToRemoveSPELLS[5] = {8019, 8027, 8024, 8018, 8017};
  6.  
  7. uint32 Player::CalculateTalentsPoints() const
  8. {
  9. uint32 base_talent = getLevel() < 10 ? 0 : getLevel()-9;
  10.  
  11.  
  12. uint32 guid = GetGUID();
  13. PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PRESTIGELEVEL_BY_GUID);
  14. stmt->setUInt32(0, guid);
  15. PreparedQueryResult resultPrestige = CharacterDatabase.Query(stmt);
  16.  
  17. if ((resultPrestige) && (getLevel() > 9))
  18. {
  19. uint32 prestige_level = (*resultPrestige)[0].GetUInt32();
  20.  
  21. if (prestige_level > 10)
  22. base_talent += 10;
  23. else
  24. base_talent += prestige_level;
  25. }
  26.  
  27. void Player::HandleFall
  28. if (damage > 0)
  29. {
  30. if (HasSpell(90170))
  31. damage = damage / 2;
  32.  
  33. void Player::GiveXP
  34. // RaF does NOT stack with rested experience
  35. if (recruitAFriend)
  36. bonus_xp = 2 * xp; // xp + bonus_xp must add up to 3 * xp for RaF; calculation for quests done client-side
  37. else
  38. {
  39. bonus_xp = victim ? GetXPRestBonus(xp) : 0; // XP resting bonus
  40. if (HasSpell(90168))
  41. bonus_xp *= 1.5f;
  42. }
  43.  
  44. float Player::GetReputationPriceDiscount(FactionTemplateEntry const* factionTemplate) const
  45. {
  46. if (!factionTemplate || !factionTemplate->faction)
  47. return 1.0f;
  48.  
  49. if (HasSpell(90158))
  50. return 0.8f;
  51.  
  52. ReputationRank rank = GetReputationRank(factionTemplate->faction);
  53. if (rank <= REP_NEUTRAL)
  54. return 1.0f;
  55.  
  56. return 1.0f - 0.05f* (rank - REP_NEUTRAL);
  57. }
  58.  
  59. void Player::GiveLevel(uint8 level)
  60. {
  61. if (level == 1)
  62. {
  63. // If player has a pet when resetting back to level 1, remove it.
  64. if (Pet* pet = GetPet())
  65. {
  66. RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true);
  67. }
  68.  
  69. // If player is a hunter, remove pets from all slots including stable, active, and dismissed.
  70. if (getClass() == CLASS_HUNTER)
  71. {
  72. PreparedStatement* stmt;
  73. stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_BY_SLOT);
  74. stmt->setUInt32(0, this->GetGUID());
  75.  
  76. CharacterDatabase.Execute(stmt);
  77. }
  78.  
  79. // If player is a shaman and has a temporary enchantment on a weapon in any slot when prestiging, get rid of it.
  80. if (getClass() == CLASS_SHAMAN)
  81. {
  82. // Remove from bags
  83. for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++)
  84. {
  85. if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
  86. {
  87. for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot)
  88. {
  89. uint32 enchantId = pItem->GetEnchantmentId(EnchantmentSlot(slot));
  90. if (enchantId > 0)
  91. {
  92. for (int i = 0; i < sizeof(weaponEnchantsToRemove); ++i)
  93. {
  94. if (enchantId == weaponEnchantsToRemove[i])
  95. {
  96. pItem->ClearEnchantment(EnchantmentSlot(slot));
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }
  103.  
  104. for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
  105. {
  106. if (Bag* pBag = GetBagByPos(i))
  107. {
  108. for (uint32 j = 0; j < pBag->GetBagSize(); j++)
  109. {
  110. if (Item* pItem = GetItemByPos(i, j))
  111. {
  112. for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot)
  113. {
  114. uint32 enchantId = pItem->GetEnchantmentId(EnchantmentSlot(slot));
  115. if (enchantId > 0)
  116. {
  117. for (int i = 0; i < sizeof(weaponEnchantsToRemove); ++i)
  118. {
  119. if (enchantId == weaponEnchantsToRemove[i])
  120. {
  121. pItem->ClearEnchantment(EnchantmentSlot(slot));
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. }
  130.  
  131. /* Remove from buyback menu
  132. for (uint8 i = BUYBACK_SLOT_START; i < BUYBACK_SLOT_END; i++)
  133. {
  134. if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
  135. {
  136. for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot)
  137. {
  138. uint32 enchantId = pItem->GetEnchantmentId(EnchantmentSlot(slot));
  139. if (enchantId > 0)
  140. {
  141. for (int i = 0; i < sizeof(weaponEnchantsToRemove); ++i)
  142. {
  143. if (enchantId == weaponEnchantsToRemove[i])
  144. {
  145. pItem->ClearEnchantment(EnchantmentSlot(slot));
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }*/
  152.  
  153. // Remove from bank slots
  154. for (uint8 i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++)
  155. {
  156. if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
  157. {
  158. for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot)
  159. {
  160. uint32 enchantId = pItem->GetEnchantmentId(EnchantmentSlot(slot));
  161. if (enchantId > 0)
  162. {
  163. for (int i = 0; i < sizeof(weaponEnchantsToRemove); ++i)
  164. {
  165. if (enchantId == weaponEnchantsToRemove[i])
  166. {
  167. pItem->ClearEnchantment(EnchantmentSlot(slot));
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }
  174.  
  175. for (uint8 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++)
  176. {
  177. if (Bag* pBag = GetBagByPos(i))
  178. {
  179. for (uint32 j = 0; j < pBag->GetBagSize(); j++)
  180. {
  181. if (Item* pItem = GetItemByPos(i, j))
  182. {
  183. for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot)
  184. {
  185. uint32 enchantId = pItem->GetEnchantmentId(EnchantmentSlot(slot));
  186. if (enchantId > 0)
  187. {
  188. for (int i = 0; i < sizeof(weaponEnchantsToRemove); ++i)
  189. {
  190. if (enchantId == weaponEnchantsToRemove[i])
  191. {
  192. pItem->ClearEnchantment(EnchantmentSlot(slot));
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. }
  201.  
  202. // Remove from equipment slot
  203. if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, 15))
  204. {
  205. for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot)
  206. {
  207. uint32 enchantId = pItem->GetEnchantmentId(EnchantmentSlot(slot));
  208. if (enchantId > 0)
  209. {
  210. for (int i = 0; i < sizeof(weaponEnchantsToRemove); ++i)
  211. {
  212. if (enchantId == weaponEnchantsToRemove[i])
  213. {
  214. pItem->ClearEnchantment(EnchantmentSlot(slot));
  215. this->EquipItem(15, pItem, true);
  216. }
  217. }
  218. }
  219. }
  220. }
  221. }
  222. }
  223.  
  224. Item* Player::EquipItem
  225. Item* pItem2 = GetItemByPos(bag, slot);
  226.  
  227. // Remove Shaman temp enchants if don't have the spell.
  228. if (getClass() == CLASS_SHAMAN)
  229. {
  230. if (!IsGameMaster())
  231. {
  232. if (pItem && (pItem->GetTemplate()->InventoryType == INVTYPE_WEAPON || pItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON || pItem->GetTemplate()->InventoryType == INVTYPE_WEAPONMAINHAND))
  233. {
  234. for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot)
  235. {
  236. uint32 enchantId = pItem->GetEnchantmentId(EnchantmentSlot(slot));
  237. for (int i = 0; i < sizeof(weaponEnchantsToRemove); ++i)
  238. {
  239. if (enchantId == (weaponEnchantsToRemove[i]))
  240. {
  241. if (!HasSpell(weaponEnchantsToRemoveSPELLS[i]))
  242. {
  243. pItem->ClearEnchantment(EnchantmentSlot(slot));
  244. }
  245. }
  246. }
  247. }
  248. }
  249. }
  250. }
  251.  
  252. Player::LearnSpell
  253. LearnSpell(itr2->second, false, fromSkill);
  254. }
  255. }
  256.  
  257. // If has the Naga racial, set backwards movement speed.
  258. if (spell_id == 90178)
  259. SetSpeedRate(MOVE_RUN_BACK, 4.75f);
  260.  
  261. Player::RemoveSpell
  262. if (!prev_activate)
  263. {
  264. WorldPacket data(SMSG_REMOVED_SPELL, 4);
  265. data << uint32(spell_id);
  266. SendDirectMessage(&data);
  267. }
  268.  
  269. // If losing the Naga racial, set backwards movement speed.
  270. if (spell_id == 90178)
  271. UpdateSpeed(MOVE_RUN_BACK);
  272. }
  273.  
  274. void Player:BuildPlayerRepop
  275. SendDirectMessage(&data);
  276.  
  277. // If the player has the Wisp racial then cast the Wisp aura on them
  278. if (HasSpell(20585))
  279. {
  280. CastSpell(this, 20584, true);
  281. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement