terrarian10
Plantera
Hi I have a new mod I created called Try Again (Version 0.0.1.2) As you can tell by the prefix it is for the PC and a Work In Progress. I would like to see if you have any ideas
This is what I have so far!
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace InsaneCrazyThing.Items
{
[AutoloadHead]
public class TOWNNPC1 : ModNPC
{
public override bool Autoload(ref string name)
{
name = "Summoner";
return true;
}
public override void SetStaticDefaults()
{
NPCID.Sets.DangerDetectRange[npc.type] = 700;
NPCID.Sets.AttackType[npc.type] = 0;
NPCID.Sets.AttackTime[npc.type] = 90;
NPCID.Sets.AttackAverageChance[npc.type] = 30;
NPCID.Sets.HatOffsetY[npc.type] = 4;
}
public override void SetDefaults()
{
npc.townNPC = true;
npc.friendly = true;
npc.width = 32;
npc.height = 64;
npc.aiStyle = 7; // Town NPC AI Style
npc.damage = 12;
npc.defense = 17;
npc.lifeMax = 250;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
npc.knockBackResist = 0.5f;
animationType = NPCID.Guide;
}
public override bool CanTownNPCSpawn(int numTownNPCs, int money)
{
for (int k = 0; k < 255; k++)
{
Player player = Main.player[k];
if (!player.active)
{
continue;
}
foreach (Item item in player.inventory)
{
if (item.type == mod.ItemType("SteelBar"))
{
return true;
}
}
}
return false;
}
public override string TownNPCName()
{
switch (WorldGen.genRand.Next(4))
{
case 0:
return "Summoner";
case 1:
return "Summoner";
case 2:
return "Summoner";
default: // Default is the default if no other case is true. In this case if the random number is 3 or more
return "Summoner";
}
}
public override string GetChat()
{
int otherNPC = NPC.FindFirstNPC(NPCID.Angler);
if (otherNPC >= 0 && Main.rand.NextBool(4))
{
return "Did you know that " + Main.npc[otherNPC].GivenName + " is the angler, he might have a few quests?";
}
switch (Main.rand.Next(4))
{
case 0:
return "Did you know I broke both my legs in a fight with skeletron prime";
case 1:
return "Sorry, I only have one hoverboard";
case 2:
return "I thing the steampunker might help me sell them";
default:
return "I would like to see you beat a boss, it is fun to watch";
}
}
public override void SetChatButtons(ref string button, ref string button2)
{
button = Language.GetTextValue("LegacyInterface.28");
}
public override void OnChatButtonClicked(bool firstButton, ref bool shop)
{
if (firstButton)
{
// This is makes it a shop
shop = true;
}
else
{
}
}
public override void SetupShop(Chest shop, ref int nextSlot)
{
// For every slot, you must have these lines.
if(NPC.downedBoss1 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.SuspiciousLookingEye);
nextSlot++;
}
if (NPC.downedBoss2 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.WormFood);
nextSlot++;
shop.item[nextSlot].SetDefaults(ItemID.BloodySpine);
}
if (NPC.downedBoss3 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.ClothierVoodooDoll);
nextSlot++;
}
if (NPC.downedQueenBee == true)
{
shop.item[nextSlot].SetDefaults(ItemID.Abeemination);
nextSlot++;
}
if (Main.hardMode == true)
{
shop.item[nextSlot].SetDefaults(ItemID.GuideVoodooDoll);
nextSlot++;
}
if (NPC.downedMechBoss1 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.MechanicalWorm);
nextSlot++;
}
if (NPC.downedMechBoss2 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.MechanicalEye);
nextSlot++;
}
if (NPC.downedMechBoss3 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.MechanicalSkull);
nextSlot++;
}
if (NPC.downedFishron == true)
{
shop.item[nextSlot].SetDefaults(ItemID.TruffleWorm);
nextSlot++;
}
if (NPC.downedPlantBoss == true)
{
shop.item[nextSlot].SetDefaults(ItemID.RocketIII);
nextSlot++;
}
if (NPC.downedGolemBoss == true)
{
shop.item[nextSlot].SetDefaults(ItemID.LihzahrdPowerCell);
nextSlot++;
}
if (NPC.downedAncientCultist == true)
{
shop.item[nextSlot].SetDefaults(ItemID.LunarCraftingStation);
nextSlot++;
}
if (NPC.downedTowerSolar == true)
{
shop.item[nextSlot].SetDefaults(ItemID.FragmentSolar);
nextSlot++;
}
if (NPC.downedTowerNebula == true)
{
shop.item[nextSlot].SetDefaults(ItemID.FragmentNebula);
nextSlot++;
}
if (NPC.downedTowerVortex == true)
{
shop.item[nextSlot].SetDefaults(ItemID.FragmentVortex);
nextSlot++;
}
if (NPC.downedTowerStardust == true)
{
shop.item[nextSlot].SetDefaults(ItemID.FragmentStardust);
nextSlot++;
}
if (NPC.downedMoonlord == true)
{
shop.item[nextSlot].SetDefaults(ItemID.CelestialSigil);
nextSlot++;
}
if (NPC.downedSlimeKing == true)
{
shop.item[nextSlot].SetDefaults(ItemID.SlimeCrown);
nextSlot++;
}
if (NPC.downedSlimeKing == true)
{
shop.item[nextSlot].SetDefaults(ItemID.SlimeCrown);
nextSlot++;
}
// You can have a max of 40?
}
public override void NPCLoot()
{
//Item.NewItem(npc.getRect(), mod.ItemType("TMMCAccessory"));
}
public override void TownNPCAttackStrength(ref int damage, ref float knockback)
{
damage = 25;
knockback = 4f;
}
public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown)
{
cooldown = 30;
randExtraCooldown = 25;
}
public override void TownNPCAttackProj(ref int projType, ref int attackDelay)
{
projType = ProjectileID.LaserMachinegun;
attackDelay = 1;
}
public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)
{
multiplier = 5f;
randomOffset = 2f;
}
// This is for if you want custom spawn conditions
// This example will check for the TMMCTile and TMMCWall
public override bool CheckConditions(int left, int right, int top, int bottom)
{
int score = 0;
for (int x = left; x <= right; x++)
{
for (int y = top; y <= bottom; y++)
{
int type = Main.tile[x, y].type;
if (type == mod.TileType("TMMCGenericTile"))
{
score++;
}
if (Main.tile[x, y].wall == mod.WallType("TMMCGenericWall"))
{
score++;
}
}
}
return score >= (right - left) * (bottom - top) / 2;
}
}
}
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace InsaneCrazyThing.Items
{
[AutoloadHead]
public class TOWNNPC1 : ModNPC
{
public override bool Autoload(ref string name)
{
name = "Summoner";
return true;
}
public override void SetStaticDefaults()
{
NPCID.Sets.DangerDetectRange[npc.type] = 700;
NPCID.Sets.AttackType[npc.type] = 0;
NPCID.Sets.AttackTime[npc.type] = 90;
NPCID.Sets.AttackAverageChance[npc.type] = 30;
NPCID.Sets.HatOffsetY[npc.type] = 4;
}
public override void SetDefaults()
{
npc.townNPC = true;
npc.friendly = true;
npc.width = 32;
npc.height = 64;
npc.aiStyle = 7; // Town NPC AI Style
npc.damage = 12;
npc.defense = 17;
npc.lifeMax = 250;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
npc.knockBackResist = 0.5f;
animationType = NPCID.Guide;
}
public override bool CanTownNPCSpawn(int numTownNPCs, int money)
{
for (int k = 0; k < 255; k++)
{
Player player = Main.player[k];
if (!player.active)
{
continue;
}
foreach (Item item in player.inventory)
{
if (item.type == mod.ItemType("SteelBar"))
{
return true;
}
}
}
return false;
}
public override string TownNPCName()
{
switch (WorldGen.genRand.Next(4))
{
case 0:
return "Summoner";
case 1:
return "Summoner";
case 2:
return "Summoner";
default: // Default is the default if no other case is true. In this case if the random number is 3 or more
return "Summoner";
}
}
public override string GetChat()
{
int otherNPC = NPC.FindFirstNPC(NPCID.Angler);
if (otherNPC >= 0 && Main.rand.NextBool(4))
{
return "Did you know that " + Main.npc[otherNPC].GivenName + " is the angler, he might have a few quests?";
}
switch (Main.rand.Next(4))
{
case 0:
return "Did you know I broke both my legs in a fight with skeletron prime";
case 1:
return "Sorry, I only have one hoverboard";
case 2:
return "I thing the steampunker might help me sell them";
default:
return "I would like to see you beat a boss, it is fun to watch";
}
}
public override void SetChatButtons(ref string button, ref string button2)
{
button = Language.GetTextValue("LegacyInterface.28");
}
public override void OnChatButtonClicked(bool firstButton, ref bool shop)
{
if (firstButton)
{
// This is makes it a shop
shop = true;
}
else
{
}
}
public override void SetupShop(Chest shop, ref int nextSlot)
{
// For every slot, you must have these lines.
if(NPC.downedBoss1 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.SuspiciousLookingEye);
nextSlot++;
}
if (NPC.downedBoss2 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.WormFood);
nextSlot++;
shop.item[nextSlot].SetDefaults(ItemID.BloodySpine);
}
if (NPC.downedBoss3 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.ClothierVoodooDoll);
nextSlot++;
}
if (NPC.downedQueenBee == true)
{
shop.item[nextSlot].SetDefaults(ItemID.Abeemination);
nextSlot++;
}
if (Main.hardMode == true)
{
shop.item[nextSlot].SetDefaults(ItemID.GuideVoodooDoll);
nextSlot++;
}
if (NPC.downedMechBoss1 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.MechanicalWorm);
nextSlot++;
}
if (NPC.downedMechBoss2 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.MechanicalEye);
nextSlot++;
}
if (NPC.downedMechBoss3 == true)
{
shop.item[nextSlot].SetDefaults(ItemID.MechanicalSkull);
nextSlot++;
}
if (NPC.downedFishron == true)
{
shop.item[nextSlot].SetDefaults(ItemID.TruffleWorm);
nextSlot++;
}
if (NPC.downedPlantBoss == true)
{
shop.item[nextSlot].SetDefaults(ItemID.RocketIII);
nextSlot++;
}
if (NPC.downedGolemBoss == true)
{
shop.item[nextSlot].SetDefaults(ItemID.LihzahrdPowerCell);
nextSlot++;
}
if (NPC.downedAncientCultist == true)
{
shop.item[nextSlot].SetDefaults(ItemID.LunarCraftingStation);
nextSlot++;
}
if (NPC.downedTowerSolar == true)
{
shop.item[nextSlot].SetDefaults(ItemID.FragmentSolar);
nextSlot++;
}
if (NPC.downedTowerNebula == true)
{
shop.item[nextSlot].SetDefaults(ItemID.FragmentNebula);
nextSlot++;
}
if (NPC.downedTowerVortex == true)
{
shop.item[nextSlot].SetDefaults(ItemID.FragmentVortex);
nextSlot++;
}
if (NPC.downedTowerStardust == true)
{
shop.item[nextSlot].SetDefaults(ItemID.FragmentStardust);
nextSlot++;
}
if (NPC.downedMoonlord == true)
{
shop.item[nextSlot].SetDefaults(ItemID.CelestialSigil);
nextSlot++;
}
if (NPC.downedSlimeKing == true)
{
shop.item[nextSlot].SetDefaults(ItemID.SlimeCrown);
nextSlot++;
}
if (NPC.downedSlimeKing == true)
{
shop.item[nextSlot].SetDefaults(ItemID.SlimeCrown);
nextSlot++;
}
// You can have a max of 40?
}
public override void NPCLoot()
{
//Item.NewItem(npc.getRect(), mod.ItemType("TMMCAccessory"));
}
public override void TownNPCAttackStrength(ref int damage, ref float knockback)
{
damage = 25;
knockback = 4f;
}
public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown)
{
cooldown = 30;
randExtraCooldown = 25;
}
public override void TownNPCAttackProj(ref int projType, ref int attackDelay)
{
projType = ProjectileID.LaserMachinegun;
attackDelay = 1;
}
public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)
{
multiplier = 5f;
randomOffset = 2f;
}
// This is for if you want custom spawn conditions
// This example will check for the TMMCTile and TMMCWall
public override bool CheckConditions(int left, int right, int top, int bottom)
{
int score = 0;
for (int x = left; x <= right; x++)
{
for (int y = top; y <= bottom; y++)
{
int type = Main.tile[x, y].type;
if (type == mod.TileType("TMMCGenericTile"))
{
score++;
}
if (Main.tile[x, y].wall == mod.WallType("TMMCGenericWall"))
{
score++;
}
}
}
return score >= (right - left) * (bottom - top) / 2;
}
}
}