Standalone [1.3] tModLoader - A Modding API

So i have an odd question. I'm working on several accessories right now and one of them combines the Worm Scarf with another accessory. I could not figure out the player. usage that would apply a 17% damage reduction after defense is calculated. So i tried using player.brokenArmor = 1.1f; (brokenArmor sets, or used to set, a multiplier for defense) but it was asking for a Bool, and worked fine building wise with it set to true. So, after that long intro to my question, do you know how to either set a after defense calculated damage reduction(like the worm scarf) or at least a defense multiplier that works? thank you for the insight.
 
So i have an odd question. I'm working on several accessories right now and one of them combines the Worm Scarf with another accessory. I could not figure out the player. usage that would apply a 17% damage reduction after defense is calculated. So i tried using player.brokenArmor = 1.1f; (brokenArmor sets, or used to set, a multiplier for defense) but it was asking for a Bool, and worked fine building wise with it set to true. So, after that long intro to my question, do you know how to either set a after defense calculated damage reduction(like the worm scarf) or at least a defense multiplier that works? thank you for the insight.
I found this for the worm scarf code:
this.endurance += 0.17f;
So I assume you would do something like this:
player.endurance += /*insert reduction here*/;
 
I found this for the worm scarf code:
this.endurance += 0.17f;
So I assume you would do something like this:
player.endurance += /*insert reduction here*/;
Thanks, may i ask where you "find" this information so i don't have to ask every time? (give a man a fish, he wont be hungry for a day....teach a man to fish...)
 
Thanks, may i ask where you "find" this information so i don't have to ask every time? (give a man a fish, he wont be hungry for a day....teach a man to fish...)
First, I find the worm scarf's ID by searching in the ItemID class. Then in the Player class I go to the UpdateEquips method and search for the ID there.
 
So I'm trying to create a magma shield accessory and it says there is a missing texture
68696-ea49c4ba7cd8b5a42e67726110d5dc3f.jpg
Here is the code for the magma shield which I used the example shield to help me a lot
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace CoolWeapons.Items {
public class MagmaShield : ModItem
{
public override bool Autoload(ref string name, ref string texture, ref EquipType? equip)
{
equip = EquipType.Shield;
return true;
}

public override void SetDefaults()
{
item.width = 24;
item.height = 28;
item.toolTip = "Slightly increases life regeneration";
item.value = 10000;
item.rare = 2;
item.accessory = true;
item.defense = 3;
item.lifeRegen = 2;
}

public override void UpdateAccessory(Player player)
{
player.magmaStone = true;
}
}}

Also here is the code for the mod file
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using CoolWeapons.Items;

namespace CoolWeapons {
public class CoolWeapons : Mod
{
public override void SetModInfo(out string name, ref ModProperties properties)
{
name = "CoolWeapons";
properties.Autoload = true;
}

public override void Load()
{
AddItem("Platinum Katana", new PlatinumKatana(), "CoolWeapons/Items/PlatinumKatana");

AddItem("Mega Gold Sword", new MegaGoldSword(), "CoolWeapons/Items/MegaGoldSword");

AddItem("Diamond Sword", new DiamondSword(), "CoolWeapons/Items/DiamondSword");

AddItem("Magma Shield", new MagmaShield(), "CoolWeapons/Items/MagmaShield");
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.PlatinumBar, 20);
recipe.SetResult(null, "Platinum Katana");
recipe.AddRecipe();
recipe.AddTile(TileID.Anvils);

recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.GoldBar, 20);
recipe.SetResult(null, "Mega Gold Sword");
recipe.AddRecipe();
recipe.AddTile(TileID.Anvils);

recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.Diamond, 15);
recipe.SetResult(null, "Diamond Sword");
recipe.AddRecipe();
recipe.AddTile(TileID.Anvils);

recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.HellstoneBar, 15);
recipe.SetResult(null, "Magma Shield");
recipe.AddRecipe();
recipe.AddTile(TileID.Anvils);
}
}}
 

Attachments

  • 2015-08-04_00001.jpg
    2015-08-04_00001.jpg
    153.7 KB · Views: 342
So I'm trying to create a magma shield accessory and it says there is a missing texture
68696-ea49c4ba7cd8b5a42e67726110d5dc3f.jpg
Here is the code for the magma shield which I used the example shield to help me a lot
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace CoolWeapons.Items {
public class MagmaShield : ModItem
{
public override bool Autoload(ref string name, ref string texture, ref EquipType? equip)
{
equip = EquipType.Shield;
return true;
}

public override void SetDefaults()
{
item.width = 24;
item.height = 28;
item.toolTip = "Slightly increases life regeneration";
item.value = 10000;
item.rare = 2;
item.accessory = true;
item.defense = 3;
item.lifeRegen = 2;
}

public override void UpdateAccessory(Player player)
{
player.magmaStone = true;
}
}}

Also here is the code for the mod file
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using CoolWeapons.Items;

namespace CoolWeapons {
public class CoolWeapons : Mod
{
public override void SetModInfo(out string name, ref ModProperties properties)
{
name = "CoolWeapons";
properties.Autoload = true;
}

public override void Load()
{
AddItem("Platinum Katana", new PlatinumKatana(), "CoolWeapons/Items/PlatinumKatana");

AddItem("Mega Gold Sword", new MegaGoldSword(), "CoolWeapons/Items/MegaGoldSword");

AddItem("Diamond Sword", new DiamondSword(), "CoolWeapons/Items/DiamondSword");

AddItem("Magma Shield", new MagmaShield(), "CoolWeapons/Items/MagmaShield");
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.PlatinumBar, 20);
recipe.SetResult(null, "Platinum Katana");
recipe.AddRecipe();
recipe.AddTile(TileID.Anvils);

recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.GoldBar, 20);
recipe.SetResult(null, "Mega Gold Sword");
recipe.AddRecipe();
recipe.AddTile(TileID.Anvils);

recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.Diamond, 15);
recipe.SetResult(null, "Diamond Sword");
recipe.AddRecipe();
recipe.AddTile(TileID.Anvils);

recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.HellstoneBar, 15);
recipe.SetResult(null, "Magma Shield");
recipe.AddRecipe();
recipe.AddTile(TileID.Anvils);
}
}}
Did you make sure to make a png file with the same name and in the same folders as that error is telling you?
 
Ok, new problem :p some part of UpdateAccessory seems to be wonky for me. I have just tried two of my new accessories(one at a time to isolate the problem) and when either one of them is in my mod, the game crashes at setting up after building the mod fine, then trying to reload. I then tried your example shield(slightly modified to work with my file names) and the same problem occurred.I tried using the error loggers in the accessory but nothing was written in the logs. here is the code for my accessory if its needed.
Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace WyvernCore.Items {
public class HeavyHeart : ModItem
{
    public override bool Autoload(ref string name, ref string texture, ref EquipType? equip)
    {
        equip = EquipType.Body;
        return true;
    }

    public override void SetDefaults()
    {
        item.name = "Heavy Heart";
        item.width = 24;
        item.height = 28;
        item.toolTip = "A Heart weighed down with sadness.";
        item.toolTip2 = "Increases Health and Immune time.";
        item.value = 10000;
        item.rare = 4;
        item.accessory = true;
        ErrorLogger.Log("test");
    }
    public override void UpdateAccessory(Player player)
    {
        player.immuneTime = 3;
        player.statLifeMax2 += 40;
        ErrorLogger.Log("test2");
    }
    public override void AddRecipes()
    {
        ModRecipe recipe = new ModRecipe(mod);
        recipe.AddIngredient("DirtBlock");
        //recipe.AddIngredient(null,"LifeHeart");
        recipe.SetResult(this);
        recipe.AddRecipe();
        ErrorLogger.Log("test3");
    }
}
}
thanks again
 
Ok, new problem :p some part of UpdateAccessory seems to be wonky for me. I have just tried two of my new accessories(one at a time to isolate the problem) and when either one of them is in my mod, the game crashes at setting up after building the mod fine, then trying to reload. I then tried your example shield(slightly modified to work with my file names) and the same problem occurred.I tried using the error loggers in the accessory but nothing was written in the logs. here is the code for my accessory if its needed.
Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace WyvernCore.Items {
public class HeavyHeart : ModItem
{
    public override bool Autoload(ref string name, ref string texture, ref EquipType? equip)
    {
        equip = EquipType.Body;
        return true;
    }

    public override void SetDefaults()
    {
        item.name = "Heavy Heart";
        item.width = 24;
        item.height = 28;
        item.toolTip = "A Heart weighed down with sadness.";
        item.toolTip2 = "Increases Health and Immune time.";
        item.value = 10000;
        item.rare = 4;
        item.accessory = true;
        ErrorLogger.Log("test");
    }
    public override void UpdateAccessory(Player player)
    {
        player.immuneTime = 3;
        player.statLifeMax2 += 40;
        ErrorLogger.Log("test2");
    }
    public override void AddRecipes()
    {
        ModRecipe recipe = new ModRecipe(mod);
        recipe.AddIngredient("DirtBlock");
        //recipe.AddIngredient(null,"LifeHeart");
        recipe.SetResult(this);
        recipe.AddRecipe();
        ErrorLogger.Log("test3");
    }
}
}
thanks again
Does anything get written to the Runtime Error file in the Logs folder? Most crashes will write the error message to that file.
 
No, theirs nothing in the logs folder right now.
So it's crashing at the Setting up content part?
That's the part where it resizes all the arrays then gets the textures for everything. Resizing arrays should never cause any errors, and if something goes wrong with getting the textures an error message should pop up, so I'm not completely sure what's happening... wait a minute... I just realized, my exception-handling code doesn't cover the textures for worn equipment. I'll fix this for the next update, and for now I would double check your equipment-on-player texture names.

Well I have 2 png files for the magma shield, both in the items folder. MagmaShield.png and MagmaShield_Shield.png
Your Items folder starts with a capital I, and that's inside a folder called CoolWeapons, right? If so, then the only thing I can think of at the moment would be checking for typos.
 
So it's crashing at the Setting up content part?
That's the part where it resizes all the arrays then gets the textures for everything. Resizing arrays should never cause any errors, and if something goes wrong with getting the textures an error message should pop up, so I'm not completely sure what's happening... wait a minute... I just realized, my exception-handling code doesn't cover the textures for worn equipment. I'll fix this for the next update, and for now I would double check your equipment-on-player texture names.


Your Items folder starts with a capital I, and that's inside a folder called CoolWeapons, right? If so, then the only thing I can think of at the moment would be checking for typos.
Yup, that makes sense, im 95% that's why its crashing then, is there a way for your accessorizes to not show up? would i just leave the worn accessory texture blank?
 
Yup, that makes sense, im 95% that's why its crashing then, is there a way for your accessorizes to not show up? would i just leave the worn accessory texture blank?
If you don't want the accessories to show on the player (like how the Discount Card doesn't show), then you would just not give it any EquipType. All that's needed to be able to equip an accessory is for item.accessory to be set to true in SetDefaults.
 
I cant really mod, or at least haven't tried to, so I was wondering if someone could make a tutorial video for it? Or maybe do some modding for me?
 
I cant really mod, or at least haven't tried to, so I was wondering if someone could make a tutorial video for it? Or maybe do some modding for me?
I highly highly recommend if you want to get into modding to first look at some c# tutorials. (just the basics, nothing too complex) and then when you can understand the code and the formatting, look through the example mod provided, start simple, and have fun modding.
 
I highly highly recommend if you want to get into modding to first look at some c# tutorials. (just the basics, nothing too complex) and then when you can understand the code and the formatting, look through the example mod provided, start simple, and have fun modding.
You see the problem with that is my knowledge is so non-existent in the field of modding that dint even know what c# is. I mean, obviously its a type of code, right?
 
Your Items folder starts with a capital I, and that's inside a folder called CoolWeapons, right? If so, then the only thing I can think of at the moment would be checking for typos.
I got it to work! I think there was a typo on the MagmaShield.png file, because I renamed it and carefully typed "MagmaShield" and then it worked.
 
You see the problem with that is my knowledge is so non-existent in the field of modding that dint even know what c# is. I mean, obviously its a type of code, right?
Yes it is. C# is the main coding language that is used to make mods using Tmodloader (I think you use something else for really really complicated scripts*don't quote me :p *) and is rather easy to understand with very little knowledge of coding. So just look up c# tutorials, theirs one on msdn(one of the top sites) and just look through to the versioning tutorial and you should have a good start to modding, then i would say jump in and look at the example mod, then slowly alter that until you feel comfortable with starting your own mod from scratch(don't post your altered example mod, that would be stealing)
 
Back
Top Bottom