tAPI [Discontinued] tAPI - A Mod To Make Mods

Status
Not open for further replies.
Yes, it's definitely possible. What you want to do is use the OnLoad hook in MBase to replace the sky texture. The code would look something like this:
Code:
public override void OnLoad()
{
    if (bossDefeated)
    {
        Main.backgroundTexture[0] = MBase.GetTexture("RedSky");
    }
}


However, the GetTexture hook comes from Grox the Great's GRealm mod, so you'll have to either add his mod as a reference or incorporate the GetTexture hook into your own code.
So I can just can make a 10x10 .png file colored in red?
 
So I can just can make a 10x10 .png file colored in red?

More like a 48x1300 .png file with a red gradient. (That's what I used with my old tConfig mod, except it was orange)

I should also point out that the code I gave you will only be called when your mod is loaded; the sky won't change in game as soon as the boss is defeated.
 
If your armor has no separate arm layer, you're going to have to create one (unless you mean for the arm to show - which you stated you don't)

Let me provide a general explanation of how this works...
  • Player body skin is drawn
  • If player is wearing a chestplate, draw it.
  • -some other irrelevant stuff draw-
  • Player weapon is drawn (think of a swung sword)
  • if chestplate has the 'hasArms' attribute, the player's bare arm skin will draw
  • if chestplate has the 'hasHands' attribute, the player's bare hands skin (palms , whatever you call it) will draw
  • if chestplate has an arms layer, it will draw

Ahh, I had hasHands to true, did not quite understand what it was implying! Thanks. Also I cannot get my Multi-Projectile Ranged Weapon to Work...
Code:
using Terraria;
using System;
using System.Diagnostics;
using Microsoft.Xna.Framework;

using TAPI;

namespace The_Luposi.Items
{
    public class RevegskardeMSX4 : ModItem
    {
        public override bool PreShoot(Player player,Vector2 ShootPos,Vector2 ShootVelocity,int projType,int Damage,float knockback)
        {
            int ShotAmt = 4; 
            int spread = 65; 
            float spreadMult = 0.05f;
            for(int i = 0; i < ShotAmt; i++)
            {
                float vX = ShootVelocity.X+(float)Main.rand.Next(-spread,spread+1) * spreadMult;
                float vY = ShootVelocity.Y+(float)Main.rand.Next(-spread,spread+1) * spreadMult;

                Projectile.NewProjectile(ShootPos.X,ShootPos.Y,vX,vY,projType,Damage,knockback,Main.myPlayer);
            }
            return false;
        }
    }
}
 
Ahh, I had hasHands to true, did not quite understand what it was implying! Thanks. Also I cannot get my Multi-Projectile Ranged Weapon to Work...
Code:
using Terraria;
using System;
using System.Diagnostics;
using Microsoft.Xna.Framework;

using TAPI;

namespace The_Luposi.Items
{
    public class RevegskardeMSX4 : ModItem
    {
        public override bool PreShoot(Player player,Vector2 ShootPos,Vector2 ShootVelocity,int projType,int Damage,float knockback)
        {
            int ShotAmt = 4;
            int spread = 65;
            float spreadMult = 0.05f;
            for(int i = 0; i < ShotAmt; i++)
            {
                float vX = ShootVelocity.X+(float)Main.rand.Next(-spread,spread+1) * spreadMult;
                float vY = ShootVelocity.Y+(float)Main.rand.Next(-spread,spread+1) * spreadMult;

                Projectile.NewProjectile(ShootPos.X,ShootPos.Y,vX,vY,projType,Damage,knockback,Main.myPlayer);
            }
            return false;
        }
    }
}

Here is your code. Change Mod name, Item name and shooting parameters.
Code:
using System;
using System.Diagnostics;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace Tremor.Items
{
    public class HellstoneShotgun : ModItem
    {
         public override bool PreShoot(Player player,Vector2 ShootPos,Vector2 ShootVelocity,int projType,int Damage,float knockback)
        {
            int ShotAmt = 3; // Amount of shots fired
            int spread = 30; // Shot spread
            float spreadMult = 0.05f; // Spread multiplier
            for(int i = 0; i < ShotAmt; i++)
            {
                float vX = ShootVelocity.X+(float)Main.rand.Next(-spread,spread+1) * spreadMult;
                float vY = ShootVelocity.Y+(float)Main.rand.Next(-spread,spread+1) * spreadMult;
    
                Projectile.NewProjectile(ShootPos.X,ShootPos.Y,vX,vY,projType,Damage,knockback,Main.myPlayer);
            }
            return false;
        }
    }
}
 

Actually, Yorai is wrong with the order here - the hand draws *after* the armor, not *before*. (which is why you see it in the first place)

To fix that issue just don't use 'hasHands' and you will be fine.

I'm not sure if this is a tAPI thing or a thing with the Decorations mod, but apparently some underground cabins register as valid housing.

I started this map for farming purposes, and suddenly the Merchant arrived despite the fact I never built any houses. I was greeted with this on the map screen.
C1668CA0EE13C45465C0B9C8944C24CD05FEDB63


And then to make matters weirder, when I went to check out the Merchant.... they switched places!
B63FC1AD529B53C89CDCE2B0518E934FE8E1134D


I should have screencapped the house the guide was in before dismantling it, but I'm wondering what's causing this. If it's not a tAPI-specific thing, I'll bring it up on the decorations thread.

Late reply, but: Can you get a screenshot of the house the Merchant is in, untouched? I am betting Decorations is adding an item it registers as a chair (as workbenches can show up in vanilla), or is just changing valid housing in general. (@ the post you put in the thread, with the demo's 'room')

Another thing to note is the 'table' 'torch' 'door' and 'chair' requirements are very loose - there's quite a few items flagged as 'chair' despite not being anything of the sort (most decorative tiles, beds, etc.) Likewise pretty much anything you can stand on can be counted as a 'table', and platforms also count as 'doors'. The only one that is truly broken is the Demo's room - which is nothing more then platforms and torches.
 
Last edited:
A few bug reports and questions...

The tAPI builder forcefully modifies the directory structure of mods I rebuild with it, hence breaking some of them. Maybe it's intentional, but it's problematic nonetheless.

While I was modding people's mod to work in MP, I had to rebuild them, of course, and the files I ended up with were fairly broken. I had to convert them back to a zip file, move directories around, and rezip them to get them to work again.

The builder seems to create another directory named after the mod and moves all of it's sub-directories under that, which causes problems for some mods... most actually, that I rebuilt.

So, if I download someone's mod and its structure is:
ThisMod.tapi, decompresses to
ThisMod (folder)
Buffs (folder)
Images (folder)
Items (folder)
!Mod.tapimod
Modinfo.json

If I rebuild it, I'll get
ThisMod (folder)
ThisMod (folder)
Buffs (folder)
Images (folder)
Items (folder)
Modinfo.json (now there are two of these)
!Mod.tapimod
Modinfo.json

I would think if you downloaded a mod and rebuilt it without changing anything, you would get the same structure as a result.

---

Concerning textures...

Why does it take so long for them to load? These are just tiny png files, of course, but it takes quite a while, as in the case with large mods like Necropolis, to load all of the files.
Will this be optimized down the road or is this some limitation you're stuck with for tAPI?

---

There are definite, hard to reproduce memory leaks and out of memory issues with tAPI 14a. I can load the game once without any problems, and other times, launch it again, without touching any mods, get an out of memory exception while loading mods.

I had a problem just now where the load order had to be changed to get around this. The 2nd to last mod being loaded never produced and error for me before, but I was unable to load the game with it enabled after a crash. I changed it to the first mod loaded, as reloaded the mods. I did notice a message I've never seen before, saying the the audio was being reset (something like that). This mod has large .wav files that were probably causing a problem somehow.

Reloading mods can be a memory leak issue too. The game seems to keep allocating more memory when this is done, but strangely, not all the time.

When the game is losing ram, you can see the cloud animation getting choppy and then you know you're going to get an out of memory exception.

---

When trying MP today with a player and world that work fine in SP, I'm getting this when trying to view my inventory (tAPI server running in dos box, locally, connecting via ip, not hosting):

Code:
System.NullReferenceException: Object reference not set to an instance of an object.
  at Terraria.Main.DrawInventory()
  at TAPI.InterfaceLayer.<.cctor>b__10(TAPI.InterfaceLayer layer, Microsoft.Xna.Framework.Graphics.SpriteBatch sb)
  at TAPI.InterfaceLayer+Action.OnDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch sb)
  at TAPI.InterfaceLayer.Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch sb)
  at Terraria.Main.DrawInterface()
  at Terraria.Main.Draw(Microsoft.Xna.Framework.GameTime gameTime)

The server isn't crashing though. I thought it might be that the server was trying to draw an item for which it doesn't have an associated texture, but it's the client that's producing the error. It doesn't have this problem in SP.

That's it for now.

Thanks
 
Last edited:
Sounds like tAPI/terarria crashed.

Wait, why are you trying to open a mod from the game launcher? That doesn't even make sense.
The game launcher just launches different Terraria versions, not mods specifically.
You should have an entry for tAPI, and tAPI will load the mods you've told it to previously, under the mods menu.
i phrased that wrong what i meant to say is that im trying to load the version of terraria that has tAPI so i can go on a mod.?
 
A couple of suggestions/comments/bug reports...

The tAPI builder forcefully modifies the directory structure of mods I rebuild with it, hence breaking some of them. Maybe it's intentional, but it's problematic nonetheless.

While I was modding people's mod to work in MP, I had to rebuild them, of course, and the files I ended up with were fairly broken. I had to convert them back to a zip file, move directories around, and rezip them to get them to work again.

The builder seems to create another directory named after the mod and moves all of it's sub-directories under that, which causes problems for some mods... most actually, that I rebuilt.

So, if I download someone's mod and its structure is:
ThisMod.tapi, decompresses to
ThisMod (folder)
Buffs (folder)
Images (folder)
Items (folder)
!Mod.tapimod
Modinfo.json

If I rebuild it, I'll get
ThisMod (folder)
ThisMod (folder)
Buffs (folder)
Images (folder)
Items (folder)
Modinfo.json (now there are two of these)
!Mod.tapimod
Modinfo.json

I would think if you downloaded a mod and rebuilt it without changing anything, you would get the same structure as a result.

---

Concerning textures...

Why does it take so long for them to load? These are just tiny png files, of course, but it takes quite a while, as in the case with large mods like Necropolis, to load all of the files.
Will this be optimized down the road or is this some limitation you're stuck with for tAPI?

Thanks
I guess I derped with the mod packing thing lately... I'd be grateful if you reported it here: http://tapi.axxim.net/bugs/
About texture loading times: nothing can be done. That's how slow XNA is when loading textures from PNG files. We could allow XNB files to be loaded instead, but it requires some stupid hackish code to get them right AND requires the mod author to create the XNB files.
 
Here is your code. Change Mod name, Item name and shooting parameters.
Code:
using System;
using System.Diagnostics;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace Tremor.Items
{
    public class HellstoneShotgun : ModItem
    {
         public override bool PreShoot(Player player,Vector2 ShootPos,Vector2 ShootVelocity,int projType,int Damage,float knockback)
        {
            int ShotAmt = 3; // Amount of shots fired
            int spread = 30; // Shot spread
            float spreadMult = 0.05f; // Spread multiplier
            for(int i = 0; i < ShotAmt; i++)
            {
                float vX = ShootVelocity.X+(float)Main.rand.Next(-spread,spread+1) * spreadMult;
                float vY = ShootVelocity.Y+(float)Main.rand.Next(-spread,spread+1) * spreadMult;
   
                Projectile.NewProjectile(ShootPos.X,ShootPos.Y,vX,vY,projType,Damage,knockback,Main.myPlayer);
            }
            return false;
        }
    }
}

Figured it out, I was using the wrong namespace, mine has the author name included :)
 
Since the documentation of projectiles is not quite out yet, is there any way to create a waveform pattern for a projectile to follow?
 
Since the documentation of projectiles is not quite out yet, is there any way to create a waveform pattern for a projectile to follow?
calculate the unit vector for direction of travel, rotate it 90 degrees, put in ai[0]. Take the cosine of a time counter in ai[1] and multiply that by some constant. multiply vector by scalar and add that to velocity every tick? since derivative of cosine is sine, the path should also be sinusoidal.
 
I've had a report of enemy projectiles becoming invisible when my mod's buff is applied to the player, as detailed in the linked post. http://forums.terraria.org/index.php?threads/sonicrs-doctor-who-mod.842/page-3#post-178151 My own testing has confirmed this.

Is this a tAPI bug, or something on my end? Here's the code for the buff just in case it is:
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace DoctorWhoMod.Buffs
{
    public class Regenerating : TAPI.ModBuff
    {
        public override void Start(Player P, int index)
        {
            P.statLife=P.statLifeMax;  
            Main.PlaySound(("DoctorWhoMod:Regenerating"), -1, -1, true, null, Single.NaN, Single.NaN, Single.NaN);
        }
        public override void Effects(Player P, int index)
        {
            P.lifeRegen+=5;
            P.controlUp    = false;
            P.controlDown  = false;
            P.controlLeft  = false;
            P.controlRight = false;
            P.controlJump  = false;
            P.noItems = true;
            P.immuneAlpha = 0;
            Color color = Color.Gold;
            int count = 60;
            for (int i = 1; i <= count; i++)
            {
                if (P.direction == -1)
                {
                    //spawn dusts
                    int dust = Dust.NewDust(new Vector2((float) P.position.X + 2f, (float) P.position.Y + 12f), 10, 8, 57, P.velocity.X, -3f, 0, color, 1f); //head
                    Main.dust[dust].noGravity = true;
                    int dust2 = Dust.NewDust(new Vector2((float) P.position.X + 10f, (float) P.position.Y + 24f), 2, 2, 57, 5f, 3f, 0, color, 1f); //right arm
                    Main.dust[dust2].noGravity = true;
                    int dust3 = Dust.NewDust(new Vector2((float) P.position.X, (float) P.position.Y + 24f), 2, 2, 57, -5f, 3f, 0, color, 1f); //left arm
                    Main.dust[dust3].noGravity = true;
                }
                else
                {
                    int dust = Dust.NewDust(new Vector2((float) P.position.X + 1f, (float) P.position.Y + 11f), 10, 8, 57, P.velocity.X, -3f, 0, color, 1f);
                    Main.dust[dust].noGravity = true;
                    int dust2 = Dust.NewDust(new Vector2((float) P.position.X + 10f, (float) P.position.Y + 21f), 2, 2, 57, 5f, 3f, 0, color, 1f);
                    Main.dust[dust2].noGravity = true;
                    int dust3 = Dust.NewDust(new Vector2((float) P.position.X + 3, (float) P.position.Y + 22f), 2, 2, 57, -5f, 3f, 0, color, 1f);
                    Main.dust[dust3].noGravity = true;
                }
            }
            Lighting.AddLight((int)P.position.X, (int)P.position.Y, 255, 215, 0);
        }
        public override void End (Player P, int index)
        {
            int style = Main.rand.Next(123);
            bool gender = Convert.ToBoolean(Main.rand.Next(2));
            if(P.GetSubClass<MPlayer>().hairChange)
            {
                P.hair = style;
            }
            if(P.GetSubClass<MPlayer>().genderChange)
            {
                P.male = gender;
            }
            if(P.GetSubClass<MPlayer>().colourSkin)
            {
                P.skinColor = new Color(Main.rand.Next(255), Main.rand.Next(255), Main.rand.Next(255), 50);
            }
            if(P.GetSubClass<MPlayer>().colourHair)
            {
                P.hairColor = new Color(Main.rand.Next(255), Main.rand.Next(255), Main.rand.Next(255), 50);
            }
            if(P.GetSubClass<MPlayer>().colourEye)
            {
                P.eyeColor = new Color(0, Main.rand.Next(255), Main.rand.Next(255), Main.rand.Next(255));
            }
            P.statLife = P.statLifeMax;
        }
    }
}

And the MPlayer code as well:
Code:
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace DoctorWhoMod
{
    public class MPlayer : TAPI.ModPlayer
    {
        public int timesRegenerated = 0;

        public bool isHuman = true;
        public bool timeLord = false;
        public bool hairChange = false;
        public bool genderChange = false;
        public bool colourHair = false;
        public bool colourSkin = false;
        public bool colourEye = false;
               
        public override void Load(BinBuffer bb)
        {
            timesRegenerated = bb.ReadInt();

            isHuman = bb.ReadBool();
            timeLord = bb.ReadBool();
            hairChange = bb.ReadBool();
            genderChange = bb.ReadBool();
            colourHair = bb.ReadBool();
            colourSkin = bb.ReadBool();
            colourEye = bb.ReadBool();
        }
        public override void Save(BinBuffer bb)
        {
           bb.Write(timesRegenerated);

            bb.Write(isHuman);
            bb.Write(timeLord);
            bb.Write(hairChange);
            bb.Write(genderChange);
            bb.Write(colourHair);
            bb.Write(colourSkin);
            bb.Write(colourEye);
        }
        public override void PostUpdate()
        {
            if (player.GetSubClass<MPlayer>().timeLord)//if player is a Time Lord
            {
                player.breathMax = 600; 
                player.statDefense +=5; 
                player.accWatch = 3;             
            }
        }
        public override bool? PreKill(double damage, int hitDirection, bool pvp, string deathText)
        {
            if (player.difficulty == 2)
            {
                if (player.GetSubClass<MPlayer>().timeLord) 
                {
                    foreach (int B in player.buffType) if (B == BuffDef.byName["DoctorWhoMod:Regenerating"]) return true; 
                    if (player.GetSubClass<MPlayer>().timesRegenerated > 12) return true; 
                    player.GetSubClass<MPlayer>().timesRegenerated++; /
                    player.statLife = 1; 
                    player.AddBuff(BuffDef.byName["DoctorWhoMod:Regenerating"], 420, false); 
                    return false; 
                }
                return true;
            }
            if (player.GetSubClass<MPlayer>().timeLord)
            {
                foreach(int B in player.buffType) if(B == BuffDef.byName["DoctorWhoMod:Regenerating"]) return true;
                player.statLife = 1;
                player.AddBuff(BuffDef.byName["DoctorWhoMod:Regenerating"],420,false);
                return false;
            }
            return true;
        }
    }
}

Thanks.
 
I've had a report of enemy projectiles becoming invisible when my mod's buff is applied to the player, as detailed in the linked post. http://forums.terraria.org/index.php?threads/sonicrs-doctor-who-mod.842/page-3#post-178151 My own testing has confirmed this.

Is this a tAPI bug, or something on my end? Here's the code for the buff just in case it is:
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace DoctorWhoMod.Buffs
{
    public class Regenerating : TAPI.ModBuff
    {
        public override void Start(Player P, int index)
        {
            P.statLife=P.statLifeMax;
            Main.PlaySound(("DoctorWhoMod:Regenerating"), -1, -1, true, null, Single.NaN, Single.NaN, Single.NaN);
        }
        public override void Effects(Player P, int index)
        {
            P.lifeRegen+=5;
            P.controlUp    = false;
            P.controlDown  = false;
            P.controlLeft  = false;
            P.controlRight = false;
            P.controlJump  = false;
            P.noItems = true;
            P.immuneAlpha = 0;
            Color color = Color.Gold;
            int count = 60;
            for (int i = 1; i <= count; i++)
            {
                if (P.direction == -1)
                {
                    //spawn dusts
                    int dust = Dust.NewDust(new Vector2((float) P.position.X + 2f, (float) P.position.Y + 12f), 10, 8, 57, P.velocity.X, -3f, 0, color, 1f); //head
                    Main.dust[dust].noGravity = true;
                    int dust2 = Dust.NewDust(new Vector2((float) P.position.X + 10f, (float) P.position.Y + 24f), 2, 2, 57, 5f, 3f, 0, color, 1f); //right arm
                    Main.dust[dust2].noGravity = true;
                    int dust3 = Dust.NewDust(new Vector2((float) P.position.X, (float) P.position.Y + 24f), 2, 2, 57, -5f, 3f, 0, color, 1f); //left arm
                    Main.dust[dust3].noGravity = true;
                }
                else
                {
                    int dust = Dust.NewDust(new Vector2((float) P.position.X + 1f, (float) P.position.Y + 11f), 10, 8, 57, P.velocity.X, -3f, 0, color, 1f);
                    Main.dust[dust].noGravity = true;
                    int dust2 = Dust.NewDust(new Vector2((float) P.position.X + 10f, (float) P.position.Y + 21f), 2, 2, 57, 5f, 3f, 0, color, 1f);
                    Main.dust[dust2].noGravity = true;
                    int dust3 = Dust.NewDust(new Vector2((float) P.position.X + 3, (float) P.position.Y + 22f), 2, 2, 57, -5f, 3f, 0, color, 1f);
                    Main.dust[dust3].noGravity = true;
                }
            }
            Lighting.AddLight((int)P.position.X, (int)P.position.Y, 255, 215, 0);
        }
        public override void End (Player P, int index)
        {
            int style = Main.rand.Next(123);
            bool gender = Convert.ToBoolean(Main.rand.Next(2));
            if(P.GetSubClass<MPlayer>().hairChange)
            {
                P.hair = style;
            }
            if(P.GetSubClass<MPlayer>().genderChange)
            {
                P.male = gender;
            }
            if(P.GetSubClass<MPlayer>().colourSkin)
            {
                P.skinColor = new Color(Main.rand.Next(255), Main.rand.Next(255), Main.rand.Next(255), 50);
            }
            if(P.GetSubClass<MPlayer>().colourHair)
            {
                P.hairColor = new Color(Main.rand.Next(255), Main.rand.Next(255), Main.rand.Next(255), 50);
            }
            if(P.GetSubClass<MPlayer>().colourEye)
            {
                P.eyeColor = new Color(0, Main.rand.Next(255), Main.rand.Next(255), Main.rand.Next(255));
            }
            P.statLife = P.statLifeMax;
        }
    }
}

And the MPlayer code as well:
Code:
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace DoctorWhoMod
{
    public class MPlayer : TAPI.ModPlayer
    {
        public int timesRegenerated = 0;

        public bool isHuman = true;
        public bool timeLord = false;
        public bool hairChange = false;
        public bool genderChange = false;
        public bool colourHair = false;
        public bool colourSkin = false;
        public bool colourEye = false;
             
        public override void Load(BinBuffer bb)
        {
            timesRegenerated = bb.ReadInt();

            isHuman = bb.ReadBool();
            timeLord = bb.ReadBool();
            hairChange = bb.ReadBool();
            genderChange = bb.ReadBool();
            colourHair = bb.ReadBool();
            colourSkin = bb.ReadBool();
            colourEye = bb.ReadBool();
        }
        public override void Save(BinBuffer bb)
        {
           bb.Write(timesRegenerated);

            bb.Write(isHuman);
            bb.Write(timeLord);
            bb.Write(hairChange);
            bb.Write(genderChange);
            bb.Write(colourHair);
            bb.Write(colourSkin);
            bb.Write(colourEye);
        }
        public override void PostUpdate()
        {
            if (player.GetSubClass<MPlayer>().timeLord)//if player is a Time Lord
            {
                player.breathMax = 600;
                player.statDefense +=5;
                player.accWatch = 3;           
            }
        }
        public override bool? PreKill(double damage, int hitDirection, bool pvp, string deathText)
        {
            if (player.difficulty == 2)
            {
                if (player.GetSubClass<MPlayer>().timeLord)
                {
                    foreach (int B in player.buffType) if (B == BuffDef.byName["DoctorWhoMod:Regenerating"]) return true;
                    if (player.GetSubClass<MPlayer>().timesRegenerated > 12) return true;
                    player.GetSubClass<MPlayer>().timesRegenerated++; /
                    player.statLife = 1;
                    player.AddBuff(BuffDef.byName["DoctorWhoMod:Regenerating"], 420, false);
                    return false;
                }
                return true;
            }
            if (player.GetSubClass<MPlayer>().timeLord)
            {
                foreach(int B in player.buffType) if(B == BuffDef.byName["DoctorWhoMod:Regenerating"]) return true;
                player.statLife = 1;
                player.AddBuff(BuffDef.byName["DoctorWhoMod:Regenerating"],420,false);
                return false;
            }
            return true;
        }
    }
}

Thanks.
I believe that Terraria itself has a limit as to how many dust particles can be displayed at once. The amount depends on what the game's visual quality is set to.
So, basically, I don't think it's really a bug with anything, it's just Terraria's way of preventing a probable FPS drop/game lag.

Edit: I think the way to fix this would be to reduce the amount of dust particles spawned in your buff code.
 
Here's a rather easy question to answer:

How do I give an after image to NPCs? I know you can do that with players by simply changing its drawAfterimage to true, but NPCs don't seem to have that property. How would I do this?
Thank you for the information, but I'm having difficulty understanding what you wrote; I've just started with C#.

I would assume the update part goes in the AI() right? Something like this?
Code:
npc.oldPosition = npc.position;

I have no clue how to apply the drawing part, all help is appreciated.

Sorry for this bump, but it's been a couple pages of comments and my question is still unresolved. I have no idea what piece of code I would include to get that afterimage effect for NPCs.
 
Sorry for this bump, but it's been a couple pages of comments and my question is still unresolved. I have no idea what piece of code I would include to get that afterimage effect for NPCs.
You are right NPCs don't have this setting as it is a player only thing as of right now. If you wanted to do this to an NPC it would have to be custom coded.

What you could do is look at the source and find out how the afterimage is done for the player and then just do the same for an NPC but.... This is not necessarily an easy thing to do unless you know what you are doing.

Also, this would not go in AI() at all - likely in PostAI() and the code you linked - npc.oldPosition = npc.position; would do nothing of the sort of what you are looking for.

Sorry to be so abrupt with the response, but you will need to understand some C# to do what you want.

EDIT: Lastly, after looking back it looks like @Yoraiz0r already told you how to accomplish your goal. You just need to understand what he was saying and someone new to C# or code in general wouldn't be. I suggest looking at some online C# tutorials

(I have linked these in the past)
C# for absolute beginners: http://www.homeandlearn.co.uk/csharp/csharp.html
C# crashcourse and XNA Tutorials: http://rbwhitaker.wikidot.com/xna-tutorials
 

Thank you for the information. I've tried various programming languages in the past, such as LUA and Python; however, none of which the process relates to the C# language. Certainly, getting used to C# will be a task, but I believe it's a matter of patience.

Again, thank you for the wonderfully explained response; its abrupt characteristic is what deemed the response its most efficient.
 
Can someone tell me if it's possible to have a sword that combines several effects, like Terra Blade + Horseman Pumpkins.

I got the beam part down pat, but I haven't found out how to add Horseman's effect, and I'm not even certain if that's doable.
Code:
{
  "displayName"  : "Redacted",
   "texture"   : "Items/Redacted",
   "size"   : [62, 62],
   "maxStack"   : 1,
   "value"   : [0,0,10,0],
   "rare"   : 7,
   "tooltip"   : "Redacted",
   "useStyle": 1,
   "useAnimation"   : 10,
   "useTime": 10,
   "damage": 200,
   "knockback": 10,
   "useSound": 1,
   "autoReuse": true,
   "useTurn": false,
   "melee": true,
   "shoot": "Freenight:Redacted",
   "shootSpeed": 60,
}
 
Can someone tell me if it's possible to have a sword that combines several effects, like Terra Blade + Horseman Pumpkins.

I got the beam part down pat, but I haven't found out how to add Horseman's effect, and I'm not even certain if that's doable.
~snip~

It's actually not that hard to accomplish, you just can't do it in a json. You will need to manually create the additional projectiles or effects using code.

To do what you want, you would need to look at how the horseman's blade creates it's projectiles and duplicate that in the code of your current "terra blade" clone
 
Status
Not open for further replies.
Back
Top Bottom