This script makes weapons take damage and eventually break. Each weapon has a HP stat, that is reduced by 1 each time the weapon is fired. When there is only 25 % HP left, a warning is shown that the weapon is about to break. When the HP reaches 0 %, the weapon is removed from the inventory.
How to use:
1) Place an entity to a map
2) Set the AI System:Main to Moshroom\weapon_global.lua
3) Set the Static Mode boolean to Off, Alway Active to Yes and IsImmobile to Yes
4) Set a desired sound effects: Sound0 = Warning, Sound1 = Weapon breaks
Add weapons to a map (recommended, but optional*):
5) Place a weapon entity to a map
6) Set the AI System:Main to Moshroom\weapon_collect.lua
* = The global script works with default weapon.lua too, but there is a subtle difference. When using moshroom_weapon.lua, the weapon HP counter resets each time player picks up a new weapon even if player is already holding a similar weapon (for example if player is holding a Shotgun, picking up a new Shotgun resets the damage counter as if player throws the old shotgun away and starts using the new undamaged one). When using the default weapon.lua, the weapon HP counter only resets when previous weapon of same type is destroyed (for example if player is holding a Shotgun, picking up a new Shotgun only adds shells, but leaves the damage be as if player takes away the shells from the new shotgun, throws it away and keeps using the old one).
How to customize:
1) Open Moshroom\weapon_database.lua with Notepad
2) Edit the names, default HP:s and breakabilities of individual weapons