public override void AI() { if (++animationCounter >= 5) { animationCounter = 0; if (++frame >= Main.projFrames[_type]) { frame = 0; } } projectile.frameCounter = 0; projectile.frame = frame; var owner = Main.player[projectile.owner]; if (owner.active && owner.HasBuff(HarpyPetBuff._type)) { projectile.timeLeft = 2; } if (projectile.owner != Main.myPlayer) { return; } if (Timer > 0) { --Timer; return; } float direction; if (projectile.direction < 0) { direction = FOVHelper.POS_X_DIR + projectile.rotation; } else { direction = FOVHelper.NEG_X_DIR - projectile.rotation; } var origin = projectile.Center; var fov = new FOVHelper(); fov.adjustCone(origin, FOV, direction); float maxDistSquared = Max_Range * Max_Range; for (int i = 0; i < Main.maxNPCs; ++i) { NPC npc = Main.npc[i]; Vector2 npcPos = npc.Center; if (npc.CanBeChasedBy() && fov.isInCone(npcPos) && Vector2.DistanceSquared(origin, npcPos) < maxDistSquared && Collision.CanHitLine(origin, 0, 0, npc.position, npc.width, npc.height)) { ShootFeathersAt(npcPos); Timer = 140; break; } } }
public override void UpdateEffects(Player player) { PlayerHook modPlayer = player.GetModPlayer <PlayerHook>(mod); modPlayer.copterBrake = false; float tilt = player.fullRotation; if (player.wet || player.honeyWet || player.lavaWet) { player.mount.Dismount(player); return; } //Only keep flying, when the player is holding up if (player.controlUp || player.controlJump) { player.mount._abilityCharging = true; player.mount._flyTime = 0; player.mount._fatigue = -verticalSpeed; } else { player.mount._abilityCharging = false; } //Slow down the helicopter, if it's on the ground if (modPlayer.onGround) { if (player.controlUp || player.controlJump) { player.position.Y -= mountData.acceleration; } else { modPlayer.copterBrake = true; } } //tilt the helicopter tilt = player.velocity.X * (MathHelper.PiOver2 * 0.125f); tilt = (float)Math.Sin(tilt) * maxTilt; player.fullRotation = tilt; player.fullRotationOrigin = new Vector2(10f, 14f); //If you change this, also change the x and y values below. //Scan for enemies and fire at them if (player.mount._abilityCooldown == 0) { //Don't change these values, unless you want to adjust the nozzle position. float x = 20f * player.direction; float y = 12f; float sin = (float)Math.Sin(tilt); float cos = (float)Math.Cos(tilt); Vector2 muzzle = new Vector2(x * cos - y * sin, x * sin + y * cos); muzzle = muzzle + player.fullRotationOrigin + player.position; //Readjust the scanning cone to the current position. float direction; if (player.direction == 1) { direction = FOVHelper.POS_X_DIR + tilt; } else { direction = FOVHelper.NEG_X_DIR - tilt; } helper.adjustCone(muzzle, fov, direction); //Look for the nearest, unobscured enemy inside the cone NPC nearest = null; float distNearest = rangeSquare; for (int i = 0; i < 200; i++) { NPC npc = Main.npc[i]; Vector2 npcCenter = npc.Center; if (npc.CanBeChasedBy() && helper.isInCone(npcCenter)) //first param of canBeChasedBy has no effect { float distCurrent = Vector2.DistanceSquared(muzzle, npcCenter); if (distCurrent < distNearest && Collision.CanHitLine(muzzle, 0, 0, npc.position, npc.width, npc.height)) { nearest = npc; distNearest = distCurrent; } } } //Shoot 'em dead if (nearest != null) { if (player.whoAmI == Main.myPlayer) { Vector2 aim = nearest.Center - muzzle; aim.Normalize(); aim *= velocity; float vX = aim.X; float vY = aim.Y; //This precisely mimics the Gatligators spread Random rand = Main.rand; vX += rand.Next(-50, 51) * 0.03f; vY += rand.Next(-50, 51) * 0.03f; vX += rand.Next(-40, 41) * 0.05f; vY += rand.Next(-40, 41) * 0.05f; if (rand.Next(3) == 0) { vX += Main.rand.Next(-30, 31) * 0.02f; vY += Main.rand.Next(-30, 31) * 0.02f; } Projectile.NewProjectile(muzzle.X, muzzle.Y, vX, vY, mod.ProjectileType("CandyCopterBullet"), (int)(damage * player.minionDamage), knockback * player.minionKB, player.whoAmI); //CandyCopterBullet } Point point = player.Center.ToTileCoordinates(); Lighting.AddLight(point.X, point.Y, lightColor.X, lightColor.Y, lightColor.Z); modPlayer.copterFiring = true; modPlayer.copterFireFrame = 0; player.mount._abilityCooldown = cooldown - 1; } else { modPlayer.copterFiring = false; } return; } else if (player.mount._abilityCooldown > cooldown) { player.mount._abilityCooldown = cooldown; } }
public override void UpdateEffects(Player player) { MagicalPlayer modPlayer = player.GetModPlayer <MagicalPlayer>(); float tilt = player.fullRotation; player.blockRange += 5; player.resistCold = true; player.accDivingHelm = true; player.statDefense += 150; player.doubleJumpBlizzard = true; player.noFallDmg = true; player.iceSkate = true; player.pickSpeed -= 0.25f; player.buffImmune[BuffID.Slow] = true; player.buffImmune[BuffID.Frozen] = true; player.buffImmune[BuffID.Webbed] = true; player.buffImmune[BuffID.BrokenArmor] = true; player.buffImmune[BuffID.Poisoned] = true; if (Main.rand.Next(30) == 0) { Rectangle rect = player.getRect(); Dust.NewDust(new Vector2(rect.X, rect.Y), rect.Width, rect.Height, 135); } #region Santa Target and Fire //Scan for enemies and fire at them if (player.mount._abilityCooldown == 0) { //Don't change these values, unless you want to adjust the nozzle position. float x = 5f * player.direction;//20 and 12 float y = 5f; float sin = (float)Math.Sin(tilt); float cos = (float)Math.Cos(tilt); Vector2 muzzle = new Vector2(x * cos - y * sin, x * sin + y * cos); muzzle = muzzle + player.fullRotationOrigin + player.position; //Readjust the scanning cone to the current position. float direction; if (player.direction == 1) { direction = FOVHelper.POS_X_DIR + tilt; } else { direction = FOVHelper.NEG_X_DIR - tilt; } helper.adjustCone(muzzle, fov, direction); //Look for the nearest, unobscured enemy inside the cone NPC nearest = null; float distNearest = rangeSquare; for (int i = 0; i < 200; i++) { NPC npc = Main.npc[i]; Vector2 npcCenter = npc.Center; if (npc.CanBeChasedBy() && helper.isInCone(npcCenter)) //first param of canBeChasedBy has no effect { float distCurrent = Vector2.DistanceSquared(muzzle, npcCenter); if (distCurrent < distNearest && Collision.CanHitLine(muzzle, 0, 0, npc.position, npc.width, npc.height)) { nearest = npc; distNearest = distCurrent; } } } //Shoot 'em dead if (nearest != null) { if (player.whoAmI == Main.myPlayer) { Vector2 aim = nearest.Center - muzzle; aim.Normalize(); aim *= velocity; float vX = aim.X; float vY = aim.Y; //This precisely mimics the Gatligators spread //Random rand = Main.rand; commenting this out because I changed the rand lines here and waiting on more experienced help- Jenosis vX += Main.rand.Next(-20, 21) * 0.03f; vY += Main.rand.Next(-20, 21) * 0.03f; vX += Main.rand.Next(-10, 11) * 0.05f; vY += Main.rand.Next(-10, 11) * 0.05f; if (Main.rand.Next(3) == 0) { vX += Main.rand.Next(-15, 16) * 0.02f; vY += Main.rand.Next(-15, 16) * 0.02f; } Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 41); Projectile.NewProjectile(muzzle.X, muzzle.Y, vX, vY, ProjectileID.BulletHighVelocity, (int)(damage * player.minionDamage), knockback * player.minionKB, player.whoAmI); //CandyCopterBullet } Point point = player.Center.ToTileCoordinates(); Lighting.AddLight(point.X, point.Y, lightColor.X, lightColor.Y, lightColor.Z); modPlayer.SantaFiring = true; modPlayer.SantaFireFrame = 0; player.mount._abilityCooldown = cooldown - 1; } else { modPlayer.SantaFiring = false; } return; } else if (player.mount._abilityCooldown > cooldown) { player.mount._abilityCooldown = cooldown; } #endregion }