本文整理汇总了C++中Damage::MultiplyDup方法的典型用法代码示例。如果您正苦于以下问题:C++ Damage::MultiplyDup方法的具体用法?C++ Damage::MultiplyDup怎么用?C++ Damage::MultiplyDup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Damage
的用法示例。
在下文中一共展示了Damage::MultiplyDup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ApplyDamage
// This is a NPC implementation of damage system (incomplete)
bool NPC::ApplyDamage(Damage &d) {
_log(ITEM__TRACE, "%u: Applying %.1f total damage from %u", GetID(), d.GetTotal(), d.source->GetID());
double total_damage = 0;
bool killed = false;
int random_damage = 0;
double random_damage_mult = 1.0;
//apply resistances...
//damageResistance?
//Shield:
double available_shield = m_shieldCharge;
Damage shield_damage = d.MultiplyDup(
m_self->GetAttribute(AttrShieldKineticDamageResonance).get_float(),
m_self->GetAttribute(AttrShieldThermalDamageResonance).get_float(),
m_self->GetAttribute(AttrShieldEmDamageResonance).get_float(),
m_self->GetAttribute(AttrShieldExplosiveDamageResonance).get_float()
);
//other:
//emDamageResistanceBonus
//explosiveDamageResistanceBonus
//kineticDamageResistanceBonus
//thermalDamageResistanceBonus
//
//TODO: deal with seepage from shield into armor.
//shieldUniformity
//uniformity (chance of seeping through to armor)
/*
* Here we calculates the uniformity thing.
* I think this must be calculated based on
* the type of damage -> resistance basis.
*
double shield_uniformity = available_shield / m_self->shieldCapacity();
if( shield_uniformity < ( 1.0 - m_self->shieldUniformity() ) )
{
/*
* As far i can see mostly npc/entities have a
* chance of transpassing when the shield is below 25%
/
}
*/
// Make a random value to use in msg's and attack multiplier
random_damage = static_cast<int32>(MakeRandomInt(0, 5));
random_damage_mult = (double)(random_damage / 10.0);
// Not sure about this, but with this we get some random hits... :)
//total_shield_damage += total_shield_damage * random_damage_mult;
shield_damage.SumWithMultFactor( random_damage_mult );
double total_shield_damage = shield_damage.GetTotal();
if(total_shield_damage <= available_shield)
{
//we can take all this damage with our shield...
double new_charge = m_shieldCharge - total_shield_damage;
m_shieldCharge = new_charge;
total_damage += total_shield_damage;
_log(ITEM__TRACE, "%s(%u): Applying entire %.1f damage to shields. New charge: %.1f", GetName(), GetID(), total_shield_damage, new_charge);
}
else
{
//first determine how much we can actually apply to
//the shield, the rest goes further down.
double consumed_shield_ratio = available_shield / shield_damage.GetTotal();
d *= 1.0 - consumed_shield_ratio;
if(available_shield > 0) {
total_damage += available_shield;
_log(ITEM__TRACE, "%s(%us): Shield depleated with %.1f damage. %.1f damage remains.", GetName(), GetID(), available_shield, d.GetTotal());
//set shield to 0, it is fully depleated.
m_shieldCharge = 0;
}
//Armor:
double available_armor = m_self->GetAttribute(AttrArmorHP).get_float() - m_armorDamage;
Damage armor_damage = d.MultiplyDup(
m_self->GetAttribute(AttrArmorKineticDamageResonance).get_float(),
m_self->GetAttribute(AttrArmorThermalDamageResonance).get_float(),
m_self->GetAttribute(AttrArmorEmDamageResonance).get_float(),
m_self->GetAttribute(AttrArmorExplosiveDamageResonance).get_float()
);
//other:
//activeEmResistanceBonus
//activeExplosiveResistanceBonus
//activeThermicResistanceBonus
//activeKineticResistanceBonus
//passiveEmDamageResistanceBonus
//passiveExplosiveDamageResistanceBonus
//passiveKineticDamageResistanceBonus
//passiveThermicDamageResistanceBonus
//TODO: figure out how much passes through to structure/modules.
//.........这里部分代码省略.........