当前位置: 首页>>代码示例>>C++>>正文


C++ CCharEntity::UpdateHealth方法代码示例

本文整理汇总了C++中CCharEntity::UpdateHealth方法的典型用法代码示例。如果您正苦于以下问题:C++ CCharEntity::UpdateHealth方法的具体用法?C++ CCharEntity::UpdateHealth怎么用?C++ CCharEntity::UpdateHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCharEntity的用法示例。


在下文中一共展示了CCharEntity::UpdateHealth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddStatusEffect

/************************************************************************
* *
* ????????? ??????-?????? ? ????????? *
* ???? ?? ????????, ?? ???????????-????????? ?????????? ???????? 32 *
* *
************************************************************************/
bool CStatusEffectContainer::AddStatusEffect(CStatusEffect* PStatusEffect, bool silent)
{
if(PStatusEffect == NULL){
ShowWarning("status_effect_container::AddStatusEffect Status effect given was NULL!\n");
return false;
}
uint16 statusId = PStatusEffect->GetStatusID();
if(statusId >= MAX_EFFECTID){
ShowWarning("status_effect_container::AddStatusEffect statusId given is OVER limit %d\n", statusId);
return false;
}
if(CanGainStatusEffect((EFFECT)statusId, PStatusEffect->GetPower()))
{
// remove clean up other effects
OverwriteStatusEffect(PStatusEffect);
PStatusEffect->SetOwner(m_POwner);
SetEffectParams(PStatusEffect);
// remove effects with same type
DelStatusEffectsByType(PStatusEffect->GetType());
PStatusEffect->SetStartTime(gettick());
m_StatusEffectList.push_back(PStatusEffect);
luautils::OnEffectGain(m_POwner, PStatusEffect);
m_POwner->addModifiers(&PStatusEffect->modList);
if( m_POwner->health.maxhp != 0) //make sure we're not in the middle of logging in
{
m_POwner->UpdateHealth();
}
if (m_POwner->objtype == TYPE_PC)
{
CCharEntity* PChar = (CCharEntity*)m_POwner;
if (PStatusEffect->GetIcon() != 0)
{
UpdateStatusIcons();
}
if (PChar->status == STATUS_NORMAL) PChar->status = STATUS_UPDATE;
if( m_POwner->health.maxhp != 0) //make sure we're not in the middle of logging in
{
//check for latents
CLatentEffectContainer* PLatentEffectContainer;
PChar->PLatentEffectContainer->CheckLatentsFoodEffect();
PChar->PLatentEffectContainer->CheckLatentsStatusEffect();
PChar->UpdateHealth();
PChar->pushPacket(new CCharHealthPacket(PChar));
}
PChar->pushPacket(new CCharSyncPacket(PChar));
}
return true;
}
return false;
}
开发者ID:will4wachter,项目名称:Project1,代码行数:56,代码来源:status_effect_container.cpp

示例2: RemoveStatusEffect

void CStatusEffectContainer::RemoveStatusEffect(uint32 id, bool silent)
{
    CStatusEffect* PStatusEffect = m_StatusEffectList.at(id);

    if (PStatusEffect->GetStatusID() >= EFFECT_FIRE_MANEUVER &&
        PStatusEffect->GetStatusID() <= EFFECT_DARK_MANEUVER &&
        m_POwner->objtype == TYPE_PC)
    {
        puppetutils::CheckAttachmentsForManeuver((CCharEntity*)m_POwner, PStatusEffect->GetStatusID(), false);
    }

    m_StatusEffectList.erase(m_StatusEffectList.begin() + id);
    luautils::OnEffectLose(m_POwner, PStatusEffect);

    m_POwner->delModifiers(&PStatusEffect->modList);
    m_POwner->UpdateHealth();

    if (m_POwner->objtype == TYPE_PC)
    {
        CCharEntity* PChar = (CCharEntity*)m_POwner;

        if (PStatusEffect->GetIcon() != 0)
        {
            UpdateStatusIcons();
			if (silent == false)
			{
				PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, PStatusEffect->GetIcon(), 0, 206));
			}
        }
		//check for latents
		PChar->PLatentEffectContainer->CheckLatentsFoodEffect();
		PChar->PLatentEffectContainer->CheckLatentsStatusEffect();
        PChar->PLatentEffectContainer->CheckLatentsRollSong(HasStatusEffectByFlag(EFFECTFLAG_SONG | EFFECTFLAG_ROLL));
		PChar->UpdateHealth();

        PChar->pushPacket(new CCharHealthPacket(PChar));
        PChar->pushPacket(new CCharSyncPacket(PChar));
    }
	else
	{
		if (silent == false && PStatusEffect->GetIcon() != 0 && ((PStatusEffect->GetFlag() & EFFECTFLAG_NO_LOSS_MESSAGE) == 0) && !m_POwner->isDead())
		{
			m_POwner->loc.zone->PushPacket(m_POwner, CHAR_INRANGE, new CMessageBasicPacket(m_POwner, m_POwner, PStatusEffect->GetIcon(), 0, 206));
		}
	}
    delete PStatusEffect;
}
开发者ID:DomingoSeven,项目名称:darkstar,代码行数:47,代码来源:status_effect_container.cpp

示例3: RemoveStatusEffect

void CStatusEffectContainer::RemoveStatusEffect(uint32 id, bool silent)
{
    CStatusEffect* PStatusEffect = m_StatusEffectList.at(id);

    m_StatusEffectList.erase(m_StatusEffectList.begin() + id);
    luautils::OnEffectLose(m_POwner, PStatusEffect);

    m_POwner->delModifiers(&PStatusEffect->modList);
    m_POwner->UpdateHealth();

    if (m_POwner->objtype == TYPE_PC)
    {
        CCharEntity* PChar = (CCharEntity*)m_POwner;

        if (PStatusEffect->GetIcon() != 0)
        {
            UpdateStatusIcons();
			if (silent == false)
			{
				PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, PStatusEffect->GetIcon(), 0, 206));
			}
        }
		//check for latents
		CLatentEffectContainer* PLatentEffectContainer;
		PChar->PLatentEffectContainer->CheckLatentsFoodEffect();
		PChar->PLatentEffectContainer->CheckLatentsStatusEffect();
		PChar->UpdateHealth();

        if (PChar->status == STATUS_NORMAL) PChar->status = STATUS_UPDATE;

        PChar->pushPacket(new CCharHealthPacket(PChar));
        PChar->pushPacket(new CCharSyncPacket(PChar));
    }
	else
	{
		if (silent == false && PStatusEffect->GetIcon() != 0 && ((PStatusEffect->GetFlag() & EFFECTFLAG_NO_LOSS_MESSAGE) == 0) && !m_POwner->isDead())
		{
			m_POwner->loc.zone->PushPacket(m_POwner, CHAR_INRANGE, new CMessageBasicPacket(m_POwner, m_POwner, PStatusEffect->GetIcon(), 0, 206));
		}
	}
    delete PStatusEffect;
}
开发者ID:Croex,项目名称:darkstar,代码行数:42,代码来源:status_effect_container.cpp

示例4: AddStatusEffect

bool CStatusEffectContainer::AddStatusEffect(CStatusEffect* PStatusEffect, bool silent)
{
    if(PStatusEffect == nullptr){
        ShowWarning("status_effect_container::AddStatusEffect Status effect given was nullptr!\n");
        return false;
    }

    uint16 statusId = PStatusEffect->GetStatusID();

    if(statusId >= MAX_EFFECTID){
        ShowWarning("status_effect_container::AddStatusEffect statusId given is OVER limit %d\n", statusId);
        return false;
    }

	if(CanGainStatusEffect((EFFECT)statusId, PStatusEffect->GetPower()))
	{

            // check for minimum duration
            if(PStatusEffect->GetDuration() < effects::EffectsParams[statusId].MinDuration){
                PStatusEffect->SetDuration(effects::EffectsParams[statusId].MinDuration);
            }

        // remove clean up other effects
        OverwriteStatusEffect(PStatusEffect);

        PStatusEffect->SetOwner(m_POwner);

        SetEffectParams(PStatusEffect);

        // remove effects with same type
        DelStatusEffectsByType(PStatusEffect->GetType());

        PStatusEffect->SetStartTime(gettick());

        m_StatusEffectList.push_back(PStatusEffect);

        luautils::OnEffectGain(m_POwner, PStatusEffect);

        m_POwner->addModifiers(&PStatusEffect->modList);

        if (PStatusEffect->GetStatusID() >= EFFECT_FIRE_MANEUVER &&
            PStatusEffect->GetStatusID() <= EFFECT_DARK_MANEUVER &&
            m_POwner->objtype == TYPE_PC)
        {
            puppetutils::CheckAttachmentsForManeuver((CCharEntity*)m_POwner, PStatusEffect->GetStatusID(), true);
        }

        if( m_POwner->health.maxhp != 0) //make sure we're not in the middle of logging in
        {
            m_POwner->UpdateHealth();
        }

        if (m_POwner->objtype == TYPE_PC)
        {
            CCharEntity* PChar = (CCharEntity*)m_POwner;

            if (PStatusEffect->GetIcon() != 0)
            {
                UpdateStatusIcons();
            }

			if( m_POwner->health.maxhp != 0) //make sure we're not in the middle of logging in
			{
				//check for latents
				PChar->PLatentEffectContainer->CheckLatentsFoodEffect();
				PChar->PLatentEffectContainer->CheckLatentsStatusEffect();
                PChar->PLatentEffectContainer->CheckLatentsRollSong(PStatusEffect->GetFlag() & (EFFECTFLAG_SONG | EFFECTFLAG_ROLL));
				PChar->UpdateHealth();

				PChar->pushPacket(new CCharHealthPacket(PChar));
			}
            PChar->pushPacket(new CCharSyncPacket(PChar));
        }
        m_POwner->updatemask |= UPDATE_HP;

        return true;
	}

    return false;
}
开发者ID:DomingoSeven,项目名称:darkstar,代码行数:80,代码来源:status_effect_container.cpp


注:本文中的CCharEntity::UpdateHealth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。