void JustDied(Unit* killer)
        {
            if (!ghost && instance)
            {
                Unit* dalronn = Unit::GetUnit(*me, instance->GetData64(DATA_DALRONN));
                if (dalronn)
                {
                    if (dalronn->isDead())
                    {
                        DoScriptText(YELL_SKARVALD_DAL_DIED, me);
                        instance->SetData(DATA_SKARVALD_DALRONN_EVENT, DONE);
						if(IsHeroic()){
						Map* map = me->GetMap();
						Map::PlayerList const &PlayerList = map->GetPlayers();
						for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
						if (Player* player = itr->getSource())
							 player->AddItem(ITEM_EMBLEM_OF_HEROISM,1);
						}
                    }
                    else
                    {
                        DoScriptText(YELL_SKARVALD_SKA_DIEDFIRST, me);

                        me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
                        //DoCast(me, SPELL_SUMMON_SKARVALD_GHOST, true);
                        Creature* temp = me->SummonCreature(MOB_SKARVALD_GHOST, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_CORPSE_DESPAWN, 5000);
                        if (temp)
                        {
                            temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            temp->AI()->AttackStart(killer);
                        }
                    }
                }
            }
        }
Example #2
0
static bool HandleRespawnCommand(ChatHandler* handler, char const* /*args*/)
    {
        Player* player = handler->GetSession()->GetPlayer();

        Unit* target = handler->getSelectedUnit();
        if (player->GetSelection() && target)
        {
            if (target->GetTypeId() != TYPEID_UNIT || target->isPet())
            {
                handler->SendSysMessage(LANG_SELECT_CREATURE);
                handler->SetSentErrorMessage(true);
                return false;
            }
			if(player->GetAreaId() == 4722)
				return false;

            if (target->isDead())
                target->ToCreature()->Respawn();
            return true;
        }

        CellCoord p(Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()));
        Cell cell(p);
        cell.SetNoCreate();

        Trinity::RespawnDo u_do;
        Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do);

        TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
        cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange());

        return true;
    }
Example #3
0
//Gets the first found attacker of Unit if not nearestToAttacked > finds the one nearest to bot
Unit *PlayerbotClassAI::GetNearestAttackerOf(Unit *pAttacked, bool nearestToAttacked)
{
    if (!pAttacked) {
        pAttacked = m_bot;
        if (!pAttacked) return NULL;
    }

    Unit::AttackerSet fAttackerSet = pAttacked->getAttackers();
    if (fAttackerSet.size() <= 0) {
        return NULL;
    }

    Unit *nearestTo = m_bot;
    if (nearestToAttacked) {
        nearestTo = pAttacked;
    }

    Unit *curAtt = NULL;
    float minDist = 30;


    for (Unit::AttackerSet::const_iterator itr = fAttackerSet.begin(); itr != fAttackerSet.end(); ++itr)
    {
        Unit *tAtt = (*itr);
        if (!tAtt) break; // Something is wrong.. How can a non existing mob attack?
        if (tAtt->isDead()) break;
        if (m_bot->GetDistance(tAtt) >= minDist) continue; //Get the nearest one
        curAtt = tAtt;
        minDist = tAtt->GetDistance(nearestTo);
    }
    return curAtt;

}
        void JustDied(Unit* killer)
        {
            if (!ghost && instance)
            {
                Unit* skarvald = Unit::GetUnit(*me, instance->GetData64(DATA_SKARVALD));
                if (skarvald)
                {
                    if (skarvald->isDead())
                    {
                        Talk(YELL_DALRONN_SKA_DIED);

                        if (instance)
                            instance->SetData(DATA_SKARVALD_DALRONN_EVENT, DONE);
                    }
                    else
                    {
                        Talk(YELL_DALRONN_DAL_DIEDFIRST);

                        me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
                        //DoCast(me, SPELL_SUMMON_DALRONN_GHOST, true);
                        Creature* temp = me->SummonCreature(NPC_DALRONN_GHOST, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_CORPSE_DESPAWN, 5000);
                        if (temp)
                        {
                            temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            temp->AI()->AttackStart(killer);
                        }
                    }
                }
            }
        }
    void JustDied(Unit* Killer)
    {
        if (!ghost && m_pInstance)
        {
            Unit* dalronn = m_creature->GetMap()->GetUnit(ObjectGuid(m_pInstance->GetData64(DATA_DALRONN)));
            if (dalronn)
            {
                if (dalronn->isDead())
                {
                    DoScriptText(YELL_SKARVALD_DAL_DIED,m_creature);

					m_pInstance->SetData(DATA_SKARVALD_DALRONN_EVENT, DONE);

					if(pGhost = GetClosestCreatureWithEntry(m_creature, MOB_DALRONN_GHOST, 1000))
						pGhost->ForcedDespawn();
                }
                else
                {
                    DoScriptText(YELL_SKARVALD_SKA_DIEDFIRST,m_creature);

                    m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
                    //DoCast(m_creature, SPELL_SUMMON_SKARVALD_GHOST, true);
                    Creature* temp = m_creature->SummonCreature(MOB_SKARVALD_GHOST,m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(),0,TEMPSUMMON_CORPSE_DESPAWN,5000);
                    if (temp)
                    {
                        temp->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NON_ATTACKABLE);
                        temp->AI()->AttackStart(Killer);
                    }
                }
            }
        }
    }
        void Reset()
        {
            Enraged = false;

            if (pInstance)
            {
                Unit* Temp =  Unit::GetUnit((*me), pInstance->GetData64(DATA_ALYTHESS));
                if (Temp)
                {
                    if (Temp->isDead())
                        CAST_CRE(Temp)->Respawn();
                    else if (Temp->getVictim())
                        me->getThreatManager().addThreat(Temp->getVictim(), 0.0f);
                }
            }

            if (!me->isInCombat())
            {
                ShadowbladesTimer = 10000;
                ShadownovaTimer = 30000;
                ConfoundingblowTimer = 25000;
                ShadowimageTimer = 20000;
                ConflagrationTimer = 30000;
                EnrageTimer = 360000;

                SisterDeath = false;
            }

            if (pInstance)
                pInstance->SetData(DATA_EREDAR_TWINS_EVENT, NOT_STARTED);
        }
 void UpdateAI(const uint32 diff)
 {
     if (!Vorpil)
     {
         me->DealDamage(me, me->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
         return;
     }
     if (move <= diff)
     {
         if (sacrificed)
         {
             SpellEntry *spell = (SpellEntry *)GetSpellStore()->LookupEntry(HeroicMode?H_SPELL_EMPOWERING_SHADOWS:SPELL_EMPOWERING_SHADOWS);
             if (spell)
                 Vorpil->AddAura(new EmpoweringShadowsAura(spell, 0, NULL, Vorpil, me));
             Vorpil->SetHealth(Vorpil->GetHealth()+Vorpil->GetMaxHealth()/25);
             DoCast(me, SPELL_SHADOW_NOVA, true);
             me->DealDamage(me, me->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
             return;
         }
         me->GetMotionMaster()->MoveFollow(Vorpil, 0, 0);
         if (me->GetDistance(Vorpil) < 3)
         {
             DoCast(me, SPELL_SACRIFICE, false);
             sacrificed = true;
             move = 500;
             return;
         }
         if (!Vorpil->isInCombat() || Vorpil->isDead())
         {
             me->DealDamage(me, me->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
             return;
         }
         move = 1000;
     } else move -= diff;
 }
        void Reset()
        {
            Enraged = false;

            if (pInstance)
            {
                Unit* Temp =  Unit::GetUnit((*me), pInstance->GetData64(DATA_SACROLASH));
                if (Temp)
                {
                    if (Temp->isDead())
                        CAST_CRE(Temp)->Respawn();
                    else if (Temp->getVictim())
                        me->getThreatManager().addThreat(Temp->getVictim(), 0.0f);
                }
            }

            if (!me->isInCombat())
            {
                ConflagrationTimer = 45000;
                BlazeTimer = 100;
                PyrogenicsTimer = 15000;
                ShadownovaTimer = 40000;
                EnrageTimer = 360000;
                FlamesearTimer = 15000;
                IntroYellTimer = 10000;

                SisterDeath = false;
            }

            if (pInstance)
                pInstance->SetData(DATA_EREDAR_TWINS_EVENT, NOT_STARTED);
        }
    void JustDied(Unit* Killer)
    {
        if(!ghost)
        {
            if (pInstance)
			{
				Unit* dalronn = Unit::GetUnit((*m_creature),pInstance->GetData64(NPC_DALRONN));
				if(dalronn)
				{
					if(dalronn->isDead())
					{
						DoScriptText(SAY_SKARVALD_DAL_DIED, m_creature);

						pInstance->SetData(EVENT_SKARVALD_AND_DALRONN, DONE);
						m_creature->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
						dalronn->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
					}
					else
					{
						DoScriptText(SAY_SKARVALD_SKA_DIEDFIRST, m_creature);
						m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
						Creature* temp = m_creature->SummonCreature(MOB_SKARVALD_GHOST, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_CORPSE_DESPAWN,5000);
						temp->AI()->AttackStart(Killer);
					}
				}
			}
        }
    }
Example #10
0
    void Reset()
    {
        m_creature->Relocate(2642.2,-3388.39,285.6); 
       (*m_creature).GetMotionMaster()->MoveTargetedHome();
        InCombat = false;
        phase1end_timer = 24000; 
        teleport_timer = 20000;//test
        harvestsouls_timer = 5000;//test
        shadowbolt_timer = 7500;//test
        phase = -1;    
        pos = -1; // teleport possition .. -1 Start , 0 life , 1 death
        spawn_trainee = 27000;
        spawn_deathknight = 77000;
        spawn_rider = 137000; 	

        m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
		if(pInstance)
		{
			pInstance->SetData(ENCOUNT_GOTHIK, 0);
			HandleDoors(GO_VACCUUM_EXIT, 1);
			HandleDoors(GO_VACCUUM_COMBAT, 0);
			HandleDoors(GO_DEATHKNIGHT_DOOR, 1);
            Unit *temp = Unit::GetUnit((*m_creature),pInstance->GetData64(GUID_RAZUVIOUS));
			if(temp && temp->isDead())
			    HandleDoors(GO_VACCUUM_ENTER, 0);
		}
    }
Example #11
0
uint8 PlayerbotClassAI::GetHealthPercentRaid(Player *gPlayer, uint8 &countNeedHealing)
{
    uint8 validMemberCount=0;
    uint16 totalHPPercent=0;
    std::list<Unit*> unitList;
    gPlayer->GetRaidMember(unitList,30);
    if(!unitList.empty()) {
        for (std::list<Unit*>::iterator itr = unitList.begin() ; itr!=unitList.end(); ++itr) {
            //Player *tPlayer = GetPlayerBot()->GetObjPlayer((*itr)->GetGUID());
            Unit *tPlayer = sObjectMgr->GetPlayer((*itr)->GetGUID());
            if(tPlayer == NULL) continue;
            if(tPlayer->isDead()) continue;
            if(GetPlayerBot()->GetAreaId() != tPlayer->GetAreaId()) continue;
            //if(tPlayer->GetGUID() == GetPlayerBot()->GetGUID()) continue;
            if(GetPlayerBot()->GetDistance(tPlayer) > 30) continue;
            uint8 fndHPPercent =  tPlayer->GetHealth()*100 / tPlayer->GetMaxHealth();
            totalHPPercent+=fndHPPercent;
            validMemberCount++;
            if (fndHPPercent < 100) countNeedHealing++;

            //const std::string myname = GetPlayerBot()->GetName();
            //const std::string hisname = tPlayer->GetName();
            //sLog->outDebug(LOG_FILTER_NETWORKIO, "me = %s, checked= %s %u [%u / %u]", myname.c_str(), hisname.c_str(), fndHPPercent, tPlayer->GetHealth(), tPlayer->GetMaxHealth());

        }
    }
    if (validMemberCount == 0) return 100;
    return totalHPPercent / validMemberCount;
}
Example #12
0
void Group::cleanDead()
{
	for (int x = 0; x < width; ++x)
		for (int y = 0; y < height; ++y)
		{
			Unit* unit = grid[x][y];
			if (unit != NULL && unit->isDead())
			{
				int x = unit->getGridX();
				int y = unit->getGridY();
				grid[x][y] = NULL;
				dead.push_back(unit);
			}
		}

	vector<Unit*> temp(summoned.size());
	int ind = 0;
	for (int i = 0; i < summoned.size(); ++i)
	{
		if (summoned[i]->isAvailable())
		{
			temp[ind] = summoned[i];
			++ind;
		}
	}
	temp.resize(ind);
	summoned = temp;
}
        void JustDied(Unit* Killer)
        {
            if (!ghost && instance)
            {
                Unit* dalronn = Unit::GetUnit((*me), instance->GetData64(DATA_DALRONN));
                if (dalronn)
                {
                    if (dalronn->isDead())
                    {
                        DoScriptText(YELL_SKARVALD_DAL_DIED, me);

                        instance->SetData(DATA_SKARVALD_DALRONN_EVENT, DONE);
                    }
                    else
                    {
                        DoScriptText(YELL_SKARVALD_SKA_DIEDFIRST, me);

                        me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
                        //DoCast(me, SPELL_SUMMON_SKARVALD_GHOST, true);
                        Creature* temp = me->SummonCreature(MOB_SKARVALD_GHOST, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_CORPSE_DESPAWN, 5000);
                        if (temp)
                        {
                            temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            temp->AI()->AttackStart(Killer);
                        }
                    }
                }
            }
        }
Example #14
0
    void UpdateAI(const uint32 diff) override
    {
        if (!zealot)
        {
            if (Unit* owner = m_creature->GetCreator())
                zealot = owner;
        }

        if (channelTarget == NULL/* || lastTarget == NULL */|| zealot == NULL)
            return;

        if (zealot->HasAura(SPELL_TWILIGHT_EVOLUTION) || zealot->isDead())
            return;

        if (uiCheckPlayerIsBetween <= diff)
        {
            channelTarget = zealot;
            Map::PlayerList const &PlayerList = m_creature->GetMap()->GetPlayers();

            if (!PlayerList.isEmpty())
            {
                for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                {
                    if(i->getSource()->IsInBetween(m_creature, zealot, 1.0f))
                        channelTarget = i->getSource();
                }
            }

            SpellAuraHolder* holder = channelTarget->GetSpellAuraHolder(SPELL_EVOLUTION, zealot->GetObjectGuid());
            if (!holder)
                holder = channelTarget->_AddAura(SPELL_EVOLUTION, 15000, zealot);

            if (holder)
            {
                holder->ModStackAmount(1);
                holder->RefreshHolder();

                if (holder->GetStackAmount() >= holder->GetSpellProto()->GetStackAmount())
                {
                    if(channelTarget == zealot)
                        channelTarget->RemoveAllAuras();

                    zealot->CastSpell(channelTarget, SPELL_TWILIGHT_EVOLUTION, true);
                }
            }

            uiCheckPlayerIsBetween = 500;
        }
        else
            uiCheckPlayerIsBetween -= diff;

        if (uiNetherEssenceVisual <= diff)
        {
            m_creature->CastSpell(m_creature, SPELL_NETHERESSENCE_VISUAL, true);
            uiNetherEssenceVisual = urand(3500,4000);
        }
        else
            uiNetherEssenceVisual -= diff;
    }
Example #15
0
 void MaxDamage::v_setHelper( const Unit &u, const vector< Unit > *vecVariables, const TargetSelectionDomain *domain )
 {
   if( !u.isDead() && u.canShoot() && u.getValue() != -1 )
   {
     auto hits = u.computeDamage( domain->getAllEnemies() );
     heuristicValueHelper.at( u.getValue() + 1 ) = 1. / hits.at( u.getValue() );
   }
 }
    void UpdateAI(const uint32 diff)
    {
        if(ghost)
        {
            if (pInstance)
				if(pInstance->GetData(EVENT_SKARVALD_AND_DALRONN) != IN_PROGRESS)
				{
					m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
				}
        }

       if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() )
            return;

        if(!ghost)
        {
            if(Check_Timer)
                if(Check_Timer < diff)
                {
                    Check_Timer = 5000;
                    if (pInstance)
					{
						Unit* dalronn = Unit::GetUnit((*m_creature),pInstance->GetData64(NPC_DALRONN));
						if(dalronn && dalronn->isDead())
						{
							Dalronn_isDead = true;
							Response_Timer = 2000;
							Check_Timer = 0;
						}
					}
                }else Check_Timer -= diff;

            if(Response_Timer) 
                if(Dalronn_isDead)
                    if(Response_Timer < diff)
                    {
                        DoScriptText(SAY_SKARVALD_DAL_DIEDFIRST,m_creature);

                        Response_Timer = 0;
                    }else Response_Timer -= diff;
        }

        if(Charge_Timer < diff)
        {
            DoCast(SelectUnit(SELECT_TARGET_RANDOM, 1), SPELL_CHARGE);
            Charge_Timer = 5000+rand()%5000;
        }else Charge_Timer -= diff;

        if(StoneStrike_Timer < diff)
        {
            DoCast(m_creature->getVictim(), SPELL_STONE_STRIKE);
            StoneStrike_Timer = 5000+rand()%5000;
        }else StoneStrike_Timer -= diff;
      
        DoMeleeAttackIfReady();
    }
Example #17
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

       if (m_creature->HasAura(SPELL_RIFT_SHIELD))
       {
            if (!m_ChaoticRiftGuid.IsEmpty())
            {
                Unit* Rift = m_creature->GetMap()->GetUnit(m_ChaoticRiftGuid);
                if (Rift && Rift->isDead())
                {
                    m_creature->RemoveAurasDueToSpell(SPELL_RIFT_SHIELD);
                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    DoScriptText(SAY_RIFT , m_creature);
                    m_ChaoticRiftGuid.Clear();
                }
                return;
            }
        }
        else
        {
            m_ChaoticRiftGuid.Clear();
            m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
        }

        if ((m_uiPhase == 0) && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.75))
        {
            m_uiPhase = 1;
            SummonRifts();
        }

        if ((m_uiPhase == 1) && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.50))
        {
            m_uiPhase = 2;
            SummonRifts();
        }

        if ((m_uiPhase == 2) && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.25))
        {
            m_uiPhase = 3;
            SummonRifts();
        }

        if (m_uiSparkTimer < uiDiff)
        {
            if (Unit *pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                DoCast(pTarget, m_bIsRegularMode ? SPELL_SPARK_N : SPELL_SPARK_H);
            m_uiSparkTimer = 5*IN_MILLISECONDS;
        }
        else
            m_uiSparkTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
Example #18
0
void Turret::update(int64 diff)
{
   // No target : try to find a new one
   if(!isAttacking) {
      const std::map<uint32, Object*>& objects = map->getObjects();
      Unit* nextTarget = 0;
      unsigned int nextTargetPriority = 10;
      for(auto& it : objects) {
         Unit* u = dynamic_cast<Unit*>(it.second);

         if(!u || u->isDead() || u->getTeam() == getTeam() || distanceWith(u) > TURRET_RANGE) {
            continue;
         }
         
         // Note: this method means that if there are two champions within turret range,
         // The player to have been added to the game first will always be targeted before the others
         if (!targetUnit) {
            auto priority = classifyTarget(u);
            if (priority < nextTargetPriority) {
               nextTarget = u;
               nextTargetPriority = priority;
            }
         } else {
            Champion* targetIsChampion = dynamic_cast<Champion*>(targetUnit);
            
            // Is the current target a champion? If it is, don't do anything
            if (!targetIsChampion) {
               // Find the next champion in range targeting an enemy champion who is also in range
               Champion* enemyChamp = dynamic_cast<Champion*>(u);
               if (enemyChamp&& enemyChamp->getTargetUnit() != 0) {
                  Champion* enemyChampTarget = dynamic_cast<Champion*>(enemyChamp->getTargetUnit());
                  if (enemyChampTarget &&                                                                   // Enemy Champion is targeting an ally
                      enemyChamp->distanceWith(enemyChampTarget) <= enemyChamp->getStats().getRange() &&    // Enemy within range of ally
                      distanceWith(enemyChampTarget) <= TURRET_RANGE) {                                     // Enemy within range of this turret
                     nextTarget = enemyChamp; // No priority required
                     break;
                  }
               }
            }
         }
      }
      if (nextTarget) {
         targetUnit = nextTarget;
         map->getGame()->notifySetTarget(this, nextTarget);
      }
   }
   
   // Lose focus of the unit target if the target is out of range
   if(targetUnit && distanceWith(targetUnit) > TURRET_RANGE) {
      setTargetUnit(0);
      map->getGame()->notifySetTarget(this, 0);
   }

   Unit::update(diff);
}
Example #19
0
bool ItemUse_item_muiseks_vessel(Player *player, Item* _Item, SpellCastTargets const& targets)
{
    Unit* uTarget = targets.getUnitTarget();
    uint32 itemSpell = _Item->GetProto()->Spells[0].SpellId;
    uint32 cEntry = 0;
    uint32 cEntry2 = 0;
    uint32 cEntry3 = 0;
    uint32 cEntry4 = 0;

    if(itemSpell)
    {
        switch(itemSpell)
        {
            case 11885:                                     //Wandering Forest Walker
                cEntry =  7584;
                break;
            case 11886:                                     //Owlbeasts
                cEntry =  2927;
                cEntry2 = 2928;
                cEntry3 = 2929;
                cEntry4 = 7808;
                break;
            case 11887:                                     //Freyfeather Hippogryphs
                cEntry =  5300;
                cEntry2 = 5304;
                cEntry3 = 5305;
                cEntry4 = 5306;
                break;
            case 11888:                                     //Sprite Dragon Sprite Darters
                cEntry =  5276;
                cEntry2 = 5278;
                break;
            case 11889:                                     //Zapped Land Walker Land Walker Zapped Cliff Giant Cliff Giant
                cEntry =  5357;
                cEntry2 = 5358;
                cEntry3 = 14640;
                cEntry4 = 14604;
                break;
        }
        if( uTarget && uTarget->GetTypeId()==TYPEID_UNIT && uTarget->isDead() &&
            (uTarget->GetEntry()==cEntry || uTarget->GetEntry()==cEntry2 || uTarget->GetEntry()==cEntry3 || uTarget->GetEntry()==cEntry4) )
        {
            ((Creature*)uTarget)->RemoveCorpse();
            return false;
        }
    }

    WorldPacket data(SMSG_CAST_FAILED, (4+2));              // prepare packet error message
    data << uint32(_Item->GetEntry());                      // itemId
    data << uint8(SPELL_FAILED_BAD_TARGETS);                // reason
    player->GetSession()->SendPacket(&data);                // send message: Invalid target

    player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL);      // break spell
    return true;
}
Example #20
0
 void JustDied(Unit* Killer)
 {
     if (pInstance)
     {
         pInstance->SetData(ENCOUNT_GLUTH, 2);
         HandleDoors(GO_GLUTH_EXIT, 0);
         Unit *temp = Unit::GetUnit((*m_creature),pInstance->GetData64(GUID_PATCHWERK));
         if (temp && temp->isDead())
             HandleDoors(GO_THADDIUS_DOOR, 0);
     }
 }
        void UpdateAI(uint32 diff)
        {
            if (ghost)
            {
                if (instance && instance->GetData(DATA_SKARVALD_DALRONN_EVENT) != IN_PROGRESS)
                    me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            }

            if (!UpdateVictim())
                return;

            if (!ghost)
            {
                if (Check_Timer)
                {
                    if (Check_Timer <= diff)
                    {
                        Check_Timer = 5000;
                        Unit* dalronn = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_DALRONN) : 0);
                        if (dalronn && dalronn->isDead())
                        {
                            Dalronn_isDead = true;
                            Response_Timer = 2000;
                            Check_Timer = 0;
                        }
                    } else Check_Timer -= diff;
                }
                if (Response_Timer && Dalronn_isDead)
                {
                    if (Response_Timer <= diff)
                    {
                        Talk(YELL_SKARVALD_DAL_DIEDFIRST);

                        Response_Timer = 0;
                    } else Response_Timer -= diff;
                }
            }

            if (Charge_Timer <= diff)
            {
                DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0, SkarvaldChargePredicate(me)), SPELL_CHARGE);
                Charge_Timer = 5000+rand()%5000;
            } else Charge_Timer -= diff;

            if (StoneStrike_Timer <= diff)
            {
                DoCastVictim(SPELL_STONE_STRIKE);
                StoneStrike_Timer = 5000+rand()%5000;
            } else StoneStrike_Timer -= diff;

            if (!me->HasUnitState(UNIT_STATE_CASTING))
                DoMeleeAttackIfReady();
        }
Example #22
0
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            if (me->GetDistance(me->GetHomePosition()) > 60.0f)
            {
                //Not blizzlike, hack to avoid an exploit
                EnterEvadeMode();
                return;
            }

            if (me->HasAura(SPELL_RIFT_SHIELD))
            {
                if (uiChaoticRiftGUID)
                {
                    Unit* Rift = Unit::GetUnit((*me), uiChaoticRiftGUID);
                    if (Rift && Rift->isDead())
                    {
                        me->RemoveAurasDueToSpell(SPELL_RIFT_SHIELD);
                        uiChaoticRiftGUID = 0;
                    }
                    return;
                }
            } else
                uiChaoticRiftGUID = 0;

            if (me->HealthBelowPct(100 - 25 * uiHealthAmountModifier))
            {
                ++uiHealthAmountModifier;
                DoScriptText(SAY_SHIELD, me);
                DoCast(me, SPELL_RIFT_SHIELD);
                Creature* Rift = me->SummonCreature(MOB_CHAOTIC_RIFT, RiftLocation[urand(0,5)], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1*IN_MILLISECONDS);
                if (Rift)
                {
                    me->AddAura(SPELL_CHARGE_RIFT,Rift);
                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                        Rift->AI()->AttackStart(pTarget);
                    uiChaoticRiftGUID = Rift->GetGUID();
                    DoScriptText(SAY_RIFT , me);
                }
            }


            if (uiSparkTimer <= diff)
            {
                if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                DoCast(pTarget, DUNGEON_MODE(SPELL_SPARK,H_SPELL_SPARK));
                uiSparkTimer = 5*IN_MILLISECONDS;
            } else uiSparkTimer -= diff;

            DoMeleeAttackIfReady();
        }
