public override void KillMultiTile(int i, int j, int frameX, int frameY) { Item.NewItem(i * 16, j * 16, 48, 48, ModContent.ItemType <AquaticMonolith>()); CalValEXPlayer modPlayer = Main.LocalPlayer.GetModPlayer <CalValEXPlayer>(); modPlayer.leviMonolith = false; }
public override void KillMultiTile(int i, int j, int frameX, int frameY) { Item.NewItem(i * 16, j * 16, 32, 48, ModContent.ItemType<PlagueMonolith>()); CalValEXPlayer modPlayer = Main.LocalPlayer.GetModPlayer<CalValEXPlayer>(); modPlayer.pbgMonolith = false; pbgon = false; }
//you usualy don't have to use the lower two unless you want the pet to have an aura, glowmask //or if you want the pet to emit light public override void SafeAI(Player player) { CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.sDuke = false; } if (modPlayer.sDuke) { projectile.timeLeft = 2; } /* THIS CODE ONLY RUNS AFTER THE MAIN CODE RAN. * for custom behaviour, you can check if the projectile is walking or not via projectile.localAI[1] * you should make new custom behaviour with numbers higher than 0, or less than 0 * the next few lines is an example on how to implement this * * switch ((int)projectile.localAI[1]) * { * case -1: * break; * case 1: * break; * } * * 0 is already in use. * 0 = flying * * you can still use this, changing thing inside (however it's not recomended unless you want to add custom behaviour to this) */ }
public override void SafeAI(Player player) { CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.darksunSpirits = false; } if (modPlayer.darksunSpirits) { projectile.timeLeft = 2; } rotation += 0.1f; if (extraScale > 0.25f && !yep) { yep = true; } if (extraScale < -0.10f && yep) { yep = false; } if (!yep) { extraScale += 0.01f; } if (yep) { extraScale -= 0.01f; } }
public override void AI() { Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.ProviPet = false; } if (modPlayer.ProviPet) { projectile.timeLeft = 2; } Lighting.AddLight(projectile.position, new Vector3(1.61568627f, 0.901960784f, 0.462745098f)); Vector2 vectorToOwner = player.Center - projectile.Center; float distanceToOwner = vectorToOwner.Length(); if (distanceToOwner > 3000f) { projectile.position = player.Center; projectile.velocity *= 0.1f; projectile.netUpdate = true; } }
public override void AI() { Player player = Main.LocalPlayer; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); countdown++; if (projectile.frame != 1) { projectile.frame = 1; } projectile.rotation = 0; if (countdown == 660) { projectile.Kill(); } else if (countdown == 600) { player.AddBuff(BuffID.Obstructed, 60); } else if (countdown == 300) { player.AddBuff(BuffID.Blackout, 360); player.AddBuff(BuffID.Darkness, 360); } }
public override void SafeAI(Player player) { CalValEXPlayer modPlayer = player.GetModPlayer<CalValEXPlayer>(); if (player.dead) modPlayer.mSlime = false; if (modPlayer.mSlime) projectile.timeLeft = 2; }
public override void UpdateAccessory(Player player, bool hideVisual) { CalValEXPlayer p = player.GetModPlayer <CalValEXPlayer>(); p.signutTrans = true; if (hideVisual) { p.signutHide = true; } }
public override void SafeAI(Player player) { CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.darksunSpirits = false; } if (modPlayer.darksunSpirits) { projectile.timeLeft = 2; } }
public override void SafeAI(Player player) { CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.AstPhage = false; } if (modPlayer.AstPhage) { projectile.timeLeft = 2; } }
public override bool NewRightClick(int i, int j) { CalValEXPlayer modPlayer = Main.LocalPlayer.GetModPlayer<CalValEXPlayer>(); if ((modPlayer.scalMonolith && modPlayer.yharonMonolith) || (modPlayer.scalMonolith && modPlayer.dogMonolith) || (modPlayer.scalMonolith && modPlayer.provMonolith) || (modPlayer.scalMonolith && modPlayer.leviMonolith) || (modPlayer.leviMonolith && modPlayer.calMonolith) || (modPlayer.leviMonolith && modPlayer.provMonolith) || (modPlayer.leviMonolith && modPlayer.dogMonolith) || (modPlayer.leviMonolith && modPlayer.yharonMonolith) || (modPlayer.calMonolith && modPlayer.yharonMonolith) || (modPlayer.calMonolith && modPlayer.dogMonolith) || (modPlayer.calMonolith && modPlayer.provMonolith) || (modPlayer.dogMonolith && modPlayer.provMonolith) || (modPlayer.dogMonolith && modPlayer.yharonMonolith) || (modPlayer.yharonMonolith && modPlayer.provMonolith)) { return false; } else { Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); HitWire(i, j); return true; } //If one monolith is active and its off /*if (CalValEXWorld.OneMonolith && !CalValEXWorld.TwoMonolith && Main.tile[i, j].frameY < 56) { CalValEXWorld.TwoMonolith = true; Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); HitWire(i, j); return true; } //If no monoliths are actives and it's off else if (!CalValEXWorld.OneMonolith && !CalValEXWorld.TwoMonolith && Main.tile[i, j].frameY < 56) { CalValEXWorld.OneMonolith = true; Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); HitWire(i, j); return true; } //If two monoliths are active and its on else if (CalValEXWorld.TwoMonolith && Main.tile[i, j].frameY >= 56) { CalValEXWorld.TwoMonolith = false; Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); HitWire(i, j); return true; } //If one monolith is active and its on else if (CalValEXWorld.OneMonolith && !CalValEXWorld.TwoMonolith && Main.tile[i, j].frameY >= 56) { CalValEXWorld.OneMonolith = false; Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); HitWire(i, j); return true; } else { return false; }*/ }
public override void AI() { Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.BabyCnidrion = false; } if (modPlayer.BabyCnidrion) { projectile.timeLeft = 2; } }
public override void NearbyEffects(int i, int j, bool closer) { Mod clamMod = ModLoader.GetMod("CalamityMod"); CalValEXPlayer modPlayer = Main.LocalPlayer.GetModPlayer <CalValEXPlayer>(); if (Main.tile[i, j].frameY >= 56) { modPlayer.leviMonolith = true; } else { modPlayer.leviMonolith = false; } }
/*public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) * { * Tile tile = Main.tile[i, j]; * Texture2D texture; * if (Main.canDrawColorTile(i, j)) * { * texture = Main.tileAltTexture[Type, (int)tile.color()]; * } * else * { * texture = Main.tileTexture[Type]; * } * Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); * if (Main.drawToScreen) * { * zero = Vector2.Zero; * } * int height = tile.frameY % animationFrameHeight == 36 ? 18 : 16; * int animate = 0; * if (tile.frameY >= 54) * { * animate = Main.tileFrame[Type] * animationFrameHeight; * } * Main.spriteBatch.Draw(texture, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.frameX, tile.frameY + animate, 16, height), Lighting.GetColor(i, j), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); * return false; * }*/ public override bool NewRightClick(int i, int j) { CalValEXPlayer modPlayer = Main.LocalPlayer.GetModPlayer <CalValEXPlayer>(); // if ((modPlayer.scalMonolith && modPlayer.yharonMonolith) || (modPlayer.scalMonolith && modPlayer.dogMonolith) || (modPlayer.scalMonolith && modPlayer.pbgMonolith) || (modPlayer.scalMonolith && modPlayer.leviMonolith) || (modPlayer.leviMonolith && modPlayer.calMonolith) || (modPlayer.leviMonolith && modPlayer.pbgMonolith) || (modPlayer.leviMonolith && modPlayer.dogMonolith) || (modPlayer.leviMonolith && modPlayer.yharonMonolith) || (modPlayer.calMonolith && modPlayer.yharonMonolith) || (modPlayer.calMonolith && modPlayer.dogMonolith) || (modPlayer.calMonolith && modPlayer.pbgMonolith) || (modPlayer.dogMonolith && modPlayer.pbgMonolith) || (modPlayer.dogMonolith && modPlayer.yharonMonolith) || (modPlayer.yharonMonolith && modPlayer.pbgMonolith)) { return(false); } else { Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); HitWire(i, j); return(true); } /*if (CalValEXWorld.OneMonolith && !CalValEXWorld.TwoMonolith && Main.tile[i, j].frameY < 56) * { * CalValEXWorld.TwoMonolith = true; * Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); * HitWire(i, j); * return true; * } * if (!CalValEXWorld.OneMonolith && !CalValEXWorld.TwoMonolith && Main.tile[i, j].frameY < 56) * { * CalValEXWorld.OneMonolith = true; * Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); * HitWire(i, j); * return true; * } * if (CalValEXWorld.TwoMonolith && Main.tile[i, j].frameY >= 56) * { * CalValEXWorld.TwoMonolith = false; * Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); * HitWire(i, j); * return true; * } * if (CalValEXWorld.OneMonolith && !CalValEXWorld.TwoMonolith && Main.tile[i, j].frameY >= 56) * { * CalValEXWorld.OneMonolith = false; * Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); * HitWire(i, j); * return true; * } * else * { * return false; * }*/ }
public override bool NewRightClick(int i, int j) { CalValEXPlayer modPlayer = Main.LocalPlayer.GetModPlayer <CalValEXPlayer>(); if ((modPlayer.scalMonolith && modPlayer.provMonolith) || (modPlayer.scalMonolith && modPlayer.yharonMonolith) || (modPlayer.scalMonolith && modPlayer.pbgMonolith) || (modPlayer.scalMonolith && modPlayer.dogMonolith) || (modPlayer.dogMonolith && modPlayer.calMonolith) || (modPlayer.dogMonolith && modPlayer.pbgMonolith) || (modPlayer.dogMonolith && modPlayer.yharonMonolith) || (modPlayer.dogMonolith && modPlayer.provMonolith) || (modPlayer.calMonolith && modPlayer.provMonolith) || (modPlayer.calMonolith && modPlayer.yharonMonolith) || (modPlayer.calMonolith && modPlayer.pbgMonolith) || (modPlayer.yharonMonolith && modPlayer.pbgMonolith) || (modPlayer.yharonMonolith && modPlayer.provMonolith) || (modPlayer.provMonolith && modPlayer.pbgMonolith)) { return(false); } else { Main.PlaySound(SoundID.Mech, i * 16, j * 16, 0); HitWire(i, j); return(true); } }
public override void AI() { Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { projectile.timeLeft = 0; } if (!modPlayer.vanityhote) { projectile.timeLeft = 0; } if (modPlayer.vanityhote) { projectile.timeLeft = 2; } Vector2 vectorToOwner = player.Center; vectorToOwner.Y -= 160f; vectorToOwner.X -= 40f; float value = 8f; float velY = MathHelper.Clamp(player.velocity.Y, -value, value); float velX = MathHelper.Clamp(player.velocity.X, -value, value); vectorToOwner.X += 0.5f * -velX; vectorToOwner.Y += 0.5f * -velY; projectile.Center = vectorToOwner; projectile.frameCounter++; if (projectile.frameCounter > 8) { projectile.frame++; projectile.frameCounter = 0; } if (projectile.frame >= 6) { projectile.frame = 0; } }
public override void AI() { Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.Enredpet = false; } if (modPlayer.Enredpet) { projectile.timeLeft = 2; } Vector2 vectorToOwner = player.Center; vectorToOwner.Y -= 64f; float value = 8f; float velY = MathHelper.Clamp(player.velocity.Y, -value, value); float velX = MathHelper.Clamp(player.velocity.X, -value, value); vectorToOwner.X += 0.5f * -velX; vectorToOwner.Y += 0.5f * -velY; projectile.Center = vectorToOwner; projectile.frameCounter++; if (projectile.frameCounter > 5) { frame++; projectile.frameCounter = 0; if (frame > 5) { frame = 0; } } Lighting.AddLight(projectile.Center, new Vector3(1.2f, 0.65882353f, 1.38039216f)); }
public override void AI() { Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.SupJ = false; } if (modPlayer.SupJ) { projectile.timeLeft = 2; } Vector2 idlePosition = player.Center; idlePosition.Y -= projectile.height / 2; idlePosition.X -= projectile.width / 2; projectile.position = idlePosition; projectile.spriteDirection = 1; projectile.frameCounter++; if (projectile.frameCounter > 22) { projectile.frame++; projectile.frameCounter = 0; } if (projectile.frame == 3) { projectile.frame = 0; } Mod calamityMod = ModLoader.GetMod("CalamityMod"); if (calamityMod != null) { calamityMod.Call("AddAbyssLightStrength", projectile.owner, 2); } }
public override void AI() { Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.pylon = false; } if (modPlayer.pylon) { projectile.timeLeft = 2; } Vector2 vectorToOwner = player.Center; vectorToOwner.Y -= 56f; float value = 8f; float velY = MathHelper.Clamp(player.velocity.Y, -value, value); float velX = MathHelper.Clamp(player.velocity.X, -value, value); vectorToOwner.X += 0.5f * -velX; vectorToOwner.Y += 0.5f * -velY; projectile.Center = vectorToOwner; if (projectile.frameCounter++ % 8 == 7) { projectile.frame++; } if (projectile.frame >= 7) { projectile.frame = 0; } Lighting.AddLight(projectile.Center, new Vector3(0.2f, 0.35882353f, 0.58039216f)); }
public override void AI() { Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.Lightshield = false; } if (modPlayer.Lightshield) { projectile.timeLeft = 2; } Vector2 idlePosition = player.Center; idlePosition.Y -= projectile.height / 2; idlePosition.X -= projectile.width / 2; projectile.position = idlePosition; projectile.spriteDirection = 1; projectile.rotation += -0.75f; if (projectile.rotation > MathHelper.TwoPi) { projectile.rotation -= MathHelper.TwoPi; } else if (projectile.rotation < 0) { projectile.rotation += MathHelper.TwoPi; } Mod calamityMod = ModLoader.GetMod("CalamityMod"); if (calamityMod != null) { calamityMod.Call("AddAbyssLightStrength", projectile.owner, 2); } }
public override void NearbyEffects(int i, int j, bool closer) { Mod clamMod = ModLoader.GetMod("CalamityMod"); CalValEXPlayer modPlayer = Main.LocalPlayer.GetModPlayer <CalValEXPlayer>(); if (Main.tile[i, j].frameY >= 56) { if ((bool)clamMod.Call("GetBossDowned", "supremecalamitas")) { modPlayer.scalMonolith = true; modPlayer.calMonolith = false; } else { modPlayer.calMonolith = true; } } else { modPlayer.calMonolith = false; modPlayer.scalMonolith = false; } }
public override void SafeAI(Player player) { CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.mChan = false; } if (modPlayer.mChan) { projectile.timeLeft = 2; } if ((bool)calamityMod.Call("DifficultyActive", "armageddon") && (bool)calamityMod.Call("DifficultyActive", "death") && (bool)calamityMod.Call("DifficultyActive", "ironheart")) { if (projectile.frameCounter++ > 8) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame >= 8) { projectile.frame = 4; } } } else if (!((bool)calamityMod.Call("DifficultyActive", "armageddon") && (bool)calamityMod.Call("DifficultyActive", "death") && (bool)calamityMod.Call("DifficultyActive", "ironheart"))) { if (projectile.frameCounter++ % 8 == 7) { projectile.frame++; } if (projectile.frame >= 4) { projectile.frame = 0; } } }
//you usualy don't have to use the lower two unless you want the pet to have an aura, glowmask //or if you want the pet to emit light public override void SafeAI(Player player) { CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.drone = false; } if (modPlayer.drone) { projectile.timeLeft = 2; } if (player.HasBuff(ModContent.BuffType <PylonBuff>())) { if (projectile.frameCounter++ > 8) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame >= 8) { projectile.frame = 4; } } } else if (!player.HasBuff(ModContent.BuffType <PylonBuff>())) { if (projectile.frameCounter++ % 8 == 7) { projectile.frame++; } if (projectile.frame >= 4) { projectile.frame = 0; } } }
public override void AI() { // Consistently update the worm if ((int)Main.time % 120 == 0) { projectile.netUpdate = true; } if (projectile.ai[1] == 1f) { projectile.ai[1] = 0f; projectile.netUpdate = true; } float segmentAheadRotation; // This, and Size will likely need to be changed based on the sprite size of the segment float travelFactor = 15f; Vector2 segmentAheadCenter; int segmentAhead = (int)projectile.ai[0]; // Verify the projectile we specified as the segment ahead is a part of this worm, and exists if (segmentAhead >= 0 && Main.projectile[segmentAhead].active && (Main.projectile[segmentAhead].type == ModContent.ProjectileType <MoistScourgeBody>()) || Main.projectile[segmentAhead].type == ModContent.ProjectileType <MoistScourgeHead>()) { segmentAheadCenter = Main.projectile[segmentAhead].Center; segmentAheadRotation = Main.projectile[segmentAhead].rotation; Main.projectile[segmentAhead].localAI[0] = projectile.localAI[0] + 1f; } // Otherwise, kill the segment and ignore the rest of the code else { projectile.Kill(); return; } projectile.velocity = Vector2.Zero; Vector2 vectorToAhead = segmentAheadCenter - projectile.Center; if (segmentAheadRotation != projectile.rotation) { // Fix the angle between -pi and pi (wraps back over if one of the bounds are reached) float deltaAngle = MathHelper.WrapAngle(segmentAheadRotation - projectile.rotation); vectorToAhead = vectorToAhead.RotatedBy(deltaAngle * 0.1f); } projectile.rotation = vectorToAhead.ToRotation() + MathHelper.PiOver2; projectile.position = projectile.Center; // If scale is not 1, adjust the width and height based on that too projectile.width = projectile.height = Size; projectile.Center = projectile.position; // Adjust the position of this segment relative to the one ahead if (vectorToAhead != Vector2.Zero) { projectile.Center = segmentAheadCenter - Vector2.Normalize(vectorToAhead) * travelFactor; } projectile.spriteDirection = (vectorToAhead.X > 0f).ToDirectionInt(); Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (modPlayer.moistPet) { projectile.timeLeft = 2; } }
public override void AI() { if (!SpawnedSegments) { int tail = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType <MoistScourgeTail>(), projectile.damage, projectile.knockBack, 0, projectile.whoAmI); // The minus one is because this segment and the tail are incorporated in the worm as well for (int i = 0; i < SegmentCount - 2; i++) { float uuid = (float)Projectile.GetByUUID(Main.myPlayer, Main.projectile[tail].ai[0]); int body = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType <MoistScourgeBody>(), projectile.damage, projectile.knockBack, 0, uuid); int back = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType <MoistScourgeBody>(), projectile.damage, projectile.knockBack, 0, (float)body); Main.projectile[body].ai[1] = 1f; Main.projectile[body].netUpdate = true; Main.projectile[body].identity = projectile.whoAmI; Main.projectile[back].netUpdate = true; Main.projectile[back].ai[1] = 1f; Main.projectile[body].identity = projectile.whoAmI; Main.projectile[tail].ai[0] = Main.projectile[body].projUUID; Main.projectile[tail].netUpdate = true; Main.projectile[tail].ai[1] = 1f; } SpawnedSegments = true; } // Consistently update the worm if ((int)Main.time % 120 == 0) { projectile.netUpdate = true; } // Custom AI here Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.moistPet = false; } if (modPlayer.moistPet) { projectile.timeLeft = 2; } Vector2 PlayerCenter = player.Center; float MinVel = 0.36f; Vector2 ProjDistance = PlayerCenter - projectile.Center; if (ProjDistance.Length() < 100f) { MinVel = 0.22f; } if (ProjDistance.Length() < 80f) { MinVel = 0.1f; } if (ProjDistance.Length() > 50f) { if (Math.Abs(PlayerCenter.X - projectile.Center.X) > 10f) { projectile.velocity.X = projectile.velocity.X + MinVel * (float)Math.Sign(PlayerCenter.X - projectile.Center.X); } if (Math.Abs(PlayerCenter.Y - projectile.Center.Y) > 5f) { projectile.velocity.Y = projectile.velocity.Y + MinVel * (float)Math.Sign(PlayerCenter.Y - projectile.Center.Y); } } else if (projectile.velocity.Length() > 1.6f) { projectile.velocity *= 0.96f; } float MaxVel = 15f; if (ProjDistance.Length() > 800f) { MaxVel = 25; } else if (ProjDistance.Length() > 500f) { MaxVel = 22f; } else if (ProjDistance.Length() > 300f) { MaxVel = 18.5f; } else { MaxVel = 15; } if (projectile.velocity.Length() > MaxVel) { projectile.velocity = Vector2.Normalize(projectile.velocity) * MaxVel; } if (ProjDistance.Length() > 2000f) { projectile.Center = PlayerCenter; } if (Math.Abs(projectile.velocity.Y) < 1f) { projectile.velocity.Y = projectile.velocity.Y - 0.1f; } // NOTE: If you wish for this worm to travel at very high speeds, the // Body and tail segments will gain gaps. You would have to change the position adjusting // In the body and tail's code to mitigate this problem. projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; int oldDirection = projectile.direction; projectile.direction = projectile.spriteDirection = (projectile.velocity.X > 0f).ToDirectionInt(); // Update the projectile in multiplayer if the determined direction is not the true direction. // It will do weird things in multiplayer because of a lack of syncing among the directions if (oldDirection != projectile.direction) { projectile.netUpdate = true; } projectile.position = projectile.Center; projectile.width = projectile.height = Size; projectile.Center = projectile.position; }
/// <param name="time">Time in seconds</param> private void MorshuConsumeCoinAI(Player player, int time) { CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (++modPlayer.morshuTimer >= time * 60) { modPlayer.morshuTimer = 0; bool consumed = false; for (int i = 50; i < 53; i++) { if (player.inventory[i].type == ItemID.CopperCoin) //there are copper coins in the inventory. great! { player.inventory[i].stack -= 1; if (player.inventory[i].stack == 0) { player.inventory[i].SetDefaults(ItemID.None); } consumed = true; break; } } #region silver if (!consumed) { bool placedDownCopper = false; for (int i = 50; i < 53; i++) { if (player.inventory[i].type == ItemID.SilverCoin) { player.inventory[i].stack -= 1; if (player.inventory[i].stack == 0) { player.inventory[i].SetDefaults(ItemID.None); } if (player.inventory[i].type == ItemID.None) //easy solution, its already empty. { player.inventory[i].SetDefaults(ItemID.CopperCoin); player.inventory[i].stack = 99; placedDownCopper = true; break; } consumed = true; } } if (consumed) { if (!placedDownCopper) { PlaceCoinsDown(player, 99, ItemID.CopperCoin, ref placedDownCopper); } } } #endregion #region gold if (!consumed) { bool placedDownSilver = false; bool placedDownCopper = false; for (int i = 50; i < 53; i++) { if (player.inventory[i].type == ItemID.GoldCoin) { player.inventory[i].stack -= 1; if (player.inventory[i].stack == 0) { player.inventory[i].SetDefaults(ItemID.None); } if (player.inventory[i].type == ItemID.None) { player.inventory[i].SetDefaults(ItemID.SilverCoin); player.inventory[i].stack = 99; placedDownSilver = true; } consumed = true; break; } } if (!placedDownSilver && consumed) { PlaceCoinsDown(player, 99, ItemID.SilverCoin, ref placedDownSilver); } if (!placedDownCopper && consumed) { PlaceCoinsDown(player, 99, ItemID.CopperCoin, ref placedDownCopper); } } #endregion #region platinum if (!consumed) { bool placedDownGold = false; bool placedDownSilver = false; bool placedDownCopper = false; for (int i = 50; i < 53; i++) { if (player.inventory[i].type == ItemID.PlatinumCoin) { player.inventory[i].stack -= 1; if (player.inventory[i].stack == 0) { player.inventory[i].SetDefaults(ItemID.None); } if (player.inventory[i].type == ItemID.None) { player.inventory[i].SetDefaults(ItemID.GoldCoin); player.inventory[i].stack = 99; placedDownGold = true; } consumed = true; break; } } if (!placedDownGold && consumed) { PlaceCoinsDown(player, 99, ItemID.GoldCoin, ref placedDownGold); } if (!placedDownSilver && consumed) { PlaceCoinsDown(player, 99, ItemID.SilverCoin, ref placedDownSilver); } if (!placedDownCopper && consumed) { PlaceCoinsDown(player, 99, ItemID.CopperCoin, ref placedDownCopper); } } #endregion //if no coin consumed, make the player slower. mountData.runSpeed = 8f; mountData.dashSpeed = 8f; mountData.acceleration = 0.35f; mountData.jumpHeight = 18; mountData.jumpSpeed = 8.25f; if (!consumed) { mountData.runSpeed = 2f; mountData.dashSpeed = 2f; mountData.acceleration = 0.05f; mountData.jumpHeight = 4; mountData.jumpSpeed = 8.25f; } } }
public override void SafeAI(Player player) { CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.mClam = false; } if (modPlayer.mClam) { projectile.timeLeft = 2; } Vector2 vectorToOwner = player.Center - projectile.Center; float distanceToOwner = vectorToOwner.Length(); switch ((int)projectile.localAI[1]) { case -1: //jaming if (distanceToOwner > distance[2]) { projectile.localAI[1] = 1; ResetMe(); } projectile.frameCounter++; if (projectile.frameCounter > 10) { projectile.frame++; projectile.frameCounter = 0; if (projectile.frame < 11 || projectile.frame > 14) { projectile.frame = 11; } } break; case 0: if (projectile.ai[0]++ > 240) { projectile.localAI[1] = -1; ResetMe(); } break; case 1: if (jumpCounter > 0) { jumpCounter--; } if (jumpFrameLimits[0] != -1 && jumpFrameLimits[1] != -1) { if (jumpCounter > 0) { if (projectile.frameCounter >= animationSpeed[3]) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame >= jumpFrameLimits[1]) { projectile.frame = jumpFrameLimits[1] - 1; } } } } break; } /* THIS CODE ONLY RUNS AFTER THE MAIN CODE RAN. * for custom behaviour, you can check if the projectile is walking or not via projectile.localAI[1] * you should make new custom behaviour with numbers higher than 2, or less than 0 * the next few lines is an example on how to implement this * * switch ((int)projectile.localAI[1]) * { * case -1: * break; * case 3: * break; * } * * 0, 1 and 2 are already in use. * 0 = idling * 1 = walking * 2 = flying * * you can still use these, changing thing inside (however it's not recomended unless you want to add custom behaviour to these) */ }
public override void SafeAI(Player player) { CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.CalamityBABYBool = false; } if (modPlayer.CalamityBABYBool) { projectile.timeLeft = 2; } Vector2 vectorToOwner = player.Center - projectile.Center; float distanceToOwner = vectorToOwner.Length(); myRotation[0] += 0.025f; myRotation[1] -= 0.025f; switch (projectile.localAI[1]) { case -1: //TRANSITION projectile.tileCollide = false; projectile.rotation = 0; if (scale < 2f) { scale += 0.002f; } projectile.velocity *= 0.93f; if (projectile.frameCounter++ > 5) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame < 13 || projectile.frame > 14) { projectile.frame = 13; } } projectile.ai[0]++; int timeBetweenTexts = 120; if (projectile.ai[0] == timeBetweenTexts) { EdgyTalk("Congratulations, I see you are unworthy...", Color.White, true); } if (projectile.ai[0] == timeBetweenTexts * 2) { EdgyTalk("If you only summoned Astrageldon I could spare you, but well", Color.White, true); } if (projectile.ai[0] == timeBetweenTexts * 3) { EdgyTalk("GL surviving my power", Color.White, true); } if (projectile.ai[0] == timeBetweenTexts * 4) { EdgyTalk("Next time call my friend if you want me to be your pet... or don't get hit.", Color.White, true); } if (projectile.ai[0] == timeBetweenTexts * 5) { Mod calamityMod = ModLoader.GetMod("CalamityMod"); for (int i = 0; i < bossList.Count; i++) { NPC.NewNPC((int)projectile.position.X, (int)projectile.position.Y, calamityMod.NPCType(bossList[i])); } } if (projectile.ai[0] == (timeBetweenTexts * 5) + 30) { projectile.ai[0] = 0; projectile.localAI[1] = 0; for (int i = 0; i < Main.maxPlayers; i++) { Player myPlayer = Main.player[i]; if (myPlayer.active) { myPlayer.GetModPlayer <CalValEXPlayer>().CalamityBabyGotHit = false; } } MyDudeJustGotHitLikeTheIdiotItIs = false; projectile.netUpdate = true; } break; case 0: projectile.tileCollide = false; projectile.rotation = projectile.velocity.X * 0.025f; scale = 0.25f; Vector2 offset = new Vector2(offSetX, offSetY); vectorToOwner += offset; distanceToOwner = vectorToOwner.Length(); if (Math.Abs(player.velocity.X) < 0.05 && Math.Abs(player.velocity.Y) < 0.05) { if (++projectile.ai[0] >= 210 && distanceToOwner < 50f) { projectile.localAI[1] = 1; projectile.ai[0] = 0; } } else { projectile.ai[0] = 0; } if (projectile.frameCounter++ > 15) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame > 3) { projectile.frame = 0; } } break; case 1: //laying down projectile.tileCollide = true; projectile.velocity *= 0.98f; projectile.velocity.Y += 0.1f; projectile.rotation = 0; scale = 0.25f; if (distanceToOwner > 320f) { if (++projectile.ai[0] >= 210) { projectile.localAI[1] = 0; projectile.ai[0] = 0; } } else { projectile.ai[0] = 0; } if (projectile.frameCounter++ > 15) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame < 4 || projectile.frame > 11) { projectile.frame = 4; } } break; } }
private int jumpCounter = 0; //this will determine how long the jump frame should happen public override void AI() { //this can also be a only flying pet, go below and search for the bool onlyFlying. Player owner = Main.player[projectile.owner]; if (!owner.active) { projectile.active = false; return; } { Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); if (player.dead) { modPlayer.eb = false; } if (modPlayer.eb) { projectile.timeLeft = 2; } } //this is heavely uneeded. you could just replace all these values with proper values inside the code, however //for simplicity sake, i put them like this for you to easely manipulate each thing without needing to go into the code. bool onlyFlying = false; //should the pet only fly? float[] speed = new float[2]; //speed of the pet speed[0] = 22f; //walking speed speed[1] = 10f; //flight speed float[] inertia = new float[2]; //makes it so that the pet is 'innacurate' with how it moves (i myself dont know what it does, just does a thing that it should) inertia[0] = 20f; //walking inertia inertia[1] = 80f; //flight inertia float[] jumpSpeed = new float[5]; //how high the pet should jump in each case. put negative in here so that it jumps up jumpSpeed[0] = -4f; //1 tile above pet jumpSpeed[1] = -6f; //2 tiles above pet jumpSpeed[2] = -8f; //5 tiles above pet jumpSpeed[3] = -7f; //4 tiles above pet jumpSpeed[4] = -6.5f; //any other tile number above pet //-------------------------------------------------------------------------------- //-1 should only be put when there is no existent min/max frame for something. if there is only one frame, do this instead: //idleFrameLimits[0] = idleFrameLimits[1] = frame number; int[] idleFrameLimits = new int[2]; idleFrameLimits[0] = 0; idleFrameLimits[1] = 1; int[] walkingFrameLimits = new int[2]; walkingFrameLimits[0] = 0; //what your min walking frame is (start of walking animation) walkingFrameLimits[1] = 3; //what your max walking frame is (end of walking animation) int[] flyingFrameLimits = new int[2]; flyingFrameLimits[0] = 4; flyingFrameLimits[1] = 6; //what your min flying frame is (start of flying animation) int[] jumpFrameLimits = new int[2]; jumpFrameLimits[0] = -1; //what your min jump frame is (start of jump animation) jumpFrameLimits[1] = -1; //what your max jump frame is (end of jump animation //-------------------------------------------------------------------------------- float[] animationSpeed = new float[4]; //how fast the animation should play animationSpeed[0] = 10; //idle animation speed animationSpeed[1] = 5; //walking animation speed animationSpeed[2] = 5; //flying animation speed animationSpeed[3] = -1; //jumping animation speed int jumpAnimationLength = -1; //how long the jump animation should stay //-------------------------------------------------------------------------------- //each tile is 16f, multiply it by how much you want till the pet does something float[] distance = new float[6]; distance[0] = 1840f; //teleport distance[1] = 560f; //speed increase distance[2] = 320f; //when to walk distance[3] = 80f; //when to stop walking distance[4] = 360f; //when to fly distance[5] = 240f; //when to stop flying //-------------------------------------------------------------------------------- float gravity = 0.1f; //needs to be positive for the pet to be pushed down platforms plus for it to have gravity float[] drag = new float[2]; //friction on ground, for it to stop moving/sliding. these should always be between 1f and 0.80f. drag[0] = 0.92f; //idle drag drag[1] = 0.95f; //walking drag //how do you know what speed is right? you just have to test out different values. same for inertia //-------------------------------------------------------------------------------- //flying offset, so that it flys behind and a little above the player float offsetX = 48 * -owner.direction; Vector2 offset = new Vector2(offsetX, -50f); //-------------------------------------------------------------------------------- Vector2 vectorToOwner = owner.Center - projectile.Center; float distanceToOwner = vectorToOwner.Length(); //here we make the projectile image flip depending what their velocity is. //this depends where the sprite is facing initialy (on the sprite). //if the sprite is directed towards the right (facing right on the sprite), it should be this: projectile.spriteDirection = projectile.velocity.X > 0 ? 1 : -1; //however, if the sprite is directed towards the left (facing left on the sprite), it should be the example below (uncomment the below and comment the above if that is the case): //projectile.spriteDirection = projectile.velocity.X > 0 ? -1 : 1; //this teleports the pet to the player if (distanceToOwner > distance[0]) //when to teleport { projectile.position = owner.Center; projectile.velocity *= 0.1f; projectile.netUpdate = true; } //makes the pet faster when too far away if (distanceToOwner > distance[1]) //when 35 tiles away { //you can also just apply a new thing via speed[0] = numberf, for example speed[0] *= 1.25f; speed[1] /= 1.25f; inertia[0] *= 1.25f; inertia[1] /= 1.25f; } if (onlyFlying) { projectile.localAI[1] = 2; } switch ((int)projectile.localAI[1]) { case 0: //idling projectile.tileCollide = true; projectile.velocity.X *= drag[0]; //drag //check if player is away for a certain amount of tiles if (distanceToOwner > distance[2]) //20 tiles { ResetMe(); projectile.localAI[1] = 1; //start walking } //gravity projectile.velocity.Y += gravity; //animation projectile.frameCounter++; if (projectile.frameCounter >= animationSpeed[0]) //each frame in the game is a tick. change 15 to how fast you want it to change sprites { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame < idleFrameLimits[0] || projectile.frame > idleFrameLimits[1]) { projectile.frame = idleFrameLimits[0]; } } projectile.rotation = 0; break; case 1: //walking projectile.tileCollide = true; projectile.velocity.X *= drag[1]; //drag //check if the owner is nearby, if so, go back to idling if (distanceToOwner < distance[3]) { ResetMe(); projectile.localAI[1] = 0; } //check if the owner is far away, if so, go to flying if (distanceToOwner > distance[4]) { ResetMe(); projectile.localAI[1] = 2; } //gravity projectile.velocity.Y += gravity; //this is for tile detection int i = (int)(projectile.position.X + (float)(projectile.width / 2)) / 16; int j = (int)(projectile.position.Y + (float)(projectile.height / 2)) / 16; if (projectile.velocity.X <= 0.1 && projectile.velocity.X >= -0.1) { i += projectile.direction; } else { i += (int)projectile.velocity.X; } //this is for jumping if (jumpCounter > -1) { jumpCounter--; } if (WorldGen.SolidTile(i, j)) { int i2 = (int)(projectile.position.X + (float)(projectile.width / 2)) / 16; int j2 = (int)(projectile.position.Y + (float)projectile.height) / 16 + 1; if (WorldGen.SolidTile(i2, j2) || Main.tile[i2, j2].halfBrick() || Main.tile[i2, j2].slope() > 0) { try { i2 = (int)(projectile.position.X + (float)(projectile.width / 2)) / 16; j2 = (int)(projectile.position.Y + (float)(projectile.height / 2)) / 16; int num = projectile.velocity.X < 0f ? 1 : -1; i2 += num; i2 += (int)projectile.velocity.X; if (!WorldGen.SolidTile(i2, j2 - 1) && !WorldGen.SolidTile(i2, j2 - 2)) { projectile.velocity.Y = jumpSpeed[0]; jumpCounter = jumpAnimationLength; } else if (!WorldGen.SolidTile(i2, j2 - 2)) { projectile.velocity.Y = jumpSpeed[1]; jumpCounter = jumpAnimationLength; } else if (WorldGen.SolidTile(i2, j2 - 5)) { projectile.velocity.Y = jumpSpeed[2]; jumpCounter = jumpAnimationLength; } else if (WorldGen.SolidTile(i2, j2 - 4)) { projectile.velocity.Y = jumpSpeed[3]; jumpCounter = jumpAnimationLength; } else { projectile.velocity.Y = jumpSpeed[4]; jumpCounter = 15; } } catch { projectile.velocity.Y = jumpSpeed[4]; } } } //this is for moving vectorToOwner.Normalize(); vectorToOwner *= speed[0]; projectile.velocity.X = (projectile.velocity.X * (inertia[0] - 1) + vectorToOwner.X) / inertia[0]; //animation projectile.frameCounter++; if (projectile.frameCounter >= animationSpeed[1]) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame < walkingFrameLimits[0] || projectile.frame > walkingFrameLimits[1]) { projectile.frame = walkingFrameLimits[0]; } } //jump animation if (jumpFrameLimits[0] != -1 && jumpFrameLimits[1] != -1) { if (jumpCounter > 0) { if (projectile.frameCounter >= animationSpeed[3]) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame < jumpFrameLimits[0] || projectile.frame > jumpFrameLimits[1]) { projectile.frame = jumpFrameLimits[0]; } } } } projectile.rotation = 0; break; case 2: //flying projectile.tileCollide = false; if (distanceToOwner < distance[5] && !onlyFlying) { projectile.localAI[1] = 1; ResetMe(); } vectorToOwner += offset; distanceToOwner = vectorToOwner.Length(); //movement if (distanceToOwner > 20f) { vectorToOwner.Normalize(); vectorToOwner *= speed[1]; projectile.velocity = (projectile.velocity * (inertia[1] - 1) + vectorToOwner) / inertia[1]; } else if (projectile.velocity == Vector2.Zero) { //boop it so it moves projectile.velocity.X = -0.15f; projectile.velocity.Y = -0.15f; } //animation projectile.frameCounter++; if (projectile.frameCounter >= animationSpeed[2]) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame < flyingFrameLimits[0] || projectile.frame > flyingFrameLimits[1]) { projectile.frame = flyingFrameLimits[0]; } } projectile.rotation = projectile.velocity.X * 0.1f; //so that it turns towards where its flying break; } }
public override void AI() { // Custom AI here Player player = Main.player[projectile.owner]; CalValEXPlayer modPlayer = player.GetModPlayer <CalValEXPlayer>(); CalamityPlayer calPlayer = player.GetModPlayer <CalamityPlayer>(); if (player.dead) { modPlayer.goozmaPet = false; } if (modPlayer.goozmaPet) { projectile.timeLeft = 2; } Vector2 PlayerCenter = player.Center; float MinVel = 0.36f; Vector2 ProjDistance = PlayerCenter - projectile.Center; if (ProjDistance.Length() < 100f) { MinVel = 0.22f; } if (ProjDistance.Length() < 80f) { MinVel = 0.1f; } if (ProjDistance.Length() > 50f) { if (Math.Abs(PlayerCenter.X - projectile.Center.X) > 10f) { projectile.velocity.X = projectile.velocity.X + MinVel * (float)Math.Sign(PlayerCenter.X - projectile.Center.X); } if (Math.Abs(PlayerCenter.Y - projectile.Center.Y) > 5f) { projectile.velocity.Y = projectile.velocity.Y + MinVel * (float)Math.Sign(PlayerCenter.Y - projectile.Center.Y); } } else if (projectile.velocity.Length() > 1.6f) { projectile.velocity *= 0.96f; } float MaxVel = 15f; if (ProjDistance.Length() > 800f) { MaxVel = 25; } else if (ProjDistance.Length() > 500f) { MaxVel = 22f; } else if (ProjDistance.Length() > 300f) { MaxVel = 18.5f; } else { MaxVel = 15; } if (projectile.velocity.Length() > MaxVel) { projectile.velocity = Vector2.Normalize(projectile.velocity) * MaxVel; } if (ProjDistance.Length() > 2000f) { projectile.Center = PlayerCenter; } if (Math.Abs(projectile.velocity.Y) < 1f) { projectile.velocity.Y = projectile.velocity.Y - 0.1f; } projectile.rotation += MathHelper.ToRadians(3.6f); //Deity Logic /* * FRAME KEY: * 0 = main * 1 = corrupt * 2 = crimson * 3 = hallow * 4 = astral * 5 = surface * 6 = brimstone * 7 = underground * 8 = ocean * 9 = abyss * 10 = jungle post golem * 11 = ??? * 12 = space * 13 = dungeon * 14 = sunken sea * 15 = jungle pre golem * 16 = sulphur sea * 17 = acid rain * 18 = desert * 19 = boss rush * 20 = snow * 21 = abyss layer 1 * :22: = abyss layer 3 * 23 = pillars * 24 = ug snow/cryonic */ if (CalamityMod.Events.BossRushEvent.BossRushActive) { GoozmaSlimeGods = new List <int> { 19, 19, 19, 19, }; } else { if (player.ZoneTowerVortex || player.ZoneTowerSolar || player.ZoneTowerStardust || player.ZoneTowerNebula) { AddDeity(23); } else if (player.ZoneCorrupt) //Ebonian { AddDeity(1); } else if (player.ZoneCrimson) //Crimulan { AddDeity(2); } else if (player.ZoneHoly) //Crystalline { AddDeity(3); } else if (calPlayer.ZoneAstral) //I wonder what this could be { AddDeity(4); } else if (calPlayer.ZoneCalamity) //Charred { AddDeity(6); } else if (player.ZoneDesert) //Victide { AddDeity(18); } else if (player.ZoneSkyHeight) //Exodium { AddDeity(12); } else if (player.ZoneUnderworldHeight) //Chaotic { AddDeity(9); } else if (calPlayer.ZoneAbyssLayer1 || calPlayer.ZoneAbyssLayer2) //Scoria { AddDeity(21); } else if (calPlayer.ZoneAbyssLayer3) //Mirage { AddDeity(11); } else if (calPlayer.ZoneAbyssLayer4) //Lumenyl { AddDeity(22); } else if (calPlayer.ZoneSunkenSea) //Prism { AddDeity(14); } else if (player.ZoneJungle && player.ZoneRockLayerHeight) //Plague { AddDeity(10); } else if (player.ZoneJungle && player.ZoneDirtLayerHeight) //Plague alt { AddDeity(10); } else if (player.ZoneJungle && !player.ZoneDirtLayerHeight && !player.ZoneRockLayerHeight) //Uelibloom { AddDeity(15); } else if (player.ZoneDungeon) //Phantoplasm { AddDeity(13); } else if (player.ZoneSnow && player.ZoneRockLayerHeight) //Cryogenic { AddDeity(24); } else if (player.ZoneSnow && player.ZoneDirtLayerHeight) //Cryogenic alt { AddDeity(24); } else if (player.ZoneSnow && !player.ZoneDirtLayerHeight && !player.ZoneRockLayerHeight) //Cryonic { AddDeity(20); } else if (calPlayer.ZoneSulphur) { if (CalamityMod.World.CalamityWorld.rainingAcid) //Gamma { AddDeity(16); } else //Irradiated { AddDeity(17); } } else if (player.ZoneBeach) //Box Jelly { AddDeity(8); } else if (player.ZoneDirtLayerHeight || player.ZoneRockLayerHeight) //Perennial { AddDeity(7); } else //Wulfrum { AddDeity(5); } } }