tAPI [Discontinued] tAPI - A Mod To Make Mods

Status
Not open for further replies.
I was trying to make a new tile, and everything seemed right, but then i get this error when i press "Reload mods":

TAPI.Mods+LoadException: Miscular Mod.tapi: System.NullReferenceException: Object reference not set to an instance of an object.
at TAPI.ModJsonHandler.HandleTile(ModBase modBase, JsonData j, String fname)
at TAPI.ModJsonHandler.Handle(ModBase modBase)
at TAPI.Mod.<Load>b__0(BinBuffer bb)
at TAPI.Mods.HandleTapiModFile(FPath path, Action`1 action)
at TAPI.Mods.HandleModFile(FPath path, Action`1 action)
at TAPI.Mod.Load()
at TAPI.Mods.Load()
at TAPI.Mods.Load()

Also, when i enter a world, it crashes, gives a windows error or just gives that same error. I tried to delete the tile from the mod folder and it worked well. Any suggestions?
 
I have added Wall Clocks to my mod. But how I can make them to act like Clocks? So pressing right mouse button will show the time like Grandfather Clock.
 
A quick question. I am trying to change the gore of some enmies in Terraria. I can successfylly change the texture of items, projectiles and NPCs but when i try to do it with gore I get an error. I use this code in ModBase to change the gore.
public override void OnAllModsLoaded()
{
Main.goreTexture[57] = textures["textures/57"];
}

But when I try to do that I get this error when I reload my mod.

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item( key)
at Dragonborn.MBase.OnAllModsLoaded() in \Dragonborn Mod\MBase.cs at line 42
at TAPI.Hooks.Call(System.Action[] ts)
at TAPI.Mods.Load()

It's something wrong with the line where i try to change the gore but I just don't know what's wrong.
 
Thank you so much for your advice. PostGameUpdate happened too soon for what I wanted, so I tried PostGameDraw again. I tried that hook once before, but it caused the game to crash. I don't know what I did wrong the first time, but it resets properly now.

As for the nullable rectangle, I'd been trying several different things there and left it like that for some reason. I ended up using 'new Rectangle(0, 0, 40, 56)' to prevent the head from animating.

Onto other issues, I use the following code in my NPC's script to control its direction.

Code:
//tar is a reference to the player ... deltaX is the horizontal distance between the NPC and the player
if (deltaX > 16 && npc.velocity.X > -6) //If to the right of the player and not at maximum left velocity and not up against a wall
{
    npc.velocity.X = (npc.velocity.X <= -6) ? -6 : npc.velocity.X -= 0.3F; //Accelerate left, but not too fast
    npc.direction = -1; //Face left
} else if (deltaX < -16 && npc.velocity.X < 6) //If to the left of the player and not at maximum right velocity and not up against a wall
{
    npc.velocity.X = (npc.velocity.X >= 6) ? 6 : npc.velocity.X += 0.3F; //Accelerate right, but not too fast
    npc.direction = 1; //Face right
} else //Otherwise
{
    npc.velocity.X -= (npc.velocity.X - tar.velocity.X) * 0.3F; //Match the player's speed
    npc.direction = tar.direction; //Face the same way as the player
}
/*more code here*/

public override void SelectFrame(int frameSize)
{
    npc.spriteDirection = npc.direction;
//other animation code...

This worked the way I intended in R13, but in R14 the NPC faces the wrong way when next to the player, yet the correct way when running towards the player. I outputted the NPC's direction and spriteDirection to an interface layer. Sometimes they were different to each other even though there was no situation where 'npc.spriteDirection = npc.direction;' wasn't called.

I plan to change this NPC into a projectile so I'm not too concerned about this, but I'd be curious to know why it happened. (Yes, I have a lot of work ahead of me.)

One final thing, I think I may have found another bug. The first time someone uses a minecart on a server, the game lags for a moment and the following message pops up in the server window.

Code:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Terraria.Mount.GetHeightBoost(Int32 MountType)
   at Terraria.Player.GrappleMovement()
   at Terraria.Player.UpdatePlayer(Int32 i)
   at Terraria.Main.UpdateReal(GameTime gameTime)
Press Enter to continue

The game continues as normal without any more issues. I tested this with no mods enabled so it's not my mod causing this issue. It could be my world file though...

Anyway, thanks for bearing with me.
You are aware that position is in pixels, right? Did you divide deltaX by 16? Otherwise, you're telling it to accelerate towards the player if it's further than a single tile, it could be passing the player in such a small distance and then stopping.

The Minecart thing is known, it's because some of the minecart code in tAPI is only being run by the client. Hasn't been fixed yet, largely because I'm not 100% sure what parts of that code can be run on the server. I'll have to dig into it when I get the time.

I need alot of help with my TAPI mod.
Code:
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using Terraria;
using TAPI;


namespace T727Mod.Items
{

     public class M4A1 : ModItem
     {
         byte wheelmanager = -0;
         public override bool CanEquip(Player player, TAPI.UIKit.ItemSlot slot)
         {
             int CurrentClip = 30 ;
             int ClipSize = 30 ;  //Clip size base
             int FireRate = 9 ;  //in FPS, the higher, the slower
             int ReloadTime = 132 ;  //2.2 sec reload
                if (CurrentClip == 0 )
                 {
                    System.Diagnostics.Stopwatch reloader = new System.Diagnostics.Stopwatch();
                    Dictionary<int, Texture2D> wheelSprites = new Dictionary<int, Texture2D>();
                    wheelSprites.Add(0, Content.Load<Texture2D>("ReloadbarEmpty"));
                    wheelSprites.Add(1, Content.Load<Texture2D>("Reloadbar1of19"));
                    wheelSprites.Add(2, Content.Load<Texture2D>("Reloadbar2of19"));
                    wheelSprites.Add(3, Content.Load<Texture2D>("Reloadbar3of19"));
                    wheelSprites.Add(4, Content.Load<Texture2D>("Reloadbar4of19"));
                    wheelSprites.Add(5, Content.Load<Texture2D>("Reloadbar5of19"));
                    wheelSprites.Add(6, Content.Load<Texture2D>("Reloadbar6of19"));
                    wheelSprites.Add(7, Content.Load<Texture2D>("Reloadbar7of19"));
                    wheelSprites.Add(8, Content.Load<Texture2D>("Reloadbar8of19"));
                    wheelSprites.Add(9, Content.Load<Texture2D>("Reloadbar9of19"));
                    wheelSprites.Add(10, Content.Load<Texture2D>("Reloadbar10of19"));
                    wheelSprites.Add(11, Content.Load<Texture2D>("Reloadbar11of19"));
                    wheelSprites.Add(12, Content.Load<Texture2D>("Reloadbar12of19"));
                    wheelSprites.Add(13, Content.Load<Texture2D>("Reloadbar13of19"));
                    wheelSprites.Add(14, Content.Load<Texture2D>("Reloadbar14of19"));
                    wheelSprites.Add(15, Content.Load<Texture2D>("Reloadbar15of19"));
                    wheelSprites.Add(16, Content.Load<Texture2D>("Reloadbar16of19"));
                    wheelSprites.Add(17, Content.Load<Texture2D>("Reloadbar17of19"));
                    wheelSprites.Add(18, Content.Load<Texture2D>("Reloadbar18of19"));
                    wheelSprites.Add(19, Content.Load<Texture2D>("Reloadbar19of19"));
                    if (reloader.ElapsedMilliseconds %150 < 1)
                    {
                        wheelmanager += 1;
                        if (wheelmanager == 20)
                        {
                            wheelmanager = 0;

                        }
                  }
             }
         }
     }
}
I dont get what does %150 < 1 mean.
How can I trace a character's object material number inside his inventory?
Why in gods name are you loading sprites in the middle of item code? tAPI loads sprites for you, you should never have to load them again, just use modBase.textures to get them. Also, I don't think CanEquip is the right spot for what you're doing, considering you have stuff for a clip, you may be looking for CanUse? Not entirely sure what you're trying to do though.

"% 150" means modulus 150, google it if you want, it's a math function. It basically divides the value by 150, and gives you the remainder instead of the result. I shouldn't have to tell you what "< 1" means, it's just checking if the result from the modulus is below 1 (basically, if it equals 0)

I was trying to make a new tile, and everything seemed right, but then i get this error when i press "Reload mods":

TAPI.Mods+LoadException: Miscular Mod.tapi: System.NullReferenceException: Object reference not set to an instance of an object.
at TAPI.ModJsonHandler.HandleTile(ModBase modBase, JsonData j, String fname)
at TAPI.ModJsonHandler.Handle(ModBase modBase)
at TAPI.Mod.<Load>b__0(BinBuffer bb)
at TAPI.Mods.HandleTapiModFile(FPath path, Action`1 action)
at TAPI.Mods.HandleModFile(FPath path, Action`1 action)
at TAPI.Mod.Load()
at TAPI.Mods.Load()
at TAPI.Mods.Load()

Also, when i enter a world, it crashes, gives a windows error or just gives that same error. I tried to delete the tile from the mod folder and it worked well. Any suggestions?
It is very hard to help without seeing anything of your mod. It would appear you did something wrong, either with your tile, or with something your tile references.

I have added Wall Clocks to my mod. But how I can make them to act like Clocks? So pressing right mouse button will show the time like Grandfather Clock.
You have to use ModTileType.OnRightClick, and manually calculate and output the time yourself, as far as I know. Most vanilla tile behaviour is hardcoded, so you have to copy it in your own code.

A quick question. I am trying to change the gore of some enmies in Terraria. I can successfylly change the texture of items, projectiles and NPCs but when i try to do it with gore I get an error. I use this code in ModBase to change the gore.
public override void OnAllModsLoaded()
{
Main.goreTexture[57] = textures["textures/57"];
}

But when I try to do that I get this error when I reload my mod.

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item( key)
at Dragonborn.MBase.OnAllModsLoaded() in \Dragonborn Mod\MBase.cs at line 42
at TAPI.Hooks.Call(System.Action[] ts)
at TAPI.Mods.Load()

It's something wrong with the line where i try to change the gore but I just don't know what's wrong.
Read the error, it says something wasn't found, meaning either goreTexture[57] doesn't exist (I doubt it) or your "textures/57" is wrong, which is my bet. Everything is case sensitive, so if the directory is "Textures", you'll get an error.
 
Hello! I have recently installed tAPI, (yesterday actually) and played the game for a couple of hours w/o any problems. But when I tried launching tAPI through Steam, (the same way I had launched it yesteryday) its been giving me the finger. It says "tAPI has stopped working" whenever I launch Terraria.
-
I checked the Log on the 'Logs' Folder and this is the only message displayed there:

>>> 23:40:32 <<<
LitJson.JsonException: Invalid character ' ' in input string
at LitJson.Lexer.NextToken()
at LitJson.JsonReader.ReadToken()
at LitJson.JsonReader.Read()
at LitJson.JsonMapper.ReadValue(LitJson.WrapperFactory factory, LitJson.JsonReader reader)
at LitJson.JsonMapper.ToObject(System.String json)
at Terraria.Main.OpenSettings()
at Terraria.Main.Initialize()
at Microsoft.Xna.Framework.Game.RunGame(System.Boolean useBlockingRun)
at Terraria.Program.Main(System.String[] args)

Now, I'm a nubcaik at coding so I have no clue what that means. If anyone can help me, I'd appreciate it. :)
 
Hello! I have recently installed tAPI, (yesterday actually) and played the game for a couple of hours w/o any problems. But when I tried launching tAPI through Steam, (the same way I had launched it yesteryday) its been giving me the finger. It says "tAPI has stopped working" whenever I launch Terraria.
-
I checked the Log on the 'Logs' Folder and this is the only message displayed there:

>>> 23:40:32 <<<
LitJson.JsonException: Invalid character ' ' in input string
at LitJson.Lexer.NextToken()
at LitJson.JsonReader.ReadToken()
at LitJson.JsonReader.Read()
at LitJson.JsonMapper.ReadValue(LitJson.WrapperFactory factory, LitJson.JsonReader reader)
at LitJson.JsonMapper.ToObject(System.String json)
at Terraria.Main.OpenSettings()
at Terraria.Main.Initialize()
at Microsoft.Xna.Framework.Game.RunGame(System.Boolean useBlockingRun)
at Terraria.Program.Main(System.String[] args)

Now, I'm a nubcaik at coding so I have no clue what that means. If anyone can help me, I'd appreciate it. :)
How in the hell :dryadwhat: I'm curious, how did you close the game? This looks like a variation of another common issue, that I have no idea what is causing. Did you just close on the main menu, force close it somehow, etc?

Anyways, to fix the issue, deleting the "Config.json" file at "My Documents/My Games/Terraria/tAPI" should do. This will also erase any changes to vanilla options though, so you know, so if you changed any keybindings you'll have to redo them.
 
How in the hell :dryadwhat: I'm curious, how did you close the game? This looks like a variation of another common issue, that I have no idea what is causing. Did you just close on the main menu, force close it somehow, etc?

Anyways, to fix the issue, deleting the "Config.json" file at "My Documents/My Games/Terraria/tAPI" should do. This will also erase any changes to vanilla options though, so you know, so if you changed any keybindings you'll have to redo them.

When I was logged into the game, I just clicked on "SAVE & EXIT", that brought me to the main menu. From the main menu, I clicked on "Exit" to close down the game. :eek:
-
Thanks so much, I can access tAPI without any problems again. haha :)

EDIT: Now I get this error whenever I choose the character then the world I was previously playing on:

>>> 00:54:12 <<<
Ionic.Zip.ZipException: Cannot read that as a ZipFile
at Ionic.Zip.ZipFile.ReadIntoInstance(Ionic.Zip.ZipFile zf)
at Ionic.Zip.ZipFile.Read(System.String fileName, System.IO.TextWriter statusMessageWriter, System.Text.Encoding encoding, System.EventHandler`1[[Ionic.Zip.ReadProgressEventArgs, Ionic.Zip.Reduced, Version=1.9.1.9000, Culture=neutral, PublicKeyToken=null]] readProgress)
at Terraria.WorldFile.ActualLoadWorld(System.String world)
at Terraria.WorldFile.loadWorld()
at Terraria.WorldGen.playWorldCallBack(System.Object threadContext)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object state)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Ionic.Zip.BadReadException: Bad signature (0x00000000) at position 0x0030CAF3
at Ionic.Zip.ZipEntry.ReadHeader(Ionic.Zip.ZipEntry ze, System.Text.Encoding defaultEncoding)
at Ionic.Zip.ZipEntry.ReadEntry(Ionic.Zip.ZipContainer zc, System.Boolean first)
at Ionic.Zip.ZipFile.ReadIntoInstance_Orig(Ionic.Zip.ZipFile zf)
at Ionic.Zip.ZipFile.ReadIntoInstance(Ionic.Zip.ZipFile zf)

Again, I know absolutely nothing about ^ :(
 
Last edited:
When I was logged into the game, I just clicked on "SAVE & EXIT", that brought me to the main menu. From the main menu, I clicked on "Exit" to close down the game. :eek:
-
Thanks so much, I can access tAPI without any problems again. haha :)

EDIT: Now I get this error whenever I choose the character then the world I was previously playing on:

>>> 00:54:12 <<<
Ionic.Zip.ZipException: Cannot read that as a ZipFile
at Ionic.Zip.ZipFile.ReadIntoInstance(Ionic.Zip.ZipFile zf)
at Ionic.Zip.ZipFile.Read(System.String fileName, System.IO.TextWriter statusMessageWriter, System.Text.Encoding encoding, System.EventHandler`1[[Ionic.Zip.ReadProgressEventArgs, Ionic.Zip.Reduced, Version=1.9.1.9000, Culture=neutral, PublicKeyToken=null]] readProgress)
at Terraria.WorldFile.ActualLoadWorld(System.String world)
at Terraria.WorldFile.loadWorld()
at Terraria.WorldGen.playWorldCallBack(System.Object threadContext)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object state)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Ionic.Zip.BadReadException: Bad signature (0x00000000) at position 0x0030CAF3
at Ionic.Zip.ZipEntry.ReadHeader(Ionic.Zip.ZipEntry ze, System.Text.Encoding defaultEncoding)
at Ionic.Zip.ZipEntry.ReadEntry(Ionic.Zip.ZipContainer zc, System.Boolean first)
at Ionic.Zip.ZipFile.ReadIntoInstance_Orig(Ionic.Zip.ZipFile zf)
at Ionic.Zip.ZipFile.ReadIntoInstance(Ionic.Zip.ZipFile zf)

