Advertisement
Guest User

Untitled

a guest
May 28th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.27 KB | None | 0 0
  1. // Threat From Above
  2. #define CN_CHILLMAW                 33687
  3. #define CN_CULTIST_BOMBARDIER       33695
  4.  
  5. // Threat From Above - Chillmaw
  6. class Chillmaw : public MoonScriptCreatureAI
  7. {
  8.     MOONSCRIPT_FACTORY_FUNCTION(Chillmaw, MoonScriptCreatureAI);
  9.     uint32 spawnstate;
  10.  
  11.     Chillmaw(Creature *pCreature) : MoonScriptCreatureAI(pCreature){}
  12.  
  13.     void OnCombatStart(Unit *pAttacker)
  14.     {
  15.         spawnstate = 1;
  16.         RegisterAIUpdateEvent(10*1000);
  17.  
  18.         ParentClass::OnCombatStart(pAttacker);
  19.     }
  20.  
  21.     void OnCombatStop(Unit *pTarget)
  22.     {
  23.         DespawnInRangeCreatures(CN_CULTIST_BOMBARDIER);
  24.  
  25.         ParentClass::OnCombatStop(pTarget);
  26.     }
  27.  
  28.     void AIUpdate()
  29.     {
  30.         if (GetHealthPercent() <= 25 && spawnstate == 3)
  31.         {
  32.             SpawnBombardier();
  33.             spawnstate = 0;
  34.             RemoveAIUpdateEvent();
  35.         }
  36.         else
  37.         {
  38.             if (GetHealthPercent() <= 50 && spawnstate == 2)
  39.             {
  40.                 SpawnBombardier();
  41.                 spawnstate = 3;
  42.             }
  43.             else
  44.             {
  45.                 if (GetHealthPercent() <= 75 && spawnstate == 1)
  46.                 {
  47.                     SpawnBombardier();
  48.                     spawnstate = 2;
  49.                 }
  50.             }
  51.         }
  52.     }
  53.  
  54.     void SpawnBombardier()
  55.     {
  56.         MoonScriptCreatureAI *creat = SpawnCreature(CN_CULTIST_BOMBARDIER, true);
  57.         if (creat == NULL)
  58.             return;
  59.         creat->AggroNearestPlayer();
  60.     }
  61. };
  62.  
  63. // Threat From Above - Cultist Bombardier       TODO: still needs to cast spells. but bored atm
  64. class CultistBombardier : public MoonScriptCreatureAI
  65. {
  66.     MOONSCRIPT_FACTORY_FUNCTION(CultistBombardier, MoonScriptCreatureAI);
  67.     CultistBombardier(Creature *pCreature) : MoonScriptCreatureAI(pCreature)
  68.     {
  69.         _unit->SetSelectable(true);
  70.         _unit->EnableCombat(true);
  71.         _unit->SetAttackable(true);
  72.     }
  73. };
  74.  
  75. // Jack Me Some Lumber
  76. class ChopTree : public SpellScript
  77. {
  78. public:
  79.     void OnInit(SpellEntry *sp)
  80.     {
  81.         sSpellMgr.fixRequiresAreaId(sp, 4549);
  82.     }
  83.  
  84.     bool OnEffect(Spell *spell, uint32 i)
  85.     {
  86.         Player *plr = spell->p_caster;
  87.         if (plr == NULL)
  88.             return false;
  89.         ItemPrototype *proto = ItemPrototypeStorage.LookupEntry(45045);
  90.         if (proto == NULL)
  91.             return false;
  92.  
  93.         SlotResult slotresult = plr->GetItemInterface()->FindFreeInventorySlot(proto);
  94.         if (slotresult.Result == false)
  95.         {
  96.             plr->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_INVENTORY_FULL);
  97.             return false;
  98.         }
  99.         else
  100.         {
  101.             if (plr->GetItemInterface()->GetItemCount(45045, false) == 12)
  102.                 return false;
  103.             else
  104.             {
  105.                 Item *item = objmgr.CreateItem(45045, plr);
  106.                 plr->GetItemInterface()->SafeAddItem(item, slotresult.ContainerSlot, slotresult.Slot);
  107.                 return true;
  108.             }
  109.         }
  110.     }
  111. };
  112.  
  113. // What Do You Feed a Yeti. Anyway?         //TODO: need proper function to check if plr is underwater instead of using the z-axis
  114. #define CN_NORTH_SEA_BLUE_SHARK     35061
  115. #define CN_NORTH_SEA_MAKO           35071
  116. #define CN_NORTH_SEA_THRESHER       35060
  117. #define CN_ANGRY_KVALDIR            35072
  118.  
  119. class FreshChum : public SpellScript
  120. {
  121. public:
  122.     uint8 CanCast(Spell *spell, Unit *target)
  123.     {
  124.         Player *plr = spell->p_caster;
  125.         if (plr == NULL)
  126.             return SPELL_FAILED_BAD_TARGETS;
  127.  
  128.         if (plr->GetPositionZ() > 0.0f)
  129.             return SPELL_FAILED_ONLY_UNDERWATER;
  130.  
  131.         // check so players can't abuse it. Only useable near the boats
  132.         GameObject *go = plr->GetGameObjectNearestObject(plr, 195352);
  133.         if (go == NULL)
  134.         {
  135.             go = plr->GetGameObjectNearestObject(plr, 195353);
  136.             if (go == NULL)
  137.                 return SPELL_FAILED_OUT_OF_RANGE;
  138.         }
  139.         return SPELL_CANCAST_OK;
  140.     }
  141.  
  142.     void ExtraEffect(Spell *spell)
  143.     {
  144.         Player *plr = spell->p_caster;
  145.         if (plr == NULL)
  146.             return;
  147.  
  148.         uint32 randomMob = RandomUInt(3);
  149.         uint32 randomShark = RandomUInt(2);
  150.  
  151.         switch(randomMob)
  152.         {
  153.             case 0:
  154.                 switch (randomShark)
  155.                 {
  156.                     case 0:
  157.                         plr->SpawnCreature(CN_NORTH_SEA_BLUE_SHARK, plr->GetPositionX()+5, plr->GetPositionY()+5, plr->GetPositionZ(), plr->GetOrientation(), 2*60*1000);
  158.                         break;
  159.                     case 1:
  160.                         plr->SpawnCreature(CN_NORTH_SEA_MAKO, plr->GetPositionX()+5, plr->GetPositionY()+5, plr->GetPositionZ(), plr->GetOrientation(), 2*60*1000);
  161.                         break;
  162.                     case 2:
  163.                         plr->SpawnCreature(CN_NORTH_SEA_THRESHER, plr->GetPositionX()+5, plr->GetPositionY()+5, plr->GetPositionZ(), plr->GetOrientation(), 2*60*1000);
  164.                         break;
  165.                 }
  166.                 break;
  167.             default:
  168.                 plr->SpawnCreature(CN_ANGRY_KVALDIR, plr->GetPositionX()+5, plr->GetPositionY()+5, plr->GetPositionZ(), plr->GetOrientation(), 2*60*1000);
  169.                 break;
  170.         }
  171.     }
  172. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement