Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void UseItem(Player player, int playerID)
- {
- if (playerID == Main.myPlayer)
- {
- #region if it needs ammo
- Item MyCheckedItem = new Item();
- bool FoundUsableAmmo = false;
- bool FoundAmmoInAmmoSlot = false;
- for (int PassingIndex = 44; PassingIndex < 48; PassingIndex++)
- {
- if (player.inventory[PassingIndex].ammo == item.useAmmo && player.inventory[PassingIndex].stack > 0)
- {
- MyCheckedItem = player.inventory[PassingIndex];
- FoundUsableAmmo = true;
- FoundAmmoInAmmoSlot = true;
- break;
- }
- }
- if (!FoundAmmoInAmmoSlot)
- {
- for (int PasserIndex = 0; PasserIndex < 44; PasserIndex++)
- {
- if (player.inventory[PasserIndex].ammo == item.useAmmo && player.inventory[PasserIndex].stack > 0)
- {
- MyCheckedItem = player.inventory[PasserIndex];
- FoundUsableAmmo = true;
- break;
- }
- }
- }
- if (FoundUsableAmmo)
- {
- bool DoNotConsumeAmmo = false;
- if (player.ammoCost80 && Main.rand.Next(5) == 0)
- {
- DoNotConsumeAmmo = true;
- }
- if (player.ammoCost75 && Main.rand.Next(4) == 0)
- {
- DoNotConsumeAmmo = true;
- }
- if (!DoNotConsumeAmmo)
- {
- MyCheckedItem.stack--;
- if (MyCheckedItem.stack <= 0)
- {
- MyCheckedItem.active = false;
- MyCheckedItem.name = "";
- MyCheckedItem.type = 0;
- }
- }
- #endregion
- }
- if(FoundUsableAmmo)
- {
- #region regular
- int MyProjectileIndex = -1;
- int MyProjectileSpeed = 10;
- int MyProjectileRandomOffseter = 5;
- float x = (float) (player.itemLocation.X + (float)Main.itemTexture[item.type].Width * 0.5f)-7-MyProjectileRandomOffseter+Main.rand.Next(MyProjectileRandomOffseter);
- player.direction = -1;
- if ((player.itemLocation.X + (float)Main.itemTexture[item.type].Width * 0.5f) < (Main.mouseX + Main.screenPosition.X))
- {
- player.direction = 1;
- x = (float) (player.itemLocation.X + (float)Main.itemTexture[item.type].Width * 0.5f)-7+MyProjectileRandomOffseter+Main.rand.Next(MyProjectileRandomOffseter);
- }
- float y = (float) (player.itemLocation.Y + (float)Main.itemTexture[item.type].Height * 0.5f)-Main.rand.Next(-MyProjectileRandomOffseter,MyProjectileRandomOffseter);
- float rot = (float) Math.Atan2((Main.mouseY + Main.screenPosition.Y)-(y + 5),(Main.mouseX + Main.screenPosition.X) - (x + 5));
- float VX = (float)((Math.Cos(rot) * MyProjectileSpeed));
- float VY = (float)((Math.Sin(rot) * MyProjectileSpeed));
- VX = ((Main.mouseX + Main.screenPosition.X) - (player.position.X + player.width * 0.5f));
- VY = ((Main.mouseY + Main.screenPosition.Y) - (player.position.Y + player.height * 0.5f));
- float distance = (float) Math.Sqrt((double) ((VX * VX) + (VY * VY)));
- distance = MyProjectileSpeed / distance;
- VX *= distance;
- VY *= distance;
- MyProjectileIndex = Projectile.NewProjectile(
- x,
- y,
- VX,
- VY,
- "Blade Shot", //Type
- (int) (item.damage*player.magicDamage), //Damage
- 2.0f,
- playerID
- );
- NetMessage.SendData(27, -1, -1, "", MyProjectileIndex, 0f, 0f, 0f, 0);
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement