tAPI Can I edit vanilla things ?

Sheonori

Skeletron Prime
Hi guys, I'm new to tAPI and I want to know if I can edit vanilla things with it. I can't find anything about it on Google, it redirects me to tConfig tutorials, but obviously it's irrelevant. Does anyone have a guide or something ? Thank you in advance :)
 
I would want to make the Mana Flower to not trigger the "Mana Sickness" buff if possible, to give it a real use. I'm not sure about my sentence, but English is not my main language, so sorry
 
I would want to make the Mana Flower to not trigger the "Mana Sickness" buff if possible, to give it a real use. I'm not sure about my sentence, but English is not my main language, so sorry
I think you'll have to give it a different name and texture if you want to do that, but I'm not sure. I can help you code it.
 
I think you'll have to give it a different name and texture if you want to do that, but I'm not sure. I can help you code it.

I don't plan to upload it here, it's just for a personnal use. It may sound selfish, I know, but I'm not comfortable with making something public. If it's just for me, do I really have to make a different texture ? And can I directly view the code of the Mana Sickess buff (i think it's the thing to mod, not the Mana Flower itself if I understood the tutorials correctly) ?
 
I don't plan to upload it here, it's just for a personnal use. It may sound selfish, I know, but I'm not comfortable with making something public. If it's just for me, do I really have to make a different texture ? And can I directly view the code of the Mana Sickess buff (i think it's the thing to mod, not the Mana Flower itself if I understood the tutorials correctly) ?
If it's just for yourself, you don't need to change anything. :)
 
If you know coding and how to set up a ModPlayer class, this is a hook you might want to use
Code:
public override void PostUpdate()
Just need to check for the player's buffs and get rid of the one you need, altho I believe the buff will have effect for at least one frame, but considering we're talking about a buff that affects weapons, doubt that'll be even noticeable. If you want it to be effective only as long as you're using the Mana Flower, ye just need to check whether it is equiped or not.
 
You could try using PreUpdate or MidUpdate too. Again, can't check whether one of these would help.
 
You could try using PreUpdate or MidUpdate too. Again, can't check whether one of these would help.
For whatever stupid reason I didn't relize those were a thing earlier but on my researches I was only aware of PostUpdate. Turns out Both PreUpdate and MidUpdate are same type and don't have any parameters, so they'll work too.
 
I meant more like "they may get rid of the buff without its effects activating even for one frame".
 
Tried them out myself. Post and Mid seem to prevent the buff from coming up completelly, while Pre makes it pop up for just a second. I guess the most effective method at this point is Mid as its called earlier than Post but still effectivelly gets rid of the buff before its icon is drawn.
 
Sorry if I abuse, but what are Pre/Mid/PostUpdate ? And how can I use them ? I don't think it was in the "Getting started with Modding" guide..
 
Basically if you want a code to run every time a player is updated (which means every frame, basically), you place it on either PreUpdate, MidUpdate or PostUpdate. The difference between them is when they are called. I believe the buff applying code runs before MidUpdate, as resetting the buff in that instant does not even let the buff icon to be drawn, while calling it on PreUpdate (which in theory should run before everything else) lets the buff run for at least one frame.

Long story short, this is an example of ModPlayer class.
Code:
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using TAPI;

namespace YourMod
{
    public class MPlayer : TAPI.ModPlayer
    {

        public override void MidUpdate()
        {
            for (int index = 0; index < 22; ++index)
            {
                if (player.buffType[index] == 94)
                {
                    player.buffTime[index] = 0;
                    player.buffType[index] = 0;
                }
            }
        }
    }
}

Paste it all in any .cs file in your mods folder (call it MPlayer.cs or whatever), change the namespace with the internal name of your mod.
What the code basically does is run a for cycle that cycles through all of the player buffs, check whether Mana Sickness is one of them and resets the buff if it is.
Don't mind all the useless includes, I'm just really lazy and throw them all in.
 
Back
Top Bottom