Example #23
0
void CollisionHandler::update(float a_DT)
{
	const std::map<uint32, Object*>& objects = chart->getObjects();

	for (auto i = objects.begin(); i != objects.end(); i++)
   //auto i = objects.begin();
	{
		Object* o1 = i->second;

      Unit * unit = dynamic_cast<Unit*>(o1);
      if (unit && unit->isDead()) continue; // Don't collide with anything if we're dead.

      for (auto j = objects.begin(); j != objects.end(); j++) if (j != i) // Object-Object collision
      {
         Object* o2 = j->second;

         unit = dynamic_cast<Unit*>(o2);
         if (unit && unit->isDead()) continue; // Can't collide with dead things.

         if ((o1->getPosition() - o2->getPosition()).SqrLength() < (o1->getCollisionRadius() + o2->getCollisionRadius())*(o1->getCollisionRadius() + o2->getCollisionRadius())) //distance check
         {
            o1->onCollision(o2); // Call the collision callback
            //o2->onCollision(01); 
            // Don't do this, it's being done in a later iteration, given that o1 doesn't move away in onCollision.
            // Uh, if it does, uncomment it I guess.
         }
		}

      Target *target = o1->getTarget();
      if (target)
      {
         Vector2 test = o1->getPosition() + (o1->getDirection()*((float)o1->getCollisionRadius()*2.0f)); // Get the outer bound of your character in the direction I am walking.
                                                                                                         // Have to multiply this radius by 2 for some reason.. Idk why.
                                                                                                         // TODO: Figure out why.

         if (!chart->getAIMesh()->isWalkable(test.X, test.Y)) // If we cant walk here according to the mesh.
            o1->onCollision(0);
      }
	}
}
Example #24
0
        void UpdateAI(const uint32 diff)
        {
            if (ghost)
            {
                if (pInstance && pInstance->GetData(DATA_SKARVALD_DALRONN_EVENT) != IN_PROGRESS)
                    me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            }

            if (!UpdateVictim())
                return;

            if (!ghost)
            {
                if (Check_Timer)
                {
                    if (Check_Timer <= diff)
                    {
                        Check_Timer = 5000;
                        Unit* dalronn = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_DALRONN) : 0);
                        if (dalronn && dalronn->isDead())
                        {
                            Dalronn_isDead = true;
                            Response_Timer = 2000;
                            Check_Timer = 0;
                        }
                    } else Check_Timer -= diff;
                }
                if (Response_Timer && Dalronn_isDead)
                {
                    if (Response_Timer <= diff)
                    {
                        DoScriptText(YELL_SKARVALD_DAL_DIEDFIRST, me);

                        Response_Timer = 0;
                    } else Response_Timer -= diff;
                }
            }

            if (Charge_Timer <= diff)
            {
                DoCast(SelectTarget(SELECT_TARGET_RANDOM, 1), SPELL_CHARGE);
                Charge_Timer = 5000+rand()%5000;
            } else Charge_Timer -= diff;

            if (StoneStrike_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_STONE_STRIKE);
                StoneStrike_Timer = 5000+rand()%5000;
            } else StoneStrike_Timer -= diff;

            DoMeleeAttackIfReady();
        }