Again, I know absolutely nothing about ^ :(
It seems like the mod in the mod folder is in zip format. tAPI can't read it. Change it to .tapi if it's in the Local Folder, or extract it if it's in the Sources folder.
 
{
"displayName": "TestItem",
"texture": "Items/Test",
"size": [32, 32],
"maxStack": 99,
"value": [0, 5, 0, 0],
"rare": 1,
"tooltip": "Just a Test",

"recipies":
[{
"items": { "Dirt Block": 1 },
"tiles": [ "Work Bench" ],
"creates": 1
}]
}

No errors, but the Item won't show up in the crafting menu. The image is a .png, everything else is saved as .json; the mod is enabled and reloaded correctly (1/1 mod loaded. I also tried it without the rarity, but that won't work either. :confused:
I hope the problem isn't too hard to fix. :)
 
No errors, but the Item won't show up in the crafting menu. The image is a .png, everything else is saved as .json; the mod is enabled and reloaded correctly (1/1 mod loaded. I also tried it without the rarity, but that won't work either. :confused:
I hope the problem isn't too hard to fix. :)
you misspelled "recipes"
 
It seems like the mod in the mod folder is in zip format. tAPI can't read it. Change it to .tapi if it's in the Local Folder, or extract it if it's in the Sources folder.
Wrong, all tapi files are zips.

When I was logged into the game, I just clicked on "SAVE & EXIT", that brought me to the main menu. From the main menu, I clicked on "Exit" to close down the game. :eek:
-
Thanks so much, I can access tAPI without any problems again. haha :)

EDIT: Now I get this error whenever I choose the character then the world I was previously playing on:

>>> 00:54:12 <<<
Ionic.Zip.ZipException: Cannot read that as a ZipFile
at Ionic.Zip.ZipFile.ReadIntoInstance(Ionic.Zip.ZipFile zf)
at Ionic.Zip.ZipFile.Read(System.String fileName, System.IO.TextWriter statusMessageWriter, System.Text.Encoding encoding, System.EventHandler`1[[Ionic.Zip.ReadProgressEventArgs, Ionic.Zip.Reduced, Version=1.9.1.9000, Culture=neutral, PublicKeyToken=null]] readProgress)
at Terraria.WorldFile.ActualLoadWorld(System.String world)
at Terraria.WorldFile.loadWorld()
at Terraria.WorldGen.playWorldCallBack(System.Object threadContext)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object state)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Ionic.Zip.BadReadException: Bad signature (0x00000000) at position 0x0030CAF3
at Ionic.Zip.ZipEntry.ReadHeader(Ionic.Zip.ZipEntry ze, System.Text.Encoding defaultEncoding)
at Ionic.Zip.ZipEntry.ReadEntry(Ionic.Zip.ZipContainer zc, System.Boolean first)
at Ionic.Zip.ZipFile.ReadIntoInstance_Orig(Ionic.Zip.ZipFile zf)
at Ionic.Zip.ZipFile.ReadIntoInstance(Ionic.Zip.ZipFile zf)

Again, I know absolutely nothing about ^ :(
Did you try copying a world from vanilla to tAPI, or is this the world from tAPI? If this is a vanilla world thats the problem, but if its a tAPI world, the file might have gotten corrupted somehow :dryadconfused:

If it's a tAPI world, go into the "My Documents/My Games/Terraria/tAPI/Worlds" directory, and check for a "worldname.wld.bak" file. Delete the original, and remove the .bak from the backup one, and then load up the game and try loading that. You may have lost some progress though, warning.

Not sure why you're having so many file saving issues, do you have some programming doing something with your files, like backing them up or something? Both error's you've had look like the game failed to properly save to your hard drive.
 
I keep getting this crash whenever I kill a mob, or at least I think it's when I killed a mob.
System.NullReferenceException: Object reference not set to an instance of an object.
at TAPI.LootRule.Restore()
at Terraria.NPC.NPCLoot()
at Terraria.NPC.checkDead()
at Terraria.NPC.StrikeNPC(System.Int32 Damage, System.Single knockBack, System.Int32 hitDirection, System.Boolean crit = False, System.Boolean noEffect = False, System.Single critMult = 2)
at Terraria.Projectile.Damage()
at Terraria.Projectile.Update(System.Int32 i)
at Terraria.Main.UpdateReal(Microsoft.Xna.Framework.GameTime gameTime)
 
I keep getting this crash whenever I kill a mob, or at least I think it's when I killed a mob.
System.NullReferenceException: Object reference not set to an instance of an object.
at TAPI.LootRule.Restore()
at Terraria.NPC.NPCLoot()
at Terraria.NPC.checkDead()
at Terraria.NPC.StrikeNPC(System.Int32 Damage, System.Single knockBack, System.Int32 hitDirection, System.Boolean crit = False, System.Boolean noEffect = False, System.Single critMult = 2)
at Terraria.Projectile.Damage()
at Terraria.Projectile.Update(System.Int32 i)
at Terraria.Main.UpdateReal(Microsoft.Xna.Framework.GameTime gameTime)
That's the error I would get upon attempting to (probably incorrectly) add some LootRules. Are you/your mods doing anything similar?
 
That's the error I would get upon attempting to (probably incorrectly) add some LootRules. Are you/your mods doing anything similar?
Here is my code.
Code:
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Reflection;
using LitJson;

using TAPI;
using Terraria;
using Pumpking.Items;
using Pumpking.Projectiles;
using Pumpking.NPCs;

namespace Pumpking.Items
{
    [GlobalMod]
    public class MNPC : ModNPC
    {
    public override void SetupLootRules(NPC npc)
    {
    LootRule.AddFor("Pumpking",
    new LootRule().Chance(8.0 / 1.0).Item("Pumpking:SoulOfSpight")
    );
    }
    }
}
 
Apparently, in r14, there's a small oversight where Shockah forgot to set LootRules.settingUp to true, so setting it to true before you do your `AddFor` should fix it.
I think I put it in the wrong place.
Code:
namespace Pumpking.Items
{
    [GlobalMod]
    public class MNPC : ModNPC
    {
    public override void SetupLootRules(NPC npc)
    {
     LootRules.settingUp = true;
    LootRule.AddFor("Pumpking",
    new LootRule().Chance(8.0 / 1.0).Item("Pumpking:SoulOfSpight")
    );
    }
    }
}
 
I think I put it in the wrong place.
Code:
namespace Pumpking.Items
{
    [GlobalMod]
    public class MNPC : ModNPC
    {
    public override void SetupLootRules(NPC npc)
    {
     LootRules.settingUp = true;
    LootRule.AddFor("Pumpking",
    new LootRule().Chance(8.0 / 1.0).Item("Pumpking:SoulOfSpight")
    );
    }
    }
}

It's where it should be, and everything looks fine, except for `8.0 / 1.0`, making the chance 800% instead of `1.0 / 8.0` which would be 12.5%.
 
It's where it should be, and everything looks fine, except for `8.0 / 1.0`, making the chance 800% instead of `1.0 / 8.0` which would be 12.5%.
Yea, I got the drop chance covered.
But when I compile it, I get this.
MNPC.cs (3,23)
The name 'LootRules' does not exist in the current context
LootRules.settingUp = true;
^
 
Status
Not open for further replies.
Back
Top Bottom