start town pggiy
This commit is contained in:
1 parent
63c619fbc7
commit
fa65440d3e
9 files changed
+272
No files matched your search
@@ -0,0 +1,67 @@
|
||||
using CalamityMod.NPCs.TownNPCs;
|
||||
using CalamityMod.Packets;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Chat;
|
||||
using Terraria.Enums;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.SummonItems.TownPets
|
||||
{
|
||||
public class PiggyLicense : ModItem
|
||||
{
|
||||
public override string Texture => "Terraria/Images/Item_" + ItemID.LicenseBunny;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Item.ResearchUnlockCount = 5;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.useStyle = ItemUseStyleID.HoldUp;
|
||||
Item.consumable = true;
|
||||
Item.useAnimation = 45;
|
||||
Item.useTime = 45;
|
||||
Item.UseSound = SoundID.Item92;
|
||||
Item.width = 28;
|
||||
Item.height = 28;
|
||||
Item.maxStack = Item.CommonMaxStack;
|
||||
Item.SetShopValues(ItemRarityColor.Green2, Item.buyPrice(0, 5));
|
||||
}
|
||||
|
||||
public override bool? UseItem(Player player)
|
||||
{
|
||||
int npcType = ModContent.NPCType<TownPiggy>();
|
||||
if (player.ItemAnimationJustStarted && (!CalamityWorld.unlockedTownPig || NPC.AnyNPCs(npcType)))
|
||||
{
|
||||
if (player.whoAmI == Main.myPlayer)
|
||||
{
|
||||
SpawnPiggy();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void SpawnPiggy()
|
||||
{
|
||||
Color color = new(50, 255, 130);
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
{
|
||||
if (!CalamityWorld.unlockedTownPig)
|
||||
{
|
||||
SyncTownPigLicensePacket.Send();
|
||||
}
|
||||
}
|
||||
else if (!CalamityWorld.unlockedTownPig)
|
||||
{
|
||||
CalamityWorld.unlockedTownPig = true;
|
||||
ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Mods.CalamityMod.Misc.PiggyLicense"), color);
|
||||
CalamityNetcode.SyncWorld();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ SevensBust: Bust!
|
||||
SevensDoubles: Doubles!
|
||||
SevensTriples: Triples!
|
||||
StylishHammerHit: Stylish!
|
||||
PiggyLicense: The license teleports away to the Piggy delivery service...
|
||||
GenericConsumedText: "[c/8A8A8A:You have already consumed this item]"
|
||||
CelestialOnionText: You have already consumed a Celestial Onion. Consuming another would distort you.
|
||||
SanguineTangerineText: You have already consumed a Sanguine Tangerine. Eating any more would make your blood too thick to flow.
|
||||
|
||||
@@ -561,6 +561,36 @@ SeaKing: {
|
||||
}
|
||||
}
|
||||
|
||||
TownPiggy: {
|
||||
DisplayName: Town Pig
|
||||
Census.SpawnCondition: Use a Pig License
|
||||
|
||||
Name: {
|
||||
Oolong: Oolong
|
||||
Napoleon: Napoleon
|
||||
Waddles: Waddles
|
||||
Crenando: Crenando
|
||||
Olivia: Olivia
|
||||
Wilbur: Wilbur
|
||||
Pumbaa: Pumbaa
|
||||
Peppa: Peppa
|
||||
Conan: Conan
|
||||
Reuben: Reuben
|
||||
Porky: Porky
|
||||
Hamm: Hamm
|
||||
Runt: Runt
|
||||
Roko: Roko
|
||||
RichardHam: Richard Ham
|
||||
Curly: Curly
|
||||
}
|
||||
|
||||
Chat: {
|
||||
0: Oink!
|
||||
1: Squeal...
|
||||
2: Snort!
|
||||
}
|
||||
}
|
||||
|
||||
DraconicSwarmer.DisplayName: Draconic Swarmer
|
||||
Dragonfolly.DisplayName: Dragonfolly
|
||||
Shoreskipper.DisplayName: Shoreskipper
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace CalamityMod.NPCs.TownNPCs
|
||||
{
|
||||
[AutoloadHead]
|
||||
public class TownPiggy : ModNPC
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.npcFrameCount[Type] = 8;
|
||||
NPCID.Sets.ExtraFramesCount[Type] = 0;
|
||||
NPCID.Sets.AttackFrameCount[Type] = 0;
|
||||
NPCID.Sets.DangerDetectRange[Type] = 250;
|
||||
NPCID.Sets.HatOffsetY[Type] = 6;
|
||||
NPCID.Sets.ShimmerTownTransform[Type] = false;
|
||||
NPCID.Sets.SpecificDebuffImmunity[Type][BuffID.Shimmer] = true;
|
||||
NPCID.Sets.SpecificDebuffImmunity[Type][BuffID.Confused] = true;
|
||||
NPCID.Sets.NPCFramingGroup[Type] = 8;
|
||||
|
||||
NPCID.Sets.IsTownPet[Type] = true;
|
||||
NPCID.Sets.CannotSitOnFurniture[Type] = false;
|
||||
NPCID.Sets.TownNPCBestiaryPriority.Add(Type);
|
||||
NPCID.Sets.PlayerDistanceWhilePetting[Type] = 32;
|
||||
NPCID.Sets.IsPetSmallForPetting[Type] = true;
|
||||
|
||||
NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new()
|
||||
{
|
||||
Velocity = 0.25f,
|
||||
};
|
||||
|
||||
NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, drawModifiers);
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
NPC.townNPC = true;
|
||||
NPC.friendly = true;
|
||||
NPC.width = 20;
|
||||
NPC.height = 20;
|
||||
NPC.aiStyle = NPCAIStyleID.Passive;
|
||||
NPC.damage = 0;
|
||||
NPC.defense = 0;
|
||||
NPC.lifeMax = 50;
|
||||
NPC.HitSound = SoundID.NPCHit1;
|
||||
NPC.DeathSound = SoundID.NPCDeath1;
|
||||
NPC.knockBackResist = 0.5f;
|
||||
NPC.housingCategory = 1;
|
||||
//AnimationType = NPCID.TownBunny;
|
||||
}
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
{
|
||||
bestiaryEntry.Info.AddRange(
|
||||
[
|
||||
BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Surface,
|
||||
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.TownPiggy")
|
||||
]);
|
||||
}
|
||||
|
||||
public override bool CanTownNPCSpawn(int numTownNPCs)
|
||||
{
|
||||
if (CalamityWorld.unlockedTownPig)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
NPC.spriteDirection = NPC.direction;
|
||||
}
|
||||
|
||||
public override void FindFrame(int frameHeight)
|
||||
{
|
||||
if (NPC.velocity.X == 0)
|
||||
NPC.frame.Y = 0;
|
||||
else
|
||||
{
|
||||
if (NPC.frameCounter++ % 6 == 0)
|
||||
{
|
||||
NPC.frame.Y += frameHeight;
|
||||
if (NPC.frame.Y >= frameHeight * Main.npcFrameCount[Type])
|
||||
{
|
||||
NPC.frame.Y = frameHeight;
|
||||
}
|
||||
}
|
||||
if (NPC.frame.Y < frameHeight)
|
||||
NPC.frame.Y = frameHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public override List<string> SetNPCNameList() => new List<string>()
|
||||
{
|
||||
// Original names
|
||||
this.GetLocalizedValue("Name.Curly"),
|
||||
|
||||
// Reference names
|
||||
this.GetLocalizedValue("Name.Oolong"), // Dragon Ball
|
||||
this.GetLocalizedValue("Name.Napoleon"), // Animal Farm
|
||||
this.GetLocalizedValue("Name.Waddles"), // Gravity Falls
|
||||
this.GetLocalizedValue("Name.Crenando"), // Ganondorf
|
||||
this.GetLocalizedValue("Name.Olivia"), // Olivia
|
||||
this.GetLocalizedValue("Name.Wilbur"), // Charlotte's Web
|
||||
this.GetLocalizedValue("Name.Pumbaa"), // The Lion King
|
||||
this.GetLocalizedValue("Name.Peppa"), // Peppa Pig
|
||||
this.GetLocalizedValue("Name.Conan"), // Conan the mighty pig
|
||||
this.GetLocalizedValue("Name.Reuben"), // Minecraft: Story Mode
|
||||
this.GetLocalizedValue("Name.Porky"), // Looney Tunes
|
||||
this.GetLocalizedValue("Name.Hamm"), // Toy Story
|
||||
this.GetLocalizedValue("Name.Runt"), // Chicken Little
|
||||
this.GetLocalizedValue("Name.Roko"), // Roko's Basilisk
|
||||
this.GetLocalizedValue("Name.RichardHamm"), // Pig from Clarkson's Farm named after Richard Hammond
|
||||
|
||||
// Dedicated names
|
||||
};
|
||||
|
||||
public override string GetChat()
|
||||
{
|
||||
WeightedRandom<string> chat = new();
|
||||
|
||||
for (int i = 0; i <= 2; i++)
|
||||
{
|
||||
chat.Add(CalamityUtils.GetText("NPCs.TownPiggy.Chat." + i).Value);
|
||||
}
|
||||
|
||||
return chat;
|
||||
}
|
||||
|
||||
public override void SetChatButtons(ref string button, ref string button2)
|
||||
{
|
||||
button = Language.GetTextValue("UI.PetTheAnimal");
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 275 B |
@@ -0,0 +1,20 @@
|
||||
using System.IO;
|
||||
using CalamityMod.Items.SummonItems.TownPets;
|
||||
using CalamityMod.NPCs.Abyss;
|
||||
using Terraria;
|
||||
|
||||
namespace CalamityMod.Packets
|
||||
{
|
||||
internal sealed class SyncTownPigLicensePacket : CalamityPacket
|
||||
{
|
||||
public static SyncTownPigLicensePacket Instance { get; private set; }
|
||||
|
||||
public static void Send(int toClient = -1, int ignoreClient = -1)
|
||||
{
|
||||
var packet = Instance.CreateBasePacket();
|
||||
packet.Send(toClient, ignoreClient);
|
||||
}
|
||||
|
||||
public override void HandlePacket(BinaryReader packet, int sender) => PiggyLicense.SpawnPiggy();
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ namespace CalamityMod
|
||||
|
||||
spawnedBandit = false;
|
||||
foundHomePermafrost = false;
|
||||
unlockedTownPig = false;
|
||||
|
||||
catName = false;
|
||||
dogName = false;
|
||||
@@ -92,6 +93,8 @@ namespace CalamityMod
|
||||
downed.Add("bandit");
|
||||
if (foundHomePermafrost)
|
||||
downed.Add("archmageHome");
|
||||
if (unlockedTownPig)
|
||||
downed.Add("townPig");
|
||||
|
||||
#region Save Pet Names
|
||||
if (catName)
|
||||
@@ -143,6 +146,7 @@ namespace CalamityMod
|
||||
AcidRainEvent.AcidRainEventIsOngoing = downed.Contains("acidRain");
|
||||
spawnedBandit = downed.Contains("bandit");
|
||||
foundHomePermafrost = downed.Contains("archmageHome");
|
||||
unlockedTownPig = downed.Contains("townPig");
|
||||
|
||||
#region Load Pet Names
|
||||
catName = downed.Contains("catName");
|
||||
@@ -295,6 +299,7 @@ namespace CalamityMod
|
||||
flags12[2] = downedNuclearTerror;
|
||||
flags12[3] = downedBossRush;
|
||||
flags12[4] = DraedonMechdusa;
|
||||
flags12[5] = unlockedTownPig;
|
||||
|
||||
writer.Write(flags);
|
||||
writer.Write(flags2);
|
||||
@@ -449,6 +454,7 @@ namespace CalamityMod
|
||||
downedNuclearTerror = flags12[2];
|
||||
downedBossRush = flags12[3];
|
||||
DraedonMechdusa = flags12[4];
|
||||
unlockedTownPig = flags12[5];
|
||||
|
||||
RecipeUnlockHandler.ReceiveData(reader);
|
||||
|
||||
|
||||
@@ -79,6 +79,8 @@ namespace CalamityMod.World
|
||||
public static bool spawnedBandit = false;
|
||||
/// <summary> If true, the Archmage has lived in a house in this world. Solely used as a condition for dialogue. </summary>
|
||||
public static bool foundHomePermafrost = false;
|
||||
/// <summary> If true, the Town Pig is able to move in. </summary>
|
||||
public static bool unlockedTownPig = false;
|
||||
|
||||
/// <summary> Used for allowing custom Town Cat patreon names. </summary>
|
||||
public static bool catName = false;
|
||||
|
||||
Reference in new issue
Block a user