void netherspite_infernalAI::Cleanup()
{
    Unit *pMalchezaar = Unit::GetUnit(*me, malchezaar);

    if (pMalchezaar && pMalchezaar->isAlive())
        CAST_AI(boss_malchezaarAI, CAST_CRE(pMalchezaar)->AI())->Cleanup(me, point);
}
Example #2
0
bool ArcScriptCreatureAI::IsValidUnitTarget(Object* pObject, TargetFilter pFilter)
{
	//Make sure its a valid unit
	if( !pObject->IsUnit() ) return false;
	if( pObject->GetInstanceID() != _unit->GetInstanceID() ) return false;
	Unit* UnitTarget = static_cast<Unit*>(pObject);

	//Skip dead, feign death or invisible targets
	if( !UnitTarget->isAlive() ) return false;
	if( UnitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FEIGN_DEATH) ) return false;
	if( UnitTarget->m_invisible ) return false;

	//Skip units not on threat list
	if( _unit->GetAIInterface()->getThreatByPtr(UnitTarget) == 0 ) return false;

	//Check if we apply target filtering
	if( pFilter != TargetFilter_None )
	{
		//Skip current attacking target if requested
		if( (pFilter & TargetFilter_NotCurrent) && UnitTarget == _unit->GetAIInterface()->GetNextTarget() ) return false;

		//Keep only wounded targets if requested
		if( (pFilter & TargetFilter_Wounded) && UnitTarget->GetHealthPct() >= 99 ) return false;

		//Handle hostile/friendly
		if( pFilter & TargetFilter_Friendly ) 
		{
			if( !UnitTarget->CombatStatus.IsInCombat() ) return false; //Skip not-in-combat targets if friendly
			if( isHostile(_unit, UnitTarget) || _unit->GetAIInterface()->getThreatByPtr(UnitTarget) > 0 ) return false;
		}
	}

	return true; //This is a valid unit target
}
Example #3
0
    void JustDied(Unit* Killer)
    {
        if (!ghost && m_pInstance)
        {
            Unit* dalronn = m_pInstance->GetSingleCreatureFromStorage(NPC_DALRONN);
            if (dalronn)
            {
                if (dalronn->isDead())
                {
                    DoScriptText(YELL_SKARVALD_DAL_DIED,m_creature);

                    m_pInstance->SetData(TYPE_SKARVALD_DALRONN, 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);
                    }
                }
            }
        }
    }
Example #4
0
/**
 * @param srcUnit :: The starting unit
 * @param destUnit :: The destination unit
 * @param srcValue :: The value to convert
 * @param l1 ::       The source-sample distance (in metres)
 * @param l2 ::       The sample-detector distance (in metres)
 * @param twoTheta :: The scattering angle (in radians)
 * @param emode ::    The energy mode enumeration
 * @param efixed ::   Value of fixed energy: EI (emode=1) or EF (emode=2) (in
 * meV)
 * @return The value converted to the destination unit
 */
