Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/science_db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ item:addKeyValue(_('Sizes'), _('Small (S) / Medium (M) / Large (L)'))
populateMissileStats(item, missile_stat_keys, hvli_stats)
item:setLongDescription(_([[A high-velocity lead impactor (HVLI) fires a simple slug of lead at a high velocity. This weapon is usually found in simpler ships since it does not require guidance computers. This also means its projectiles fly in a straight line from its tube and can't pursue a target.

Each shot from an HVLI fires a burst of 5 projectiles, which increases the chance to hit but requires precision aiming to be effective. It reaches its full damage potential at a range of 2u.]]))
Each shot from an HVLI fires a burst of 5 projectiles, which increases the chance to hit but requires precision aiming to be effective. It reaches its full damage potential at a range of 1u.]]))

local function angleDifference(angle_a, angle_b)
local ret = (angle_b or 0) - (angle_a or 0)
Expand Down
1 change: 1 addition & 0 deletions src/components/lifetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ class LifeTime
{
public:
float lifetime = 1.0;
float initial_lifetime = 1.0;
sp::script::Callback on_expire;
};
1 change: 1 addition & 0 deletions src/components/missile.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ExplodeOnTouch
sp::ecs::Entity owner;
DamageType damage_type = DamageType::Kinetic;
string explosion_sfx;
float full_damage_after = 0.0f;
};
class ExplodeOnTimeout
{
Expand Down
2 changes: 2 additions & 0 deletions src/script/components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ void initComponentScriptBindings()
BIND_MEMBER(ExplodeOnTouch, owner);
BIND_MEMBER(ExplodeOnTouch, damage_type);
BIND_MEMBER(ExplodeOnTouch, explosion_sfx);
BIND_MEMBER(ExplodeOnTouch, full_damage_after);

sp::script::ComponentHandler<DelayedExplodeOnTouch>::name("delayed_explode_on_touch");
BIND_MEMBER(DelayedExplodeOnTouch, delay);
Expand Down Expand Up @@ -666,6 +667,7 @@ void initComponentScriptBindings()
BIND_MEMBER(MoveTo, on_arrival);
sp::script::ComponentHandler<LifeTime>::name("lifetime");
BIND_MEMBER(LifeTime, lifetime);
BIND_MEMBER(LifeTime, initial_lifetime);
BIND_MEMBER(LifeTime, on_expire);

sp::script::ComponentHandler<Faction>::name("faction");
Expand Down
20 changes: 17 additions & 3 deletions src/systems/missilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,17 @@ void MissileSystem::explode(sp::ecs::Entity source, sp::ecs::Entity target, Expl
if (eot.blast_range > 100.0f || !target) {
DamageSystem::damageArea(transform->getPosition(), eot.blast_range, eot.damage_at_edge, eot.damage_at_center, info, eot.blast_range / 2);
} else {
DamageSystem::applyDamage(target, eot.damage_at_center, info);
if (eot.full_damage_after > 0.0f){
auto lifetime = source.getComponent<LifeTime>();
float alive_for = lifetime->initial_lifetime - lifetime->lifetime;
if (alive_for > eot.full_damage_after){
DamageSystem::applyDamage(target, eot.damage_at_center, info);
} else {
DamageSystem::applyDamage(target, eot.damage_at_center * (alive_for / eot.full_damage_after), info);
}
} else {
DamageSystem::applyDamage(target, eot.damage_at_center, info);
}
}

auto e = sp::ecs::Entity::create();
Expand Down Expand Up @@ -292,6 +302,7 @@ void MissileSystem::spawnProjectile(sp::ecs::Entity source, MissileTubes::MountP
mc.damage_at_edge = 10.0f * category_modifier;
mc.blast_range = 20.0f * category_modifier;
mc.explosion_sfx = "sfx/explosion.wav";
mc.full_damage_after = 1000.0f / (mwd.speed / category_modifier); // Full damage after 1U
missile.addComponent<RawRadarSignatureInfo>(0.1f, 0.0f, 0.0f);
}
break;
Expand Down Expand Up @@ -349,8 +360,11 @@ void MissileSystem::spawnProjectile(sp::ecs::Entity source, MissileTubes::MountP
cpe.life_time = 10.0f;
}

if (tube.type_loaded != MW_Mine)
missile.addComponent<LifeTime>().lifetime = mwd.lifetime * category_modifier;
if (tube.type_loaded != MW_Mine){
auto& lifetime = missile.addComponent<LifeTime>();
lifetime.lifetime = mwd.lifetime * category_modifier;
lifetime.initial_lifetime = mwd.lifetime * category_modifier;
}

if (tube.type_loaded != MW_Mine) {
auto& dbad = missile.addComponent<DestroyedByAreaDamage>();
Expand Down
Loading