tAPI tAPI Community Resources - Development assistance for developers, by developers.

So, can you guyses tell me what is wrong with my code?

Code:
using System;
using Microsoft.Xna.Framework;

using TAPI;
using Terraria;

namespace Rektmod.Items
{
    public override bool PreShoot(Player P,Vector2 Pos,Vector2 Velo,int type,int DMG,float KB)
    {
        int owner = P.whoAmI;
        Projectile.NewProjectile(Pos.X,Pos.Y,Velo.X,Velo.Y,type,DMG,KB,owner);
        Projectile.NewProjectile(Pos.X,Pos.Y - 20,Velo.X,Velo.Y,type,DMG,KB,owner);
        Projectile.NewProjectile(Pos.X,Pos.Y + 20,Velo.X,Velo.Y,type,DMG,KB,owner);
  
        return false;
    }
    public virtual bool ConsumeAmmo(Player p) { return Main.rand.Next(0, 100) >= 85; }
}
Can you please tell us the error you are recieving or what isn't working?
The mod builder is telling me that it's expecting either class, delegate, enum, interface or struct in both of the code things.
I can't exactly copy the text from the builder because it's not in english.
 
The mod builder is telling me that it's expecting either class, delegate, enum, interface or struct in both of the code things.
I can't exactly copy the text from the builder because it's not in english.
You are missing a class from the top of the code.
If it's an item you need to state what it is, e.g public class NameOfModItem : ModItem
[DOUBLEPOST=1429306621][/DOUBLEPOST]Well, I have a problem myself, and it might be the final one I ask:
Why can't tAPI recognize a custom class from a mod, such as referring to a buff in a ModItem?
The two pieces I get this type of error from:
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using TAPI;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PNova.Items
{
   public class AwokenBreastplate : ModItem
   {
    
    
     public override void Effects(Player player)
  {
      player.meleeDamage += 0.55f;
      player.meleeSpeed += 0.30f;
      
  }
    
     public override void ArmorSetBonus(Player p, PNova.Buffs.phasingPower phase)
     {
       p.setBonus = "80% increased melee damage and insane life regen!";
       p.meleeDamage += 0.8f;
       p.lifeRegen = 5;
       int dust = Dust.NewDust(new Vector2((float) p.position.X, (float) p.position.Y), p.width, p.height, 25, (p.velocity.X) + (p.direction * 1), p.velocity.Y, 245, Color.Blue, 0.6f);
       Main.dust[dust].noGravity = true;
  phase.phaserTrigger = true;
  }
  public override void DamageNPC(Player P, NPC npc, int hitDir, ref int damage, ref float knockback, ref bool crit, ref float critMult, PNova.Buffs.phasingPower phase)
  {phase.phaserTrigger = true;
  phase.phaser += 60;
  }
  }
  
     }
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using TAPI;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PNova.Buffs
{
  public class phasingPower : ModBuff
  {
  public int phaser = player.buffTime[k];
  public bool phaserTrigger = false;
  public int phasedIncrease = 0.01f;
  public float defaultPhase = 0.05f;
  public int phaserMax = 18000;
  public int phasedMoreDmg;

  public override void Effects(Player player, PNova.Buffs.phasingPower phase)
  {
  phase.phasedMoreDmg += phase.phasedIncrease * (float)phase.defaultPhase * (float)player.buffTime[k];
  player.meleeDamage += phase.phasedMoreDmg;
  phase.phaserTrigger = true;
  }
  }
}
Something like this would work when inserted into the Player file in source modding. (Only problem I have with that is because I don't have working source code)
Code:
Terraria 1.2.4.1, tAPI Builder r14a

========================================
Building mod Chazm's Miscellaneous Mod

Validating Jsons...
Compiling code...
phasingPower.cs  (30,21)
  'PNova.Buffs.phasingPower.Effects(Terraria.Player, PNova.Buffs.phasingPower)': no suitable method found to override
  public override void Effects(Player player, phasingPower phase)
  ^
AwokenBreastplate.cs  (24,23)
  'PNova.Items.AwokenBreastplate.ArmorSetBonus(Terraria.Player, PNova.Buffs.phasingPower)': no suitable method found to override
  public override void ArmorSetBonus(Player p, PNova.Buffs.phasingPower phase)
  ^
AwokenBreastplate.cs  (38,32)
  'PNova.Items.AwokenBreastplate.DamageNPC(Terraria.Player, Terraria.NPC, int, ref int, ref float, ref bool, ref float, PNova.Buffs.phasingPower)': no suitable method found to override
  public override void DamageNPC(Player P, NPC npc, int hitDir, ref int damage, ref float knockback, ref bool crit, ref float critMult, PNova.Buffs.phasingPower phase)
  ^
Failed to build Chazm's Miscellaneous Mod.

========================================

Built 0 mods.
 
Ok, fun new problems today. The current goal is to create a spell that checks all NPCs (all NPCs on screen would be best, but it's not important) for a debuff, deals damage to those NPCs, and removes the debuff. Grox' Basemod has an AI method to get NPCs within a certain distance of a point, so I'm trying using that. The spell currently creates an invisible projectile that lasts only 1 frame, and the effect is carried out via PostKill(). I'm having trouble finding a way to remove the debuff from the NPCs - here's the code:
Code:
namespace Blood.Projectiles
{
    public class SanguineCall : ModProjectile
    {
        public override void PostKill()
        {
            int[] npcs = BaseMod.BaseAI.GetNPCs(projectile.Center, -1, 100000f);
            for (int m = 0; m < npcs.Length; m++)
            {
                NPC npc = Main.npc[npcs[m]];
                if (npc.HasBuff("Blood:Bloodied") != -1)
                {
                    npc.HasBuff("Blood:Bloodied") = -1;
                    { CombatText.NewText(npc.Hitbox, BaseMod.BaseConstants.NPCTEXTCOLOR_BUFF, "1000", false, true); }
                    npc.life -= 1000;
                }
            }
            Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height);
            Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y, 1);
            for (int m = 0; m < 5; m++) //projectile dust
            {
                int dustID = Dust.NewDust(projectile.position, projectile.width, projectile.height, 60, projectile.velocity.X * 1f, projectile.velocity.Y * 1f, 100, Color.White, 2.5f);
            }
        }
    }
}

The builder points to "npc.HasBuff("Blood:Bloodied") = -1;" and says "The left-hand side of an assignment must be a variable, property or indexer." Since npc.ClearBuff doesn't work, I'm not sure what to do.

If there's a simple way to accomplish all of this without using Basemod, I'd like to know that as well.

Edit: figured some stuff out, removed things I don't need help with. I added code to make enemies not simply disappear when they die.
DelBuff is what I think you're looking for.
Code:
namespace Blood.Projectiles
{
    public class SanguineCall : ModProjectile
    {
        public override void PostKill()
        {
            int[] npcs = BaseMod.BaseAI.GetNPCs(projectile.Center, -1, 100000f);
            for (int m = 0; m < npcs.Length; m++)
            {
                NPC npc = Main.npc[npcs[m]];
                if (npc.HasBuff("Blood:Bloodied") != -1)
                {
                    npc.DelBuff(BuffDef.byName["Blood:Bloodied"]); // Use DelBuff here
                    { CombatText.NewText(npc.Hitbox, BaseMod.BaseConstants.NPCTEXTCOLOR_BUFF, "1000", false, true); }
                    npc.life -= 1000;
                }
            }
            Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height);
            Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y, 1);
            for (int m = 0; m < 5; m++) //projectile dust
            {
                int dustID = Dust.NewDust(projectile.position, projectile.width, projectile.height, 60, projectile.velocity.X * 1f, projectile.velocity.Y * 1f, 100, Color.White, 2.5f);
            }
        }
    }
}
To target only on screen mobs you can try this...
Code:
namespace Blood.Projectiles
{
    public class SanguineCall : ModProjectile
    {
        public override void PostKill()
        {
            for (int m = 0; m < Main.npc.Length; m++) // Iterate through Main.npc array
            {
                NPC npc = Main.npc[m];

               if (!npc.active) // Skip Inactive NPCs
                    continue;

                if (npc.friendly) // Skip friendly NPCs
                    continue;

                if (npc.position.Y + npc.height < Main.screenPosition.Y || npc.position.Y > Main.screenPosition.Y + Main.screenHeight) // Check Y Position
                    continue;

                if (npc.position.X + npc.width < Main.screenPosition.X || npc.position.X > Main.screenPosition.X + Main.screenWidth) // Check X Position
                    continue;

                if (npc.HasBuff("Blood:Bloodied") != -1)
                {
                    npc.DelBuff(BuffDef.byName["Blood:Bloodied"]); // Use DelBuff here
                    { CombatText.NewText(npc.Hitbox, BaseMod.BaseConstants.NPCTEXTCOLOR_BUFF, "1000", false, true); }
                    npc.life -= 1000;
                }
            }
            Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height);
            Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y, 1);
            for (int m = 0; m < 5; m++) //projectile dust
            {
                int dustID = Dust.NewDust(projectile.position, projectile.width, projectile.height, 60, projectile.velocity.X * 1f, projectile.velocity.Y * 1f, 100, Color.White, 2.5f);
            }
        }
    }
}