double UnitConversion::convertViaTOF(Unit &srcUnit, Unit &destUnit,
                                     const double srcValue, const double l1,
                                     const double l2, const double twoTheta,
                                     const DeltaEMode::Type emode,
                                     const double efixed) {
    // Translate the emode to the int formulation
    int emodeAsInt(0);
    switch (emode) {
    case DeltaEMode::Elastic:
        emodeAsInt = 0;
        break;
    case DeltaEMode::Direct:
        emodeAsInt = 1;
        break;
    case DeltaEMode::Indirect:
        emodeAsInt = 2;
        break;
    default:
        throw std::invalid_argument(
            "UnitConversion::convertViaTOF - Unknown emode " +
            std::to_string(emode));
    };

    const double unused(0.0);
    const double tof = srcUnit.convertSingleToTOF(srcValue, l1, l2, twoTheta,
                       emodeAsInt, efixed, unused);
    return destUnit.convertSingleFromTOF(tof, l1, l2, twoTheta, emodeAsInt,
                                         efixed, unused);
}
Example #5
0
void WorldSession::HandlePetStopAttack(WorldPacket& recv_data)
{
    DEBUG_LOG("WORLD: Received CMSG_PET_STOP_ATTACK");

    ObjectGuid petGuid;
    recv_data >> petGuid;

    Unit* pet = GetPlayer()->GetMap()->GetUnit(petGuid);    // pet or controlled creature/player
    if (!pet)
    {
        sLog.outError("%s doesn't exist.", petGuid.GetString().c_str());
        return;
    }

    if (GetPlayer()->GetObjectGuid() != pet->GetCharmerOrOwnerGuid())
    {
        sLog.outError("HandlePetStopAttack: %s isn't charm/pet of %s.", petGuid.GetString().c_str(), GetPlayer()->GetGuidStr().c_str());
        return;
    }

    if (!pet->isAlive())
        return;

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

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

                        me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
                        //DoCast(me, SPELL_SUMMON_DALRONN_GHOST, true);
                        Creature* temp = me->SummonCreature(MOB_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);
                        }
                    }
                }
            }
        }
Example #7
0
            void HandleDummy(SpellEffIndex /*effect*/)
            {
                Unit* target = GetHitUnit();
                Unit* caster = GetCaster();
                int32 damage = 0;

                // apply percent damage mods
                damage = caster->SpellDamageBonus(target, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE);

                switch (GetSpellInfo()->Id)
                {
                    case 12162:
                        ApplyPctN(damage, 16); break; // Rank 1
                    case 12850:
                        ApplyPctN(damage, 32); break; // Rank 2
                    case 12868:
                        ApplyPctN(damage, 48); break; // Rank 3
                    default:
                        break;
                }

                SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(12721);
                uint32 ticks = spellInfo->GetDuration() / spellInfo->Effects[EFFECT_0].Amplitude;

                // Add remaining ticks to damage done
                if (AuraEffect const* aurEff = target->GetAuraEffect(12721, EFFECT_0, caster->GetGUID()))
                    damage += aurEff->GetAmount() * (ticks - aurEff->GetTickNumber());

                damage /= ticks;
                caster->CastCustomSpell(target, 12721, &damage, NULL, NULL, true);
            }
Example #8
0
    void UpdateAI(const uint32 diff)
    {
        if (RefreshTimer <= diff)
            RefreshTimer = 0;
        else RefreshTimer -= diff;

        if (TargetSelected && TargetGUID)
        {
            Unit *pTarget = Unit::GetUnit((*me), TargetGUID);
            if (pTarget && pTarget->isAlive())
            {
                pTarget->CastSpell(pTarget, SPELL_DOOMFIRE_DAMAGE, true);
                TargetGUID = 0;
                TargetSelected = false;
            }
        }

        if (CheckTimer <= diff)
        {
            if (ArchimondeGUID)
            {
                Unit* Archimonde = Unit::GetUnit((*me), ArchimondeGUID);
                if (!Archimonde || !Archimonde->isAlive())
                    me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                CheckTimer = 5000;
            }
            else me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
        } else CheckTimer -= diff;
    }
Example #9
0
    bool CanUseFingerOfDeath()
    {
        // First we check if our current victim is in melee range or not.
        Unit* victim = me->getVictim();
        if (victim && me->IsWithinDistInMap(victim, me->GetAttackDistance(victim)))
            return false;

        std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList();
        if (m_threatlist.empty())
            return false;

        std::list<Unit*> targets;
        std::list<HostileReference*>::iterator itr = m_threatlist.begin();
        for (; itr != m_threatlist.end(); ++itr)
        {
            Unit* pUnit = Unit::GetUnit((*me), (*itr)->getUnitGuid());
            if (pUnit && pUnit->isAlive())
                targets.push_back(pUnit);
        }

        if (targets.empty())
            return false;

        targets.sort(Oregon::ObjectDistanceOrderPred(me));
        Unit *pTarget = targets.front();
        if (pTarget)
        {
            if (!me->IsWithinDistInMap(pTarget, me->GetAttackDistance(pTarget)))
                return true;                                // Cast Finger of Death
            else                                            // This target is closest, he is our new tank
                me->AddThreat(pTarget, DoGetThreat(me->getVictim()));
        }

        return false;
    }
Example #10
0
    void Reset()
    {
        FrostBolt_Timer = (rand()%60)*1000;                 //It won't be more than a minute without cast it
        FrostBoltNova_Timer = 15000;                        //Cast every 15 seconds
        ChainsOfKelthuzad_Timer = (rand()%30+30)*1000;      //Cast no sooner than once every 30 seconds
        ManaDetonation_Timer = 20000;                       //Seems to cast about every 20 seconds
        ShadowFisure_Timer = 25000;                         //25 seconds
        FrostBlast_Timer = (rand()%30+30)*1000;             //Random time between 30-60 seconds
        GuardiansOfIcecrown_Timer = 5000;                   //5 seconds for summoning each Guardian of Icecrown in phase 3

        for (int i=0; i<5; i++)
        {
            if (GuardiansOfIcecrown[i])
        {
            //delete creature
            Unit* pUnit = Unit::GetUnit((*me), GuardiansOfIcecrown[i]);
            if (pUnit && pUnit->isAlive())
                pUnit->DealDamage(pUnit, pUnit->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            GuardiansOfIcecrown[i] = 0;
        }
        }

        Phase1_Timer = 310000;                              //Phase 1 lasts 5 minutes and 10 seconds
        Phase2 = false;
        Phase3 = false;
    }
Example #11
0
bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
{
    Unit *unit = getSelectedUnit();
    if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
        unit = m_session->GetPlayer();

    std::ifstream ifs("opcode.txt");
    if (ifs.bad())
        return false;

    uint32 opcode;
    ifs >> opcode;

    WorldPacket data(opcode, 0);

    while(!ifs.eof())
    {
        std::string type;
        ifs >> type;

        if(type == "")
            break;

        if(type == "uint8")
        {
            uint16 val1;
            ifs >> val1;
            data << uint8(val1);
        }
        else if(type == "uint16")
Example #12
0
void GENGINE_W::moveUnit(Unit p_unit, std::pair<int, int> p_whereTo)
{
    refreshVisibleUnit(p_unit,-1);
    getUnit(p_unit.getCoord()).setCoord(p_whereTo.first,p_whereTo.second);
    p_unit.setCoord(p_whereTo.first, p_whereTo.second);
    refreshVisibleUnit(p_unit);
} // moveUnit()
Example #13
0
        void UpdateAI(uint32 diff) override
        {
            if (!UpdateVictim())
                return;

            if (uiGripOfSladRanTimer <= diff)
            {
                Unit* target = me->GetVictim();

                DoCast(target, SPELL_GRIP_OF_SLAD_RAN);
                uiGripOfSladRanTimer = urand(3, 6)*IN_MILLISECONDS;

                Aura* grip = target->GetAura(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
                if (grip && grip->GetStackAmount() == 5)
                {
                    target->RemoveAurasDueToSpell(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
                    target->CastSpell(target, SPELL_SNAKE_WRAP, true);

                    if (TempSummon* _me = me->ToTempSummon())
                        if (Unit* summoner = _me->GetSummoner())
                            if (Creature* sladran = summoner->ToCreature())
                                sladran->AI()->SetGUID(target->GetGUID(), DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES);

                    me->DespawnOrUnsummon();
                }
            } else uiGripOfSladRanTimer -= diff;
        }
Example #14
0
    void DoSummonAtRift(uint32 creature_entry)
    {
        if (!creature_entry)
            return;

        if (m_pInstance->GetData(TYPE_MEDIVH) != IN_PROGRESS)
        {
            m_creature->InterruptNonMeleeSpells(true);
            m_creature->RemoveAllAuras();
            return;
        }

        float x,y,z;
        m_creature->GetRandomPoint(m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(),10.0f,x,y,z);

        //normalize Z-level if we can, if rift is not at ground level.
        z = std::max(m_creature->GetMap()->GetHeight(x, y, MAX_HEIGHT), m_creature->GetMap()->GetWaterLevel(x, y));

        Unit *Summon = m_creature->SummonCreature(creature_entry,x,y,z,m_creature->GetOrientation(),
                       TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,30000);

        if (Summon)
        {
            if (Unit *temp = Unit::GetUnit(*m_creature, m_pInstance->GetData64(DATA_MEDIVH)))
                Summon->AddThreat(temp);
        }
    }
 void MovementInform(uint32 type, uint32 id)
 {
     if (type != POINT_MOTION_TYPE)
         return;
     Unit* ingvar = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_INGVAR) : 0);
     if (ingvar)
     {
         switch (id)
         {
         case 1:
             Talk(YELL_RESURRECT);
             ingvar->RemoveAura(SPELL_SUMMON_BANSHEE);
             ingvar->CastSpell(ingvar, SPELL_SCOURG_RESURRECTION_DUMMY, true);
             DoCast(ingvar, SPELL_SCOURG_RESURRECTION_BEAM);
             uiResurectTimer = 8000;
             uiResurectPhase = 1;
             break;
         case 2:
             me->SetVisible(false);
             me->DealDamage(me, me->GetHealth());
             me->RemoveCorpse();
             break;
         }
     }
 }
Example #16
0
        void SetPhaseOne()
        {
            DoScriptText(SAY_HEART_CLOSED, me);

            DoCast(SPELL_STAND);
            me->SetReactState(REACT_AGGRESSIVE);

            _phase = 1;

            events.RescheduleEvent(EVENT_SEARING_LIGHT, TIMER_SEARING_LIGHT / 2);
            events.RescheduleEvent(EVENT_GRAVITY_BOMB, TIMER_GRAVITY_BOMB);
            events.RescheduleEvent(EVENT_TYMPANIC_TANTRUM, urand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX));

            Unit* heart = me->GetVehicleKit() ? me->GetVehicleKit()->GetPassenger(HEART_VEHICLE_SEAT) : NULL;
            if (!heart)
                return;

            heart->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
            heart->RemoveAurasDueToSpell(SPELL_EXPOSED_HEART);

            if (!_hardMode)
            {
                if (!_transferHealth)
                    _transferHealth = (heart->GetMaxHealth() - heart->GetHealth());

                me->ModifyHealth(-((int32)_transferHealth));
            }
        }
        void UpdateAI(const uint32 diff)
        {
            if (uiResurectTimer)
            {
                if (uiResurectTimer <= diff)
                {
                    if (uiResurectPhase == 1)
                    {
                        Unit* ingvar = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_INGVAR) : 0);
                        if (ingvar)
                        {
                            ingvar->SetStandState(UNIT_STAND_STATE_STAND);
                            ingvar->CastSpell(ingvar, SPELL_SCOURG_RESURRECTION_HEAL, false);
                        }
                        uiResurectTimer = 3000;
                        uiResurectPhase = 2;
                    }
                    else if (uiResurectPhase == 2)
                    {
                        if (Creature* ingvar = Unit::GetCreature(*me, instance ? instance->GetData64(DATA_INGVAR) : 0))
                        {
                            ingvar->RemoveAurasDueToSpell(SPELL_SCOURG_RESURRECTION_DUMMY);

                            if (ingvar->GetVictim())
                                if (boss_ingvar_the_plunderer::boss_ingvar_the_plundererAI* ai = CAST_AI(boss_ingvar_the_plunderer::boss_ingvar_the_plundererAI, ingvar->AI()))
                                    ai->StartZombiePhase();

                            me->GetMotionMaster()->MovePoint(2, x+1, y, z+30);
                            ++uiResurectPhase;
                            uiResurectTimer = 0;
                        }
                    }
                } else uiResurectTimer -= diff;
            }
        }
 void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
 {
     Unit* caster = GetCaster();
     if (caster && caster->GetEntry() == NPC_ACIDMAW)
         if (Creature* acidmaw = caster->ToCreature())
             acidmaw->AI()->Talk(SAY_SPECIAL, GetTarget());
 }
