Page 1 of 1
Add IObjectWeaponItem.MaxAmmo and IObjectWeaponItem.CurrentAmmo
Posted: Mon Mar 23, 2020 6:41 am
by NearHuscarl
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.
Re: Add IObjectWeaponItem.MaxAmmo and IObjectWeaponItem.CurrentAmmo
Posted: Sun Apr 26, 2020 1:06 pm
by Gurt
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
Code: Select all
/// <summary>
/// Gets the current ammo for this weapon item.
/// For ranged weapons, this returns the current ammo.
/// For melee weapons, this returns the current durability value (0f-100f).
/// For throwable weapons, this returns the amount of throwables.
/// For other types, this returns 0.
/// </summary>
public float GetCurrentAmmo();
/// <summary>
/// Gets the max ammo for this weapon item.
/// For ranged weapons, this returns total max possible ammo.
/// For melee weapons, this returns the max durability value (100f).
/// For throwable weapons, this returns the max amount of throwables.
/// For other types, this returns 0.
/// </summary>
public float GetMaxAmmo();
/// <summary>
/// Returns ranged weapon information. Applicable when WeaponItemType is Rifle or Handgun.
/// </summary>
public RangedWeaponItem RangedWeapon { get; }
/// <summary>
/// Returns primary rifle weapon information. Applicable when WeaponItemType is Rifle.
/// </summary>
public RifleWeaponItem RifleWeapon { get; }
/// <summary>
/// Returns secondary handgun weapon information. Applicable when WeaponItemType is Handgun.
/// </summary>
public HandgunWeaponItem HandgunWeapon { get; }
/// <summary>
/// Returns melee weapon information. Applicable when WeaponItemType is Melee.
/// </summary>
public MeleeWeaponItem MeleeWeapon { get; }
/// <summary>
/// Returns throw-weapon (e.g. grenades, mines, shuriken) information. Applicable when WeaponItemType is Thrown.
/// </summary>
public ThrownWeaponItem ThrownWeapon { get; }
/// <summary>
/// Returns powerup item information. Applicable when WeaponItemType is Powerup.
/// </summary>
public PowerupWeaponItem PowerupItem { get; }
/// <summary>
/// Returns instant pickup weapon/item (e.g. healtpack/pills) information. Applicable when WeaponItemType is InstantPickup.
/// </summary>
public InstantPickupWeaponItem InstantPickupItem { get; }
ScriptAPI: Added properties to read current ammo and max ammo for RangedWeaponItem, RifleWeaponItem, HandgunWeaponItem, MeleeWeaponItem, ThrownWeaponItem and PowerupWeaponItem.