Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Added Jungle mimic & fixed pre/hardmode crate
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsukino-uwu committed Jun 11, 2020
1 parent 9ce1d5e commit 143644c
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 22 deletions.
Binary file modified .vs/NekoTweakMod/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/NekoTweakMod/v16/.suo
Binary file not shown.
39 changes: 32 additions & 7 deletions Fishing/AddModdedCrateToForest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,49 @@ 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<Fishing.Items.ForestCrate>();
}
{
if (liquidType == 2 && Main.rand.Next(1) == 0) // if prehardmode
// if prehardmode
if (!Main.hardMode && liquidType == 2 && Main.rand.Next(100) == 100)
{
caughtType = ItemType<Fishing.Items.ForestCrate>();
}
}
}
}
}

// 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~
*/
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^
*/
Binary file added Fishing/CrateSpriteExamples.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions Fishing/Items/AddItemToCrate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
Binary file modified Fishing/Tiles/ForestCratePlaced.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions Items/ModifyEquipment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions NPCs/AddLootToNPC.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
}
106 changes: 106 additions & 0 deletions NPCs/JungleMimicChestSummon.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
}
4 changes: 2 additions & 2 deletions build.txt
Original file line number Diff line number Diff line change
@@ -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
buildIgnore = obj\*, bin\*, IconBannerArt\*, *.csproj, .git\*, .gitattributes, .gitignore, .sln, ..vs\*, LICENSE, Items.vs\* , .vs\*
Binary file modified obj/Debug/net45/NekoTweakMod.csprojAssemblyReference.cache
Binary file not shown.

0 comments on commit 143644c

Please sign in to comment.