Example #19
0
        void UpdateAI(uint32 const diff)
        {
            if (!UpdateVictim())
                return;

            if (uiRegurgitateTimer <= diff)
            {
                DoCast(me->getVictim(), SPELL_REGURGITATE);
                uiRegurgitateTimer = urand(7*IN_MILLISECONDS, 18*IN_MILLISECONDS);
            } else uiRegurgitateTimer -= diff;

            if (uiSpringTimer <= diff)
            {
                Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1);
                if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
                    if ((me->GetExactDist(pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ()) > 5) && (me->GetExactDist(pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ()) < 30))
                    {
                        DoCast(pTarget, SPELL_SPRING);
                        uiSpringTimer = urand(12*IN_MILLISECONDS, 20*IN_MILLISECONDS);

                        DoResetThreat();
                        AttackStart(pTarget);
                        me->AddThreat(pTarget, 1.0f);
                    }
            } else uiSpringTimer -= diff;

            DoMeleeAttackIfReady();
        }
    void MountOnBoss()
    {
        Unit* gormok = _instance->GetCreature(DATA_GORMOK_THE_IMPALER);
        if (gormok && gormok->IsAlive())
        {
            me->AttackStop();
            _targetGUID.Clear();
            _mountedOnPlayer = false;
            _events.CancelEvent(EVENT_BATTER);
            _events.CancelEvent(EVENT_HEAD_CRACK);

            for (uint8 i = 0; i < MAX_SNOBOLDS; i++)
            {
                if (!gormok->GetVehicleKit()->GetPassenger(i))
                {
                    me->EnterVehicle(gormok, i);
                    DoAction(ACTION_ENABLE_FIRE_BOMB);
                    break;
                }
            }
        }
        else
        {
            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
            _events.CancelEvent(EVENT_CHECK_MOUNT);
            me->AttackStop();
            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
                AttackStart(target);
            SetCombatMovement(true);
        }
    }
