Advertisement
Guest User

min dimwind pandarie

a guest
Apr 5th, 2020
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.77 KB | None | 0 0
  1. class mob_attacker_dimwind : public CreatureScript
  2. {
  3. public:
  4.     mob_attacker_dimwind() : CreatureScript("mob_attacker_dimwind") { }
  5.     CreatureAI* GetAI(Creature* creature) const
  6.     {
  7.         return new mob_attacker_dimwindAI(creature);
  8.     }
  9.    
  10.     struct mob_attacker_dimwindAI : public ScriptedAI
  11.     {
  12.         mob_attacker_dimwindAI(Creature* creature) : ScriptedAI(creature) {}
  13.        
  14.         void DamageTaken(Unit* pDoneBy, uint32 &uiDamage, DamageEffectType dmgType)
  15.         {
  16.             if(me->GetHealthPct() < 90 && pDoneBy && pDoneBy->ToCreature() && pDoneBy->ToCreature()->GetEntry() == 54785)
  17.                 uiDamage = 0;
  18.         }
  19.  
  20.         void JustDied(Unit* killer)
  21.         {
  22.             if (killer->GetTypeId() != TYPEID_PLAYER || !me->ToTempSummon())
  23.                 return;
  24.  
  25.             if (Creature* owner = me->GetMap()->GetCreature(me->ToTempSummon()->GetSummonerGUID()))
  26.                 owner->AI()->SetGUID(killer->GetGUID(), 0);
  27.         }
  28.     };
  29. };
  30.  
  31. class mob_min_dimwind : public CreatureScript
  32. {
  33. public:
  34.     mob_min_dimwind() : CreatureScript("mob_min_dimwind") { }
  35.    
  36.     CreatureAI* GetAI(Creature* creature) const
  37.     {
  38.         return new mob_min_dimwindAI(creature);
  39.     }
  40.    
  41.     struct mob_min_dimwindAI : public ScriptedAI
  42.     {
  43.         EventMap events;
  44.         GuidSet guidMob;
  45.         ObjectGuid plrGUID;
  46.         GuidSet m_player_for_event;
  47.         bool mt;
  48.  
  49.         mob_min_dimwindAI(Creature* creature) : ScriptedAI(creature)
  50.         {
  51.             mt = false;
  52.         }
  53.  
  54.         void Reset()
  55.         {
  56.             me->setActive(true);
  57.             me->HandleEmoteCommand(EMOTE_STATE_READY2H);
  58.         }
  59.  
  60.         void MoveInLineOfSight(Unit* who)
  61.         {
  62.             if (who->GetTypeId() != TYPEID_PLAYER || who->ToPlayer()->GetQuestStatus(QUEST_MISSING_DRIVER) != QUEST_STATUS_INCOMPLETE)
  63.                 return;
  64.            
  65.             GuidSet::iterator itr = m_player_for_event.find(who->GetGUID());
  66.             if (itr != m_player_for_event.end())
  67.                 return;
  68.  
  69.             m_player_for_event.insert(who->GetGUID());
  70.             if (!mt)
  71.             {
  72.                 mt = true;
  73.                 InitMobs(who);
  74.             }
  75.         }
  76.  
  77.         void DamageTaken(Unit* pDoneBy, uint32 &uiDamage, DamageEffectType dmgType)
  78.         {
  79.             if(me->GetHealthPct() < 25 && pDoneBy && pDoneBy->ToCreature() && pDoneBy->ToCreature()->GetEntry() == NPC_AMBERLEAF_SCAMP)
  80.                 uiDamage = 0;
  81.         }
  82.        
  83.         void SetGUID(ObjectGuid const& guid, int32 /*id*/ = 0)
  84.         {
  85.             plrGUID = guid;
  86.         }
  87.  
  88.         void SummonedCreatureDespawn(Creature* summon)
  89.         {
  90.             guidMob.erase(summon->GetGUID());
  91.             if (guidMob.empty())
  92.             {
  93.                 mt = false;
  94.                 me->HandleEmoteCommand(EMOTE_STATE_STAND);
  95.                 if (Player* target = sObjectAccessor->FindPlayer(plrGUID))
  96.                 {
  97.                     target->KilledMonsterCredit(54855, ObjectGuid::Empty);
  98.                     // by spell 106205
  99.                     if(TempSummon* mind = target->SummonCreature(NPC_MIN_DIMWIND_OUTRO, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1000))
  100.                     {
  101.                         mind->AI()->SetGUID(plrGUID, 0);
  102.                         mind->setFaction(35);
  103.                     }
  104.                 }
  105.                 me->DespawnOrUnsummon(1000);
  106.             }
  107.         }
  108.        
  109.         void InitMobs(Unit* who)
  110.         {
  111.             me->HandleEmoteCommand(EMOTE_STATE_READY2H);
  112.             for(GuidSet::iterator itr = guidMob.begin(); itr != guidMob.end(); ++itr)
  113.                 if (Creature* c = me->GetMap()->GetCreature(*itr))
  114.                     c->DespawnOrUnsummon(1000);
  115.             guidMob.clear();
  116.  
  117.             for(int i = 0; i < 4; i++)
  118.             {
  119.                 if(TempSummon* temp = me->SummonCreature(NPC_AMBERLEAF_SCAMP, me->GetPositionX()-3+rand()%6, me->GetPositionY() + 4 + rand()%4, me->GetPositionZ()+2, 3.3f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1000))
  120.                 {
  121.                     guidMob.insert(temp->GetGUID());
  122.                    
  123.                     if (i == 0)
  124.                         sCreatureTextMgr->SendChat(temp->ToCreature(), TEXT_GENERIC_0, who->GetGUID());
  125.  
  126.                     temp->SetFacingToObject(me);
  127.                     temp->HandleEmoteCommand(EMOTE_STATE_READY2H);
  128.                     temp->Attack(me, true);
  129.                     //temp->getThreatManager().addThreat(me, 250.0f);
  130.                 }
  131.             }
  132.         }
  133.     };
  134. };
  135.  
  136. class npc_min_dimwind_outro : public CreatureScript
  137. {
  138. public:
  139.     npc_min_dimwind_outro() : CreatureScript("npc_min_dimwind_outro") {}
  140.  
  141.     CreatureAI* GetAI(Creature* creature) const
  142.     {
  143.         return new npc_min_dimwind_outroAI (creature);
  144.     }
  145.  
  146.     struct npc_min_dimwind_outroAI : public npc_escortAI
  147.     {
  148.         npc_min_dimwind_outroAI(Creature* creature) : npc_escortAI(creature) {}
  149.  
  150.         EventMap events;
  151.         ObjectGuid playerGUID;
  152.  
  153.         enum eEvents
  154.         {
  155.             EVENT_1    = 1,
  156.             EVENT_2    = 2,
  157.         };
  158.  
  159.         void Reset()
  160.         {
  161.             playerGUID.Clear();
  162.         }
  163.  
  164.         void SetGUID(ObjectGuid const& guid, int32 id)
  165.         {
  166.             playerGUID = guid;
  167.             events.RescheduleEvent(EVENT_1, 1000);
  168.         }
  169.  
  170.         void WaypointReached(uint32 pointId)
  171.         {            
  172.             switch(pointId)
  173.             {
  174.                 case 3:
  175.                 case 4:
  176.                     sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2, playerGUID);
  177.                     break;
  178.                 case 12:
  179.                     sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3, playerGUID);
  180.                     me->DespawnOrUnsummon(30000);
  181.                     break;
  182.                 default:
  183.                     break;
  184.             }
  185.         }
  186.  
  187.         void UpdateAI(uint32 diff)
  188.         {
  189.             npc_escortAI::UpdateAI(diff);
  190.             events.Update(diff);
  191.  
  192.             if (uint32 eventId = events.ExecuteEvent())
  193.             {
  194.                 switch (eventId)
  195.                 {
  196.                     // emotes only when in vehicle.
  197.                     case EVENT_1:
  198.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, playerGUID);
  199.                         events.RescheduleEvent(EVENT_2, 1000);
  200.                         break;
  201.                     case EVENT_2:
  202.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1, playerGUID);
  203.                         Start(true, true);
  204.                         break;
  205.                     default:
  206.                         break;
  207.                 }
  208.             }
  209.         }
  210.     };
  211. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement