Fixed "divided by zero" error when returning 0 in AMMOCOST hook

* with CheckWeaponAmmoCost=1

Added a value check to the return value of AMMOCOST hook.
Updated hookscripts.md to reflect this change.
This commit is contained in:
NovaRain
2023-05-18 10:01:49 +08:00
parent 5b9e90100d
commit befea69909
5 changed files with 10 additions and 5 deletions
+3 -1
View File
@@ -296,9 +296,11 @@
id: HOOK_AMMOCOST
doc: |
Runs when calculating ammo cost for a weapon. Doesn't affect damage, only how much ammo is spent.<br>
By default, weapons can make attacks when at least 1 ammo is left, regardless of ammo cost calculations.<br>
By default, a weapon can perform an attack with at least one ammo, regardless of ammo cost calculation.<br>
To add proper check for ammo before attacking and proper calculation of the number of burst rounds (hook type 1 and 2 in `arg3`), set **CheckWeaponAmmoCost=1** in **Misc** section of ddraw.ini.
__NOTE:__ The return value must be greater than or equal to 0 to be valid.
```
Item arg0 - The weapon
int arg1 - Number of bullets in burst or 1 for single shots
+3 -1
View File
@@ -394,9 +394,11 @@ int ret1 - The new maximum damage
#### `HOOK_AMMOCOST (hs_ammocost.int)`
Runs when calculating ammo cost for a weapon. Doesn't affect damage, only how much ammo is spent.\
By default, weapons can make attacks when at least 1 ammo is left, regardless of ammo cost calculations.\
By default, a weapon can perform an attack with at least one ammo, regardless of ammo cost calculation.\
To add proper check for ammo before attacking and proper calculation of the number of burst rounds (hook type 1 and 2 in `arg3`), set **CheckWeaponAmmoCost=1** in **Misc** section of ddraw.ini.
__NOTE:__ The return value must be greater than or equal to 0 to be valid.
```
Item arg0 - The weapon
int arg1 - Number of bullets in burst or 1 for single shots