Well, I have a problem myself, and it might be the final one I ask:
Why can't tAPI recognize a custom class from a mod, such as referring to a buff in a ModItem?
The two pieces I get this type of error from:

...snip...

Something like this would work when inserted into the Player file in source modding. (Only problem I have with that is because I don't have working source code)
That's not the way Virtual and Override work. The Override method must match the signature of the Virtual method exactly. That code would not work if inserted as a source mod, unless you also changed the signature of the Virtual method.
Override (C# Reference)
 
DelBuff is what I think you're looking for.
Code:
namespace Blood.Projectiles
{
    public class SanguineCall : ModProjectile
    {
        public override void PostKill()
        {
            int[] npcs = BaseMod.BaseAI.GetNPCs(projectile.Center, -1, 100000f);
            for (int m = 0; m < npcs.Length; m++)
            {
                NPC npc = Main.npc[npcs[m]];
                if (npc.HasBuff("Blood:Bloodied") != -1)
                {
                    npc.DelBuff(BuffDef.byName["Blood:Bloodied"]); // Use DelBuff here
                    { CombatText.NewText(npc.Hitbox, BaseMod.BaseConstants.NPCTEXTCOLOR_BUFF, "1000", false, true); }
                    npc.life -= 1000;
                }
            }
            Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height);
            Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y, 1);
            for (int m = 0; m < 5; m++) //projectile dust
            {
                int dustID = Dust.NewDust(projectile.position, projectile.width, projectile.height, 60, projectile.velocity.X * 1f, projectile.velocity.Y * 1f, 100, Color.White, 2.5f);
            }
        }
    }
}
To target only on screen mobs you can try this...
Code:
namespace Blood.Projectiles
{
    public class SanguineCall : ModProjectile
    {
        public override void PostKill()
Ah, ok.
But if I am to refer to that file, where would it be at the end result?
        {
            for (int m = 0; m < Main.npc.Length; m++) // Iterate through Main.npc array
            {
                NPC npc = Main.npc[m];

               if (!npc.active) // Skip Inactive NPCs
                    continue;

                if (npc.friendly) // Skip friendly NPCs
                    continue;

                if (npc.position.Y + npc.height < Main.screenPosition.Y || npc.position.Y > Main.screenPosition.Y + Main.screenHeight) // Check Y Position
                    continue;

                if (npc.position.X + npc.width < Main.screenPosition.X || npc.position.X > Main.screenPosition.X + Main.screenWidth) // Check X Position
                    continue;

                if (npc.HasBuff("Blood:Bloodied") != -1)
                {
                    npc.DelBuff(BuffDef.byName["Blood:Bloodied"]); // Use DelBuff here
                    { CombatText.NewText(npc.Hitbox, BaseMod.BaseConstants.NPCTEXTCOLOR_BUFF, "1000", false, true); }
                    npc.life -= 1000;
                }
            }
            Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height);
            Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y, 1);
            for (int m = 0; m < 5; m++) //projectile dust
            {
                int dustID = Dust.NewDust(projectile.position, projectile.width, projectile.height, 60, projectile.velocity.X * 1f, projectile.velocity.Y * 1f, 100, Color.White, 2.5f);
            }
        }
    }
}


