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

◆ PickAmmo()

void Terraria.Player.PickAmmo ( Item sItem,
ref int projToShoot,
ref float speed,
ref bool canShoot,
ref int Damage,
ref float KnockBack,
out int usedAmmoItemId,
bool dontConsume = false )
inline

Definition at line 49978 of file Player.cs.

49979 {
49980 Item item = new Item();
49981 bool flag = false;
49982 usedAmmoItemId = 0;
49983 if (sItem.useAmmo == AmmoID.Coin)
49984 {
49985 for (int i = 0; i < 4; i++)
49986 {
49987 int num = 50 + i;
49988 if (inventory[num].ammo == sItem.useAmmo && inventory[num].stack > 0)
49989 {
49990 item = inventory[num];
49991 canShoot = true;
49992 flag = true;
49993 break;
49994 }
49995 }
49996 }
49997 for (int j = 54; j < 58; j++)
49998 {
49999 if (inventory[j].ammo == sItem.useAmmo && inventory[j].stack > 0)
50000 {
50001 item = inventory[j];
50002 canShoot = true;
50003 flag = true;
50004 break;
50005 }
50006 }
50007 if (!flag)
50008 {
50009 for (int k = 0; k < 54; k++)
50010 {
50011 if (inventory[k].ammo == sItem.useAmmo && inventory[k].stack > 0)
50012 {
50013 item = inventory[k];
50014 canShoot = true;
50015 break;
50016 }
50017 }
50018 }
50019 if (!canShoot)
50020 {
50021 return;
50022 }
50023 usedAmmoItemId = item.type;
50024 int pickedProjectileId = -1;
50026 {
50028 }
50029 else if (sItem.type == 1946)
50030 {
50031 projToShoot = 338 + item.type - 771;
50032 }
50033 else if (sItem.type == 3930)
50034 {
50035 projToShoot = 715 + item.type - AmmoID.Rocket;
50036 }
50037 else if (sItem.useAmmo == AmmoID.Rocket)
50038 {
50039 projToShoot += item.shoot;
50040 }
50041 else if (sItem.useAmmo == AmmoID.Solution)
50042 {
50043 projToShoot += item.shoot;
50044 }
50045 else if (item.shoot > 0)
50046 {
50047 projToShoot = item.shoot;
50048 }
50049 if (sItem.type == 3019 && projToShoot == 1)
50050 {
50051 projToShoot = 485;
50052 }
50053 if (sItem.type == 3052)
50054 {
50055 projToShoot = 495;
50056 }
50057 if (sItem.type == 4953 && projToShoot == 1)
50058 {
50059 projToShoot = 932;
50060 }
50061 if (sItem.type == 4381)
50062 {
50063 projToShoot = 819;
50064 }
50065 if (sItem.type == 4058 && projToShoot == 474)
50066 {
50067 projToShoot = 117;
50068 }
50069 if (projToShoot == 42)
50070 {
50071 if (item.type == 370)
50072 {
50073 projToShoot = 65;
50074 Damage += 5;
50075 }
50076 else if (item.type == 408)
50077 {
50078 projToShoot = 68;
50079 Damage += 5;
50080 }
50081 else if (item.type == 1246)
50082 {
50083 projToShoot = 354;
50084 Damage += 5;
50085 }
50086 }
50087 if (inventory[selectedItem].type == 2888 && projToShoot == 1)
50088 {
50089 projToShoot = 469;
50090 }
50091 if (hasMoltenQuiver && projToShoot == 1)
50092 {
50093 projToShoot = 2;
50094 Damage += 2;
50095 }
50096 speed += item.shootSpeed;
50097 if (magicQuiver && (sItem.useAmmo == AmmoID.Arrow || sItem.useAmmo == AmmoID.Stake))
50098 {
50099 KnockBack *= 1.1f;
50100 speed *= 1.1f;
50101 }
50102 if (item.ranged)
50103 {
50104 if (item.damage > 0)
50105 {
50106 Damage += (int)((float)item.damage * rangedDamage);
50107 }
50108 }
50109 else
50110 {
50111 Damage += item.damage;
50112 }
50113 if ((sItem.useAmmo == AmmoID.Arrow || sItem.useAmmo == AmmoID.Stake) && archery)
50114 {
50115 if (speed < 20f)
50116 {
50117 speed *= 1.2f;
50118 if (speed > 20f)
50119 {
50120 speed = 20f;
50121 }
50122 }
50123 Damage = (int)((double)Damage * 1.1);
50124 }
50125 KnockBack += item.knockBack;
50126 bool flag2 = dontConsume;
50127 if (sItem.type == 3475 && Main.rand.Next(3) != 0)
50128 {
50129 flag2 = true;
50130 }
50131 if (sItem.type == 3930 && Main.rand.Next(2) == 0)
50132 {
50133 flag2 = true;
50134 }
50135 if (sItem.type == 3540 && Main.rand.Next(3) != 0)
50136 {
50137 flag2 = true;
50138 }
50139 if (sItem.type == 5134 && Main.rand.Next(3) == 0)
50140 {
50141 flag2 = true;
50142 }
50143 if (magicQuiver && (sItem.useAmmo == AmmoID.Arrow || sItem.useAmmo == AmmoID.Stake) && Main.rand.Next(5) == 0)
50144 {
50145 flag2 = true;
50146 }
50147 if (ammoBox && Main.rand.Next(5) == 0)
50148 {
50149 flag2 = true;
50150 }
50151 if (ammoPotion && Main.rand.Next(5) == 0)
50152 {
50153 flag2 = true;
50154 }
50155 if (sItem.type == 1782 && Main.rand.Next(3) == 0)
50156 {
50157 flag2 = true;
50158 }
50159 if (sItem.type == 98 && Main.rand.Next(3) == 0)
50160 {
50161 flag2 = true;
50162 }
50163 if (sItem.type == 2270 && Main.rand.Next(2) == 0)
50164 {
50165 flag2 = true;
50166 }
50167 if (sItem.type == 533 && Main.rand.Next(2) == 0)
50168 {
50169 flag2 = true;
50170 }
50171 if (sItem.type == 1929 && Main.rand.Next(2) == 0)
50172 {
50173 flag2 = true;
50174 }
50175 if (sItem.type == 1553 && Main.rand.Next(3) != 0)
50176 {
50177 flag2 = true;
50178 }
50179 if (sItem.type == 434 && !ItemAnimationJustStarted)
50180 {
50181 flag2 = true;
50182 }
50183 if (sItem.type == 4953 && itemAnimation > sItem.useAnimation - 8)
50184 {
50185 flag2 = true;
50186 }
50187 if (huntressAmmoCost90 && Main.rand.Next(10) == 0)
50188 {
50189 flag2 = true;
50190 }
50191 if (chloroAmmoCost80 && Main.rand.Next(5) == 0)
50192 {
50193 flag2 = true;
50194 }
50195 if (ammoCost80 && Main.rand.Next(5) == 0)
50196 {
50197 flag2 = true;
50198 }
50199 if (ammoCost75 && Main.rand.Next(4) == 0)
50200 {
50201 flag2 = true;
50202 }
50203 if (Main.remixWorld && sItem.type == 1319 && Main.rand.Next(2) == 0)
50204 {
50205 flag2 = true;
50206 }
50207 if (projToShoot == 85 && itemAnimation < itemAnimationMax - sItem.useTime)
50208 {
50209 flag2 = true;
50210 }
50211 if ((sItem.type == 779 || sItem.type == 5134) && itemAnimation < itemAnimationMax - sItem.useTime)
50212 {
50213 flag2 = true;
50214 }
50215 if (!flag2 && item.consumable)
50216 {
50217 item.stack--;
50218 if (item.stack <= 0)
50219 {
50220 item.active = false;
50221 item.TurnToAir();
50222 }
50223 }
50224 }
static int Arrow
Definition AmmoID.cs:108
static int Rocket
Definition AmmoID.cs:120
static int Coin
Definition AmmoID.cs:110
static int Stake
Definition AmmoID.cs:134
static int Solution
Definition AmmoID.cs:122
int stack
Definition Item.cs:149
int itemAnimationMax
Definition Player.cs:2567
bool hasMoltenQuiver
Definition Player.cs:1605
float rangedDamage
Definition Player.cs:2027
bool ItemAnimationJustStarted
Definition Player.cs:3527
bool PickAmmo_TryFindingSpecificMatches(int launcher, int ammo, out int pickedProjectileId)
Definition Player.cs:49968
bool huntressAmmoCost90
Definition Player.cs:1591
bool chloroAmmoCost80
Definition Player.cs:1589
Item[] inventory
Definition Player.cs:1257

References Terraria.ID.AmmoID.Arrow, Terraria.ID.AmmoID.Coin, Terraria.GameContent.Damage, System.item, Terraria.Main.rand, Terraria.Main.remixWorld, Terraria.ID.AmmoID.Rocket, Terraria.ID.AmmoID.Solution, Terraria.Item.stack, Terraria.ID.AmmoID.Stake, and System.type.

Referenced by Terraria.Projectile.AI_075().