tAPI Getting Started with Modding

Status
Not open for further replies.
so i'm making an armour set and here's my c# file for it but for some reason it's not registering as an armour set and i need to change the magic damage to +15% and i cant below 1 for it and that adds +100% does anyone know how to fix this?
upload_2015-6-10_17-59-36.png
 
Ok thank you, but for some reason its not working as an armor set bonus, its giving the bonus when i have the chestpiece equipped instead of the whole set, do you know what's happening?
 
How Would I Make My Mod Test To See If The World Is Corruption Or Crimson
I Want My Mod To Make It So If There World Is Corruption The Texture For My Weapon Is This
EyeRenderer_Corruption.png

I Want It To Make It Look Like This On Crimson Worlds
EyeRenderer.png
 
How Would I Make My Mod Test To See If The World Is Corruption Or Crimson
I Want My Mod To Make It So If There World Is Corruption The Texture For My Weapon Is This
View attachment 57304
I Want It To Make It Look Like This On Crimson Worlds
View attachment 57305
The only way I can think of is this.
First make a class that overrides ModWorld. Override the PostUpdate() hook. Then you'll need to do something like this:
Code:
public override void PostUpdate()
{
    if(!Main.dedServ) //dedicated servers don't store textures, so they don't need to do anything
    {
        int type = ItemDef.byName["ModName:ItemName"].type;
        ModBase modBase = Mods.GetMod("ModName").modBase;
        if(WorldGen.corruption)
        {
            Main.itemTexture[type] = modBase.textures[CorruptionTextureName"]; //for the texture names, include the folders that contain the texture
        }
        else if(WorldGen.crimson)
        {
            Main.itemTexture[type] = modBase.textures["CrimsonTextureName"];
        }
    }
}
 
The only way I can think of is this.
First make a class that overrides ModWorld. Override the PostUpdate() hook. Then you'll need to do something like this:
Code:
public override void PostUpdate()
{
    if(!Main.dedServ) //dedicated servers don't store textures, so they don't need to do anything
    {
        int type = ItemDef.byName["ModName:ItemName"].type;
        ModBase modBase = Mods.GetMod("ModName").modBase;
        if(WorldGen.corruption)
        {
            Main.itemTexture[type] = modBase.textures[CorruptionTextureName"]; //for the texture names, include the folders that contain the texture
        }
        else if(WorldGen.crimson)
        {
            Main.itemTexture[type] = modBase.textures["CrimsonTextureName"];
        }
    }
}
Awesome :)
I Could Use This For So Many Things :p
 
The only way I can think of is this.
First make a class that overrides ModWorld. Override the PostUpdate() hook. Then you'll need to do something like this:
Code:
public override void PostUpdate()
{
    if(!Main.dedServ) //dedicated servers don't store textures, so they don't need to do anything
    {
        int type = ItemDef.byName["ModName:ItemName"].type;
        ModBase modBase = Mods.GetMod("ModName").modBase;
        if(WorldGen.corruption)
        {
            Main.itemTexture[type] = modBase.textures[CorruptionTextureName"]; //for the texture names, include the folders that contain the texture
        }
        else if(WorldGen.crimson)
        {
            Main.itemTexture[type] = modBase.textures["CrimsonTextureName"];
        }
    }
}
It Doesnt Work :p
upload_2015-6-14_13-31-46.png
 
That probably means that the corruption and crimson texture names are wrong. Depending on the folders they're in, I imagine they would be something like this:
"Items/OtherFoldersYouHave/TextureName"
Make sure you don't include the ".png" in the texture name, since the game already adds that for you.
Nvm I Just Had To Add Textures/EyeRenderer_Crimson And Textures/EyeRenderer_Corruption
 
Hello Guys. I just started modding the game and since I can't find any good information on this. I decompiled Terraria.exe with ILSpy(Since that was the only tutorial I found) and looked up the Item.cs files but I was wondering where do all the items get there properties, buffs, particles etc. Only found the basic stuff in there like pickaxe power, damage and value.
 
Hello. I have a question regarding buffs, can you say give an NPC (a slime for example) a buff like health regen?
You would do a similar thing to the buff shown in the original post, except you won't need an End method, instead of using Effects(Player player, int index) you'll be using Effects(NPC npc, int index), and you'll be incrementing npc.lifeRegen in this method.
 
Hi, maybe i can't read or something :p but i can't find any information how to do add particles to my (for the example) sword or how to do made animation of running in armor set ;-;

Sry for my english :joy:
 
You would do a similar thing to the buff shown in the original post, except you won't need an End method, instead of using Effects(Player player, int index) you'll be using Effects(NPC npc, int index), and you'll be incrementing npc.lifeRegen in this method.
So something like this?
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace enhancedenemies.Buffs
{
    public class liferegen : TAPI.ModBuff
    {
        public override void Effects(NPC npc, int index)
        {
            npc.lifeRegen;
        }
    }
}
Would I have to add the lifeRegenCount; in there too?
 
So something like this?
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace enhancedenemies.Buffs
{
    public class liferegen : TAPI.ModBuff
    {
        public override void Effects(NPC npc, int index)
        {
            npc.lifeRegen;
        }
    }
}
Would I have to add the lifeRegenCount; in there too?
Right now, you're not actually doing anything with npc.lifeRegen. You need to actually increment it. So you would replace
Code:
npc.lifeRegen;
with
Code:
npc.lifeRegen += 1;
That will increment npc.lifeRegen by 1, which corresponds to 1 health every 2 seconds.
 
Right now, you're not actually doing anything with npc.lifeRegen. You need to actually increment it. So you would replace
Code:
npc.lifeRegen;
with
Code:
npc.lifeRegen += 1;
That will increment npc.lifeRegen by 1, which corresponds to 1 health every 2 seconds.
Thank you so much. I know this is a small problem for an experienced modder to help with, but I really do appreciate it.

EDIT: Also will this affect all NPC's globally, or do I have to assign it in an npc's code? (the latter is what I want so not all npc's have this buff)
 
Last edited:
Thank you so much. I know this is a small problem for an experienced modder to help with, but I really do appreciate it.

EDIT: Also will this affect all NPC's globally, or do I have to assign it in an npc's code? (the latter is what I want so not all npc's have this buff)
Since this is code for a buff, it will affect all enemies that have the buff. So what you can do is make a class that extends ModNPC, give it the GlobalMod attribute, then use if statements checking for the NPC's type to apply the buff.
 
Since this is code for a buff, it will affect all enemies that have the buff. So what you can do is make a class that extends ModNPC, give it the GlobalMod attribute, then use if statements checking for the NPC's type to apply the buff.
Alright, I got my buff code:
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace enhancedenemies.Buffs
{
    public class RegenBasic : TAPI.ModBuff
    {
        public override void Effects(NPC npc, int index)
        {
            npc.lifeRegen += 1;
        }
    }
}

And I got my code that overwrites the vanilla NPC's (Just a small test sample).
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using TAPI;
using Terraria;

namespace ModInternalName
{
    [GlobalMod]
    public class MNPC : ModNPC
    {
        public override void OnSpawn()
        {
            if (npc.type == 3)
            {
                npc.lifeMax = 160;
                npc.life = 16;
            } 
        }
    }
}
If the buff code works, what line do I add to the NPC's if statement to give it the buff?
 
Status
Not open for further replies.
Back
Top Bottom