That's not the way Virtual and Override work. The Override method must match the signature of the Virtual method exactly. That code would not work if inserted as a source mod, unless you also changed the signature of the Virtual method.
Override (C# Reference)
 
I'm trying to make an accessory that adds health drain to the player's attacks.
How would i make this so that instead of just healing 5 health every time you hit something, it would heal for 7.5% of the damage you dealt?

Code:
public override void DamageNPC(Player p, NPC n, int hitDir, ref int damage, ref float knockback, ref bool crit, ref float critMult)
        {
            p.statLife += 5;
        }
 
I'm trying to make an accessory that adds health drain to the player's attacks.
How would i make this so that instead of just healing 5 health every time you hit something, it would heal for 7.5% of the damage you dealt?

Code:
public override void DamageNPC(Player p, NPC n, int hitDir, ref int damage, ref float knockback, ref bool crit, ref float critMult)
        {
            p.statLife += 5;
        }

This code will give you what you're looking for:
Code:
        public override void DealtNPC(Player player, NPC npc, int hitDir, int dmgDealt, float knockback, bool crit)
        {
            if (Main.myPlayer == player.whoAmI)
            {
                player.statLife = Math.Min(player.statLifeMax2, player.statLife + Math.Max(1, (int)((float)dmgDealt / 10f)));
            }
        }
The key value is the float after dmgDealt; 10f will divide the damage dealt by 10, so you'll get 10% lifesteal. Modify that value to suit your needs.

DelBuff is what I think you're looking for.

Thank you very much, that's exactly what I needed. I'll try to integrate the on-screen targeting code as well.

Edit: The NPC targeting works, but upon testing, it seems that casting the spell while an enemy has the debuff and is in range now crashes the game. Here's the error:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Terraria.NPC.DelBuff(System.Int32 b)
at Blood.Projectiles.SanguineCall.PostKill() in \BloodMagic\Projectiles\SanguineCall.cs at line 23
at TAPI.Hooks.Call(System.Action[] ts)
at Terraria.Projectile.Kill()
at Terraria.Projectile.Update(System.Int32 i)
at Terraria.Main.UpdateReal(Microsoft.Xna.Framework.GameTime gameTime)
 
Last edited:
is there any way to give a weapon a sniper like effect? as in being able to zoom off-screen.

It's not easy to give items capabilities that are only active when you're holding them (not using them). I don't know exactly how it could be done, but it would likely involve a global MItem file that checked to see if the item you have selected is "item with sniper effect," then granting the player the sniper scope effect. I don't know a method for checking the currently held item, however.
 
Can anyone say how i can make a custom explosion (with dust/custom dusts or other effects) and maybe without take damage by this? :\ THX >.<
 
Last edited:
How would one make armor spawn a projectile (minion)?
I have a working minion, which i want to spawn when the player has a complete set of armor.
 
Hello!

Is it possible to a have a custom NPC like the guide to have recipes and explain stuff from my mod?

I know how to do basic JSON scripts, however cs is a bit over my head at the moment.

Thanks!
I actually asked about this, earlier. It's not super trivial. You need to draw your own ItemSlot to the display while your NPC's chat window is open. I was told something to do with MenuAnchor (InterfaceAnchor?) might also be used for this...




So I'm trying to get all player projectiles, via an accessory, to inflict a debuff on enemies they hit, among other things. DealtNPC only seems to be called when I damage an NPC with a melee weapon. Currently, all of these accessories function as intended with melee hits, but have no effect on any projectiles (spells, bullets, spear-type weapons, etc.). How can I call code when a player projectile damages an enemy?
I should note that DealtNPC comes with a flavor for melee and for projectiles, as overloads:
Code:
        public override void DealtNPC(NPC npc, int hitDir, int dmgDealt, float knockback, bool crit)
        public override void DealtNPC(Projectile projectile, NPC npc, int hitDir, int dmgDealt, float knockback, bool crit)




How would i make an accessory shoot 16 bones around you when you get hit?
I *think* what you'd do is, in your ModPlayer.PostHurt() method, check player.armor[3-7] for the presence of your mod's accessory, then create the projectiles via Projectile.NewProjectile() with velocities set to the 16 different directions.



I'm having trouble finding a way to remove the debuff from the NPCs
I think NPC.DelBuff(<index_in_the_npcs_buff_list>) is what you're looking for.



is there any way to give a weapon a sniper like effect? as in being able to zoom off-screen.
In ModPlayer's PreUpdate() method, you can check if their held item (player.inventory[player.selectedItem].type) matches the one in your mod (I just use ItemDef.byName["MyMod:MyItem"].type), then produce custom effects. I *think* you can simply set player.scope = true, and get the scope effect. There's probably more to it than that, though...



How would one make armor spawn a projectile (minion)?
I have a working minion, which i want to spawn when the player has a complete set of armor.
Check player's armor slots for matches for each of the armor types (player.armor[0-2] I believe), also in PreUpdate(). With the complete set, you AddBuff("MyMod:MyBuff", 2) to the player with a custom buff (with time = 2 it should expire immediately unless re-applied by a subsequent PreUpdate() call). Then just implement an Effect() for the buff to create said minion, like most other summons do.

That's how I'd do it, offhand.
 
Last edited:
There is a way to change shoot position without get this..?
IMG.png

I've tried to change x and y but this, is what happen:
asd3.png
asd.png
asd2.png

What i need to change for make projectile exit from the barrels position? I'm really out of mind for this ;-;
 
Last edited:
How Exactly Would I Get A Projectile To Have A Trail Like Ninja Clothes and Shadow Armor?
In the projectile's draw hook/override, you might have to draw additional sprites of the given projectile with the same rotation, but with slight shifting in position (opposite to the projectile's current velocity?) and grading of color alpha.
 
In the projectile's draw hook/override, you might have to draw additional sprites of the given projectile with the same rotation, but with slight shifting in position (opposite to the projectile's current velocity?) and grading of color alpha.
So ur saying something like this but for projectiles?
Code:
        public override void VanitySetBonus(Player p)
        {
            dustDelay = Math.Max(0, dustDelay - 1);
            if (dustDelay <= 0) //spawn some custom dust
            {
                dustDelay = 3;
                int dustID = Dust.NewDust(p.position, p.width, p.height, 5, p.velocity.X * 0.2f, p.velocity.Y * 0.2f, 100, Color.White, 1.2f);
                Texture2D texture = Main.itemTexture[item.type];
                Main.dust[dustID].OverrideTexture = texture;
                Main.dust[dustID].frame = new Rectangle(0, 0, texture.Width, texture.Height);
                Main.dust[dustID].OverrideUpdate = (dust) =>
                {
                    Color lightColor = Color.Green;
                    lightColor.R = (byte)(lightColor.R * Math.Min(1f, dust.scale));
                    lightColor.G = (byte)(lightColor.G * Math.Min(1f, dust.scale));
                    lightColor.B = (byte)(lightColor.B * Math.Min(1f, dust.scale));
                    Lighting.AddLight(dust.position, (float)lightColor.R / 255f, (float)lightColor.B / 255f, (float)lightColor.B / 255f);
                    dust.rotation += (float)(Math.PI / 16f) * dust.scale;
                    dust.alpha = 200;
                    dust.scale *= 0.965f;
                    dust.velocity *= 0.9f;
                    dust.position += dust.velocity;
                    if (dust.scale <= 0.2f) { dust.active = false; }
                };
            }
        }
    }
}
 
For a while now, I've been trying to make projectile after-images to work, however, it is currently still not working. I have narrowed it down to either PostDraw(SpriteBatch sb) for the projectile or PostGameUpdate(SpriteBatch sb). The code so far...


Code:
public override void PostDraw(SpriteBatch sb)
        {
            Color color21 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0));
            SpriteEffects effects = SpriteEffects.None;
            int num98 = 0;
            int num99 = 0;
            float num100 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f;
            for(int num126 = 0; num126 < 10; num126++)
            {
                Color alpha4 = projectile.GetAlpha(color21);
                float num127 = (float)(9 - num126) / 9f;
                alpha4.R = (byte)((float)alpha4.R * num127);
                alpha4.G = (byte)((float)alpha4.G * num127);
                alpha4.B = (byte)((float)alpha4.B * num127);
                alpha4.A = (byte)((float)alpha4.A * num127);
                float num128 = (float)(9 - num126) / 9f;
                Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], new Vector2(projectile.oldPos[num126].X - Main.screenPosition.X + num100 + (float)num99, projectile.oldPos[num126].Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY), new Rectangle?(new Rectangle(0, 0, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height)), alpha4, projectile.rotation, new Vector2(num100, (float)(projectile.height / 2 + num98)), num128 * projectile.scale, effects, 0f);
            }
        }
Code:
public override void PostGameDraw(SpriteBatch sb)
        {
            for(int i = 0; i < 1000; i++)
            {
                if(Main.projectile[i].active) //Testing with all projectiles
                {
                    Color color21 = Lighting.GetColor((int)((double)Main.projectile[i].position.X + (double)Main.projectile[i].width * 0.5) / 16, (int)(((double)Main.projectile[i].position.Y + (double)Main.projectile[i].height * 0.5) / 16.0));
                    SpriteEffects effects = SpriteEffects.None;
                    int num98 = 0;
                    int num99 = 0;
                    float num100 = (float)(Main.projectileTexture[Main.projectile[i].type].Width - Main.projectile[i].width) * 0.5f + (float)Main.projectile[i].width * 0.5f;
                    for(int num126 = 0; num126 < 10; num126++)
                    {
                        Color alpha4 = Main.projectile[i].GetAlpha(color21);
                        float num127 = (float)(9 - num126) / 9f;
                        alpha4.R = (byte)((float)alpha4.R * num127);
                        alpha4.G = (byte)((float)alpha4.G * num127);
                        alpha4.B = (byte)((float)alpha4.B * num127);
                        alpha4.A = (byte)((float)alpha4.A * num127);
                        float num128 = (float)(9 - num126) / 9f;
                        Main.spriteBatch.Draw(Main.projectileTexture[Main.projectile[i].type], new Vector2(Main.projectile[i].oldPos[num126].X - Main.screenPosition.X + num100 + (float)num99, Main.projectile[i].oldPos[num126].Y - Main.screenPosition.Y + (float)(Main.projectile[i].height / 2) + Main.projectile[i].gfxOffY), new Rectangle?(new Rectangle(0, 0, Main.projectileTexture[Main.projectile[i].type].Width, Main.projectileTexture[Main.projectile[i].type].Height)), alpha4, Main.projectile[i].rotation, new Vector2(num100, (float)(Main.projectile[i].height / 2 + num98)), num128 * Main.projectile[i].scale, effects, 0f);
                    }
                }
            }
        }

There seems to be nothing wrong with the code and I checked the placement of the hooks, but still can't figure out why it's not working...
 
There is a way to change shoot position without get this..?
View attachment 46862

I've tried to change x and y but this, is what happen:
View attachment 46868
View attachment 46882
View attachment 46883

What i need to change for make projectile exit from the barrels position? I'm really out of mind for this ;-;
Hmm, I would use a CS file for it... I would probably do something like this for the projectile.

ModProjectileName.cs
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using TAPI;
using Terraria;

namespace ModInternalName.Projectiles
{
    public class ModProjectileName : ModProjectile
    {
        public override void AI()
        {
            projectile.alpha = 255; //Set to invisible
            projectile.ai[0] += 1f; //Just adds to the timer
            if(projectile.ai[0] > 3f) //After 3 ticks, the projectile will appear, adjust the number to make it "appear" further from the weapon
            {
                projectile.alpha = 0; //Set it to visible
            }
        }
    }
}
 
Hmm, I would use a CS file for it... I would probably do something like this for the projectile.

ModProjectileName.cs
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using TAPI;
using Terraria;

namespace ModInternalName.Projectiles
{
    public class ModProjectileName : ModProjectile
    {
        public override void AI()
        {
            projectile.alpha = 255; //Set to invisible
            projectile.ai[0] += 1f; //Just adds to the timer
            if(projectile.ai[0] > 3f) //After 3 ticks, the projectile will appear, adjust the number to make it "appear" further from the weapon
            {
                projectile.alpha = 0; //Set it to visible
            }
        }
    }
}

THX >.< can be useful, but.. there is no way to make it with the coordinates ;-; ?(without make the projectile spawn from below or back of you if you are in another direction, obviously.. ) can be better for some reasons..
 
THX >.< can be useful, but.. there is no way to make it with the coordinates ;-; ?(without make the projectile spawn from below or back of you if you are in another direction, obviously.. ) can be better for some reasons..
You shouldn't really do it with coordinates, as it is much more difficult to manage moving where the projectile spawns... This code making it invisible at first then visible allows it so that it will "appear" to be correct when spawned rather than it being just spawned on the player.
 
Back
Top Bottom