stoneharry

Untitled

Jun 15th, 2011
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.88 KB | None | 0 0
  1. //AI for Shield Orbs
  2. struct mob_shield_orbAI : public ScriptedAI
  3. {
  4.     mob_shield_orbAI(Creature* c) : ScriptedAI(c)
  5.     {
  6.         pInstance = c->GetInstanceData();
  7.     }
  8.  
  9.     ScriptedInstance* pInstance;
  10.  
  11.     bool bPointReached;
  12.     bool bClockwise;
  13.     uint32 uiTimer;
  14.     uint32 uiCheckTimer;
  15.     float x, y, r, c, mx, my;
  16.  
  17.     void Reset()
  18.     {
  19.         me->AddUnitMovementFlag(MOVEFLAG_LEVITATING);
  20.         bPointReached = true;
  21.         uiTimer = urand(500,1000);
  22.         uiCheckTimer = 1000;
  23.         r = 17;
  24.         c = 0;
  25.         mx = ShieldOrbLocations[0][0];
  26.         my = ShieldOrbLocations[0][1];
  27.         bClockwise = urand(0,1);
  28.     }
  29.  
  30.     void UpdateAI(const uint32 diff)
  31.     {
  32.         if (bPointReached)
  33.         {
  34.             if (bClockwise)
  35.             {
  36.                 y = my - r * sin(c);
  37.                 x = mx - r * cos(c);
  38.             }
  39.             else
  40.             {
  41.                 y = my + r * sin(c);
  42.                 x = mx + r * cos(c);
  43.             }
  44.             bPointReached = false;
  45.             uiCheckTimer = 1000;
  46.             me->GetMotionMaster()->MovePoint(1,x, y, SHIELD_ORB_Z);
  47.             c += M_PI/32;
  48.             if (c >= 2*M_PI) c = 0;
  49.         }
  50.         else
  51.         {
  52.             if (uiCheckTimer <= diff)
  53.             {
  54.                 DoTeleportTo(x,y,SHIELD_ORB_Z);
  55.                 bPointReached = true;
  56.             }
  57.             else uiCheckTimer -= diff;
  58.         }
  59.  
  60.         if (uiTimer <= diff)
  61.         {
  62.             if (Unit* random = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0))
  63.                 DoCast(random, SPELL_SHADOW_BOLT, false);
  64.             uiTimer = urand(500,1000);
  65.         } else uiTimer -= diff;
  66.     }
  67.  
  68.     void MovementInform(uint32 type, uint32 /*id*/)
  69.     {
  70.         if (type != POINT_MOTION_TYPE)
  71.             return;
  72.  
  73.         bPointReached = true;
  74.     }
  75. };
Advertisement
Add Comment
Please, Sign In to add comment