Example #21
0
        void UpdateAI(const uint32 diff)
        {
            if (Event_Timer <= diff)
            {
                switch (Phase)
                {
                    case 1:
                        if (someplayer)
                        {
                            Unit* u = Unit::GetUnit((*me), someplayer);
                            if (u && u->GetTypeId() == TYPEID_PLAYER) DoScriptText(EMOTE_START, me, u);
                        }
                        Event_Timer = 60000;
                        Wave = true;
                        ++Phase;
                        break;
                    case 2:
                        DoScriptText(EMOTE_60, me);
                        Event_Timer = 30000;
                        ++Phase;
                        break;
                    case 3:
                        DoScriptText(EMOTE_30, me);
                        Event_Timer = 20000;
                        DoFinalSpawnForCreature(me);
                        ++Phase;
                        break;
                    case 4:
                        DoScriptText(EMOTE_10, me);
                        Event_Timer = 10000;
                        Wave = false;
                        ++Phase;
                        break;
                    case 5:
                        DoScriptText(EMOTE_COMPLETE, me);
                        if (someplayer)
                        {
                            Unit* u = Unit::GetUnit((*me), someplayer);
                            if (u && u->GetTypeId() == TYPEID_PLAYER)
                                CAST_PLR(u)->KilledMonsterCredit(me->GetEntry(), me->GetGUID());
                            DoCast(me, SPELL_DISABLE_VISUAL);
                        }
                        if (goConsole)
                        {
                            if (GameObject* go = GameObject::GetGameObject((*me), goConsole))
                                go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
                        }
                        ++Phase;
                        break;
                }
            } else Event_Timer -= diff;

            if (Wave)
            {
                if (Wave_Timer <= diff)
                {
                    DoWaveSpawnForCreature(me);
                } else Wave_Timer -= diff;
            }
        }
