reloading ship weapons query

Freeform discussion about anything related to modding Transcendence.
Post Reply
Militia Captain
Militia Captain
Posts: 742
Joined: Tue Nov 05, 2013 9:56 am

Wed Jul 10, 2019 6:23 am

Was mucking about with ShivanHunter's Ranx ships mod.

Great stuff, the ship images are great. Also the turrets.

One problem with the Ranx is they run out of ammo. This includes the mod turrets.

I was looking at ways of making the Ranx ships dock and 'reload' with ammo from their station.
From info in a forum post by PM, I checked the Reenu code but it is weapon code not ship code. It also uses <OnAIUpdate> which is a bit processor hungry.

Ideally some way of getting a ship class to dock would be best rather than a ship with a particular weapon.

Looking at 0xABCDEF's XML hierarchy I saw <OnAttacked> and <OnDamage> in the ship class events. Also <OnEventHandlerInit>.

So maybe there could be an ammo check in <OnAttacked> in the ShipClass. If the ship lacked ammo it could be ordered to dock and magically reload. Or gate out if no Ranx stations were left intact.

Would this sort of thing work? Or would a separate event handler be needed? Any info at all would be good before I spend hours working on this!
And is there some way to automatically reload stations with ammo for their weapons? TIA.
Stupid code. Do what I want, not what I typed in!

Militia Captain
Militia Captain
Posts: 525
Joined: Tue Mar 05, 2013 8:26 am

Wed Jul 10, 2019 9:05 am

OnAttacked doesn't seem ideal. OnAIUpdate should be fine as long as you don't do something very system-intensive most of the time.

It could work something like this: Check the ammo level with objHasItem with 1 for the quantity. If they're docked and low on ammo, add some ammo. Once they have enough, undock and resume normal behavior. Otherwise, if they're out of ammo or they're low on ammo and not in combat, order them to go restock. You can use the 'underAttack property or sysFindObject.

I thought some stations already events to restock the ammo for their installed weapon, but I don't see any at the moment. Maybe it's automatic now?

An event handler would let you add code to ships without totally overriding them, so you wouldn't need to update the mod if the class changed in vanilla. But if you're overriding anyway, you don't need one.

Post Reply