diff --git a/.vs/NekoTweakMod/DesignTimeBuild/.dtbcache.v2 b/.vs/NekoTweakMod/DesignTimeBuild/.dtbcache.v2 index 1d4965b..2089688 100644 Binary files a/.vs/NekoTweakMod/DesignTimeBuild/.dtbcache.v2 and b/.vs/NekoTweakMod/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/NekoTweakMod/v16/.suo b/.vs/NekoTweakMod/v16/.suo index c9d1ad3..d1fcd6b 100644 Binary files a/.vs/NekoTweakMod/v16/.suo and b/.vs/NekoTweakMod/v16/.suo differ diff --git a/Fishing/AddModdedCrateToForest.cs b/Fishing/AddModdedCrateToForest.cs index 870ca63..3c5b74b 100644 --- a/Fishing/AddModdedCrateToForest.cs +++ b/Fishing/AddModdedCrateToForest.cs @@ -23,15 +23,19 @@ public class AddModdedCrateToForest : ModPlayer } public override void CatchFish(Item fishingRod, Item bait, int power, int liquidType, int poolSize, int worldLayer, int questFish, ref int caughtType, ref bool junk) { - if (liquidType == 2 && Main.rand.Next(1) == 0) // if hardmode + // if hardmode + if (Main.hardMode && liquidType == 2 && Main.rand.Next(100) == 100) // Liquid types, 0 is water, 1 is lava, 2 is honey - // Main.rand.Next(1) == 0) is the catch % chance to catch the Crate - // n/100 chance or 1 = 100% + // Main.rand.Next(1, 100) == 0) is the catch % chance to catch the Crate & the chance required to get it + // n/100 chance or 1 = 1% + // Main.rand.Next(100), Would generates a number between 0 & 99 instead if there is no specified chance + { caughtType = ItemType(); } { - if (liquidType == 2 && Main.rand.Next(1) == 0) // if prehardmode + // if prehardmode + if (!Main.hardMode && liquidType == 2 && Main.rand.Next(100) == 100) { caughtType = ItemType(); } @@ -39,8 +43,29 @@ public override void CatchFish(Item fishingRod, Item bait, int power, int liquid } } } + +// how to check "if" hardmode examples~ +//Main.hardMode +//NPC.downedSlimeKing + /* + Main.rand explanations + +Main.rand.Next(100) +^this picks a number between 0 and 99 +Main.rand.Next(100) generates a number between 0 and 99 + +Next(5, 10) will get you the values 5, 6, 7, 8, 9 +Just like how Next(5) will only get you 0, 1, 2, 3, 4 and not 5 + Main.rand.Next(1) == 0) -Main.rand.NextBool(97) -^^how do these even work~ -*/ \ No newline at end of file +Main.rand.Next(100) == 0) == 0 is the same as 1/100 or 1% + +Main.rand.NextBool(97, 100) // 97% chance +Next(min, max) will get you a value from min to (max - 1) + +Main.rand.NextBool(100) is the same as Main.rand.Next(100) == 0 +also Next(100) can't return 100 + +Lyker,Teok,iScalieable & absoluteAquarian, trying to explain this to me^ +*/ diff --git a/Fishing/CrateSpriteExamples.png b/Fishing/CrateSpriteExamples.png new file mode 100644 index 0000000..436fc0e Binary files /dev/null and b/Fishing/CrateSpriteExamples.png differ diff --git a/Fishing/Items/AddItemToCrate.cs b/Fishing/Items/AddItemToCrate.cs index 0feb47f..5dba89e 100644 --- a/Fishing/Items/AddItemToCrate.cs +++ b/Fishing/Items/AddItemToCrate.cs @@ -13,44 +13,44 @@ public override void OpenVanillaBag(string context, Player player, int arg) // Context in this case specifies what type of thing we are opening, has to be one of these: "present", "bossBag", "crate", "lockBox", "herbBag", or "goodieBag" // arg specifies the itemid of the present/bag/crate we are trying to open { - // "number/100" or "1 = 100%" chance/rng & Itemid Specifies the item to give to the player + // "number/100" or 1 = 1% chance & Itemid Specifies the item to give to the player // Each item here will roll individually, so its possible for several of them to drop together with each other // They will also not share any specific present/bag/crate loot pool with any other items // This means they will always get a chance to roll 100% of the time when a present/bag/crate is used - // if (Main.rand.NextBool(33)) player.QuickSpawnItem(ItemID.sandstorm in a bottle); - // if (Main.rand.NextBool(25)) player.QuickSpawnItem(ItemID.Meowmere); - // if (Main.rand.NextBool(50)) player.QuickSpawnItem(ItemID.PlanteraBossBag); - // if (Main.rand.NextBool(75)) player.QuickSpawnItem(ItemID.HotlineFishingHook); + // if (Main.rand.NextBool(33, 100)) player.QuickSpawnItem(ItemID.sandstorm in a bottle); + // if (Main.rand.NextBool(25, 100)) player.QuickSpawnItem(ItemID.Meowmere); + // if (Main.rand.NextBool(50, 100)) player.QuickSpawnItem(ItemID.PlanteraBossBag); + // if (Main.rand.NextBool(75, 100)) player.QuickSpawnItem(ItemID.HotlineFishingHook); } { if (context == "crate" && arg == ItemID.oasiscratehardmode) // hardmode oasis crate { - if (Main.rand.NextBool(33)) player.QuickSpawnItem(ItemID.WoodenSword); + if (Main.rand.NextBool(33, 100)) player.QuickSpawnItem(ItemID.WoodenSword); } } { if (context == "crate" && arg == ItemID.oceancrate) { - if (Main.rand.NextBool(95)) player.QuickSpawnItem(ItemID.WaterWalkingBoots); // 5% chance for each ocean biome crate + if (Main.rand.NextBool(5, 100)) player.QuickSpawnItem(ItemID.WaterWalkingBoots); // 5% chance for each ocean biome crate } } { if (context == "crate" && arg == ItemID.oceancratehardmode) // hard mode version of ocean crate { - if (Main.rand.NextBool(95)) player.QuickSpawnItem(ItemID.WaterWalkingBoots); + if (Main.rand.NextBool(5, 100)) player.QuickSpawnItem(ItemID.WaterWalkingBoots); } } { if (context == "crate" && arg == ItemID.lavacrate) { - if (Main.rand.NextBool(97)) player.QuickSpawnItem(ItemID.LavaCharm); // 3% chance for each lava crate + if (Main.rand.NextBool(3, 100)) player.QuickSpawnItem(ItemID.LavaCharm); // 3% chance for each lava crate } } { if (context == "crate" && arg == ItemID.lavacrate) // hardmode version of lava crate { - if (Main.rand.NextBool(97)) player.QuickSpawnItem(ItemID.LavaCharm); + if (Main.rand.NextBool(3, 100)) player.QuickSpawnItem(ItemID.LavaCharm); } } } diff --git a/Fishing/Tiles/ForestCratePlaced.png b/Fishing/Tiles/ForestCratePlaced.png index 23e3b8d..436fc0e 100644 Binary files a/Fishing/Tiles/ForestCratePlaced.png and b/Fishing/Tiles/ForestCratePlaced.png differ diff --git a/Items/ModifyEquipment.cs b/Items/ModifyEquipment.cs index 075752f..82f7a18 100644 --- a/Items/ModifyEquipment.cs +++ b/Items/ModifyEquipment.cs @@ -4,14 +4,20 @@ namespace NekoTweakMod.Items { - public class ModifyEquipment : GlobalItem // class name & vanilla hook + public class ModifyEquipment : GlobalItem + // class name & GlobalItem hook(this allows us to change vanilla items) + // The GlobalItem hooks have an "item" parameter + // so we have to check if that "item" type is what we are looking for when trying to specify an itemid + // this is why we have to do for example (item.type == itemid.slimestaff) and not + // only itemid.slimestaff like we would in the ModItem hooks when we try to specify a specific vanilla item { public override void SetDefaults(Item item) // SetDefaults allows you to set/change properties of items { - // if (item.type == ItemID.BabyBirdStaff) // disabled until tmod v1.4 + // disabled until tmod v1.4 + // if (item.type == ItemID.BabyBirdStaff) // Checks the item type & the items itemid // specifies what item to change { - // item.damage = 9; // changes the items damage + // item.damage = 9; // changes the specified items damage //item.knockBack = 0; } if (item.type == ItemID.WormScarf) item.defense = 2; // Single line if statement as we are only changing 1 property diff --git a/NPCs/AddLootToNPC.cs b/NPCs/AddLootToNPC.cs new file mode 100644 index 0000000..26f286d --- /dev/null +++ b/NPCs/AddLootToNPC.cs @@ -0,0 +1,33 @@ +using Terraria.ID; +using Terraria; +using Terraria.ModLoader; + +namespace NekoTweakMod.Items +{ + public class AddLootToNPC : GlobalNPC // class name & global npc hook, allows us to change properties of NPCs/Mobs + { + public override void NPCLoot(NPC npc) // allows you to change what happens when an npc dies, in this case we are adding loot + { + if (npc.type == NPCID.BigMimicJungle)// && NPC.downedGolemBoss) // if the npc type is this specific npc & golem has been defated + { + // "number/100" or 1 = 1% chance & Itemid Specifies the item to give to the player + if (Main.rand.NextBool(33, 100)) // 33% or 33/100 chance to drop + { + Item.NewItem(npc.getRect(), ItemID.SpikyBallTrap, 15); // adds the specified itemid as a new loot/drop for the npc and makes 15 of the item drop at once + } + if (Main.rand.NextBool(33, 100)) + { + Item.NewItem(npc.getRect(), ItemID.FlameTrap, 15); + } + if (Main.rand.NextBool(33, 100)) + { + Item.NewItem(npc.getRect(), ItemID.SpearTrap, 15); + } + if (Main.rand.NextBool(33, 100)) + { + Item.NewItem(npc.getRect(), ItemID.SuperDartTrap, 15); + } + } + } + } +} \ No newline at end of file diff --git a/NPCs/JungleMimicChestSummon.cs b/NPCs/JungleMimicChestSummon.cs new file mode 100644 index 0000000..25ebd33 --- /dev/null +++ b/NPCs/JungleMimicChestSummon.cs @@ -0,0 +1,106 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace NekoTweakMod.NPCs +// need to add few more explanations for stuffs, don't understand everything in here~ +{ + // Code for Spawning/summoning a Jungle Mimic when a Temple Key is placed in a chest + public class JungleMimicChestSummon : ModPlayer + { + public int LastChest; // sets up a integer named "LastChest" + + public override void PreUpdateBuffs() // This is called before buff updates to the player happens + { // chest check + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (player.chest == -1 && LastChest >= 0 && Main.chest[LastChest] != null) // checks if the last chest used was empty when closed + { + int x2 = Main.chest[LastChest].x; + int y2 = Main.chest[LastChest].y; + ChestItemSummonCheck(x2, y2, mod); + } + LastChest = player.chest; + } + } + + public override void UpdateAutopause() + // Allows the mimic to spawn in single player while autopause is on + { + LastChest = player.chest; + } + // The actuall code for summoning/spawning a npc when an item is left in a chest + public static bool ChestItemSummonCheck(int x, int y, Mod mod) + { + if (Main.netMode == NetmodeID.MultiplayerClient || !Main.hardMode) // if its not hardmode the code will return false and wont spawn the mimic + { + return false; // stops the code if the world is not in the hardmode state + } + int num = Chest.FindChest(x, y); + if (num < 0) // checks the number of keys in the chest + { + return false; // stops the code if there are no temple keys in the chest + } + int numberofKeys = 0; // integer value for checking amount of keys + int numberOtherItems = 0; // integer value for checking if there are any other items in the chest + ushort tileType = Main.tile[Main.chest[num].x, Main.chest[num].y].type; + int tileStyle = (int)(Main.tile[Main.chest[num].x, Main.chest[num].y].frameX / 36); + if (TileID.Sets.BasicChest[tileType] && (tileStyle < 5 || tileStyle > 6)) + { + for (int i = 0; i < 40; i++) + { + if (Main.chest[num].item[i] != null && Main.chest[num].item[i].type > ItemID.None) // if the chest don't have any items in it, there are no temple keys in it + { + if (Main.chest[num].item[i].type == ItemID.TempleKey) // What item that should be used for this npc spawning/summoning + { + numberofKeys += Main.chest[num].item[i].stack; + } + else + { + numberOtherItems++; + } + } + } + } + if (numberOtherItems == 0 && numberofKeys == 1) // If there are no other items the chest & and there is 1 temple key in it + { + + if (TileID.Sets.BasicChest[Main.tile[x, y].type]) // checks if the tile is a chest + { + if (Main.tile[x, y].frameX % 36 != 0) + { + x--; + } + if (Main.tile[x, y].frameY % 36 != 0) + { + y--; + } + int number = Chest.FindChest(x, y); + for (int j = x; j <= x + 1; j++) + { + for (int k = y; k <= y + 1; k++) + { + if (TileID.Sets.BasicChest[Main.tile[j, k].type]) // Checks if the tile exist ???? + { + Main.tile[j, k].active(false); + } + } + } + for (int l = 0; l < 40; l++) + { + Main.chest[num].item[l] = new Item(); + } + Chest.DestroyChest(x, y); // removes the chest tile without dropping a chest item + NetMessage.SendData(MessageID.ChestUpdates, -1, -1, null, 1, (float)x, (float)y, 0f, number, 0, 0); + NetMessage.SendTileSquare(-1, x, y, 3); + } + int npcToSpawn = NPCID.BigMimicJungle; // What npc to spawn, in this case a Jungle Mimic + int npcIndex = NPC.NewNPC(x * 16 + 16, y * 16 + 32, npcToSpawn, 0, 0f, 0f, 0f, 0f, 255); // Determine where the npc will spawn + Main.npc[npcIndex].whoAmI = npcIndex; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npcIndex, 0f, 0f, 0f, 0, 0, 0); + Main.npc[npcIndex].BigMimicSpawnSmoke(); // Does the mimic smoke summoning animation + } + return false; // stops the code + } + } +} \ No newline at end of file diff --git a/build.txt b/build.txt index 9c1fe34..c822e6a 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ displayName = Neko's Tweak Mod author = Neko -version = 0.1.2.2 +version = 0.1.2.3 homepage = https://forums.terraria.org/index.php?threads/nekos-tweak-mod.93711/ -buildIgnore = obj\*, bin\*, IconBannerArt\*, *.csproj, .git\*, .gitattributes, .gitignore, .sln, ..vs\*, LICENSE \ No newline at end of file +buildIgnore = obj\*, bin\*, IconBannerArt\*, *.csproj, .git\*, .gitattributes, .gitignore, .sln, ..vs\*, LICENSE, Items.vs\* , .vs\* \ No newline at end of file diff --git a/obj/Debug/net45/NekoTweakMod.csprojAssemblyReference.cache b/obj/Debug/net45/NekoTweakMod.csprojAssemblyReference.cache index c15212c..8194505 100644 Binary files a/obj/Debug/net45/NekoTweakMod.csprojAssemblyReference.cache and b/obj/Debug/net45/NekoTweakMod.csprojAssemblyReference.cache differ