FANDOM


Difficulty: Difficulty-2
Clock: 5 to 10 minutes


RequirementsEdit

Have Tconfig properly installed.

It is reccommended that another tutorial about creating custom objects be completed first, such as making a custom weapon or making an accessory.

Making a custom buffEdit

Setting up a ModPackEdit

First, if not done already, create a ModPack folder inside your terraria data folder (C:\Users\Username\Documents\My Games\Terraria\ModPacks by default).

Create a folder called "Buff" inside your ModPack folder.

Buff .ini creationEdit

  1. Go to your "Buff" folder
  2. Create a new .ini file, and name it whatever you want your buff to be called. In this tutorial we will use the name "Frozen". This means our .ini file will be named "Frozen.ini".
  3. Open it, and write the following code in:
[Stats]
id=-1
tip='I can't move!'
debuff=True

The "id=-1" line means your buff is a custom buff. This causes the tconfig program to look for custom code and image when loading your buff into the game.

The "tip='I can't move!' " line is what shows up when you move your mouse over the buff on your status bar.

The "debuff=True" line is what tells the game that this is a debuff. The difference between a buff and a debuff is that a debuff can't be removed by right-clicking on it. Some debuffs are "Silenced "or "On Fire!", while some examples of buffs are "Ironskin" or "Shine"

Buff .png creationEdit

Blankdebuff

A blank debuff image for editing.

Blankbuff

A blank buff image for editing.

Add a .png file called Frozen.png there, with the image of what you want it to look like. This is the icon that will show up when your player is under the effects of your custom buff. A size around 32x32 should be good. Here are a few pictures to get you started:

Remember, debuffs usually have a red background and can't be removed by right clicking them. Buffs are usually on a blue background and CAN be dispelled by right clicking them.

Buff .cs creationEdit

Make a new file called Frozen.cs, also in the "Buff" folder, 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;
}

The method Effects() is called while your player is under the effects of your buffs (smart naming, huh?). Pretty much any kind of coding could be written here, like increasing the spawn rate of things around you, or randomly dropping money from the sky. However this particular example has 5 nearly similar commands, "player.controlX = false;" meaning nearly the same thing. They reference the Player Class and access the controlX booleans (true/false) and set them to false, meaning the player won't be able to use up/down/left/right/jump while the buff is on them.

The first line says Effects(Player player) which means the player that has the buff on them can be referenced using player.somethingFromPlayerClass. Check the page out and you can see other things about players you can modify from this buff!

More ExamplesEdit

Using the Player ClassEdit

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.

Frozen

Frozen Buff Made by:Virtulox

  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);
}

NPCEffects is called whenever an NPC (town npcs, enemies, bosses, etc) is under the effects of the buff.

  • npc.velocity.x/y = value Sets the npc's velocity to a float value.
  • npc.color=color Sets the NPC's color attribute to "color" which was just set up.

NPCEffectsEnd is called when the buff ends on an npc.

  • npc.color = default The NPC's color is reset to the default color of the NPC.

Activating BuffsEdit

To activate a buff/debuff on yourself, under the correct effects portion of a .cs file, 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

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.