Standalone [1.3] tModLoader - A Modding API

Sorry to disturb, I created a simple object by copying the .cs file from the Example Mod and changing the namespace and name.
The mod is created but when I play the object is not there, Thanks in advance

using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MiaPrimaMod.Items
{
public class Item1 : ModItem
{
public override void SetDefaults()
{
item.name = "item";
item.width = 20;
item.height = 20;
item.maxStack = 999;
AddTooltip(":.)");
item.value = 100;
item.rare = 1;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.SetResult(this, 999);
recipe.AddRecipe();
}
}
}
 
Sorry to disturb, I created a simple object by copying the .cs file from the Example Mod and changing the namespace and name.
The mod is created but when I play the object is not there, Thanks in advance

using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MiaPrimaMod.Items
{
public class Item1 : ModItem
{
public override void SetDefaults()
{
item.name = "item";
item.width = 20;
item.height = 20;
item.maxStack = 999;
AddTooltip(":.)");
item.value = 100;
item.rare = 1;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.SetResult(this, 999);
recipe.AddRecipe();
}
}
}
In the ExampleMod, there's also a file called 'ExampleMod.cs'. You'll also want the base of this file (which is just the class and the SetModInfo function). Just make sure to change the naming.
 
thank you so much, it worked ;)
But why it was this "error" ?
You see the line in the newly added class that says 'properties.Autoload = true;' ?
That makes sure all items are automatically added to the game/mod. If you did not set this to true, you would have to add each item manually (which can be quite the pain).
 
Can you pleeeeeeeeeeeeeeeeeaaaaaaaaaaase fix the mod browser for mac? i would really like to look at the large amounts of mods.(and probably get some)
 
Can you pleeeeeeeeeeeeeeeeeaaaaaaaaaaase fix the mod browser for mac? i would really like to look at the large amounts of mods.(and probably get some)
There is actually an alternative to the Mod Browser for Linux and Mac (untill the issue is fixed I guess) which you can find here.
 
So in my GlobalNPC.cs file, I have this little snippet of code. Problem is, the melee attacks aren't doing extra damage like I thought they would. I'm trying to make the attacks deal extra damage depending on the how much life the enemy has lost. Is my math wrong or does that "damage" not function like I was thinking? Any help would be appreciated, as always!
Code:
public override void OnHitByItem(NPC npc, Player player, Item item, int damage, float knockback, bool crit)
        {
            ThoriumNPCInfo info = (ThoriumNPCInfo)npc.GetModInfo(mod, "ThoriumNPCInfo");
           
            if (info.berserkBurn)
            {
                damage = item.damage + ((npc.lifeMax - npc.life) / 10);
            }
        }
 
So in my GlobalNPC.cs file, I have this little snippet of code. Problem is, the melee attacks aren't doing extra damage like I thought they would. I'm trying to make the attacks deal extra damage depending on the how much life the enemy has lost. Is my math wrong or does that "damage" not function like I was thinking? Any help would be appreciated, as always!
Code:
public override void OnHitByItem(NPC npc, Player player, Item item, int damage, float knockback, bool crit)
        {
            ThoriumNPCInfo info = (ThoriumNPCInfo)npc.GetModInfo(mod, "ThoriumNPCInfo");
          
            if (info.berserkBurn)
            {
                damage = item.damage + ((npc.lifeMax - npc.life) / 10);
            }
        }
You actually want to use this hook for that. You're doing it right, but changing variables in this function will not result in anything outside this function ;)
 
You actually want to use this hook for that. You're doing it right, but changing variables in this function will not result in anything outside this function ;)
Off the top of your head, do you know of an equation I could use that would make you deal more damage when the enemy had more health, as opposed to less?
 
Off the top of your head, do you know of an equation I could use that would make you deal more damage when the enemy had more health, as opposed to less?
Depends, do you want to use the max health or the current health in relation to the max health?
 
Off the top of your head, do you know of an equation I could use that would make you deal more damage when the enemy had more health, as opposed to less?
You could try taking the logarithm of the NPC's health then add that to the damage. (Maybe even the logarithm of the logarithm?)
 
Hmm well, that could be a bit nasty since there are NPCs with 20 health, but also NPCs with 20,000 health, right?...
I suppose what I would really be looking for is bonus damage based on a percent of the enemies life, not so much a flat increase. Maybe its not reasonable in a balance aspect...
You could try taking the logarithm of the NPC's health then add that to the damage. (Maybe even the logarithm of the logarithm?)
So I would wanna use inverse exponential growth to make it do less and less damage?

Edit - I found a decent enough solution, were good. :)
 
Last edited:
hello! I got this error about the thorium mod..i ASSUME it means I'm running way too many mods..at at 11 mods at once..i can see how that would be the problem..here it is

Insufficient memory to continue the execution of the program.
at Microsoft.Xna.Framework.Helpers.GetExceptionFromResult(UInt32 result)
at Microsoft.Xna.Framework.Audio.SoundEffect.AllocateFormatAndData(Byte[] format, Byte[] data, Int32 offset, Int32 count)
at Microsoft.Xna.Framework.Audio.SoundEffect..ctor(Stream stream)
at Microsoft.Xna.Framework.Audio.SoundEffect.FromStream(Stream stream)
at Terraria.ModLoader.ModLoader.LoadMod(TmodFile modFile, BuildProperties properties)
at Terraria.ModLoader.ModLoader.LoadMods()

edit: disabled about 3 small mods..clicked on singleplayer..decided to delete my old characters/worlds..noticed they wouldn't delete for some reason..made a new character/world..and the game crashed while loading the world...well this isn't good
 
Li'll question:
Does anyone know how to prevent the drawing of wings on a player when (lets say) a certain buff is active?
 
how would I make a custom container with a custom UI? I didnt find anything helpful in the ExampleMod
If I were you, I'd wait with that untill proper UI hooks are implemented (or you must be willing to dive into the source of Terraria).
 
Back
Top Bottom