Example #25
0
void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
{
	CHECK_INWORLD_RETURN;
	CHECK_PACKET_SIZE(recv_data, 8);
	uint64 guid;
	recv_data >> guid;

	if(!guid)
	{
		// does this mean cancel combat?
		HandleAttackStopOpcode(recv_data);
		return;
	}

	// AttackSwing
	DEBUG_LOG( "WORLD"," Recvd CMSG_ATTACKSWING Message" );

	if(GetPlayer()->IsPacified() || GetPlayer()->IsStunned() || GetPlayer()->IsFeared())
		return;

//	printf("Got ATTACK SWING: %08X %08X\n", GUID_HIPART(guid), GUID_LOPART(guid));
	Unit* pEnemy = _player->GetMapMgr()->GetUnit(guid);
	//printf("Pointer: %08X\n", pEnemy);

	if(!pEnemy)
	{
		OUT_DEBUG("WORLD: "I64FMT" does not exist.", guid);
		return;
	}

	if(pEnemy->isDead() || _player->isDead())		// haxors :(
		return;

	// Faction "Hack" by Deathshit
	if( !isAttackable( GetPlayer(), pEnemy, false ) && !pEnemy->IsInRangeOppFactSet(_player) && !pEnemy->CombatStatus.DidDamageTo(GetPlayer()->GetGUID()))
	{
		GetPlayer()->BroadcastMessage("Faction exploit detected. You will be disconnected in 5 seconds.");
		GetPlayer()->Kick(5000);
		return;
	}

	GetPlayer()->smsg_AttackStart(pEnemy);
	GetPlayer()->EventAttackStart();

	// Set PVP Flag.
	/*if(pEnemy->IsPlayer() && isHostile(_player, pEnemy))
	{
		// don't in duel.. this should be done in dealdamage anyway :S
		if( TO_PLAYER( pEnemy )->GetTeam() != _player->GetTeam() )
			_player->SetPvPFlag();
	}*/
}
bool PlayerbotShamanAI::HealGroup (Unit *target, uint8 hp, uint8 &countNeedHeal)
{
    Player *m_bot = GetPlayerBot();
    if (countNeedHeal < 2) { return false; }
    Unit *rTarget = DoSelectLowestHpFriendly(30,500);
    if (!rTarget || rTarget->isDead() || rTarget->GetHealth() * 100 / rTarget->GetMaxHealth() > 80 ) { return false; }

    if (hp < 65 && RIPTIDE && rTarget->HasAura(RIPTIDE,m_bot->GetGUID()) && CastSpell(CHAIN_HEAL, rTarget)) { return true; }
    if (hp < 85 && CastSpell(RIPTIDE, rTarget)) { return true; }
    if (hp < 75 && CastSpell(CHAIN_HEAL, rTarget,true,true)) { return true; }

    return false;
}
Example #27
0
void CAISocket::RecvNpcAttack(Packet & pkt)
{
	CNpc * pAttacker;
	Unit * pTarget;
	uint16 sAttackerID, sTargetID;
	int16 sDamage;
	uint8 bResult = ATTACK_FAIL;

	pkt >> sAttackerID >> sTargetID;

	pAttacker = g_pMain->GetNpcPtr(sAttackerID);
	pTarget = g_pMain->GetUnitPtr(sTargetID);

	if (pAttacker == nullptr
		|| pAttacker->isPlayer()
		|| pTarget == nullptr
		|| pAttacker->isDead()
		|| pTarget->isDead())
		return;

	// TO-DO: Wrap this up into its own virtual method
	sDamage = pAttacker->GetDamage(pTarget);
	if (sDamage > 0)
	{
		pTarget->HpChange(-(sDamage), pAttacker);
		if (pTarget->isDead())
			bResult = ATTACK_TARGET_DEAD;
		else
			bResult = ATTACK_SUCCESS;

		// Every hit takes a little of the defender's armour durability.
		if (pTarget->isPlayer())
			TO_USER(pTarget)->ItemWoreOut(DEFENCE, sDamage);
	}

	Packet result(WIZ_ATTACK, uint8(DIRECT_ATTACK));
	result << bResult << sAttackerID << sTargetID;
	pAttacker->SendToRegion(&result);
}
Example #28
0
            void Counter(const uint32 diff)
            {
                if (opponent  ==  NULL)
                    return;

                if (opponent->isDead())
                    return;

                if (opponent->IsNonMeleeSpellCasted(true) && isTimerReady(uiHammerOfJustice_Timer))
                {
                    doCast(opponent, SPELL_HAMMER_OF_JUSTICE);
                    uiHammerOfJustice_Timer = 600;
                }
            }
