beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
219 stars 101 forks source link

[FR] Add `Spring.SpawnWeaponExplosion` #882

Open sprunk opened 1 year ago

sprunk commented 1 year ago

User story

I am a newbie modder who wants to spawn an explosion of an existing weapon, that's it.

Deficiencies of existing interfaces

Spring.SpawnExplosion exists but it has a bad interface for this. It defaults to 0 aoe and 0 damage and 0 edgeeffectiveness and 0 literally everything. It doesn't require to pass a weaponDefID (so you can get weird ghost explosions with no FX), but even if you do pass one, it still doesn't affect the default damage/aoe/ee/etc so you need to replicate them manually. The flat (non-table) version also has the weaponDefID as far as the 16th parameter, being considered less important than such things as gfxMod and impactOnly. Using this function is tedious and error-prone.

Spring.CreateProjectile combined with either ttl=0 or Spring.DestroyProjectile seems to spawn an explosion with the correct damage etc but actually does more than that; it triggers gadget:ProjectileCreated/Destroyed which may make assumptions and have side effects.

Proposal

Add Spring.SpawnWeaponExplosion(weaponDefID, x, y, z, rest of args). The weaponDefID is mandatory and affects the default damage/aoe/ee/etc. The rest of args are in a similar format as SpawnExplosion (ie. table or flat) but the flat version has them in a more sensible order (which is a vague term and may be discussed).

WatchTheFort commented 1 year ago

Does it even need the additional args? Can't everything be read from the weapon def?

sprunk commented 1 year ago

The args are entirely optional but are there in case you want to modify the explosion. It's still superior to SpawnExplosion because you don't need to apply the ones you don't modify.