tModLoader Official tModLoader Help Thread

Hello :)

Currently I´m trying to implement a level system but I can´t increase any stats only life and mana.
Every time I call my function in my class, that interihance ModPlayer, I want to increase the maximum life and melee damage multiplier.
The function is called every time I enter a chat command like:
/skill str
Code:
player.statLife += 20;
player.statLifeMax += 20;
player.statLifeMax2 += 20;
player.meleeDamage *= 1.2f;

The problem is that he increases the maximum hp but the melee damage remains unaffected.

I also tried with many other [player.*] properties but only the following properties are working:
Code:
player.statLife += 20;
player.statLifeMax += 20;
player.statLifeMax2 += 20;
player.statMana += 10;
player.statManaMax += 10;
player.statManaMax2 += 10;

Other properties do nothing like:
Code:
player.rangedDamage += 0.1f;
player.magicDamage += 0.1f;
player.meleeSpeed += 0.1f;
player.meleeDamage += 0.1f;
The way to do this is to only change the ..Max2 variables for mana and life. The damage ones should work too. The problem is you are likely not doing these changes every frame like you should.
 
Hello :)

Currently I´m trying to implement a level system but I can´t increase any stats only life and mana.
Every time I call my function in my class, that interihance ModPlayer, I want to increase the maximum life and melee damage multiplier.
The function is called every time I enter a chat command like:
/skill str
Code:
player.statLife += 20;
player.statLifeMax += 20;
player.statLifeMax2 += 20;
player.meleeDamage *= 1.2f;

The problem is that he increases the maximum hp but the melee damage remains unaffected.

I also tried with many other [player.*] properties but only the following properties are working:
Code:
player.statLife += 20;
player.statLifeMax += 20;
player.statLifeMax2 += 20;
player.statMana += 10;
player.statManaMax += 10;
player.statManaMax2 += 10;

Other properties do nothing like:
Code:
player.rangedDamage += 0.1f;
player.magicDamage += 0.1f;
player.meleeSpeed += 0.1f;
player.meleeDamage += 0.1f;

You must change these values on every frame, so it's wiser if your command saves the amount in variables which an update function in the modplayer derived class can call and apply.
 
So a friend of mine recently installed tModLoader on mac. When he opens it, it closes after 5 seconds with no error.
 
How do i update to a newer version?
I Tried myself but i didnt work and now i got an error ;-;
upload_2016-7-23_3-16-40.png

What i did was copy the newer version of tModLoader files and overwrited the old ones.
 
You create just a projectile in the AI of the projectile than you want. I cannot help you, because this is very easy, this thing ^^'. ExampleMod exist for help you for that. It have example
 
Like other sound, this:
mod.GetSoundSlot(SoundType.Item, "Sounds/Item/...");

SoundType.Item check in the folder Sounds/Item, but change maybe other thing in the sound, you can use visualstudio for check the other folders.
 
Last edited:
In ModTile, specifically the ModifyLight() method as taken from the ExampleMod ExampleTorch:
Code:
        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            Tile tile = Main.tile[i, j];
            if (tile.frameX < 66) { r = g = b = 0.9f; }
        }

What does the '66' in the if statement control?
 
In ModTile, specifically the ModifyLight() method as taken from the ExampleMod ExampleTorch:
Code:
        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            Tile tile = Main.tile[i, j];
            if (tile.frameX < 66) { r = g = b = 0.9f; }
        }

What does the '66' in the if statement control?
66 is the x value for the 4th frame of the torch. So, if the torch is in state 0,1, or 2, make light, otherwise don't.
ExampleTorch.png
 
How do i make it so that after using the item, it plays a sound (like the vortex beater, it makes that pumping sound)?
 
i have two question (and before asked, ive searched like everywhere in the examplemod and found none of those ^^'):
1: how do I make a enemy spawn after defeating a certain enemy/boss?
2: how do I make a usable item restore health (also I tried everything that came up my mind XD)?
 
1)a) If you want say than a enemy can spawn only after defeating a certain enemy/boss, you need just add a condition on the canspawn of the enemy (after, if this is a vanilla enemy, no idea ^^)
1)b) if this is than you want spawn a enemy just after defeating a npc, you put just a npc spawn in the npcloot of the boss/enemy.(do not forgot test in multi also)

2) You need use method useItem and just put a heal effect. You can use button search in this subject (or the other help subject) and VisualStudio.
 
Why doesn't this seem to work 100% of the time for spawning a worm boss in multiplayer?
Code:
public override bool CanUseItem(Player player)
{
return player.ZoneDesert && !NPC.AnyNPCs(mod.NPCType("DesertScourgeHead")) && !NPC.AnyNPCs(mod.NPCType("DesertScourgeBody")) && !NPC.AnyNPCs(mod.NPCType("DesertScourgeTail"));
}

public override bool UseItem(Player player)
{
Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);
if (Main.netMode != 1)
{
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("DesertScourgeHead"));
}
else
{
NetMessage.SendData(61, -1, -1, "", player.whoAmI, mod.NPCType("DesertScourgeHead"), 0f, 0f, 0, 0, 0);
}
return true;
}

EDIT: Figured out I don't even need to check the netMode.
 
Last edited:
How can I decrease the size of an MP3 file without destroying the sound quality of the music? I have a file that is around 4MB and I've already trimmed it using Audacity but it's still huge.
 
Back
Top Bottom