tModLoader Official tModLoader Help Thread

You'll probably need to use a ModPlayer and set a bool variable in the debuff's Update method. Then check for that bool in several ModPlayer methods. Don't forget to reset the bool variable in ResetEffects or it won't ever wear off.
For the regen, see ModPlayer.UpdateBadLifeRegen
For stats, that's a bit more vague because there are a bunch of them. Probably the easiest thing to do is put some of the code ModPlayer.PostUpdate
Change the main stats like max health and mana there with
Code:
player.statLifeMax2 = (int)(player.statLifeMax2 * 0.95f);
player.statManaMax2 = (int)(player.statManaMax2 * 0.95f);
player.statDefense = (int)(player.statDefense * 0.95f);
There are a ton of other things like mana regen, movement speed, various crit chances, etc. You'll need to figure out what you want to alter.
And finally use ModPlayer.GetWeaponDamage to lower the player's damage by 5% rather than try to lower all the various damage stats.
[doublepost=1486826454,1486826115][/doublepost]

You need "projectile.position" instead of "this.position". To change the color, the three arguments after the position indicate red, green, and blue in a scale from 0 to 1. So all 1's will be a white light. If you set the first two to 0.5f then it'll be a light blue.
Thanks!
 
Could you please make a tutorial on how to make a paladins shield kind of accessory, or an accessory that makes you take like 10% of damage taken to people on your team?
 
Could you please make a tutorial on how to make a paladins shield kind of accessory, or an accessory that makes you take like 10% of damage taken to people on your team?
I don't think there's going to be an example for an accessory like that. Mainly because it's just too non-generic. If you want to create said accessory, you'll have to study how vanilla code handles the paladin accessory.
 
You'll probably need to use a ModPlayer and set a bool variable in the debuff's Update method. Then check for that bool in several ModPlayer methods. Don't forget to reset the bool variable in ResetEffects or it won't ever wear off.
For the regen, see ModPlayer.UpdateBadLifeRegen
For stats, that's a bit more vague because there are a bunch of them. Probably the easiest thing to do is put some of the code ModPlayer.PostUpdate
Change the main stats like max health and mana there with
Code:
player.statLifeMax2 = (int)(player.statLifeMax2 * 0.95f);
player.statManaMax2 = (int)(player.statManaMax2 * 0.95f);
player.statDefense = (int)(player.statDefense * 0.95f);
There are a ton of other things like mana regen, movement speed, various crit chances, etc. You'll need to figure out what you want to alter.
And finally use ModPlayer.GetWeaponDamage to lower the player's damage by 5% rather than try to lower all the various damage stats.
[doublepost=1486826454,1486826115][/doublepost]

You need "projectile.position" instead of "this.position". To change the color, the three arguments after the position indicate red, green, and blue in a scale from 0 to 1. So all 1's will be a white light. If you set the first two to 0.5f then it'll be a light blue.
OK, I understand about 10% of that, but thanks anyway.
 
How to play a custom sound?

I tried this method: "item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Items/Weapons/GLSound");" I have the .cs file but nothing is heard.

HTML:
using Microsoft.Xna.Framework.Audio;
using Terraria;
using Terraria.ModLoader;

namespace WeaponsMod.Sounds.Items.Weapons
{
    public class GLSound : ModSound
    {
        public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type)
        {
            // By creating a new instance, this ModSound allows for overlapping sounds. Non-ModSound behavior is to restart the sound, only permitting 1 instance.
            soundInstance = sound.CreateInstance();
            soundInstance.Volume = volume * .5f;
            soundInstance.Pan = pan;
            soundInstance.Pitch = -1.0f;
            return soundInstance;
        }
    }
}

EDIT: Solved, I rename "Items" to "Item" and magically work.
 
Last edited:
The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Terraria.GameInput.KeyConfiguration.CopyKeyState(TriggersSet oldSet, TriggersSet newSet, String newKey)
at Terraria.GameInput.PlayerInput.KeyboardInput()
at Terraria.GameInput.PlayerInput.UpdateInput()
at Terraria.Main.DoUpdate(GameTime gameTime)
at Terraria.Main.Update(GameTime gameTime)
Whats this error about
plz
 
Is there a way to create NPCs, without having to tear my hair out in Photoshop? Replacing pixels by hand, across 20 frames, and doing that repeatedly for 20 odd characters...Yuck. Y'know, such as being able to assemble the individual human sprites (torso, head, hair, etc), and then apply tints like in the player character creator.
 
I'm trying to create a chestplate to have the Royal Gel effect when equipped.
The issue is that I have no idea how to do it, as I'm very much new to modding.
I managed to create a basic item, but specific effects are quite hard for me to grasp.
 
Need a bit of help, have tried looking for any new topics on this, but nothings come up, only old threads.

Whenever I throw on armor pieces from any mod, my game starts to have FPS drops, to the point where everything is basically slow motion. Any idea on how to possibly fix this, or if anyone else is having this problem? I've seen old threads about it, but nothing new so I'm very much in the dark right now.
 
I added a minion spawning with my armor set buff, but there's some issues I haven't solved. I think most of those are originated from the fact that I use an allready existing minion to a new buff. Would it be less troublesome to just create a new minion? Or is it worth it to persevere?
 
Need a bit of help, have tried looking for any new topics on this, but nothings come up, only old threads.

Whenever I throw on armor pieces from any mod, my game starts to have FPS drops, to the point where everything is basically slow motion. Any idea on how to possibly fix this, or if anyone else is having this problem? I've seen old threads about it, but nothing new so I'm very much in the dark right now.
I never used to have frame rate drops, but they've started to happen to me lately. Usually when I have the menu open, but sometimes during normal gameplay too. I found that hiding the interface with F11 usually brings the framerate back to normal.
 
Does anyone know how to make a town NPC be like the 'Cobbler' from Thorium, as in there is an option to give the player a buff?
 
Back
Top Bottom