Guest User

Untitled

a guest
Jun 19th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. /************************************************************************
  2. * *
  3. * Calculate Power of Damage Spell *
  4. * *
  5. ************************************************************************/
  6.  
  7. uint16 TakeMagicDamage(CBattleEntity* PAttacker, CBattleEntity* PDefender)
  8. {
  9. DSP_DEBUG_BREAK_IF(PAttacker->PBattleAI->GetCurrentSpell() == NULL);
  10. DSP_DEBUG_BREAK_IF(PAttacker->PBattleAI->GetCurrentAction() != ACTION_MAGIC_FINISH);
  11.  
  12. CSpell* PSpell = PAttacker->PBattleAI->GetCurrentSpell();
  13.  
  14. int32 INT = (PAttacker->stats.INT + PAttacker->getMod(MOD_INT)) - (PDefender->stats.INT + PDefender->getMod(MOD_INT));
  15. int32 MND = (PAttacker->stats.MND + PAttacker->getMod(MOD_MND)) - (PDefender->stats.MND + PDefender->getMod(MOD_MND));
  16. int32 base = PSpell->getBase();
  17. float M = PSpell->getMultiplier();
  18. int32 magias = PSpell->getID();
  19.  
  20. if (magias >= 144 || magias <= 215)
  21. {
  22. int32 damage = INT < 0 ? base + INT : base + (INT * M);
  23.  
  24. damage = damage * (100 - (10 * PAttacker->m_ActionList.size() / 2)) / 100;
  25. damage = damage * (1000 + PDefender->getMod(MOD_FIRERES + PSpell->getElement())) / 1000;
  26.  
  27. PDefender->addHP(-damage);
  28. PDefender->m_OwnerID = PAttacker->PMaster != NULL ? PAttacker->PMaster->id : PAttacker->id;
  29.  
  30. switch (PDefender->objtype)
  31. {
  32. case TYPE_PC:
  33. {
  34. PDefender->StatusEffectContainer->DelStatusEffectsByFlag(EFFECTFLAG_DAMAGE);
  35.  
  36. if(PDefender->animation == ANIMATION_SIT)
  37. {
  38. PDefender->animation = ANIMATION_NONE;
  39. ((CCharEntity*)PDefender)->pushPacket(new CCharUpdatePacket((CCharEntity*)PDefender));
  40. }
  41. charutils::UpdateHealth((CCharEntity*)PDefender);
  42. }
  43. break;
  44. case TYPE_MOB:
  45. {
  46. ((CMobEntity*)PDefender)->PEnmityContainer->UpdateEnmityFromDamage(PAttacker, damage);
  47. }
  48. break;
  49. }
  50. return damage;
  51. }
  52. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  53. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  54. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  55. if (magias == 21 || magias == 22 || magias >= 19 || magias <= 22 )
  56. {
  57. int32 damageMND = MND < 0 ? base + MND : base + (MND * M);
  58.  
  59. damageMND = damageMND * (100 - (10 * PAttacker->m_ActionList.size() / 2)) / 100;
  60. damageMND = damageMND * (1000 + PDefender->getMod(MOD_LIGHTRES + PSpell->getElement())) / 1000;
  61.  
  62. PDefender->addHP(-damageMND);
  63. PDefender->m_OwnerID = PAttacker->PMaster != NULL ? PAttacker->PMaster->id : PAttacker->id;
  64.  
  65. switch (PDefender->objtype)
  66. {
  67. case TYPE_PC:
  68. {
  69. PDefender->StatusEffectContainer->DelStatusEffectsByFlag(EFFECTFLAG_DAMAGE);
  70.  
  71. if(PDefender->animation == ANIMATION_SIT)
  72. {
  73. PDefender->animation = ANIMATION_NONE;
  74. ((CCharEntity*)PDefender)->pushPacket(new CCharUpdatePacket((CCharEntity*)PDefender));
  75. }
  76. charutils::UpdateHealth((CCharEntity*)PDefender);
  77. }
  78. break;
  79. case TYPE_MOB:
  80. {
  81. ((CMobEntity*)PDefender)->PEnmityContainer->UpdateEnmityFromDamage(PAttacker, damage);
  82. }
  83. break;
  84. }
  85. return damageMND;
  86. }
  87. }
Add Comment
Please, Sign In to add comment