2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/Weapon/CWeapon.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
|
|
|
#include "Runtime/World/CScriptWater.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2016-12-22 19:57:21 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-12-22 19:57:21 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CWeapon::CWeapon(TUniqueId uid, TAreaId aid, bool active, TUniqueId owner, EWeaponType type, std::string_view name,
|
|
|
|
const zeus::CTransform& xf, const CMaterialFilter& filter, const CMaterialList& mList,
|
|
|
|
const CDamageInfo& dInfo, EProjectileAttrib attribs, CModelData&& mData)
|
2016-12-22 19:57:21 +00:00
|
|
|
: CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, std::move(mData), mList,
|
2019-04-03 04:32:31 +00:00
|
|
|
CActorParameters::None().HotInThermal(true), kInvalidUniqueId)
|
2018-12-08 05:30:43 +00:00
|
|
|
, xe8_projectileAttribs(attribs)
|
|
|
|
, xec_ownerId(owner)
|
|
|
|
, xf0_weaponType(type)
|
|
|
|
, xf8_filter(filter)
|
|
|
|
, x110_origDamageInfo(dInfo)
|
|
|
|
, x12c_curDamageInfo(dInfo) {}
|
2017-01-15 03:59:37 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
void CWeapon::Accept(metaforce::IVisitor& visitor) { visitor.Visit(this); }
|
2017-01-15 03:59:37 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWeapon::Think(float dt, CStateManager& mgr) {
|
|
|
|
x148_curTime += dt;
|
|
|
|
if ((xe8_projectileAttribs & EProjectileAttrib::DamageFalloff) == EProjectileAttrib::DamageFalloff) {
|
|
|
|
float damMul = std::max(0.f, 1.f - x148_curTime * x14c_damageFalloffSpeed);
|
|
|
|
x12c_curDamageInfo.SetDamage(x110_origDamageInfo.GetDamage() * damMul);
|
|
|
|
x12c_curDamageInfo.SetRadius(x110_origDamageInfo.GetRadius() * damMul);
|
|
|
|
x12c_curDamageInfo.SetKnockBackPower(x110_origDamageInfo.GetKnockBackPower() * damMul);
|
|
|
|
x12c_curDamageInfo.SetWeaponMode(x110_origDamageInfo.GetWeaponMode());
|
|
|
|
x12c_curDamageInfo.SetNoImmunity(false);
|
|
|
|
} else {
|
|
|
|
x12c_curDamageInfo = x110_origDamageInfo;
|
|
|
|
}
|
|
|
|
CEntity::Think(dt, mgr);
|
2018-02-01 23:19:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 17:28:20 +00:00
|
|
|
void CWeapon::Render(CStateManager&) {
|
2018-12-08 05:30:43 +00:00
|
|
|
// Empty
|
2018-02-01 23:19:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EWeaponCollisionResponseTypes CWeapon::GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
|
2018-12-08 05:30:43 +00:00
|
|
|
const CWeaponMode&, EProjectileAttrib) const {
|
|
|
|
return EWeaponCollisionResponseTypes::Projectile;
|
2018-02-01 23:19:34 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CWeapon::FluidFXThink(EFluidState state, CScriptWater& water, CStateManager& mgr) {
|
|
|
|
bool doRipple = true;
|
|
|
|
float mag = 0.f;
|
|
|
|
switch (xf0_weaponType) {
|
|
|
|
case EWeaponType::Power:
|
|
|
|
mag = 0.1f;
|
|
|
|
break;
|
|
|
|
case EWeaponType::Ice:
|
|
|
|
mag = 0.3f;
|
|
|
|
break;
|
|
|
|
case EWeaponType::Wave:
|
|
|
|
mag = 0.1f;
|
|
|
|
break;
|
|
|
|
case EWeaponType::Plasma:
|
|
|
|
break;
|
|
|
|
case EWeaponType::Missile:
|
|
|
|
mag = 0.5f;
|
|
|
|
break;
|
|
|
|
case EWeaponType::Phazon:
|
|
|
|
mag = 0.1f;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
doRipple = false;
|
|
|
|
break;
|
|
|
|
}
|
2018-02-01 23:19:34 +00:00
|
|
|
|
2021-06-07 19:29:18 +00:00
|
|
|
if (True(xe8_projectileAttribs & EProjectileAttrib::ComboShot) && state != EFluidState::InFluid)
|
2018-12-08 05:30:43 +00:00
|
|
|
mag += 0.5f;
|
2019-04-03 04:32:31 +00:00
|
|
|
if (True(xe8_projectileAttribs & EProjectileAttrib::Charged))
|
2018-12-08 05:30:43 +00:00
|
|
|
mag += 0.25f;
|
|
|
|
if (mag > 1.f)
|
|
|
|
mag = 1.f;
|
2018-02-01 23:19:34 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (doRipple) {
|
|
|
|
zeus::CVector3f pos = GetTranslation();
|
|
|
|
pos.z() = float(water.GetTriggerBoundsWR().max.z());
|
2019-04-03 04:32:31 +00:00
|
|
|
if (True(xe8_projectileAttribs & EProjectileAttrib::ComboShot)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!water.CanRippleAtPoint(pos))
|
|
|
|
doRipple = false;
|
|
|
|
} else if (state == EFluidState::InFluid) {
|
|
|
|
doRipple = false;
|
|
|
|
}
|
2018-02-01 23:19:34 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (doRipple) {
|
|
|
|
water.GetFluidPlane().AddRipple(mag, x8_uid, pos, water, mgr);
|
|
|
|
mgr.GetFluidPlaneManager()->CreateSplash(x8_uid, mgr, water, pos, mag,
|
|
|
|
state == EFluidState::EnteredFluid || state == EFluidState::LeftFluid);
|
2018-02-01 23:19:34 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-02-01 23:19:34 +00:00
|
|
|
}
|
|
|
|
|
2022-11-03 05:31:16 +00:00
|
|
|
void CWeapon::SetDamageFalloffSpeed(float d) {
|
|
|
|
if (d <= 0.f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
x14c_damageFalloffSpeed = 1.f / d;
|
|
|
|
}
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|