tModLoader Official tModLoader Help Thread

Ok i understand it now, but how do i apply a OnHitNPC effect to a specific zone like - im in the snow biome and i give frostburn to my enemys
 
I only need to know a few more things, how to make a custom town NPC attack things with a modded sword, and how to make it move in when a certain boss has been defeated.
How to make custom ore shine when a spelunker potion is used and how to make my modded enemies shine when a hunter potion is used.
 
Ok i understand it now, but how do i apply a OnHitNPC effect to a specific zone like - im in the snow biome and i give frostburn to my enemys
You take the earlier code, check in which zone the player is and apply a debuff:
Code:
public class MyModPlayer : ModPlayer // <- Deriving.
{
    public override void OnHitNPC(Item item, NPC target, int damage, float knockback, bool crit) // <- Overriding.
    {
    // Tadaaaa, we're hitting an NPC.
        if(player.ZoneSnow)
        {
            target.AddBuff(BuffID.Frostburn, 300);
        }
    }
}
 
im making an accessory with abilitys based on the current biome your in -
this is the current code without those abilitys added. I want to add abilitys for every biome OnHit abilitys. Is that even possible? Am i doing this wrong?
namespace MiscItems.Items
{
class BiomeBuff : ModItem
{
public override void SetDefaults()
{
item.name = "Biome Buff";
item.accessory = true;
item.width = 16;
item.height = 24;
item.toolTip = "Gives you a buff depending on what biome you are in.";
item.value = 10000000;
item.rare = 8;
}
public override void UpdateAccessory(Terraria.Player player, bool hideVisual)
{
if (player.ZoneBeach) ;
{

}
if (player.ZoneCorrupt) ;
{

}
if (player.ZoneCrimson) ;
{

}
if (player.ZoneDesert) ;
{

}
if (player.ZoneDirtLayerHeight) ;
{

}
if (player.ZoneDungeon) ;
{

}
if (player.ZoneGlowshroom) ;
{

}
if (player.ZoneJungle) ;
{

}
if (player.ZoneMeteor) ;
{

}
if (player.ZoneOldOneArmy) ;
{

}
if (player.ZoneOverworldHeight) ;
{

}
if (player.ZonePeaceCandle) ;
{

}
if (player.ZoneRain) ;
{

}
if (player.ZoneRockLayerHeight) ;
{

}
if (player.ZoneSandstorm) ;
{

}
if (player.ZoneSkyHeight) ;
{

}
if (player.ZoneSnow) ;
{

}
if (player.ZoneTowerNebula) ;
{

}
if (player.ZoneTowerSolar) ;
{

}
if (player.ZoneHoly);
{

}
}
 
I only need to know a few more things, how to make a custom town NPC attack things with a modded sword, and how to make it move in when a certain boss has been defeated.
How to make custom ore shine when a spelunker potion is used and how to make my modded enemies shine when a hunter potion is used.
Those are quite some questions...
I think I'd be able to help you better and faster if we were to chat over at the tModLoader Discord.
You can add me as a friend with Eldrazi#2385
If you do not have Discord, then that's no problem.
 
Do anyone know a list of player.<stuff> to give buff like player.statLife or player.statDefense or player.magicDamage i would like to know them all
 
If you are using Visual Studio when you type player. (bunch of stuff should come up in a dropdown thingy) so just choose what you need
[doublepost=1484753317,1484753267][/doublepost]
If you are using Visual Studio when you type player. (bunch of stuff should come up in a dropdown thingy) so just choose what you need
Making a list of them all would be boring and not fun
 
I would have to make a ModPlayer class with it somehow detecting if the accessory is equiped and giving a buff as you said about the zones and stuff?
 
I would have to make a ModPlayer class with it somehow detecting if the accessory is equiped and giving a buff as you said about the zones and stuff?
Indeed. Detecting the accessory is actually not all that hard. On your ModPlayer create a boolean:
Code:
public bool myAccessoryEquipped;

public override void ResetEffects()
{
    this.myAccessoryEquipped = false;
}
Then over at your accessory, you can do:
Code:
// Inside the UpdateAccessory method:
player.GetModPlayer<MyModPlayer>(mod).myAccessoryEquipped = true;
And then you can use that boolean in the player.
 
Please can someone answer my question
Your question has been answered.
There is no such list (for as far as we know, that is) and compiling one for you would be painstakingly awful, because there are just SO many variables we'd have to list (and their usage next to it too).
Like @Heroriks said before, the best way would be to download a program with Intellisense (like Microsoft Visual Studio).
 
how would you use Intellisense to get the list
When you have (for example) Visual Studio installed, you can add references to certain libraries/dll's/exe's.
When you reference Terraria.exe and with the correct using statements, you can do things like:
Code:
player.
And Intellisense will give you a full list of all variables and methods you can access from that Player instance.
 
public bool myAccessoryEquipped; public override void ResetEffects() { this.myAccessoryEquipped = false; }

Indeed. Detecting the accessory is actually not all that hard. On your ModPlayer create a boolean:
Code:
public bool myAccessoryEquipped;

public override void ResetEffects()
{
this.myAccessoryEquipped = false;
}
Then over at your accessory, you can do:
Code:
// Inside the UpdateAccessory method:
player.GetModPlayer<MyModPlayer>(mod).myAccessoryEquipped = true;
And then you can use that boolean in the player.
i want to create the Modplayer with - If accessory equiped - OnHitNPC if player.zonesnow do frostburn
 
Back
Top Bottom