stoneharry

Untitled

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