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

◆ IsAmmoFreeThisShot()

bool Terraria.Player.IsAmmoFreeThisShot ( Item weapon,
Item ammo,
int projToShoot )
inline

Determines whether or not the given ammunition should be conserved, based on the given weapon as wielded by this player.

Parameters
weaponThe weapon attempting to consume the ammo.
ammoThe ammo attempting to be conserved (i.e. not consumed).
projToShootThe projectile that should be shot by the given weapon/ammo combination.
Returns
True if the ammo should be conserved on the given shot; false otherwise.

Definition at line 54222 of file Player.cs.

54223 {
54224 if (!CombinedHooks.CanConsumeAmmo(this, weapon, ammo))
54225 {
54226 return true;
54227 }
54228 if (weapon.consumeAmmoOnFirstShotOnly && !ItemAnimationJustStarted)
54229 {
54230 return true;
54231 }
54232 if (weapon.consumeAmmoOnLastShotOnly)
54233 {
54234 int useTime = CombinedHooks.TotalUseTime(weapon.useTime, this, weapon);
54235 if (itemAnimation > useTime && (!weapon.useLimitPerAnimation.HasValue || ItemUsesThisAnimation != weapon.useLimitPerAnimation - 1))
54236 {
54237 return true;
54238 }
54239 }
54240 bool flag2 = false;
54241 if (weapon.type == 3475 && Main.rand.Next(3) != 0)
54242 {
54243 flag2 = true;
54244 }
54245 if (weapon.type == 3930 && Main.rand.Next(2) == 0)
54246 {
54247 flag2 = true;
54248 }
54249 if (weapon.type == 3540 && Main.rand.Next(3) != 0)
54250 {
54251 flag2 = true;
54252 }
54253 if (weapon.type == 5134 && Main.rand.Next(3) == 0)
54254 {
54255 flag2 = true;
54256 }
54257 if (magicQuiver && AmmoID.Sets.IsArrow[weapon.useAmmo] && Main.rand.Next(5) == 0)
54258 {
54259 flag2 = true;
54260 }
54261 if (ammoBox && Main.rand.Next(5) == 0)
54262 {
54263 flag2 = true;
54264 }
54265 if (ammoPotion && Main.rand.Next(5) == 0)
54266 {
54267 flag2 = true;
54268 }
54269 if (weapon.type == 1782 && Main.rand.Next(3) == 0)
54270 {
54271 flag2 = true;
54272 }
54273 if (weapon.type == 98 && Main.rand.Next(3) == 0)
54274 {
54275 flag2 = true;
54276 }
54277 if (weapon.type == 2270 && Main.rand.Next(2) == 0)
54278 {
54279 flag2 = true;
54280 }
54281 if (weapon.type == 533 && Main.rand.Next(2) == 0)
54282 {
54283 flag2 = true;
54284 }
54285 if (weapon.type == 1929 && Main.rand.Next(2) == 0)
54286 {
54287 flag2 = true;
54288 }
54289 if (weapon.type == 1553 && Main.rand.Next(3) != 0)
54290 {
54291 flag2 = true;
54292 }
54293 if (huntressAmmoCost90 && Main.rand.Next(10) == 0)
54294 {
54295 flag2 = true;
54296 }
54297 if (chloroAmmoCost80 && Main.rand.Next(5) == 0)
54298 {
54299 flag2 = true;
54300 }
54301 if (ammoCost80 && Main.rand.Next(5) == 0)
54302 {
54303 flag2 = true;
54304 }
54305 if (ammoCost75 && Main.rand.Next(4) == 0)
54306 {
54307 flag2 = true;
54308 }
54309 if (ammo.CountsAsClass(DamageClass.Throwing))
54310 {
54311 if (ThrownCost50 && Main.rand.Next(100) < 50)
54312 {
54313 flag2 = true;
54314 }
54315 if (ThrownCost33 && Main.rand.Next(100) < 33)
54316 {
54317 flag2 = true;
54318 }
54319 }
54320 if (Main.remixWorld && weapon.type == 1319 && Main.rand.Next(2) == 0)
54321 {
54322 flag2 = true;
54323 }
54324 return flag2;
54325 }
static bool[] IsArrow
If true for a given item type (F:Terraria.Item.type), then items of that type are counted as arrows f...
Definition AmmoID.cs:118
AmmoID entries represent ammo types. Ammo items that share the same AmmoID value assigned to F:Terrar...
Definition AmmoID.cs:11
static bool CanConsumeAmmo(Player player, Item weapon, Item ammo)
static int TotalUseTime(float useTime, Player player, Item item)
static DamageClass Throwing
Class provided for modders who want to coordinate throwing accessories and items. Not used by any van...
T:Terraria.ModLoader.DamageClass is used to determine the application of item effects,...
bool ItemAnimationJustStarted
Returns true if the item animation is in its first frame.
Definition Player.cs:4408
int ItemUsesThisAnimation
The number of times the item has been used/fired this animation (swing)
Definition Player.cs:4689
bool ThrownCost50
If true, player has a 50% chance of not consuming the thrown item. Only applies to consumable items ...
Definition Player.cs:4592
bool ThrownCost33
If true, player has a 33% chance of not consuming the thrown item. Only applies to consumable items ...
Definition Player.cs:4584
bool huntressAmmoCost90
Definition Player.cs:2166
bool chloroAmmoCost80
Definition Player.cs:2164

References Terraria.Player.ammoBox, Terraria.Player.ammoCost75, Terraria.Player.ammoCost80, Terraria.Player.ammoPotion, Terraria.ModLoader.CombinedHooks.CanConsumeAmmo(), Terraria.Player.chloroAmmoCost80, Terraria.Item.CountsAsClass(), Terraria.Player.huntressAmmoCost90, Terraria.ID.AmmoID.Sets.IsArrow, Terraria.Player.itemAnimation, Terraria.Player.ItemAnimationJustStarted, Terraria.Player.ItemUsesThisAnimation, Terraria.Player.magicQuiver, Terraria.Main.rand, Terraria.Main.remixWorld, Terraria.ModLoader.DamageClass.Throwing, Terraria.Player.ThrownCost33, Terraria.Player.ThrownCost50, and Terraria.ModLoader.CombinedHooks.TotalUseTime().

Referenced by Terraria.Player.PickAmmo().

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