Advertisement
Guest User

Untitled

a guest
Sep 8th, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. diff -r 864820a88a38 -r 301845e6ca3b src/game/Spell.cpp
  2. --- a/src/game/Spell.cpp Mon Sep 05 13:27:30 2011 +0600
  3. +++ b/src/game/Spell.cpp Thu Sep 08 15:03:26 2011 +0600
  4. @@ -2747,6 +2747,7 @@
  5.  
  6. TakePower();
  7. TakeReagents(); // we must remove reagents before HandleEffects to allow place crafted item in same slot
  8. + TakeAmmo();
  9.  
  10. SendCastResult(castResult);
  11. SendSpellGo(); // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()...
  12. @@ -3714,6 +3715,35 @@
  13. m_caster->SetLastManaUse();
  14. }
  15.  
  16. +void Spell::TakeAmmo()
  17. +{
  18. + if (m_attackType == RANGED_ATTACK && m_caster->GetTypeId() == TYPEID_PLAYER)
  19. + {
  20. + Item* pItem = ((Player*)m_caster)->GetWeaponForAttack(RANGED_ATTACK, true, false);
  21. +
  22. + // wands don't have ammo
  23. + if (!pItem || pItem->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_WAND)
  24. + return;
  25. +
  26. + if (pItem->GetProto()->InventoryType == INVTYPE_THROWN)
  27. + {
  28. + if (pItem->GetMaxStackCount() == 1)
  29. + {
  30. + // decrease durability for non-stackable throw weapon
  31. + ((Player*)m_caster)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_RANGED);
  32. + }
  33. + else
  34. + {
  35. + // decrease items amount for stackable throw weapon
  36. + uint32 count = 1;
  37. + ((Player*)m_caster)->DestroyItemCount(pItem, count, true);
  38. + }
  39. + }
  40. + else if (uint32 ammo = ((Player*)m_caster)->GetUInt32Value(PLAYER_AMMO_ID))
  41. + ((Player*)m_caster)->DestroyItemCount(ammo, 1, true);
  42. + }
  43. +}
  44. +
  45. void Spell::TakeReagents()
  46. {
  47. if (m_caster->GetTypeId() != TYPEID_PLAYER)
  48. diff -r 864820a88a38 -r 301845e6ca3b src/game/Spell.h
  49. --- a/src/game/Spell.h Mon Sep 05 13:27:30 2011 +0600
  50. +++ b/src/game/Spell.h Thu Sep 08 15:03:26 2011 +0600
  51. @@ -305,6 +305,7 @@
  52. void cast(bool skipCheck = false);
  53. void finish(bool ok = true);
  54. void TakePower();
  55. + void TakeAmmo();
  56. void TakeReagents();
  57. void TakeCastItem();
  58.  
  59. diff -r 864820a88a38 -r 301845e6ca3b src/game/SpellEffects.cpp
  60. --- a/src/game/SpellEffects.cpp Mon Sep 05 13:27:30 2011 +0600
  61. +++ b/src/game/SpellEffects.cpp Thu Sep 08 15:03:26 2011 +0600
  62. @@ -3207,33 +3207,6 @@
  63. if(m_caster->GetTypeId()==TYPEID_PLAYER)
  64. ((Player*)m_caster)->AddComboPoints(unitTarget, 1);
  65. }
  66. -
  67. - // take ammo
  68. - if(m_attackType == RANGED_ATTACK && m_caster->GetTypeId() == TYPEID_PLAYER)
  69. - {
  70. - Item *pItem = ((Player*)m_caster)->GetWeaponForAttack(RANGED_ATTACK, true, false);
  71. -
  72. - // wands don't have ammo
  73. - if (!pItem || pItem->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_WAND)
  74. - return;
  75. -
  76. - if (pItem->GetProto()->InventoryType == INVTYPE_THROWN)
  77. - {
  78. - if(pItem->GetMaxStackCount()==1)
  79. - {
  80. - // decrease durability for non-stackable throw weapon
  81. - ((Player*)m_caster)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_RANGED);
  82. - }
  83. - else
  84. - {
  85. - // decrease items amount for stackable throw weapon
  86. - uint32 count = 1;
  87. - ((Player*)m_caster)->DestroyItemCount( pItem, count, true);
  88. - }
  89. - }
  90. - else if(uint32 ammo = ((Player*)m_caster)->GetUInt32Value(PLAYER_AMMO_ID))
  91. - ((Player*)m_caster)->DestroyItemCount(ammo, 1, true);
  92. - }
  93. }
  94.  
  95. void Spell::EffectThreat(SpellEffectIndex /*eff_idx*/)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement