Standalone [1.3] tModLoader - A Modding API

Put this in the swords.cs
Code:
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            player.statLife += 6; //Heals by 6; Can be changed of course
            player.HealEffect(6); //Shows a green 6 above your head to show you've been healed; Can be changed of course
        }
[doublepost=1463240110,1463239980][/doublepost] I'm pretty sure if you just return true for public override bool CanTownNPCSpawn(int numTownNPCs, int money), that town npc will move in when he can. Aka, only a table, wall and chairs are required.

I found it out myself C:

But i have an another Question
Do you know how to make an Item only Drop in an Specifik Biome?
also how the
if ()
whould looks like
 
Does anybody know how to make it so it can either be copper or tin in a crafting recipe?
In your Mod.cs, put this.
Code:
public override void AddCraftGroups()
        {
            AddCraftGroup("AnyCopperBar", Lang.misc[37] + " Copper Bar ", ItemID.CopperBar, ItemID.TinBar);

        }
and within the item you want to utilize that, put this in the recipe like you would recipe.AddIngredient(ItemID.Item, 1);

Code:
recipe.AddCraftGroup(null, "AnyCopperBar");
 
How can I add a special on hit healing effect to a melee weapon?

Can't we add buffs to item like this:

public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
{
player.AddBuff("GrievingRusherBuff");

}


because if I do it can't build the mod, it says this error:

c:\Users\LKF\Documents\My Games\Terraria\ModLoader\Mod Sources\Primum\Items\Weapons\GrievingRusher.cs(50,4) : error CS1501: No overload for method 'AddBuff' takes 1 arguments.

The 50 row is the " player.AddBuff("GrievingRusherBuff"); "
 
Can we controll how often does the buff something in the buff.cs?
For e.g. the buff heals only every second once.

For now the full code looks like this:


using Terraria;
using Terraria.ModLoader;

namespace Primum.Buffs
{
public class GrievingRusherBuff : ModBuff
{
public override void SetDefaults()
{
Main.buffName[this.Type] = "Grieving heal";
Main.buffTip[this.Type] = "You are healed by dealing damage!";
canBeCleared = false;
}

public override void Update(Player player, ref int buffIndex)
{
int extra = player.buffTime[buffIndex] / 60;
player.buffTime[buffIndex] -= extra;
player.statLife += 1;
}

public override bool ReApply(Player player, int time, int buffIndex)
{
player.buffTime[buffIndex] += time;
return true;
}
}
}
 
Last edited:
How whould see the out the Set Defaults for an NPC with these Sprite?
LoneTrapper.png

I dont get the Animaton to work,in Some Animations He Disappers or there is the little Part of the Legs over him
 
Hey, does anybody know how to make a variable that would be static for all the players in a multiplayer game? I made a jukebox which has a bool variable showing if it is playing or not, but it's only true for the one person who turns it on. Can I make it true for all the other players as well somehow?

Or maybe I'm thinking use one of the Net- classes Terraria has, except I have no idea how. Been digging through NetMessage but didn't figure it out.
 
Last edited:
Hey, does anybody know how to make a variable that would be static for all the players in a multiplayer game? I made a jukebox which has a bool variable showing if it is playing or not, but it's only true for the one person who turns it on. Can I make it true for all the other players as well somehow?

Or maybe I'm thinking use one of the Net- classes Terraria has, except I have no idea how. Been digging through NetMessage but didn't figure it out.
Usually the frame is what determines the state of a tile. A variable won't work since all tiles of a type share the same class. The music boxes and fountains all work that way.
 
Is it possible for a townie to have a second button next to the Shop? Saaayyy something like a Quest function, perhaps?
Due to the way Terraria's programmed, each town NPC can only have up to 2 functional buttons. So you can have both Shop and Quest, but you won't be able to have anything else.

@bluemagic123 will ,ac users ever be able to create mods?
It's already possible. It just requires more programming experience than with Windows; and if you're making a mod, you should already have programming experience anyways.

And another semi-related question: how would one have a townie's shop contents reset every day?
In general that's done by checking the phase of the moon.
 
Back
Top Bottom