tModLoader Potion Code?

Lukas04

Official Terrarian
I want to make a Mod About Potions but,I Curently dont know how to Code a Potion
and i dont find an Buff Potion in the Example Mod

So can anyone tell me how to make a Potion/Consumable that gives an Buff?
 
It doesent have the drinking sound, but im too lazy to add that in. anyways, hope it helps





using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace yourmod.Potions
{
public class potion : ModItem
{
public override void SetDefaults()
{
item.name = "Potion";
item.width = 12;
item.height = 26;
item.maxStack = 99;
AddTooltip("ayy");
item.value = 500;
item.rare = 3;
item.useAnimation = 30;
item.useTime = 30;
item.useStyle = 4;
item.consumable = true;
}

public override bool UseItem(Player player)
{
player.AddBuff(BuffID.Ironskin, 7200);
player.AddBuff(BuffID.Swiftness, 7200);
return true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(Terraria.ID.ItemID.Bottle, 1);
recipe.AddTile(14);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}
}
}
 
It doesent have the drinking sound, but im too lazy to add that in. anyways, hope it helps





using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace yourmod.Potions
{
public class potion : ModItem
{
public override void SetDefaults()
{
item.name = "Potion";
item.width = 12;
item.height = 26;
item.maxStack = 99;
AddTooltip("ayy");
item.value = 500;
item.rare = 3;
item.useAnimation = 30;
item.useTime = 30;
item.useStyle = 4;
item.consumable = true;
}

public override bool UseItem(Player player)
{
player.AddBuff(BuffID.Ironskin, 7200);
player.AddBuff(BuffID.Swiftness, 7200);
return true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(Terraria.ID.ItemID.Bottle, 1);
recipe.AddTile(14);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}
}
}

I already found it out,but thanks!
 
Back
Top Bottom