stoneharry

Untitled

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