Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Add IObjectWeaponItem.MaxAmmo and IObjectWeaponItem.CurrentAmmo

Here you can find ScriptAPI suggestions implemented in the game.
Forum rules
By using the forum you agree to the following rules.
Locked
NearHuscarl
Superfighter
Superfighter
Posts: 89
Joined: Thu Feb 07, 2019 4:36 am

Add IObjectWeaponItem.MaxAmmo and IObjectWeaponItem.CurrentAmmo

Post by NearHuscarl » Mon Mar 23, 2020 6:41 am

I'm writing a modified version of the whip weapon for a boss that can retrieve the weapon the enemy is holding back to the them on every hit. The boss then will decide whether to equip the new weapon or not by comparing with the current weapon type and ammo. There is no way to tell how much ammo an IObjectWeaponItem has at the moment.

IObjectWeaponItem.MaxAmmo and IObjectWeaponItem.CurrentAmmo will have different meanings depend on the IObjectWeaponItem.WeaponItemType:

If it's a melee weapon, CurrentAmmo and MaxAmmo will be the durability of that weapon
If it's a rifle or handgun, CurrentAmmo and MaxAmmo will be the ammo of that weapon
If it's a throwable weapon, CurrentAmmo and MaxAmmo will be the number of the throwable items
If it's a powerup, CurrentAmmo and MaxAmmo will always be 0

Both values are float because the largest floating point precision type is durability which use float.
1 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 31

Post by Gurt » Sun Apr 26, 2020 1:06 pm

Added after v.1.3.5:
ScriptAPI: Added IObjectWeaponItem.GetCurrentAmmo(), IObjectWeaponItem.GetMaxAmmo() which returns current ammo for the item. Read documentation for details what it means for different weapon types.

IObjectWeaponItem:
► Show Spoiler
ScriptAPI: Added properties to read current ammo and max ammo for RangedWeaponItem, RifleWeaponItem, HandgunWeaponItem, MeleeWeaponItem, ThrownWeaponItem and PowerupWeaponItem.
0 x
Gurt

Locked