Advertisement
Bitupx

Untitled

Aug 29th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. // COMBAT.CPP
  2. ReturnValue Combat::canDoCombat(const Creature* attacker, const Creature* target, bool isAggressive)
  3. {
  4. if(!attacker)
  5. return RET_NOERROR;
  6.  
  7. // Verifica si el combate está deshabilitado para el atacante
  8. if (attacker->isCombatDisabled()) {
  9. return RET_NOTPOSSIBLE;
  10. }
  11.  
  12. // Resto de la lógica....
  13. }
  14.  
  15. // CREATURE.H
  16. class Creature : public AutoId, virtual public Thing
  17. {
  18. protected:
  19. Creature();
  20.  
  21. public:
  22. bool isCombatDisabled() const;
  23. };
  24.  
  25. // CREATURE.CPP
  26. bool Creature::isCombatDisabled() const
  27. {
  28. return hasCondition(CONDITION_COMBAT_DISABLE);
  29. }
  30.  
  31. // CONDITION.H
  32. enum ConditionType_t
  33. {
  34. CONDITION_LOGINPROTECTION = 1 << 25,
  35. CONDITION_COMBAT_DISABLE = 1 << 26
  36. };
  37.  
  38. // 050-FUNCTION.LUA
  39. function isCombatDisabled(creatureId)
  40. return hasCondition(creatureId, CONDITION_COMBAT_DISABLE)
  41. end
  42.  
  43. // GAMAKICHI_FOLLOW.LUA
  44. function onThink(creatureId)
  45. if not isCreature(creatureId) then
  46. return true
  47. end
  48.  
  49. if isCombatDisabled(creatureId) then
  50. -- Si el combate está deshabilitado, simplemente detenemos cualquier ataque en curso
  51. local target = getCreatureTarget(creatureId)
  52. if target ~= 0 then
  53. doRemoveCondition(creatureId, CONDITION_INFIGHT)
  54. end
  55. return true
  56. end
  57.  
  58.  
  59. local master = getCreatureMaster(creatureId)
  60. if master and isPlayer(master) then
  61. end
  62. return true
  63. end
  64.  
  65. // MONSTER.XML
  66. <script>
  67. <event name="GamakichiThink"/>
  68. </script>
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement