//public Item item = new item(); public override void AI() { Player player = Main.player[projectile.owner]; timer++; int weaponDamage = projectile.damage; float weaponKnockback = player.inventory[player.selectedItem].knockBack; canShoot = player.HasAmmo(QwertyMethods.MakeItemFromID(mod.ItemType("GunArrow")), true) && player.inventory[player.selectedItem + 10].useAmmo == 97; if (timer == 30) { player.PickAmmo(QwertyMethods.MakeItemFromID(mod.ItemType("GunArrow")), ref bullet, ref speed, ref canShoot, ref weaponDamage, ref weaponKnockback, false); Projectile b = Main.projectile[Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, bullet, weaponDamage, weaponKnockback, Main.myPlayer)]; if (projectile.GetGlobalProjectile <arrowgigantism>().GiganticArrow) { b.scale *= 3; b.GetGlobalProjectile <arrowgigantism>().GiganticArrow = true; } } if (timer == 60) { player.PickAmmo(QwertyMethods.MakeItemFromID(mod.ItemType("GunArrow")), ref bullet, ref speed, ref canShoot, ref weaponDamage, ref weaponKnockback, true); Projectile b = Main.projectile[Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, bullet, weaponDamage, weaponKnockback, Main.myPlayer)]; if (projectile.GetGlobalProjectile <arrowgigantism>().GiganticArrow) { b.scale *= 3; b.GetGlobalProjectile <arrowgigantism>().GiganticArrow = true; } } }
void Shoot() { Main.PlaySound(SoundID.Item38, projectile.Center); timer += 10; Player player = Main.player[projectile.owner]; int weaponDamage = projectile.damage; float weaponKnockback = projectile.knockBack; int bulletCount = 8 + (int)((((1 / player.meleeSpeed) - 1) * 100) / 10); //CombatText.NewText(player.getRect(), new Color(38, 126, 126), bulletCount, true, false); Item sItem = QwertyMethods.MakeItemFromID(ItemID.FlintlockPistol); sItem.damage = weaponDamage; player.PickAmmo(sItem, ref bullet, ref speedB, ref canShoot, ref weaponDamage, ref weaponKnockback, false); List <Projectile> bullets = QwertyMethods.ProjectileSpread(projectile.Center, bulletCount, BulVel, bullet, weaponDamage, weaponKnockback, projectile.owner); foreach (Projectile bul in bullets) { bul.melee = true; bul.ranged = false; if (Main.netMode == 1) { QwertysRandomContent.UpdateProjectileClass(bul); } } }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { Main.PlaySound(SoundID.Item38, projectile.Center); Player player = Main.player[projectile.owner]; int weaponDamage = projectile.damage; float weaponKnockback = projectile.knockBack; int bulletCount = 8 + (int)((((1 / player.meleeSpeed) - 1) * 100) / 10); float bulletSpacing = 2 * (float)Math.PI / bulletCount; player.PickAmmo(QwertyMethods.MakeItemFromID(ItemID.FlintlockPistol), ref bullet, ref speedB, ref canShoot, ref weaponDamage, ref weaponKnockback, false); for (; bulletCount > 0; bulletCount--) { Projectile bul = Main.projectile[Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(dir) * BulVel, (float)Math.Sin(dir) * BulVel, bullet, weaponDamage, weaponKnockback, Main.myPlayer)]; bul.melee = true; bul.ranged = false; if (Main.netMode == 1) { QwertysRandomContent.UpdateProjectileClass(bul); } dir += bulletSpacing; } projectile.velocity.X = -projectile.velocity.X; projectile.velocity.Y = -projectile.velocity.Y; }
public override void AI() { Player player = Main.player[projectile.owner]; player.itemAnimation = 2; player.itemTime = 2; bool firing = player.channel && player.HasAmmo(QwertyMethods.MakeItemFromID(ItemID.FlintlockPistol), true) && !player.noItems && !player.CCed; int weaponDamage = player.GetWeaponDamage(player.inventory[player.selectedItem]); int Ammo = 14; float speed = 14f; float weaponKnockback = player.inventory[player.selectedItem].knockBack; if (runOnce) { angleInRing = (float)(projectile.ai[1] * Math.PI / 3f); runOnce = false; } trigTimer += (float)Math.PI / 10; radius = 125 + 25 * (float)Math.Sin(trigTimer); angleInRing += rotateSpeed; projectile.rotation = angleInRing + (float)Math.PI; projectile.Center = new Vector2(Main.MouseWorld.X + (float)Math.Cos(angleInRing) * radius, Main.MouseWorld.Y + (float)Math.Sin(angleInRing) * radius); if (player.channel) { reloadTimer++; projectile.timeLeft = 2; if (reloadTimer % 15 == 0) { player.PickAmmo(QwertyMethods.MakeItemFromID(ItemID.FlintlockPistol), ref Ammo, ref speed, ref firing, ref weaponDamage, ref weaponKnockback, Main.rand.Next(2) == 0); if (firing && player.CheckMana((int)((float)player.inventory[player.selectedItem].mana / 6f), !player.GetModPlayer <BloodMedalionEffect>().effect)) { if (player.GetModPlayer <BloodMedalionEffect>().effect) { player.statLife -= (int)(player.inventory[player.selectedItem].mana / 6f * player.manaCost); if (player.statLife <= 0) { player.KillMe(PlayerDeathReason.ByCustomReason(player.name + " madly drained " + (player.Male ? "his " : "her") + " lifeforce!"), (int)(player.inventory[player.selectedItem].mana * player.manaCost), 0); } } player.manaRegenDelay = (int)player.maxRegenDelay; Main.PlaySound(SoundID.Item11, player.position); Projectile bul = Main.projectile[Projectile.NewProjectile(projectile.Center, new Vector2((float)Math.Cos(projectile.rotation) * speed, (float)Math.Sin(projectile.rotation) * speed), Ammo, projectile.damage, projectile.knockBack, player.whoAmI)]; bul.magic = true; bul.ranged = false; if (Main.netMode == 1) { QwertysRandomContent.UpdateProjectileClass(bul); } } } } else { } }
public override void AI() { Player player = Main.player[projectile.owner]; QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(); varTime++; if (varTime >= 60) { varTime = 0; if (Main.netMode != 2) { Yvar = Main.rand.Next(0, 80); Xvar = Main.rand.Next(-80, 80); } } Vector2 moveTo = new Vector2(player.Center.X + Xvar, player.Center.Y - Yvar) - projectile.Center; projectile.velocity = (moveTo) * .04f; if (modPlayer.LuneArcher) { projectile.timeLeft = 2; } timer++; if (QwertyMethods.ClosestNPC(ref target, 10000, player.Center, false, player.MinionAttackTargetNPC)) { projectile.rotation = (target.Center - projectile.Center).ToRotation(); if (timer > 90) { int weaponDamage = projectile.damage; float weaponKnockback = projectile.knockBack; player.PickAmmo(QwertyMethods.MakeItemFromID(39), ref arrow, ref speedB, ref canShoot, ref weaponDamage, ref weaponKnockback, Main.rand.Next(2) == 0); if (Main.netMode != 1) { Projectile bul = Main.projectile[Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(projectile.rotation) * BulVel, (float)Math.Sin(projectile.rotation) * BulVel, arrow, weaponDamage, weaponKnockback, Main.myPlayer)]; bul.ranged = false; bul.minion = true; if (Main.netMode == 1) { QwertysRandomContent.UpdateProjectileClass(bul); } } timer = 0; } projectile.rotation += (float)Math.PI / 2; } }
void Shoot() { Player player = Main.player[projectile.owner]; Main.PlaySound(SoundID.Item11, projectile.position); int weaponDamage = projectile.damage; float weaponKnockback = projectile.knockBack; Item sItem = QwertyMethods.MakeItemFromID(ItemID.Handgun); sItem.damage = weaponDamage; player.PickAmmo(sItem, ref bullet, ref speedB, ref canShoot, ref weaponDamage, ref weaponKnockback, Main.rand.Next(2) == 0); Projectile bul = Main.projectile[Projectile.NewProjectile(projectile.Center + QwertyMethods.PolarVector(29, gunRotation), QwertyMethods.PolarVector(10, gunRotation), bullet, weaponDamage, weaponKnockback, Main.myPlayer)]; bul.ranged = false; bul.minion = true; if (Main.netMode == 1) { QwertysRandomContent.UpdateProjectileClass(bul); } shotCooldown = 0; }
public override void AI() { Player player = Main.player[projectile.owner]; for (int k = 0; k < 200; k++) { possibleTarget = Main.npc[k]; distance = (possibleTarget.Center - projectile.Center).Length(); if (distance < maxDistance && possibleTarget.active && !possibleTarget.dontTakeDamage && !possibleTarget.friendly && possibleTarget.lifeMax > 5 && !possibleTarget.immortal && Collision.CanHit(projectile.Center, 0, 0, possibleTarget.Center, 0, 0)) { target = Main.npc[k]; foundTarget = true; maxDistance = (target.Center - projectile.Center).Length(); } } timer++; if (foundTarget) { dir = (target.Center - projectile.Center).ToRotation(); if (timer > 20) { int weaponDamage = projectile.damage; float weaponKnockback = projectile.knockBack; player.PickAmmo(QwertyMethods.MakeItemFromID(ItemID.WoodenBow), ref arrow, ref speedB, ref canShoot, ref weaponDamage, ref weaponKnockback, Main.rand.Next(2) == 0); if (Main.netMode != 1) { Projectile bul = Main.projectile[Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(dir) * BulVel, (float)Math.Sin(dir) * BulVel, arrow, weaponDamage, weaponKnockback, Main.myPlayer)]; bul.melee = true; bul.ranged = false; } timer = 0; } } maxDistance = 1000; foundTarget = false; }
public override bool OnTileCollide(Vector2 velocityChange) { Main.PlaySound(SoundID.Item38, projectile.Center); timer += 10; Player player = Main.player[projectile.owner]; int weaponDamage = projectile.damage; float weaponKnockback = projectile.knockBack; int bulletCount = 8 + (int)((((1 / player.meleeSpeed) - 1) * 100) / 10); float bulletSpacing = 2 * (float)Math.PI / bulletCount; //CombatText.NewText(player.getRect(), new Color(38, 126, 126), bulletCount, true, false); player.PickAmmo(QwertyMethods.MakeItemFromID(ItemID.FlintlockPistol), ref bullet, ref speedB, ref canShoot, ref weaponDamage, ref weaponKnockback, false); for (; bulletCount > 0; bulletCount--) { Projectile bul = Main.projectile[Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(dir) * BulVel, (float)Math.Sin(dir) * BulVel, bullet, weaponDamage, weaponKnockback, Main.myPlayer)]; bul.melee = true; bul.ranged = false; if (Main.netMode == 1) { QwertysRandomContent.UpdateProjectileClass(bul); } dir += bulletSpacing; } if (projectile.velocity.X != velocityChange.X) { projectile.velocity.X = -velocityChange.X; } if (projectile.velocity.Y != velocityChange.Y) { projectile.velocity.Y = -velocityChange.Y; } return(false); }
public override void AI() { if (runOnce) { projectile.rotation = projectile.velocity.ToRotation(); runOnce = false; } Player player = Main.player[projectile.owner]; shotCounter++; if (player.HeldItem.GetGlobalItem <ChromeGunToggle>().mode == 3) { projectile.timeLeft = 300; } else if (player.HeldItem.type != mod.ItemType("ChromeShotgunDefault")) { projectile.Kill(); } Vector2 spot = player.Center; if (QwertyMethods.ClosestNPC(ref target, 1000, projectile.Center, false, player.MinionAttackTargetNPC)) { spot = target.Center; } Vector2 Difference = (spot - projectile.Center); projectile.rotation = QwertyMethods.SlowRotation(projectile.rotation, Difference.ToRotation(), 5); if (Difference.Length() > 100) { projectile.velocity = Difference *= .02f; } else { projectile.velocity = Vector2.Zero; } for (int i = 0; i < 2; i++) { NPC gunTarget = new NPC(); if (QwertyMethods.ClosestNPC(ref gunTarget, 450, GunPositions[i], false, player.MinionAttackTargetNPC)) { GunRotations[i] = QwertyMethods.SlowRotation(GunRotations[i], (gunTarget.Center - GunPositions[i]).ToRotation() + (float)Math.PI / 2 * (i == 1 ? 1 : -1) - projectile.rotation, 6); if (shotCounter % 30 == i * 15) { int bullet = ProjectileID.Bullet; bool canShoot = true; float speedB = 14f; int weaponDamage = projectile.damage; float kb = projectile.knockBack; player.PickAmmo(QwertyMethods.MakeItemFromID(mod.ItemType("ChromeShotgunDefault")), ref bullet, ref speedB, ref canShoot, ref weaponDamage, ref kb, false); if (canShoot) { Projectile.NewProjectile(GunPositions[i], QwertyMethods.PolarVector(16, GunRotations[i] + projectile.rotation + (float)Math.PI / 2 * (i == 0 ? 1 : -1)), bullet, weaponDamage, kb, projectile.owner); } } } else { GunRotations[i] = QwertyMethods.SlowRotation(GunRotations[i], 0f, 6); } } GunPositions[0] = projectile.Center + QwertyMethods.PolarVector(13, projectile.rotation) + QwertyMethods.PolarVector(14, projectile.rotation + (float)Math.PI / 2); GunPositions[1] = projectile.Center + QwertyMethods.PolarVector(13, projectile.rotation) + QwertyMethods.PolarVector(14, projectile.rotation - (float)Math.PI / 2); }
public override void AI() { Player player = Main.player[projectile.owner]; if (runOnce) { reloadTime = player.inventory[player.selectedItem].useTime; runOnce = false; } projectile.timeLeft = 10; timer++; var modPlayer = player.GetModPlayer <QwertyPlayer>(); bool firing = player.channel && player.HasAmmo(QwertyMethods.MakeItemFromID(ItemID.FlintlockPistol), true) && !player.noItems && !player.CCed; int Ammo = 14; float speed = 14f; int weaponDamage = player.GetWeaponDamage(player.inventory[player.selectedItem]); direction = (Main.MouseWorld - player.Center).ToRotation(); float weaponKnockback = player.inventory[player.selectedItem].knockBack; if (firing) { ///////////////////////////////////// copied from vanilla drill/chainsaw AI Vector2 vector24 = Main.player[projectile.owner].RotatedRelativePoint(Main.player[projectile.owner].MountedCenter, true); if (Main.myPlayer == projectile.owner) { if (Main.player[projectile.owner].channel) { float num264 = Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].shootSpeed * projectile.scale; Vector2 vector25 = vector24; float num265 = (float)Main.mouseX + Main.screenPosition.X - vector25.X; float num266 = (float)Main.mouseY + Main.screenPosition.Y - vector25.Y; if (Main.player[projectile.owner].gravDir == -1f) { num266 = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector25.Y; } float num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266)); num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266)); num267 = num264 / num267; num265 *= num267; num266 *= num267; if (num265 != projectile.velocity.X || num266 != projectile.velocity.Y) { projectile.netUpdate = true; } projectile.velocity.X = num265; projectile.velocity.Y = num266; } else { projectile.Kill(); } } if (projectile.velocity.X > 0f) { Main.player[projectile.owner].ChangeDir(1); } else if (projectile.velocity.X < 0f) { Main.player[projectile.owner].ChangeDir(-1); } projectile.spriteDirection = projectile.direction; Main.player[projectile.owner].ChangeDir(projectile.direction); Main.player[projectile.owner].heldProj = projectile.whoAmI; Main.player[projectile.owner].itemTime = 2; Main.player[projectile.owner].itemAnimation = 2; projectile.position.X = vector24.X - (float)(projectile.width / 2); projectile.position.Y = vector24.Y - (float)(projectile.height / 2); projectile.rotation = (float)(Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.5700000524520874); if (Main.player[projectile.owner].direction == 1) { Main.player[projectile.owner].itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); } else { Main.player[projectile.owner].itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); } projectile.velocity.X = projectile.velocity.X * (1f + (float)Main.rand.Next(-3, 4) * 0.01f); if (Main.rand.Next(6) == 0) { int num268 = Dust.NewDust(projectile.position + projectile.velocity * (float)Main.rand.Next(6, 10) * 0.1f, projectile.width, projectile.height, 31, 0f, 0f, 80, default(Color), 1.4f); Dust dust51 = Main.dust[num268]; dust51.position.X = dust51.position.X - 4f; Main.dust[num268].noGravity = true; Dust dust3 = Main.dust[num268]; dust3.velocity *= 0.2f; Main.dust[num268].velocity.Y = -(float)Main.rand.Next(7, 13) * 0.15f; return; } /////////////////////////////// if (!player.HasBuff(mod.BuffType("TrexMountB"))) { player.velocity.X = 0; float VelYOld = player.velocity.Y; player.velocity.Y = (float)Math.Abs(VelYOld); } if (timer >= reloadTime) { VarA = direction + MathHelper.ToRadians(Main.rand.Next(-100, 101) / 10); VarB = direction + MathHelper.ToRadians(Main.rand.Next(-100, 101) / 10); VarC = direction + MathHelper.ToRadians(Main.rand.Next(-100, 101) / 10); VarD = direction + MathHelper.ToRadians(Main.rand.Next(-100, 101) / 10); VarE = direction + MathHelper.ToRadians(Main.rand.Next(-100, 101) / 10); float shellShift = MathHelper.ToRadians(-50); SVarA = shellShift + MathHelper.ToRadians(Main.rand.Next(-100, 301) / 10); SVarB = shellShift + MathHelper.ToRadians(Main.rand.Next(-100, 301) / 10); SVarC = shellShift + MathHelper.ToRadians(Main.rand.Next(-100, 301) / 10); SVarD = shellShift + MathHelper.ToRadians(Main.rand.Next(-100, 301) / 10); SVarE = shellShift + MathHelper.ToRadians(Main.rand.Next(-100, 301) / 10); float SspeedA = .05f * Main.rand.Next(15, 41); float SspeedB = .05f * Main.rand.Next(15, 41); float SspeedC = .05f * Main.rand.Next(15, 41); float SspeedD = .05f * Main.rand.Next(15, 41); float SspeedE = .05f * Main.rand.Next(15, 41); Main.PlaySound(SoundID.Item11, projectile.Center); Item sItem = QwertyMethods.MakeItemFromID(ItemID.FlintlockPistol); sItem.damage = weaponDamage; player.PickAmmo(sItem, ref Ammo, ref speed, ref firing, ref weaponDamage, ref weaponKnockback, Main.rand.Next(0, 2) == 0); if (player.whoAmI == Main.myPlayer) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(VarA) * speed, (float)Math.Sin(VarA) * speed, Ammo, weaponDamage, weaponKnockback, Main.myPlayer); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(SVarA) * SspeedA * -player.direction, (float)Math.Sin(SVarA) * SspeedA, mod.ProjectileType("Shell"), 0, 0, Main.myPlayer); if (reloadTime < 32) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(VarB) * speed, (float)Math.Sin(VarB) * speed, Ammo, weaponDamage, weaponKnockback, Main.myPlayer); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(SVarB) * SspeedB * -player.direction, (float)Math.Sin(SVarB) * SspeedB, mod.ProjectileType("Shell"), 0, 0, Main.myPlayer); } if (reloadTime < 28) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(VarC) * speed, (float)Math.Sin(VarC) * speed, Ammo, weaponDamage, weaponKnockback, Main.myPlayer); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(SVarC) * SspeedC * -player.direction, (float)Math.Sin(SVarC) * SspeedC, mod.ProjectileType("Shell"), 0, 0, Main.myPlayer); } if (reloadTime < 24) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(VarD) * speed, (float)Math.Sin(VarD) * speed, Ammo, weaponDamage, weaponKnockback, Main.myPlayer); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(SVarD) * SspeedD * -player.direction, (float)Math.Sin(SVarD) * SspeedD, mod.ProjectileType("Shell"), 0, 0, Main.myPlayer); } if (reloadTime < 20) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(VarE) * speed, (float)Math.Sin(VarE) * speed, Ammo, weaponDamage, weaponKnockback, Main.myPlayer); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(SVarE) * SspeedE * -player.direction, (float)Math.Sin(SVarE) * SspeedE, mod.ProjectileType("Shell"), 0, 0, Main.myPlayer); } } if (reloadTime > 3) { reloadTime -= 1; } timer = 0; } } else { modPlayer.usingVulcan = false; reloadTime = player.inventory[player.selectedItem].useTime; projectile.Kill(); } }