void ABaseCharacter::CalculateDamage(FDamageStruct damage) { float crit = FMath::FRand(); float critmult = crit < damage.criticalChance ? damage.criticalMultiplier : 1.0f; int calcdamage = 0; calcdamage += damage.physicalDamage * (1.0f - resistances.physicalResist); calcdamage += damage.heatDamage * (1.0f - resistances.heatResist); calcdamage += damage.coldDamage * (1.0f - resistances.coldResist); calcdamage += damage.electricDamage * (1.0f - resistances.electricResist); calcdamage += damage.chemicalDamage * (1.0f - resistances.chemicalResist); calcdamage += damage.voidDamage * (1.0f - resistances.voidResist); calcdamage *= critmult; CalculateHealth(-calcdamage); }
void CPlayerState::IncrPickup(EItemType type, u32 amount) { if (type >= EItemType::Max) return; switch (type) { case EItemType::Missiles: case EItemType::PowerBombs: case EItemType::ChargeBeam: case EItemType::SpaceJumpBoots: case EItemType::EnergyTanks: case EItemType::Truth: case EItemType::Strength: case EItemType::Elder: case EItemType::Wild: case EItemType::Lifegiver: case EItemType::Warrior: case EItemType::Chozo: case EItemType::Nature: case EItemType::Sun: case EItemType::World: case EItemType::Spirit: case EItemType::Newborn: { CPowerUp& pup = x24_powerups[u32(type)]; pup.x0_amount = std::min(pup.x0_amount + u32(amount), pup.x4_capacity); if (type == EItemType::EnergyTanks) IncrPickup(EItemType::HealthRefill, 9999); break; } case EItemType::HealthRefill: xc_health.SetHP(std::min(amount + xc_health.GetHP(), CalculateHealth())); break; default: break; } }