How to detect whether character's vehicle fired single shot?

Place to get help with not working mods / modding interface.
Post Reply
x2605
Inserter
Inserter
Posts: 41
Joined: Fri Jul 31, 2020 4:08 pm
Contact:

How to detect whether character's vehicle fired single shot?

Post by x2605 »

I'm trying to make custom artillery vehicle.
My objective :
- Make vehicle not to react to global artillery-targeting-remote.
- No automatic fire.
- Only react to custom remote used inside of vehicle. Remote cannot invoke other same types of vehicle.
- Can fire directly with fire button, like normal tank.
- Yes, it is self propelled gun. SPG.

Because there is only prototypes of car, artillery-wagon, artillery-turret, and they cannot be mixed, it's quite hard.
I've already met an error car prototype's turret animation doesn't accept ".slice", so I couldn't apply 256 direction images of existing artillery turret head.
And I had to remove cannon barrel animation.

But I found that it is possible to make it fire even in mapview via .shooting_state of character entity.
I think I can partly setup custom targeting flare with custom remote. Passing target position is easy.

But how to detect whether SPG fired only single shot?
I want it to stop shooting just after it fired single shot.
It's type is "car", so it can have its own gun inventory slot and ammo inventory slot.
on_player_ammo_inventory_changed event not fires when shooting in vehicle.

One more thing I have wondered, .ammo_stack_limit is only defined in artillery-wagon and turret.
How can I make similar thing in car prototype? Should I have to create stackable artillery shells? But I want to use existing shells if possible, and don't want to make it modified.
Is there any way to limit item type of full of car trunk to only shells?
1.jpg
1.jpg (58.54 KiB) Viewed 747 times
2.jpg
2.jpg (66.64 KiB) Viewed 747 times
English is not my native language. Sorry for bad English.
My mods :
Lua API global Variable Viewer (mod portal)
Lua API Event Trace (mod portal)
My tools :
Locale String Editor (github.io webapp)

robot256
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: How to detect whether character's vehicle fired single shot?

Post by robot256 »

That tank looks hilarious! Nice job.

This doesn't really answer your question, but in many cases when mods want to mix the abilities of two entities (in this car and artillery turret), they make non-colliding or invisible version of one and teleport it to stay with the rest of the compound entity. Turret Wagons is a crude example of this. It might not help since you also want manual shooting (not sure if you can configure artillery turret to behave how you want), but it would allow the turret animation to play correctly.

Post Reply

Return to “Modding help”