Advertisement
Bitupx

Untitled

Nov 2nd, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. ReturnValue Combat::canDoCombat(const Creature* attacker, const Creature* target, bool isAggressive)
  2. {
  3. if(!attacker)
  4. return RET_NOERROR;
  5.  
  6. bool success = true;
  7. CreatureEventList combatEvents = const_cast<Creature*>(attacker)->getCreatureEvents(CREATURE_EVENT_COMBAT);
  8. for(CreatureEventList::iterator it = combatEvents.begin(); it != combatEvents.end(); ++it)
  9. {
  10. if(!(*it)->executeCombat(const_cast<Creature*>(attacker), const_cast<Creature*>(target), isAggressive) && success)
  11. success = false;
  12. }
  13.  
  14. if(!success)
  15. return RET_NOTPOSSIBLE;
  16.  
  17. if(g_config.getBool(ConfigManager::MONSTER_ATTACK_MONSTER))
  18. {
  19. if(target->getType() == CREATURETYPE_MONSTER && attacker->getType() == CREATURETYPE_MONSTER && !target->isPlayerSummon() && !attacker->isPlayerSummon())
  20. return RET_NOTPOSSIBLE;
  21.  
  22. if(!attacker->isSummon() && !target->isSummon()) {
  23. if(attacker->getType() == CREATURETYPE_MONSTER && target->getType() == CREATURETYPE_MONSTER)
  24. return RET_NOTPOSSIBLE;
  25. }
  26. }
  27.  
  28. if (attacker->isSummon())
  29. {
  30. if (target == attacker->getMaster())
  31. {
  32. return RET_NOTPOSSIBLE;
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement