Example #1
0
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        if (m_uiDarkTimer <= diff)
        {
            Unit* pTarget = me->SelectNearestTarget(45);
            if(pTarget && pTarget->GetMaxHealth() && pTarget->IsFriendlyTo(me))
            {
                DoCast(pTarget, SPELL_DARKBLESSING);
                m_uiDarkTimer = 20000;
            }
        } else m_uiDarkTimer -= diff;

        if (m_uiShadowboltTimer <= diff)
        {
            Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
            DoCast(pTarget, SPELL_SHADOWBOLT);
            m_uiShadowboltTimer = 8000;
        } else m_uiShadowboltTimer -= diff;

        if (m_uiMendTimer  <= diff)
        {
            Unit* pTarget = me->SelectNearestTarget(45);

            if(pTarget->GetHealth()*100 / pTarget->GetMaxHealth() < 30 && pTarget->IsFriendlyTo(me))
            {
                DoCast(pTarget, RAID_MODE(SPELL_SHADOWMEND_10,SPELL_SHADOWMEND_25));
                m_uiMendTimer  = 25000;
            }
        } else m_uiMendTimer -= diff;

        DoMeleeAttackIfReady();
    }
void PlayerbotShamanAI::DoNonCombatActions()
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return; }

    //If Casting or Eating/Drinking return
    if (m_bot->HasUnitState(UNIT_STAT_CASTING)) { return; }
    if (m_bot->getStandState() == UNIT_STAND_STATE_SIT) { return; }

    //buff and heal raid
    if (DoSupportRaid(m_bot)) { return; }

    //heal pets and bots
    Unit *target = DoSelectLowestHpFriendly(40, 1000);
    if (target && target->isAlive() && HealTarget(target, target->GetHealth()*100 / target->GetMaxHealth())) { return; }

    //Buffs
    if (ChangeWeaponEnchants()) { return; }
    if (CastSpell(WATER_SHIELD,m_bot)) { return; }
    if (CastSpell(EARTH_SHIELD,m_bot)) { return; }

    //mana/hp check
    //Don't bother with eating, if low on hp, just let it heal themself
    if (m_bot->getRace() == (uint8) RACE_UNDEAD_PLAYER && ai->GetHealthPercent() < 75 && CastSpell(R_CANNIBALIZE,m_bot)) { return; }
    if (m_bot->GetHealth() < m_bot->GetMaxHealth() && CastSpell(LESSER_HEAL,m_bot)) { return; }
	if (ai->GetManaPercent() < 50) { ai->Feast(); }

} //end DoNonCombatActions
 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;
 }
Example #4
0
    void UpdateAI(const uint32 diff)
    {
        if (!ArchimondeGUID)
        {
            if (pInstance)
                ArchimondeGUID = pInstance->GetData64(DATA_ARCHIMONDE);
        }

        if (CheckTimer <= diff)
        {
            if (ArchimondeGUID)
            {
                Unit* Archimonde = Unit::GetUnit((*me), ArchimondeGUID);
                if (Archimonde)
                {
                    if ((((Archimonde->GetHealth() * 100) / Archimonde->GetMaxHealth()) < 2) || !Archimonde->IsAlive())
                        DoCast(me, SPELL_DENOUEMENT_WISP);
                    else
                        DoCast(Archimonde, SPELL_ANCIENT_SPARK);
                }
            }
            CheckTimer = 1000;
        }
        else CheckTimer -= diff;
    }
Example #5
0
void CRetreatTask::Update()
{
	CCircuitAI* circuit = manager->GetCircuit();
	int frame = circuit->GetLastFrame();
	bool isExecute = (++updCount % 4 == 0);
	auto assignees = units;
	for (CCircuitUnit* unit : assignees) {
		Unit* u = unit->GetUnit();
		const float healthPerc = u->GetHealth() / u->GetMaxHealth();
		bool isRepaired;
		// FIXME: Wait until 101.0 engine
//		if (ass->GetShield() != nullptr) {
//			isRepaired = (healthPerc > 0.98f) && unit->IsShieldCharged(0.9f));
//		} else {
			isRepaired = healthPerc > 0.98f;
//		}

		if (isRepaired && !unit->IsDisarmed(frame)) {
			RemoveAssignee(unit);
		} else if (unit->IsForceExecute() || isExecute) {
			Execute(unit);
		} else {
			unit->Update(circuit);
		}
	}
}
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("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 #7
0
            void SetPhaseOne()
            {
                DoScriptText(SAY_HEART_CLOSED, me);

                DoCast(me, 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 = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_XT002_HEART));
                if (!heart)
                    return;

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

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

                    me->ModifyHealth(-((int32)_transferHealth));
                }
            }
Example #8
0
            void SetPhaseOne()
            {
                Talk(SAY_HEART_CLOSED);
                Talk(EMOTE_HEART_CLOSED);

                DoCast(me, 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_EXPOSED) : NULL;
                if (!heart)
                    return;

                heart->ChangeSeat(HEART_VEHICLE_SEAT_NORMAL, false);
                heart->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                heart->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
                heart->RemoveAurasDueToSpell(SPELL_EXPOSED_HEART);

                if (!_hardMode)
                    me->DealDamage(me, heart->GetMaxHealth() - heart->GetHealth());
            }
void PlayerbotDruidAI::DoNonCombatActions()
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return; }

    //If Casting or Eating/Drinking return
    if (m_bot->HasUnitState(UNIT_STAT_CASTING)) { return; }
    if (m_bot->getStandState() == UNIT_STAND_STATE_SIT) { return; }

    //buff and heal raid
    if (DoSupportRaid(GetMaster())) { return; }
    if (m_bot->GetGroup() && GetMaster()->GetGroup() != m_bot->GetGroup() && DoSupportRaid(m_bot)) { return; }

    //heal pets and bots
    Unit *target = DoSelectLowestHpFriendly(30, 1000);
    if (target && target->isAlive() && HealTarget(target, target->GetHealth()*100 / target->GetMaxHealth())) { return; }

    //mana/hp check
    //Don't bother with eating, if low on hp, just let it heal themself
    if (m_bot->getRace() == (uint8) RACE_UNDEAD_PLAYER && ai->GetHealthPercent() < 75 && CastSpell(R_CANNIBALIZE,m_bot)) { return; }
    if (ai->GetManaPercent() < 10 && CastSpell (INNERVATE, m_bot)) { return; } //Need mana fast
    if (m_bot->GetHealth() < m_bot->GetMaxHealth() &&
        (ai->GetForm() != FORM_CAT && ai->GetForm() != FORM_MOONKIN && ai->GetForm() != FORM_DIREBEAR && ai->GetForm() != FORM_BEAR)
        && CastSpell(REGROWTH,m_bot)) { return; }
    if (ai->GetManaPercent() < 50) { ai->Feast(); }

} //end DoNonCombatActions
Example #10
0
            void SetPhaseOne()
            {
                DoScriptText(SAY_HEART_CLOSED, me);

                DoCast(me, 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));
                }
            }
Example #11
0
 void SonicBoomEffect()
 {
     ThreatList const& tList = m_creature->getThreatManager().getThreatList();
     for (ThreatList::const_iterator itr = tList.begin();itr != tList.end(); ++itr)
     {
        Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
        if (target && target->GetTypeId() == TYPEID_PLAYER)
        {
            //Not do anything without aura, spell can be resisted!
            if (target->HasAura(SPELL_SONIC_BOOM_CAST, EFFECT_INDEX_1) && m_creature->IsWithinDistInMap(target, 34.0f))
            {
                //This will be wrong calculation. Also, comments suggest it must deal damage
                target->SetHealth(uint32(target->GetMaxHealth() - target->GetMaxHealth() * 0.8));
            }
        }
     }
 }
Example #12
0
 void HandlePeriodicTick(AuraEffect const* /*aurEff*/)
 {
     PreventDefaultAction();
     Unit* caster = GetCaster();
     int32 missingHealth = int32(caster->GetMaxHealth() - caster->GetHealth());
     caster->ModifyHealth(missingHealth);
     caster->ModifyPower(POWER_MANA, -missingHealth);
 }
Example #13
0
 void SonicBoomEffect()
 {
     std::list<HostileReference *> t_list = m_creature->getThreatManager().getThreatList();
     for (std::list<HostileReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
     {
        Unit *pTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
        if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
        {
            //Not do anything without aura, spell can be resisted!
            if (pTarget->HasAura(SPELL_SONIC_BOOM_CAST) && m_creature->IsWithinDistInMap(pTarget, 34.0f))
            {
                //This will be wrong calculation. Also, comments suggest it must deal damage
                pTarget->SetHealth(uint32(pTarget->GetMaxHealth() - pTarget->GetMaxHealth() * 0.8));
            }
        }
     }
 }
 void HandleScript(SpellEffIndex /*effIndex*/)
 {
     Unit* target = GetHitUnit();
     int32 casterHpPct = (int32) GetCaster()->GetHealthPct();
     uint32 newHp = target->CountPctFromMaxHealth(casterHpPct);
     if (newHp <= 0)
         newHp = target->GetMaxHealth() - 1;
     target->SetHealth(newHp);
 }
Example #15
0
    void SonicBoomEffect()
    {
        std::vector<ObjectGuid> vGuids;
        m_creature->FillGuidsListFromThreatList(vGuids);
        for (std::vector<ObjectGuid>::const_iterator itr = vGuids.begin();itr != vGuids.end(); ++itr)
        {
           Unit* target = m_creature->GetMap()->GetUnit(*itr);

           if (target && target->GetTypeId() == TYPEID_PLAYER)
           {
               //Not do anything without aura, spell can be resisted!
               if (target->HasAura(SPELL_SONIC_BOOM_CAST, EFFECT_INDEX_1) && m_creature->IsWithinDistInMap(target, 34.0f))
               {
                   //This will be wrong calculation. Also, comments suggest it must deal damage
                   target->SetHealth(uint32(target->GetMaxHealth() - target->GetMaxHealth() * 0.8));
               }
           }
        }
    }
Example #16
0
void CBRepairTask::OnUnitDamaged(CCircuitUnit* unit, CEnemyUnit* attacker)
{
	Unit* u = unit->GetUnit();
	if (u->GetHealth() >= u->GetMaxHealth() * unit->GetCircuitDef()->GetRetreat()) {
		return;
	}

	CRetreatTask* task = manager->GetCircuit()->GetBuilderManager()->EnqueueRetreat();
	manager->AssignTask(unit, task);
}
Example #17
0
void CBRepairTask::OnUnitDamaged(CCircuitUnit* unit, CEnemyUnit* attacker)
{
	Unit* u = unit->GetUnit();
	// TODO: floating retreat coefficient
	if (u->GetHealth() >= u->GetMaxHealth() * 0.8f) {
		return;
	}

	manager->AssignTask(unit, manager->GetRetreatTask());
}
Example #18
0
SPELL_EFFECT_OVERRIDE_RETURNS AH_16191( Aura *aur, bool apply, uint8 i )
{
    if( apply == true && aur->GetSpellProto()->eff[i].EffectApplyAuraName == SPELL_AURA_MOD_STAT )
    {
        Unit *c = aur->GetUnitCaster();
        if( c )
        {
            Unit *owner = c->GetTopOwner();
            aur->mod->m_amount = aur->GetSpellProto()->eff[i].EffectBasePoints * owner->GetStat( STAT_SPIRIT ) / 100;
            //my max health should be owner's max health
            uint32 MyMaxHealth = owner->GetMaxHealth() * 10 / 100;
            if(c->GetMaxHealth() < MyMaxHealth )
            {
                c->SetMaxHealth( MyMaxHealth );
                c->SetHealth( MyMaxHealth );
            }
        }
    }
    return SPELL_EFFECT_OVERRIDE_CONTINUE_EXECUTION;
}
Example #19
0
void CBRepairTask::OnUnitIdle(CCircuitUnit* unit)
{
	Unit* u = target->GetUnit();
	if (u->GetHealth() < u->GetMaxHealth()) {
		// unit stuck or event order fail
		RemoveAssignee(unit);
	} else {
		// task finished
		manager->DoneTask(this);
	}
}
bool Hysteria(uint32 i, Aura* pAura, bool apply)
{
	if(! apply)
		return true;

	Unit* target = pAura->GetTarget();

	uint32 dmg = (uint32) target->GetMaxHealth() * (pAura->GetSpellProto()->EffectBasePoints[i] + 1) / 100;
	target->DealDamage(target, dmg, 0, 0, 0);

	return true;
}
Example #21
0
 void DeSpawnAdds()
 {
     for(uint8 i = 0; i < 4 ; ++i)
     {
         Unit* Temp = NULL;
         if (AddGUID[i])
         {
             Temp = Unit::GetUnit((*m_creature),AddGUID[i]);
             if (Temp && Temp->isAlive())
                 Temp->DealDamage(Temp, Temp->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
         }
     }
 }
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;
}
	void DamageTaken(Unit * /*done_by*/, uint32 &damage) {
		Unit *pOtherBoss = GetOtherBoss();
		if (pOtherBoss) {
			float dPercent = ((float) damage) / ((float) me->GetMaxHealth());
			int odmg = (int) (dPercent * ((float) pOtherBoss->GetMaxHealth()));
			int ohealth = pOtherBoss->GetHealth() - odmg;
			pOtherBoss->SetHealth(ohealth > 0 ? ohealth : 0);
			if (ohealth <= 0) {
				pOtherBoss->setDeathState(JUST_DIED);
				pOtherBoss->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
			}
		}
	}
Example #24
0
void IBuilderTask::OnUnitDamaged(CCircuitUnit* unit, CEnemyUnit* attacker)
{
	Unit* u = unit->GetUnit();
	// TODO: floating retreat coefficient
	if (u->GetHealth() >= u->GetMaxHealth() * 0.8f) {
		return;
	}

	if (target == nullptr) {
		manager->AbortTask(this);
	}

	manager->AssignTask(unit, manager->GetRetreatTask());
}
Example #25
0
bool PlayerbotClassAI::DoSupportRaid(Player *gPlayer, float radius, bool dResurrect, bool dGroupHeal, bool dHeal, bool dCure, bool dBuff)
{
    bool needHeal = false;
    if (dGroupHeal || dHeal)
    {
        uint8 cntNeedHeal = 0;
        uint8 raidHPPercent = GetHealthPercentRaid(gPlayer, cntNeedHeal);
        if (dGroupHeal && raidHPPercent <=90 && cntNeedHeal > 1)
        {
            if (HealGroup(gPlayer, raidHPPercent, cntNeedHeal)) return true;
        }
        if (raidHPPercent < 60 ) needHeal = true;
    }
    //std::list<Unit*> unitList;
    //gPlayer->GetRaidMember(unitList,30);
    Group *pGroup = gPlayer->GetGroup();
    if (!pGroup) return false;
    for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
    {
        Unit* tPlayer = itr->getSource();
        if(!tPlayer || gPlayer->IsHostileTo(tPlayer)) continue;
        if(GetPlayerBot()->GetAreaId() != tPlayer->GetAreaId()) continue;
        if(!m_bot->IsWithinDistInMap(tPlayer, radius)) {
            continue;
        }
        if(tPlayer->isDead()) // May be we can rez
        {
            if(!dResurrect) continue;
            if(needHeal) continue; //First heal others needing heal
            if(tPlayer->GetGUID() == GetPlayerBot()->GetGUID()) continue;
            if(tPlayer->IsNonMeleeSpellCasted(true)) continue; //Already rez
            if(RezTarget(tPlayer)) {
                return true;
            }
            else continue;
        }
        if (dHeal)
        {
            uint8 tarHPPercent = tPlayer->GetHealth()*100 / tPlayer->GetMaxHealth();
            if (tarHPPercent < 100 && HealTarget(tPlayer, tarHPPercent)) return true;
        }
        if (needHeal && dHeal) continue; //First heal others needing heal
        if (dCure && CureTarget(tPlayer)) return true;
        if (dBuff && BuffPlayer(tPlayer)) return true;
    }
    return false;
}
Example #26
0
            void HandleHeal(SpellEffIndex /*effIndex*/)
            {
                Unit* caster = GetCaster();

                if(!caster)
                    return;

                if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_WARRIOR_BLOODTHIRST_DAMAGE))
                {
                    int32 calculatedHeal = CalculatePct(caster->GetMaxHealth(), float(spellInfo->Effects[EFFECT_1].CalcValue(GetCaster())) / 1000);

                    // Field Dressing check
                    if(AuraEffect* aurEff = caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_WARRIOR, 2671, EFFECT_1))
                        AddPct(calculatedHeal, aurEff->GetAmount());

                    SetHitHeal(calculatedHeal);
                }
            }
Example #27
0
void IFighterTask::OnUnitDamaged(CCircuitUnit* unit, CEnemyUnit* attacker)
{
	CCircuitAI* circuit = manager->GetCircuit();
	int frame = circuit->GetLastFrame();
	CCircuitDef* cdef = unit->GetCircuitDef();
	Unit* u = unit->GetUnit();
	const float healthPerc = u->GetHealth() / u->GetMaxHealth();
	if (unit->GetShield() != nullptr) {
		const float minShield = circuit->GetSetupManager()->GetEmptyShield();
		if ((healthPerc > cdef->GetRetreat()) && unit->IsShieldCharged(minShield)) {
			if (cdef->IsRoleHeavy() && (healthPerc < 0.9f)) {
				circuit->GetBuilderManager()->EnqueueRepair(IBuilderTask::Priority::NOW, unit);
			}
			return;
		}
	} else if ((healthPerc > cdef->GetRetreat()) && !unit->IsDisarmed(frame)) {
		if (cdef->IsRoleHeavy() && (healthPerc < 0.9f)) {
			circuit->GetBuilderManager()->EnqueueRepair(IBuilderTask::Priority::NOW, unit);
		}
		return;
	} else if (healthPerc < 0.2f) {  // stuck units workaround: they don't shoot and don't see distant threat
		CRetreatTask* task = manager->GetCircuit()->GetMilitaryManager()->EnqueueRetreat();
		manager->AssignTask(unit, task);
		return;
	}

	CThreatMap* threatMap = circuit->GetThreatMap();
	const float range = cdef->GetMaxRange();
	if ((target == nullptr) || !target->IsInLOS()) {
		CRetreatTask* task = circuit->GetMilitaryManager()->EnqueueRetreat();
		manager->AssignTask(unit, task);
		return;
	}
	const AIFloat3& pos = unit->GetPos(frame);
	if ((target->GetPos().SqDistance2D(pos) > SQUARE(range)) ||
		(threatMap->GetThreatAt(unit, pos) * 2 > threatMap->GetUnitThreat(unit)))
	{
		CRetreatTask* task = circuit->GetMilitaryManager()->EnqueueRetreat();
		manager->AssignTask(unit, task);
		return;
	}
	cowards.insert(unit);
}
    void UpdateAI(const uint32 uiDiff)
    {
        //Return since we have no target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if(m_bCanShatter)
            if(m_uiShatterTimer < uiDiff)
            {
                ShatterGolem();
                m_bCanShatter = false;
            }else m_uiShatterTimer -= uiDiff;

        for(uint8 i=0; i<3; ++i)
        {
            Unit* pGolem = Unit::GetUnit(*m_creature, m_uiGolemsGUID[i][0]);
            if(pGolem && pGolem->isAlive())
                if(pGolem->GetHealth()*100 / pGolem->GetMaxHealth() < 1)
                    m_uiGolemsGUID[i][1] = 1; 
        }

        if(!m_bCanShatter && m_uiGolemsGUID[0][1] == 1 && m_uiGolemsGUID[1][1] == 1 && m_uiGolemsGUID[2][1] == 1) 
        {
            DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_SHATTERING_STOMP_N : SPELL_SHATTERING_STOMP_H);
            m_uiShatterTimer = 3000;
            m_bCanShatter = true;
        }

        // Health check
        if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < (100-(20*m_uiHealthAmountModifier)))
        {
            SummonGolems();
            ++m_uiHealthAmountModifier;

            DoScriptText(urand(0, 1) ? SAY_FORGE_1 : SAY_FORGE_2, m_creature);
        }

        DoMeleeAttackIfReady();
    }
Example #29
0
		uint32 AbsorbDamage(uint32 School, uint32* dmg)
		{
			Unit* caster = GetUnitCaster();
			if(caster == NULL)
				return 0;

			int health_pct = caster->GetHealthPct();
			uint32 cur_health = caster->GetHealth();
			uint32 max_health = caster->GetMaxHealth();
			uint32 new_health_pct = (cur_health - *dmg) * 100 / max_health;

			// "Damage that would take you below $s1% health or taken while you are at $s1% health is reduced by $52284s1%."
			if((health_pct > 35 && new_health_pct < 35) || health_pct == 35)
			{
				uint32 dmg_absorbed = *dmg * (GetSpellProto()->EffectBasePoints[0] + 1) / 100;
				*dmg -= dmg_absorbed;

				return dmg_absorbed;
			}
			else
				return 0;
		}
Example #30
0
            void SetPhaseOne()
            {
                DoScriptText(SAY_HEART_CLOSED, me);
                if (me->HasAura(SPELL_SUBMERGE))
                    me->RemoveAurasDueToSpell(SPELL_SUBMERGE);
                DoCast(me, SPELL_STAND);
                // Just for the case this isn't done by the spell above.
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
                me->SetReactState(REACT_AGGRESSIVE);

                phase = PHASE_ONE;
                events.SetPhase(PHASE_ONE);

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

                Unit* heart = FindHeart();
                if (!heart)
                    return;

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

                if (!hardMode)
                {
                    if (!transferHealth) // Not settled == heart did not die
                        if ( uint32 healthDiff = (heart->GetMaxHealth() - heart->GetHealth()) )
                        {
                            me->DealDamage(me, healthDiff);
                            me->LowerPlayerDamageReq(healthDiff);
                        }

                    // Note: if the heart did not go down enough or the players sucked too much (heal through bots), we may have jumped back in heart-phase
                    // Otherwise, damage to the heart got mirrored to the XT002, thus one or more of the heart-phases can be excluded.  
                    RecalcHeartPhase();
                }
            }