Example #22
0
void WriteToFile(const Unit &U, const std::string &Path) {
  // Use raw C interface because this function may be called from a sig handler.
  FILE *Out = fopen(Path.c_str(), "w");
  if (!Out) return;
  fwrite(U.data(), sizeof(U[0]), U.size(), Out);
  fclose(Out);
}
Example #23
0
void AssistanceMovementGenerator::Finalize(Unit &unit)
{
    ((Creature*)&unit)->SetNoCallAssistance(false);
    ((Creature*)&unit)->CallAssistance();
    if (unit.isAlive())
        unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY));
}
Example #24
0
//--------- Begin of function FirmMonster::assign_unit ---------//
//
// Mobilized defender units are assigned back to the firm.
//
void FirmMonster::assign_unit(int unitRecno)
{
	Unit*		 unitPtr  = unit_array[unitRecno];
	UnitInfo* unitInfo = unit_res[unitPtr->unit_id];

	err_when( !unitInfo->is_monster );

	switch( unitPtr->rank_id )
	{
		case RANK_KING:
			set_king(unitPtr->get_monster_id(), unitPtr->skill.combat_level);
			break;

		case RANK_GENERAL:
			add_general(unitRecno);
			break;

		case RANK_SOLDIER:
			add_soldier(unitPtr->leader_unit_recno);
			break;
	}

	//--------- the unit disappear in firm -----//

	unit_array.disappear_in_firm(unitRecno);
}
Example #25
0
//--------- Begin of function UnitMarine::load_unit ---------//
//
// Load an unit to the ship.
//
// <int> unitRecno - recno of the unit to be loaded.
//
void UnitMarine::load_unit(int unitRecno)
{
	if(unit_array.is_deleted(unitRecno))
		return;

	Unit *unitPtr = unit_array[unitRecno];

	if(unitPtr->hit_points<=0 || unitPtr->cur_action==SPRITE_DIE || unitPtr->action_mode2==ACTION_DIE)
		return;

	if( unit_count == MAX_UNIT_IN_SHIP )
		return;

	unit_recno_array[unit_count++] = unitRecno;

	unitPtr->set_mode(UNIT_MODE_ON_SHIP, sprite_recno);	// set unit mode

	if(unitPtr->selected_flag)
	{
		unitPtr->selected_flag = 0;
		unit_array.selected_count--;
	}
	unitPtr->deinit_sprite();

	//--- if this marine unit is currently selected ---//

	if(unit_array.selected_recno==sprite_recno)
	{
		if(!remote.is_enable() || nation_recno==nation_array.player_recno || config.show_ai_info)
			disp_info(INFO_UPDATE);
	}
}
Example #26
0
//-------- Begin of function FirmMonster::clear_defense_mode -------//
//
// This function is called when the firm monster is destroyed.
//
void FirmMonster::clear_defense_mode()
{
	//------------------------------------------------------------------//
	// change defense unit's to non-defense mode
	//------------------------------------------------------------------//

	Unit *unitPtr;

	for(int i=unit_array.size(); i>=1; --i)
	{
		if(unit_array.is_deleted(i))
			continue;

		unitPtr = unit_array[i];

		//------ reset the monster's defense mode -----//

		if(unitPtr->in_monster_defend_mode() && unitPtr->action_misc==ACTION_MISC_MONSTER_DEFEND_FIRM_RECNO &&
			unitPtr->action_misc_para==firm_recno)
		{
			unitPtr->clear_monster_defend_mode();
			((UnitMonster*)unitPtr)->set_monster_action_mode(MONSTER_ACTION_STOP);
		}

		//--- if this unit belongs to this firm, reset its association with this firm ---//

		if( unitPtr->unit_mode == UNIT_MODE_MONSTER &&
			 unitPtr->unit_mode_para == firm_recno )
		{
			unitPtr->unit_mode_para = 0;
		}
	}
}
        void FlameWreathEffect()
        {
            std::vector<Unit*> targets;
            std::list<HostileReference*> t_list = me->getThreatManager().getThreatList();

            if (t_list.empty())
                return;

            //store the threat list in a different container
            for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
            {
                Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                //only on alive players
                if (target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER)
                    targets.push_back(target);
            }

            //cut down to size if we have more than 3 targets
            while (targets.size() > 3)
                targets.erase(targets.begin()+rand()%targets.size());

            uint32 i = 0;
            for (std::vector<Unit*>::const_iterator itr = targets.begin(); itr!= targets.end(); ++itr)
            {
                if (*itr)
                {
                    FlameWreathTarget[i] = (*itr)->GetGUID();
                    FWTargPosX[i] = (*itr)->GetPositionX();
                    FWTargPosY[i] = (*itr)->GetPositionY();
                    DoCast((*itr), SPELL_FLAME_WREATH, true);
                    ++i;
                }
            }
        }
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            if (uiChaoticEnergyBurstTimer <= diff)
            {
                Unit* pAnomalus = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_ANOMALUS) : 0);
                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0))
                {
                    if (pAnomalus && pAnomalus->HasAura(SPELL_RIFT_SHIELD))
                        DoCast(pTarget, SPELL_CHARGED_CHAOTIC_ENERGY_BURST);
                    else
                        DoCast(pTarget, SPELL_CHAOTIC_ENERGY_BURST);
                }
                uiChaoticEnergyBurstTimer = 1*IN_MILLISECONDS;
            } else uiChaoticEnergyBurstTimer -= diff;

            if (uiSummonCrazedManaWraithTimer <= diff)
            {
                Creature* Wraith = me->SummonCreature(MOB_CRAZED_MANA_WRAITH, me->GetPositionX()+1, me->GetPositionY()+1, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1*IN_MILLISECONDS);
                if (Wraith)
                    if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        Wraith->AI()->AttackStart(pTarget);
                Unit* Anomalus = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_ANOMALUS) : 0);
                if (Anomalus && Anomalus->HasAura(SPELL_RIFT_SHIELD))
                    uiSummonCrazedManaWraithTimer = 5*IN_MILLISECONDS;
                else
                    uiSummonCrazedManaWraithTimer = 10*IN_MILLISECONDS;
            } else uiSummonCrazedManaWraithTimer -= diff;
        }
