How to Make a Custom Buff
Comments171this wiki
Redirected from How to make a custom buff
|
Under Construction
|
Contents |
Making a custom buff.
Edit
Setting up a ModPack
Edit
First, if not done already, create a modpack folder in your terraria folder. (C:\Users\You\Documents\My Games\Terraria\Create it here)
Create a folder called "Buff" inside your ModPack folder.
Making your buff
Edit
- Go to your "Buff" folder
- Create a new .ini file, and name it whatever you want your buff to be called (eg. "Frozen")
- Open it, and write your code in:
[Stats] id=-1 ;States that your buff is a custom one tip='I can't move!' ;The message that will appear on mouseover debuff=True ;Can you dispell it by right-clicking on it. (true = you can't)



1. Add a .png file called Frozen.png there, with the image of what you want it to look like. (32x32 is ideal)
2. Make a new file called Frozen.cs, and add the following code into it:
public static void Effects(Player player) {
player.controlUp = false;
player.controlDown = false;
player.controlLeft = false;
player.controlRight = false;
player.controlJump = false;
}
3. Save all the files.
Edit
More Examples
Edit
The Player Class page shows many of the attributes that can be changed with buffs. For example, the following code allows you to reflect damage, walk on hellstone and meteor, walk on water and lava, place tiles really far away, and allows rocket flying!
public static void Effects(Player player) {
player.thorns=true;
player.fireWalk=true;
player.waterWalk=true;
player.blockRange = 20;
player.canRocket=true;
}
Ice Spell
Edit
The NPC Class page shows all of the things you can change with a buff.
A good example of this is a freeze spell.
public static void NPCEffects(NPC npc)
{
npc.velocity.X = npc.velocity.X /2f;
npc.velocity.Y = npc.velocity.Y /2f;
Color color = new Color(0, 144, 255, 100);
npc.color = color;
}
public static void NPCEffectsEnd(NPC npc, int buffType)
{
npc.color = default(Color);
}
Here is a list of what this code does:
Edit
- npc.velocity.x/y sets the npc's velocity.
- color sets the NPC's color
- NPCEffectsEnd executes when the buff ends. The color is reset to default here.
Activating Buffs
Edit
To activate your (de)buff, in any .cs, add
myPlayer.AddBuff("your buff name", 300, false); //set the 300 to buff time
Note: to add buffs from the original game, use the type number of the buff you want to use instead of the name.
myPlayer.AddBuff(28, 10800, false); //Werewolf