bool CStatusEffectContainer::ApplyBardEffect(CStatusEffect* PStatusEffect, uint8 maxSongs)
{
	//if all match tier/id/effect then overwrite

	//if tier/effect match then overwrite //but id doesn't, NO EFFECT
	//if targ has <2 of your songs on, then just apply
	//if targ has 2 of your songs, remove oldest one and apply this one.

	uint8 numOfEffects = 0;
	CStatusEffect* oldestSong = nullptr;
	for (uint16 i = 0; i < m_StatusEffectList.size(); ++i)
	{
		if (m_StatusEffectList.at(i)->GetStatusID() >= EFFECT_REQUIEM &&
			m_StatusEffectList.at(i)->GetStatusID() <= EFFECT_NOCTURNE) //is a brd effect
		{
            if (m_StatusEffectList.at(i)->GetTier() == PStatusEffect->GetTier() &&
				m_StatusEffectList.at(i)->GetStatusID()==PStatusEffect->GetStatusID()){//same tier/type, overwrite
					//OVERWRITE
                    DelStatusEffectByTier(PStatusEffect->GetStatusID(), PStatusEffect->GetTier());
					AddStatusEffect(PStatusEffect);
					return true;
			}
			if(m_StatusEffectList.at(i)->GetSubID() == PStatusEffect->GetSubID()){//YOUR BRD effect
				numOfEffects++;
				if(!oldestSong){
					oldestSong = m_StatusEffectList.at(i);
				}
				else if(m_StatusEffectList.at(i)->GetDuration() + m_StatusEffectList.at(i)->GetStartTime() <
					oldestSong->GetDuration() + oldestSong->GetStartTime()){
						oldestSong = m_StatusEffectList.at(i);
				}
			}
		}
	}

	if(numOfEffects<maxSongs){
		AddStatusEffect(PStatusEffect);
		return true;
	}
	else if (oldestSong){
		//overwrite oldest
        DelStatusEffectByTier(oldestSong->GetStatusID(), oldestSong->GetTier());
		AddStatusEffect(PStatusEffect);
		return true;
	}

	return false;
}
Пример #2
0
	void Spell::HandleDoTEffect(GameObject *target, SpellEffectData &effect, SpellState &state)
	{
		int32_t statValue = this->GetDamageStatValue(target, effect, state);
		double percent = effect.percentSourceMin * 0.01;
		int32_t damageTotal = effect.flatAmountMin + (percent * statValue);

		auto character = target->FindComponent<CharacterComponent>();

		StatusEffectType type;
		if (effect.effectType == SpellEffectDoT && damageTotal > 0) {
			damageTotal *= -1;
			type = StatusEffectDebuff;
		}
		else {
			type = StatusEffectBuff;
		}

		std::string name = mData->GetName() + "_" + effect.id.toString();

		
		if (!this->FindStatusEffect(character, name, effect)) {
			DOT_STATUS_EFFECT_DESC desc;
			desc.Target = target;
			desc.Type = type;
			desc.Name = name;
			desc.TickDuration = effect.dotTick * 1000;
			desc.Duration = effect.dotDuration * 1000;
			desc.Damage = damageTotal;
			desc.RootSpell = this;

			DOTStatusEffect *status = new DOTStatusEffect(desc);
			character->AddStatusEffect(status);
		}
	}
void CStatusEffectContainer::LoadStatusEffects()
{
    DSP_DEBUG_BREAK_IF(m_POwner->objtype != TYPE_PC);

	const int8* fmtQuery = "SELECT effectid, icon, power, tick, duration, flag, subid \
							FROM char_effects \
							WHERE charid = %u;";

	int32 ret = Sql_Query(SqlHandle, fmtQuery, m_POwner->id);

	if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) 
		{
			CStatusEffect* PStatusEffect = new CStatusEffect(
				(EFFECT)Sql_GetUIntData(SqlHandle,0),
                (uint16)Sql_GetUIntData(SqlHandle,1),
				(uint16)Sql_GetUIntData(SqlHandle,2),
				(uint32)Sql_GetUIntData(SqlHandle,3),
				(uint32)Sql_GetUIntData(SqlHandle,4),
				(uint16)Sql_GetUIntData(SqlHandle,5),
				(uint16)Sql_GetUIntData(SqlHandle,6));

			AddStatusEffect(PStatusEffect);
		}
	}
}
void CStatusEffectContainer::LoadStatusEffects()
{
    DSP_DEBUG_BREAK_IF(m_POwner->objtype != TYPE_PC);

    const int8* Query =
        "SELECT "
        "effectid,"
        "icon,"
        "power,"
        "tick,"
        "duration,"
        "subid,"
        "subpower,"
        "tier "
        "FROM char_effects "
        "WHERE charid = %u;";

    int32 ret = Sql_Query(SqlHandle, Query, m_POwner->id);

    std::vector<CStatusEffect*> PEffectList;

    if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
    {
        while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
        {
            CStatusEffect* PStatusEffect = new CStatusEffect(
                (EFFECT)Sql_GetUIntData(SqlHandle, 0),
                (uint16)Sql_GetUIntData(SqlHandle, 1),
                (uint16)Sql_GetUIntData(SqlHandle, 2),
                (uint32)Sql_GetUIntData(SqlHandle, 3),
                (uint32)Sql_GetUIntData(SqlHandle, 4),
                (uint16)Sql_GetUIntData(SqlHandle, 5),
                (uint16)Sql_GetUIntData(SqlHandle, 6),
                (uint16)Sql_GetUIntData(SqlHandle, 7));

            PEffectList.push_back(PStatusEffect);

            // load shadows left
            if (PStatusEffect->GetStatusID() == EFFECT_COPY_IMAGE) {
                m_POwner->setModifier(MOD_UTSUSEMI, PStatusEffect->GetPower());
            }
            else if (PStatusEffect->GetStatusID() == EFFECT_BLINK) {
                m_POwner->setModifier(MOD_BLINK, PStatusEffect->GetPower());
            }
        }
    }

    for (auto&& PStatusEffect : PEffectList)
    {
        AddStatusEffect(PStatusEffect);
    }

    m_POwner->UpdateHealth(); // после загрузки эффектов пересчитываем максимальное количество HP/MP
}
/************************************************************************
* *
* ????????? ??????? ????????? *
* *
************************************************************************/
void CStatusEffectContainer::LoadStatusEffects()
{
DSP_DEBUG_BREAK_IF(m_POwner->objtype != TYPE_PC);
const int8* Query =
"SELECT "
"effectid,"
"icon,"
"power,"
"tick,"
"duration,"
"subid,"
"subpower,"
"tier "
"FROM char_effects "
"WHERE charid = %u;";
int32 ret = Sql_Query(SqlHandle, Query, m_POwner->id);
if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
{
while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
CStatusEffect* PStatusEffect = new CStatusEffect(
(EFFECT)Sql_GetUIntData(SqlHandle,0),
(uint16)Sql_GetUIntData(SqlHandle,1),
(uint16)Sql_GetUIntData(SqlHandle,2),
(uint32)Sql_GetUIntData(SqlHandle,3),
(uint32)Sql_GetUIntData(SqlHandle,4),
(uint16)Sql_GetUIntData(SqlHandle,5),
(uint16)Sql_GetUIntData(SqlHandle,6),
(uint16)Sql_GetUIntData(SqlHandle,7));
AddStatusEffect(PStatusEffect);
// load shadows left
if(PStatusEffect->GetStatusID() == EFFECT_COPY_IMAGE){
m_POwner->setModifier(MOD_UTSUSEMI, PStatusEffect->GetPower());
} else if(PStatusEffect->GetStatusID() == EFFECT_BLINK){
m_POwner->setModifier(MOD_BLINK, PStatusEffect->GetPower());
}
}
}
m_POwner->UpdateHealth(); // ????? ???????? ???????? ????????????? ???????????? ?????????? HP/MP
}
Пример #6
0
	void Spell::HandleBuffEffect(GameObject *target, SpellEffectData &effect, SpellState &state)
	{
		auto character = target->FindComponent<CharacterComponent>();
		CharacterStats &targetStats = character->GetStats();

		
		int32_t statValue = effect.percentSourceMin;

		StatusEffectType type;
		if (effect.effectType == SpellEffectBuff) {
			type = StatusEffectBuff;
		}
		else {
			type = StatusEffectDebuff;
			statValue *= -1;
		}

		double buffValue = (double) statValue * 0.01;

		std::string name = mData->GetName() + "_" + effect.id.toString();

		if (!this->FindStatusEffect(character, name, effect)) {
			STAT_STATUS_EFFECT_DESC desc;
			desc.Target = target;
			desc.Type = type;
			desc.Duration = effect.buffDuration * 1000;
			desc.Name = name;
			desc.Stat = effect.buffSource;
			desc.AddValue = effect.flatAmountMin;
			desc.MultiplyValue = buffValue;
			desc.RootSpell = this;

			StatStatusEffect *status = new StatStatusEffect(desc);
			character->AddStatusEffect(status);
		}
	}
