So... I am working on a mod, which adds a couple new weapons and their corresponding ammo types (power cells). Now, I scoured through base and core, and couldn't find the scripts responsible for deleting empty magazines.
Is there any way to prevent the deletion of an empty magazine (or, alternatively, to give the player a new item called 'depleted cell' when a magazine is fully used up)?
Prevent deletion of empty magazines
Re: Prevent deletion of empty magazines
Vanilla functionality of the game is done in C++ and its code is inaccessible to common folks.
You might want to play around with on_player_ammo_inventory_changed event.
If that fails, the only way would be to perform inventory checks each few ticks.
You might want to play around with on_player_ammo_inventory_changed event.
If that fails, the only way would be to perform inventory checks each few ticks.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: Prevent deletion of empty magazines
I see, thank you. I'll try that. So, I presume, count the number of magazines in the player's inventory whenever the inventory is changed, and then add the appropriate number of cells.
However, when the player manually drops off stuff from his inventory into a container, that would trigger the script would it not? If the player unloads magazines from his inventory, 'depleted' magazines will spawn in his inventory. No? Also, as far as I know, there're no events for a player manually removing items from his inventory which could be used as a failsafe. There would also appear to be no event for the player using, or attempting to use, a weapon.
However, when the player manually drops off stuff from his inventory into a container, that would trigger the script would it not? If the player unloads magazines from his inventory, 'depleted' magazines will spawn in his inventory. No? Also, as far as I know, there're no events for a player manually removing items from his inventory which could be used as a failsafe. There would also appear to be no event for the player using, or attempting to use, a weapon.
Re: Prevent deletion of empty magazines
You're probably right. Though you could maintain a counter of how much ammo player has on him, and check, how much ammo is gone, if more than a single clip - it is unlikely due to shooting, if a single clip is gone, you could check the player's inventory and opened entity, and see if missing clip is there. It is not 100% correct for external inventories, as there's not way to know what was in them before the event, but covers most of the situations.
Or the trigger_created_entity event might be of use to detect player shooting if the weapon you're devising is not too fast shooting. Then you could implement all the counting logic in the lua completely.
Or the trigger_created_entity event might be of use to detect player shooting if the weapon you're devising is not too fast shooting. Then you could implement all the counting logic in the lua completely.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: Prevent deletion of empty magazines
Actually, I think you just gave me the solution. Thanks very much; you've been most helpful.
Also, I have to say - I love your profile picture.
Also, I have to say - I love your profile picture.
Re: Prevent deletion of empty magazines
Why thank you.
Good luck with the solution and the project of yours.
Good luck with the solution and the project of yours.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.