Example #29
0
    void UpdateAI(const uint32 diff)
    {
        if (ghost)
        {
            if (m_pInstance && m_pInstance->GetData(TYPE_SKARVALD_DALRONN) != IN_PROGRESS)
                m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
        }

        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (!ghost)
        {
            if (Check_Timer)
                if (Check_Timer <= diff)
                {
                    Check_Timer = 5000;
                    Unit* dalronn = m_pInstance->GetSingleCreatureFromStorage(NPC_DALRONN);
                    if (dalronn && dalronn->isDead())
                    {
                        Dalronn_isDead = true;
                        Response_Timer = 2000;
                        Check_Timer = 0;
                    }
                } else Check_Timer -= diff;

            if (Response_Timer)
                if (Dalronn_isDead)
                    if (Response_Timer <= diff)
                    {
                        DoScriptText(YELL_SKARVALD_DAL_DIEDFIRST,m_creature);

                        Response_Timer = 0;
                    } else Response_Timer -= diff;
        }

        if (Charge_Timer <= diff)
        {
            DoCast(m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1), SPELL_CHARGE);
            Charge_Timer = 5000+rand()%5000;
        } else Charge_Timer -= diff;

        if (StoneStrike_Timer <= diff)
        {
            DoCast(m_creature->getVictim(), SPELL_STONE_STRIKE);
            StoneStrike_Timer = 5000+rand()%5000;
        } else StoneStrike_Timer -= diff;

        DoMeleeAttackIfReady();
    }
Example #30
0
    void JustDied(Unit* Killer)
    {
        DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL);
        DoPlaySoundToSet(m_creature, SOUND_DEATH);
        if(pInstance)
        {
            pInstance->SetData(ENCOUNT_PATCHWERK, 2);
            HandleDoors(GO_PATCHWORK_EXIT, 0);
            Unit *temp = Unit::GetUnit((*m_creature),pInstance->GetData64(GUID_GLUTH));
            if (temp && temp->isDead())
                HandleDoors(GO_THADDIUS_DOOR, 0);
        }

    }