TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ PickAmmo() [2/2]

bool Terraria.Player.PickAmmo ( Item weapon,
out int projToShoot,
out float speed,
out int damage,
out float knockBack,
out int usedAmmoItemId,
bool dontConsume = false )
inline

A more-convenient-to-call variant of the vanilla PickAmmo method, which handles most vanilla ammunition logic to decide various common stats related to ammunition-consuming weapons.
The stats output by this method take into account any extra stats which the ammunition it finds may provide (read: it accounts for ammo damage and knockback).

Parameters
weaponThe weapon for which to handle ammunition logic.
projToShootThe projectile that should be shot based on the given weapon and the located ammunition.
speedThe speed at which the projectile that would be made by the given weapon and located ammunition should move.
damageThe damage value that the projectile shot should have, based on the given weapon and the located ammunition.
knockBackThe knockback value that the projectile shot should have, based on the given weapon and the located ammunition.
usedAmmoItemIdThe numerical ID of the located ammunition.
dontConsumeWhether or not ammo consumption logic should be called upon.
This defaults to false, and if it is true for any reason, ammo will not be consumed at the end of the method.
This is useful for gathering the data needed based on PickAmmo's calculations without incidentally consuming any ammunition in the process.
Returns
True if ammo was found/chosen, and false otherwise.

Definition at line 54018 of file Player.cs.

54019 {
54020 projToShoot = weapon.shoot;
54021 speed = weapon.shootSpeed;
54022 damage = GetWeaponDamage(weapon);
54023 knockBack = GetWeaponKnockback(weapon);
54024 bool canShoot = false;
54026 if (!canShoot)
54027 {
54028 projToShoot = 0;
54029 return false;
54030 }
54031 return true;
54032 }
bool PickAmmo(Item weapon, out int projToShoot, out float speed, out int damage, out float knockBack, out int usedAmmoItemId, bool dontConsume=false)
A more-convenient-to-call variant of the vanilla PickAmmo method, which handles most vanilla ammuniti...
Definition Player.cs:54018
int GetWeaponDamage(Item sItem, bool forTooltip=false)
Definition Player.cs:53945
float GetWeaponKnockback(Item sItem)
Definition Player.cs:53926

References Terraria.Player.GetWeaponDamage(), Terraria.Player.GetWeaponKnockback(), and Terraria.Player.PickAmmo().

Referenced by Terraria.Projectile.AI_075(), Terraria.Player.ItemCheck_Shoot(), and Terraria.Player.PickAmmo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: