public override void HitWire(int i, int j) { Tile tile = Main.tile[i, j]; int style = tile.frameY / 18; Vector2 spawnPosition; // This logic here corresponds to the orientation of the sprites in the spritesheet, change it if your tile is different in design. int horizontalDirection = (tile.frameX == 0) ? -1 : ((tile.frameX == 18) ? 1 : 0); int verticalDirection = (tile.frameX < 36) ? 0 : ((tile.frameX < 72) ? -1 : 1); // Each trap style within this Tile shoots different projectiles. if (style == 0) { // Wiring.CheckMech checks if the wiring cooldown has been reached. Put a longer number here for less frequent projectile spawns. 200 is the dart/flame cooldown. Spear is 90, spiky ball is 300 if (Wiring.CheckMech(i, j, 60)) { spawnPosition = new Vector2(i * 16 + 8 + 0 * horizontalDirection, j * 16 + 9 + 0 * verticalDirection); // The extra numbers here help center the projectile spawn position if you need to. // In reality you should be spawning projectiles that are both hostile and friendly to do damage to both players and NPC. // Make sure to change velocity, projectile, damage, and knockback. Projectile.NewProjectile(spawnPosition, new Vector2(horizontalDirection, verticalDirection) * 6f, ProjectileID.IchorBullet, 20, 2f, Main.myPlayer); } } else if (style == 1) { if (Wiring.CheckMech(i, j, 200)) // A longer cooldown for ChlorophyteBullet trap. { spawnPosition = new Vector2(i * 16 + 8 + 0 * horizontalDirection, j * 16 + 9 + 0 * verticalDirection); // The extra numbers here help center the projectile spawn position. Projectile.NewProjectile(spawnPosition, new Vector2(horizontalDirection, verticalDirection) * 8f, ProjectileID.ChlorophyteBullet, 40, 2f, Main.myPlayer); } } }
public override void HitWire(int i, int j) { // Find the coordinates of top left tile square through math int y = j - (Main.tile[i, j].frameY / 18); int x = i - (Main.tile[i, j].frameX / 18); Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); int spawnX = x * 16 + 16; int spawnY = (y + 3) * 16; int npcIndex = -1; if (Wiring.CheckMech(x, y, 30) && NPC.MechSpawn((float)spawnX, (float)spawnY, mod.NPCType("PartyZombie"))) { npcIndex = NPC.NewNPC(spawnX, spawnY - 12, mod.NPCType("PartyZombie")); } if (npcIndex >= 0) { Main.npc[npcIndex].value = 0f; Main.npc[npcIndex].npcSlots = 0f; } }
public override void HitWire(int i, int j) { if (Wiring.CheckMech(i, j, 60)) { Vector2 velocity = Vector2.Zero; if (Main.tile[i, j].frameX < 18) { velocity = new Vector2(-.001f, 0); } else if (Main.tile[i, j].frameX < 36) { velocity = new Vector2(.001f, 0); } else if (Main.tile[i, j].frameX < 72) { velocity = new Vector2(0, -.001f); } else if (Main.tile[i, j].frameX < 108) { velocity = new Vector2(0, .001f); } Projectile.NewProjectile(new Vector2(i, j) * 16 + new Vector2(8, 8) + velocity.SafeNormalize(-Vector2.UnitY) * 16, velocity, mod.ProjectileType("FortressTrapP"), 18, .5f, Main.myPlayer, 0f); Projectile.NewProjectile(new Vector2(i, j) * 16 + new Vector2(8, 8) + velocity.SafeNormalize(-Vector2.UnitY) * 16, velocity, mod.ProjectileType("FortressTrapP"), 18, .5f, Main.myPlayer, 20f); } }
public override void HitWire(int i, int j) { int y = j; int x = i; Wiring.SkipWire(x, y); int spawnX = x * 16; int spawnY = y * 16; int style = Main.tile[i, j].frameX / 18; string type; switch (style) { case 0: if (Wiring.CheckMech(x, y, 90) && NPC.MechSpawn((float)spawnX, (float)spawnY, mod.ProjectileType("ElectricBallTrap"))) { Projectile.NewProjectile((float)spawnX + 8, (float)spawnY + 8, 0f, -3f, mod.ProjectileType("ElectricBallTrap"), 130, 0); } break; case 1: if (Wiring.CheckMech(x, y, 90) && NPC.MechSpawn((float)spawnX, (float)spawnY, mod.ProjectileType("ElectricBrainTrap"))) { Projectile.NewProjectile((float)spawnX + 8, (float)spawnY + 8, 0f, -4f, mod.ProjectileType("ElectricBrainTrap"), 5, 0); } break; default: return; } }
public override void HitWire(int i, int j) { Point16 Pos = new Point16(i - ((Main.tile[i, j].frameX % 36) / 18), j - (Main.tile[i, j].frameY / 18)); Wiring.SkipWire(Pos); Wiring.SkipWire(Pos.X, Pos.Y + 1); Wiring.SkipWire(Pos.X + 1, Pos.Y); Wiring.SkipWire(Pos.X + 1, Pos.Y + 1); if (Wiring.CheckMech(Pos.X, Pos.Y, 500)) { int cframe = Main.tile[Pos.X, Pos.Y].frameX / 36; Vector2 spawn = Pos.ToWorldCoordinates(16f, 16f); Vector2 velocity = Vector2.UnitY; switch (cframe) { case 1: velocity = -Vector2.UnitX; break; case 2: velocity = Vector2.UnitX; break; case 3: velocity = -velocity; break; } Projectile.NewProjectile(spawn, velocity * 3.5f, ProjectileType <Projectiles.TempleBoulder>(), 70, 3f, Main.myPlayer, Main.rand.Next(2)); } }
/* * Abaixo uma função do tipo void que significa que nao precisa de retorno * O código referece ao sistema de wireless * Nota: não alterei esse código do mod de exemplo, porém não achei necessário */ public override void HitWire(int i, int j) { int y = j - (Main.tile[i, j].frameY / 18); int x = i - (Main.tile[i, j].frameX / 18); Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); int spawnX = x * 16 + 16; int spawnY = (y + 3) * 16; int npcIndex = -1; if (Wiring.CheckMech(x, y, 30) && NPC.MechSpawn((float)spawnX, (float)spawnY, mod.NPCType("gosma"))) { npcIndex = NPC.NewNPC(spawnX, spawnY - 12, mod.NPCType("gosma")); //Pd- é um npc/monstro no qual eu criei, peço desculpas pela falta de criatividade } if (npcIndex >= 0) { Main.npc[npcIndex].value = 0f; Main.npc[npcIndex].npcSlots = 0f; } }
public override void HitWire(int i, int j) { Tile tile = Main.tile[i, j]; Player player = Main.player[Main.myPlayer]; if (Wiring.CheckMech(i, j, 1600)) { Projectile.NewProjectile(i, j, 0f, 0f, mod.ProjectileType("OrbProj1"), 5, 1f, player.whoAmI); } }
public override void HitWire(int i, int j) { // Find the coordinates of top left tile square through math int y = j - Main.tile[i, j].frameY / 18; int x = i - Main.tile[i, j].frameX / 18; Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); // We add 16 to x to spawn right between the 2 tiles. We also want to right on the ground in the y direction. int spawnX = x * 16 + 16; int spawnY = (y + 3) * 16; // This example shows both item spawning code and npc spawning code, you can use whichever code suits your mod if (Main.rand.NextFloat() < .95f) // There is a 95% chance for item spawn and a 5% chance for npc spawn { // If you want to make a item spawning statue, see below. if (Wiring.CheckMech(x, y, 60) && Item.MechSpawn(spawnX, spawnY, ItemID.SilverCoin) && Item.MechSpawn(spawnX, spawnY, ItemID.GoldCoin) && Item.MechSpawn(spawnX, spawnY, ItemID.PlatinumCoin)) { int id = ItemID.SilverCoin; if (Main.rand.NextBool(100)) { id++; if (Main.rand.NextBool(100)) { id++; } } Item.NewItem(spawnX, spawnY - 20, 0, 0, id, 1, false, 0, false); } } else { // If you want to make an NPC spawning statue, see below. int npcIndex = -1; // 30 is the time before it can be used again. NPC.MechSpawn checks nearby for other spawns to prevent too many spawns. 3 in immediate vicinity, 6 nearby, 10 in world. if (Wiring.CheckMech(x, y, 30) && NPC.MechSpawn((float)spawnX, (float)spawnY, NPCID.Goldfish)) { npcIndex = NPC.NewNPC(spawnX, spawnY - 12, NPCID.Goldfish); } if (npcIndex >= 0) { Main.npc[npcIndex].value = 0f; Main.npc[npcIndex].npcSlots = 0f; // Prevents Loot if NPCID.Sets.NoEarlymodeLootWhenSpawnedFromStatue and !Main.HardMode or NPCID.Sets.StatueSpawnedDropRarity != -1 and NextFloat() >= NPCID.Sets.StatueSpawnedDropRarity or killed by traps. // Prevents CatchNPC Main.npc[npcIndex].SpawnedFromStatue = true; } } }
public override void HitWire(int i, int j) { int y = j; int x = i; Wiring.SkipWire(x, y); int spawnX = x * 16; int spawnY = y * 16; if (Wiring.CheckMech(x, y, 90) && NPC.MechSpawn((float)spawnX, (float)spawnY, mod.ProjectileType("ElectricBrainTrap"))) { Projectile.NewProjectile((float)spawnX + 8, (float)spawnY + 8, 0f, -4f, mod.ProjectileType("ElectricBrainTrap"), 5, 0); } }
public bool InjectItem(int x, int y, Item item) { if (item.type != ItemID.Snowball) { return(false); } Tile tile = Main.tile[x, y]; if (tile == null || !tile.active()) { return(false); } int originX = x - tile.frameX % 54 / 18; int originY = y - tile.frameY % 54 / 18; if (!Wiring.CheckMech(originX, originY, 10)) { return(false); } Main.PlaySound(SoundID.Item11, x * 16, y * 16); float velocityX = Main.rand.Next(85, 105); float velocityY = Main.rand.Next(-35, 11); Vector2 position = new Vector2((float)((originX + 2) * 16 - 8), (float)((originY + 2) * 16 - 8)); if (tile.frameX / 54 == 0) { velocityX *= -1f; position.X -= 12f; } else { position.X += 12f; } float velocity = (12f + (float)Main.rand.Next(450) * 0.01f) / (float)Math.Sqrt((double)(velocityX * velocityX + velocityY * velocityY)); velocityX *= velocity; velocityY *= velocity; Projectile.NewProjectile(position.X, position.Y, velocityX, velocityY, ProjectileID.SnowBallFriendly, 35, 3.5f, Main.myPlayer, 0, 0); item.stack--; return(true); }
public override void HitWire(int i, int j) { int entity = ModContent.GetInstance <CommandTileEntity>().Find(i, j); if (entity == -1) { return; } CommandTileEntity tileEntity = (CommandTileEntity)TileEntity.ByID[entity]; if (Wiring.CheckMech(i, j, 20)) { KhaiosUtil.ExecuteCommand(tileEntity.commandTileCommand, ref tileEntity); } }
public bool InjectItem(int x, int y, Item item) { Tile tile = Main.tile[x, y]; if (tile == null || !tile.active()) { return(false); } int expectedType = 0; int ammotype = 0; if (Main.tile[x, y].frameX < 72) { expectedType = ItemID.Cannonball; ammotype = 1; } else if (Main.tile[x, y].frameX < 144) { expectedType = ItemID.ExplosiveBunny; ammotype = 2; } else if (Main.tile[x, y].frameX < 288) { expectedType = ItemID.Confetti; ammotype = 3; } if (ammotype == 0 || item.type != expectedType) { return(false); } int originX = x - tile.frameX % 72 / 18; int originY = y - tile.frameY % 54 / 18; int angle = tile.frameY / 54; if (!Wiring.CheckMech(originX, originY, 30)) { return(false); } WorldGen.ShootFromCannon(originX, originY, angle, ammotype, item.damage, item.knockBack, Main.myPlayer); item.stack--; return(true); }
public override void HitWire(int i, int j) { // Find the coordinates of top left tile square through math int y = j - Main.tile[i, j].frameY / 18; int x = i - Main.tile[i, j].frameX / 18; Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); // We add 16 to x to spawn right between the 2 tiles. We also want to right on the ground in the y direction. int spawnX = x * 16 + 16; int spawnY = (y + 3) * 16; // This example shows both item spawning code and npc spawning code, you can use whichever code suits your mod // If you want to make an NPC spawning statue, see below. int npcIndex = -1; // 30 is the time before it can be used again. NPC.MechSpawn checks nearby for other spawns to prevent too many spawns. 3 in immediate vicinity, 6 nearby, 10 in world. int critter; if (Main.LocalPlayer.GetModPlayer <CalValEXPlayer>().ZoneAstral) { critter = ModContent.NPCType <Blightolemur>(); } else { critter = ModContent.NPCType <Violemur>(); } if (Wiring.CheckMech(x, y, 30) && NPC.MechSpawn((float)spawnX, (float)spawnY, (critter))) { npcIndex = NPC.NewNPC(spawnX, spawnY - 12, (critter)); } if (npcIndex >= 0) { Main.npc[npcIndex].value = 0f; Main.npc[npcIndex].npcSlots = 0f; // Prevents Loot if NPCID.Sets.NoEarlymodeLootWhenSpawnedFromStatue and !Main.HardMode or NPCID.Sets.StatueSpawnedDropRarity != -1 and NextFloat() >= NPCID.Sets.StatueSpawnedDropRarity or killed by traps. // Prevents CatchNPC Main.npc[npcIndex].SpawnedFromStatue = true; } }
public override void HitWire(int i, int j) { // Find the coordinates of top left tile square through math int y = j - (Main.tile[i, j].frameY / 18); int x = i - (Main.tile[i, j].frameX / 18); Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); if (Wiring.CheckMech(x, y, 30)) { Main.time = 32400.1; } }
public bool InjectItem(int x, int y, Item item) { if (item.ammo == 0 || item.shoot == 0 || item.ammo == AmmoID.Rocket) { return(false); } Tile tile = Main.tile[x, y]; if (tile == null || !tile.active()) { return(false); } int originX = x - (tile.frameX % 36) / 18; int originY = y - (tile.frameY % 36) / 18; Tile origin = Main.tile[originX, originY]; if (origin == null || !origin.active()) { return(false); } int style = origin.frameX / 36; if (fireRate[style] != 0 && !Wiring.CheckMech(originX, originY, fireRate[style])) { return(false); } Vector2 position = new Vector2((originX + 1) * 16, (originY + 1) * 16); Vector2 direction = Vector2.Zero; switch (origin.frameY) { case 0: direction = new Vector2(-1f, 0f); break; case 38: direction = new Vector2(-0.5f, -0.5f); break; case 76: direction = new Vector2(0f, -1f); break; case 114: direction = new Vector2(0.5f, -0.5f); break; case 152: direction = new Vector2(1f, 0f); break; case 190: direction = new Vector2(0.5f, 0.5f); position.Y -= 8; break; case 228: direction = new Vector2(-0.5f, 0.5f); position.Y -= 8; break; } Main.PlaySound(SoundID.Item11, position); Projectile proj = Main.projectile[Projectile.NewProjectile(position, direction * shootSpeed[style], item.shoot, baseDamage[style] * (1 + item.damage / 100), item.knockBack, Main.myPlayer)]; proj.hostile = true; if (Main.netMode == 2) { ModPacket packet = NetRouter.GetPacketTo(this, mod); packet.Write((Int16)proj.identity); packet.Write((byte)proj.owner); packet.Send(); } if (item.consumable) { item.stack--; } return(true); }