bool CStatusEffectContainer::ApplyCorsairEffect(CStatusEffect* PStatusEffect, uint8 maxRolls, uint8 bustDuration)
{
	//break if not a COR roll.
	DSP_DEBUG_BREAK_IF(!(PStatusEffect->GetStatusID() >= EFFECT_FIGHTERS_ROLL &&
		PStatusEffect->GetStatusID() <= EFFECT_SCHOLARS_ROLL));

	//if all match tier/id/effect then overwrite

	//if tier/effect match then overwrite //but id doesn't, NO EFFECT
	//if targ has <2 of your rolls on, then just apply
	//if targ has 2 of your rolls, remove oldest one and apply this one.

	uint8 numOfEffects = 0;
	CStatusEffect* oldestRoll = nullptr;
	for (uint16 i = 0; i < m_StatusEffectList.size(); ++i)
	{
		if ((m_StatusEffectList.at(i)->GetStatusID() >= EFFECT_FIGHTERS_ROLL &&
			m_StatusEffectList.at(i)->GetStatusID() <= EFFECT_SCHOLARS_ROLL) ||
			m_StatusEffectList.at(i)->GetStatusID() == EFFECT_BUST)//is a cor effect
		{
			if(m_StatusEffectList.at(i)->GetStatusID() == PStatusEffect->GetStatusID() &&
				m_StatusEffectList.at(i)->GetSubID() == PStatusEffect->GetSubID() &&
				m_StatusEffectList.at(i)->GetSubPower() < PStatusEffect->GetSubPower()){//same type, double up
					if( PStatusEffect->GetSubPower() < 12)
					{
						PStatusEffect->SetDuration(m_StatusEffectList.at(i)->GetDuration());
						DelStatusEffectSilent(PStatusEffect->GetStatusID());
						AddStatusEffect(PStatusEffect, true);
						return true;
					} else {
						if (!CheckForElevenRoll())
						{
							uint16 duration = 300;
							duration -= bustDuration;
							CStatusEffect* bustEffect = new CStatusEffect(EFFECT_BUST, EFFECT_BUST, PStatusEffect->GetPower(),
								0, duration, PStatusEffect->GetTier(), PStatusEffect->GetStatusID());
							AddStatusEffect(bustEffect, true);
						}
						DelStatusEffectSilent(PStatusEffect->GetStatusID());

						return true;
					}
			}
			if(m_StatusEffectList.at(i)->GetSubID() == PStatusEffect->GetSubID() ||
				m_StatusEffectList.at(i)->GetStatusID() == EFFECT_BUST){//YOUR cor effect
				numOfEffects++;
				if(oldestRoll==nullptr){
					oldestRoll = m_StatusEffectList.at(i);
				}
				else if(m_StatusEffectList.at(i)->GetDuration() + m_StatusEffectList.at(i)->GetStartTime() <
					oldestRoll->GetDuration() + oldestRoll->GetStartTime()){
						oldestRoll = m_StatusEffectList.at(i);
				}
			}
		}
	}

	if(numOfEffects<maxRolls){
		AddStatusEffect(PStatusEffect, true);
		return true;
	}
	else{
		//i'm a liar, can overwrite rolls
		DelStatusEffect(oldestRoll->GetStatusID());
		AddStatusEffect(PStatusEffect);
		return true;
	}

	return false;
}