Guest User

Untitled

a guest
Jun 22nd, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.50 KB | None | 0 0
  1. From 4f7498042ee217b8c9e0ffe0c73a1a2350d4a585 Mon Sep 17 00:00:00 2001
  2. From: higi <higi@calu.cz>
  3. Date: Sat, 11 Feb 2012 14:41:48 +0100
  4. Subject: [PATCH]  ulduar stuff
  5.  
  6. ---
  7.  src/server/game/AI/CreatureAI.cpp                  |   52 +++++++++++++++++++-
  8.  src/server/game/AI/CreatureAI.h                    |    4 +-
  9.  src/server/game/AI/ScriptedAI/ScriptedCreature.cpp |   49 ++++++++++++++----
  10.  3 files changed, 92 insertions(+), 13 deletions(-)
  11.  
  12. diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
  13. index c8818f8..6c56818 100755
  14. --- a/src/server/game/AI/CreatureAI.cpp
  15. +++ b/src/server/game/AI/CreatureAI.cpp
  16. @@ -22,6 +22,7 @@
  17.  #include "World.h"
  18.  #include "SpellMgr.h"
  19.  #include "Vehicle.h"
  20. +#include "Group.h"
  21.  #include "Log.h"
  22.  #include "MapReference.h"
  23.  #include "Player.h"
  24. @@ -110,7 +111,56 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/, float maxRangeToN
  25.      }
  26.  }
  27.  
  28. -// scripts does not take care about MoveInLineOfSight loops
  29. +void CreatureAI::DoAttackerAreaInCombat(Unit* attacker, float range, Unit* pUnit)
  30. +{
  31. +    if (!attacker)
  32. +        attacker = me;
  33. +
  34. +    if (!pUnit)
  35. +        pUnit = me;
  36. +
  37. +    Map *map = pUnit->GetMap();
  38. +
  39. +    if (!map->IsDungeon())
  40. +        return;
  41. +
  42. +    if (!pUnit->CanHaveThreatList() || pUnit->getThreatManager().isThreatListEmpty())
  43. +        return;
  44. +
  45. +    Map::PlayerList const &PlayerList = map->GetPlayers();
  46. +    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
  47. +    {
  48. +        if (Player* i_pl = i->getSource())
  49. +            if (i_pl->isAlive() && attacker->GetDistance(i_pl) <= range )
  50. +            {
  51. +                pUnit->SetInCombatWith(i_pl);
  52. +                i_pl->SetInCombatWith(pUnit);
  53. +                pUnit->AddThreat(i_pl, 0.0f);
  54. +            }
  55. +    }
  56. +}
  57. +
  58. +void CreatureAI::DoAttackerGroupInCombat(Player* attacker)
  59. +{
  60. +    if (attacker)
  61. +    {
  62. +        if (Group* pGroup = attacker->GetGroup() )
  63. +        {
  64. +            for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
  65. +            {
  66. +                Player* pGroupGuy = itr->getSource();
  67. +
  68. +                if (pGroupGuy && pGroupGuy->isAlive() && pGroupGuy->GetMapId() == me->GetMapId())
  69. +                {
  70. +                    me->SetInCombatWith(pGroupGuy);
  71. +                    pGroupGuy->SetInCombatWith(me);
  72. +                    me->AddThreat(pGroupGuy, 0.0f);
  73. +                }
  74. +            }
  75. +        }
  76. +    }
  77. +}
  78. +
  79.  // MoveInLineOfSight can be called inside another MoveInLineOfSight and cause stack overflow
  80.  void CreatureAI::MoveInLineOfSight_Safe(Unit* who)
  81.  {
  82. diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h
  83. index 0113447..4831a2b 100755
  84. --- a/src/server/game/AI/CreatureAI.h
  85. +++ b/src/server/game/AI/CreatureAI.h
  86. @@ -97,6 +97,7 @@ class CreatureAI : public UnitAI
  87.          // Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
  88.          virtual void EnterCombat(Unit* /*victim*/) {}
  89.  
  90. +        virtual void ElementalDamageTaken(Unit * /*done_by*/, uint32 /*damage*/, SpellSchoolMask /*damageSchoolMask*/) {}
  91.          // Called when the creature is killed
  92.          virtual void JustDied(Unit* /*killer*/) {}
  93.  
  94. @@ -125,7 +126,6 @@ class CreatureAI : public UnitAI
  95.  
  96.          // Called at waypoint reached or point movement finished
  97.          virtual void MovementInform(uint32 /*type*/, uint32 /*id*/) {}
  98. -        virtual void SummonedCreatureMovementInform(uint32 /*MovementType*/, uint32 /*Data*/, Creature *) {}
  99.  
  100.          void OnCharmed(bool apply);
  101.  
  102. @@ -135,6 +135,8 @@ class CreatureAI : public UnitAI
  103.          virtual void JustReachedHome() {}
  104.  
  105.          void DoZoneInCombat(Creature* creature = NULL, float maxRangeToNearestTarget = 50.0f);
  106. +        void DoAttackerAreaInCombat(Unit* attacker, float range, Unit* pUnit = NULL);
  107. +        void DoAttackerGroupInCombat(Player* attacker);
  108.  
  109.          // Called at text emote receive from player
  110.          virtual void ReceiveEmote(Player* /*player*/, uint32 /*emoteId*/) {}
  111. diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
  112. index e3518cb..8851754 100644
  113. --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
  114. +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
  115. @@ -42,7 +42,7 @@ void SummonList::DoAction(uint32 entry, int32 info)
  116.      }
  117.  }
  118.  
  119. -void SummonList::DespawnEntry(uint32 entry)
  120. +void SummonList::DespawnEntry(uint32 entry, uint32 msTimeToDespawn)
  121.  {
  122.      for (iterator i = begin(); i != end();)
  123.      {
  124. @@ -52,14 +52,14 @@ void SummonList::DespawnEntry(uint32 entry)
  125.          else if (summon->GetEntry() == entry)
  126.          {
  127.              erase(i++);
  128. -            summon->DespawnOrUnsummon();
  129. +            summon->DespawnOrUnsummon(msTimeToDespawn);
  130.          }
  131.          else
  132.              ++i;
  133.      }
  134.  }
  135.  
  136. -void SummonList::DespawnAll()
  137. +void SummonList::DespawnAll(uint32 msTimeToDespawn)
  138.  {
  139.      while (!empty())
  140.      {
  141. @@ -69,7 +69,13 @@ void SummonList::DespawnAll()
  142.          else
  143.          {
  144.              erase(begin());
  145. -            summon->DespawnOrUnsummon();
  146. +            if (TempSummon* summ = summon->ToTempSummon())
  147. +            {
  148. +                summon->DestroyForNearbyPlayers();
  149. +                summ->UnSummon(msTimeToDespawn);
  150. +            }
  151. +            else
  152. +                summon->DespawnOrUnsummon(msTimeToDespawn);
  153.          }
  154.      }
  155.  }
  156. @@ -298,7 +304,8 @@ void ScriptedAI::DoModifyThreatPercent(Unit* unit, int32 pct)
  157.  void ScriptedAI::DoTeleportTo(float x, float y, float z, uint32 time)
  158.  {
  159.      me->Relocate(x, y, z);
  160. -    me->SendMonsterMove(x, y, z, time);
  161. +    float speed = me->GetDistance(x, y, z) / ((float)time * 0.001f);
  162. +    me->MonsterMoveWithSpeed(x, y, z, speed);
  163.  }
  164.  
  165.  void ScriptedAI::DoTeleportTo(const float position[4])
  166. @@ -406,7 +413,8 @@ enum eNPCs
  167.      NPC_BROODLORD   = 12017,
  168.      NPC_VOID_REAVER = 19516,
  169.      NPC_JAN_ALAI    = 23578,
  170. -    NPC_SARTHARION  = 28860
  171. +    NPC_SARTHARION  = 28860,
  172. +    NPC_LEVIATHAN   = 33113
  173.  };
  174.  
  175.  // Hacklike storage used for misc creatures that are expected to evade of outside of a certain area.
  176. @@ -430,7 +438,7 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(uint32 const diff)
  177.  
  178.      switch (me->GetEntry())
  179.      {
  180. -        case NPC_BROODLORD:                                         // broodlord (not move down stairs)
  181. +        case NPC_BROODLORD:                                           // broodlord (not move down stairs)
  182.              if (z > 448.60f)
  183.                  return false;
  184.              break;
  185. @@ -438,14 +446,18 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(uint32 const diff)
  186.              if (me->GetDistance2d(432.59f, 371.93f) < 105.0f)
  187.                  return false;
  188.              break;
  189. -        case NPC_JAN_ALAI:                                         // jan'alai (calculate by Z)
  190. +        case NPC_JAN_ALAI:                                            // jan'alai (calculate by Z)
  191.              if (z > 12.0f)
  192.                  return false;
  193.              break;
  194. -        case NPC_SARTHARION:                                         // sartharion (calculate box)
  195. +        case NPC_SARTHARION:                                          // sartharion (calculate box)
  196.              if (x > 3218.86f && x < 3275.69f && y < 572.40f && y > 484.68f)
  197.                  return false;
  198.              break;
  199. +        case NPC_LEVIATHAN:                                           // flame leviathan (calculate box)
  200. +            if (x > 145.14f && x < 447.26f && y < 83.29f && y > -149.73f)
  201. +                return false;
  202. +            break;
  203.          default: // For most of creatures that certain area is their home area.
  204.              sLog->outDetail("TSCR: EnterEvadeIfOutOfCombatArea used for creature entry %u, but does not have any definition. Using the default one.", me->GetEntry());
  205.              uint32 homeAreaId = me->GetMap()->GetAreaId(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY(), me->GetHomePosition().GetPositionZ());
  206. @@ -474,6 +486,7 @@ BossAI::BossAI(Creature* creature, uint32 bossId) : ScriptedAI(creature),
  207.      _boundary(instance ? instance->GetBossBoundary(bossId) : NULL),
  208.      _bossId(bossId)
  209.  {
  210. +    SetImmuneToPushPullEffects(true);
  211.  }
  212.  
  213.  void BossAI::_Reset()
  214. @@ -486,6 +499,8 @@ void BossAI::_Reset()
  215.      summons.DespawnAll();
  216.      if (instance)
  217.          instance->SetBossState(_bossId, NOT_STARTED);
  218. +
  219. +    inFightAggroCheck_Timer = MAX_AGGRO_PULSE_TIMER;
  220.  }
  221.  
  222.  void BossAI::_JustDied()
  223. @@ -499,6 +514,18 @@ void BossAI::_JustDied()
  224.      }
  225.  }
  226.  
  227. +void BossAI::_DoAggroPulse(const uint32 diff)
  228. +{
  229. +    if (inFightAggroCheck_Timer < diff)
  230. +    {
  231. +        if (me->getVictim() && me->getVictim()->ToPlayer())
  232. +            DoAttackerGroupInCombat(me->getVictim()->ToPlayer());
  233. +        inFightAggroCheck_Timer = MAX_AGGRO_PULSE_TIMER;
  234. +    }
  235. +    else
  236. +        inFightAggroCheck_Timer -= diff;
  237. +}
  238. +
  239.  void BossAI::_EnterCombat()
  240.  {
  241.      me->setActive(true);
  242. @@ -594,7 +621,7 @@ void BossAI::UpdateAI(uint32 const diff)
  243.  
  244.      events.Update(diff);
  245.  
  246. -    if (me->HasUnitState(UNIT_STAT_CASTING))
  247. +    if (me->HasUnitState(UNIT_STATE_CASTING))
  248.          return;
  249.  
  250.      while (uint32 eventId = events.ExecuteEvent())
  251. @@ -653,7 +680,7 @@ void WorldBossAI::UpdateAI(uint32 const diff)
  252.  
  253.      events.Update(diff);
  254.  
  255. -    if (me->HasUnitState(UNIT_STAT_CASTING))
  256. +    if (me->HasUnitState(UNIT_STATE_CASTING))
  257.          return;
  258.  
  259.      while (uint32 eventId = events.ExecuteEvent())
  260. --
  261. 1.7.7.msysgit.1
Add Comment
Please, Sign In to add comment