Example #29
0
void WorldSession::HandlePetStopAttack(WorldPacket &recv_data)
{
    uint64 guid;
    recv_data >> guid;

    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_PET_STOP_ATTACK for GUID " UI64FMTD "", guid);

    Unit* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);

    if (!pet)
    {
        sLog->outError("HandlePetStopAttack: Pet %u does not exist", uint32(GUID_LOPART(guid)));
        return;
    }

    if (pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm())
    {
        sLog->outError("HandlePetStopAttack: Pet GUID %u isn't a pet or charmed creature of player %s", uint32(GUID_LOPART(guid)), GetPlayer()->GetName());
        return;
    }

    if (!pet->isAlive())
        return;

    pet->AttackStop();
}
Example #30
0
        void UpdateAI(uint32 diff) override
        {
            if (!UpdateVictim())
                return;

            if (EnrageTimer < diff && !me->HasAura(SPELL_ENRAGE, 0))
            {
                DoCast(me, SPELL_ENRAGE, false);
            } else EnrageTimer -= diff;

            if (BlackHoleSummonTimer <= diff)
            {
                Unit* random = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                if (!random)
                    return;

                DoCast(random, SPELL_DARKNESS_E, false);

                random = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                if (!random)
                    return;

                random->CastSpell(random, SPELL_BLACKHOLE, false);
                BlackHoleSummonTimer = 15000;
            } else BlackHoleSummonTimer -= diff;

            DoMeleeAttackIfReady();
        }