tAPI [Tutorial] Projectile Guide and Implementation

Wut do u mean? I pretty much made a sprite dats 1x1 and had it spawn paladins hammers (The friendly kind) every frame and the game thinks the player threw the paladins hammers so they flew 2 my character
 
Wut do u mean? I pretty much made a sprite dats 1x1 and had it spawn paladins hammers (The friendly kind) every frame and the game thinks the player threw the paladins hammers so they flew 2 my character
Actually, that sounds hilarious, I love it how my tutorial is being used like this!
 
Just imagine 5000 paladins hammers flying toward your character all at once. And how do i take screen shots/make gifs of me doing these things?
ive played terraria for so long yet still havent bothered to find out
 
Just imagine 5000 paladins hammers flying toward your character all at once. And how do i take screen shots/make gifs of me doing these things?
ive played terraria for so long yet still havent bothered to find out
I use Fraps trial version to record (there's probably something better out there) and then use Photoshop to make the GIF.
 
Gimp is great for making sprite transparent. Do you know who posted that really good spriting tut? i cant find it any more :(
 
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using TAPI;
using Terraria;

namespace MPT.Projectiles
{
public class ExampleProjectileB : ModProjectile
{
public override void AI()
{
projectile.light = 0.9f; //Glow just enough for it to cover the projectile
projectile.alpha = 128; //Makes it semi-transparent
projectile.rotation += (float)projectile.direction * 0.8f; - Makes the projectile spin
int DustID = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width + 4, projectile.height + 4, 36, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 120, default(Color), 0.75f); //Create Dust
Main.dust[DustID].noGravity = true; //Makes the Dust not fall into the ground
}
}
}


When I try to use this code, my compiler says that color and Vector2 aren't valid assemblies.
 
Is it possible to create weapons that don't look awkward when using them? What I mean is, when you hold out a gun shouldn't you be holding on it's handle? Or if you want to create a Rapier like sword that has a handguard and you want your character to actually hold it on it's handle? Thank's for creating the tutorial though, appreciate it.
 
Is it possible to create weapons that don't look awkward when using them? What I mean is, when you hold out a gun shouldn't you be holding on it's handle? Or if you want to create a Rapier like sword that has a handguard and you want your character to actually hold it on it's handle? Thank's for creating the tutorial though, appreciate it.
You can adjust where the item is held when used with this peice of code within your item's JSON file.

Code:
"holdoutOffset": [x,y], //How far away or close to the player you want the item to be in terms of pixels.
 
Hey Sin Costan I Made These
upload_2015-4-11_13-48-7.png
 
Sin Costan How Would I Overwrite particles from an Ai style. When i give my weapons an Ai style of 9 it shows blue and white particles
 
Sin Costan How Would I Overwrite particles from an Ai style. When i give my weapons an Ai style of 9 it shows blue and white particles
You cannot override AI Styles, only add to them. However, you can edit the vanilla code and adjust it to your means, you would just need to have the vanilla code, which I have included within this tutorial. Just look for a specific AI style, and copy and paste the vanilla AIStyle and then edit it. All you need to do is replcae "this" with "projectile".
 
You cannot override AI Styles, only add to them. However, you can edit the vanilla code and adjust it to your means, you would just need to have the vanilla code, which I have included within this tutorial. Just look for a specific AI style, and copy and paste the vanilla AIStyle and then edit it. All you need to do is replcae "this" with "projectile".
Thank You
 
Do you know whether you could make a projectile deal extra damage to specific enemy?
Code:
public override void AI()
{
       foreach NPC N in Main.NPC
       {
              Rectangle MB = new Rectangle((int)projectile.position.X + (int)projectile.velocity.X, (int)projectile.position.Y + (int)projectile.velocity.Y, projectile.width, projectile.height); //Variable sets up projectile's hitbox
                Rectangle NB = new Rectangle((int)N.position.X, (int)N.position.Y, N.width, N.height); //Variable sets up NPC's hitbox
                if (MB.Intersects(NB))
                {
                       int weakNPCs = INT; //Input IDs of desired NPCs here
                       float damageMult = FLOAT;  //Input desired damage multiplier here
                       if (N.type == weakNPCs)
                       {
                                projectile.damage *= damageMult;
                       }
                }
       }
}
In the projectile's CS file
 
Code:
public override void AI()
{
       foreach NPC N in Main.NPC
       {
              Rectangle MB = new Rectangle((int)projectile.position.X + (int)projectile.velocity.X, (int)projectile.position.Y + (int)projectile.velocity.Y, projectile.width, projectile.height); //Variable sets up projectile's hitbox
                Rectangle NB = new Rectangle((int)N.position.X, (int)N.position.Y, N.width, N.height); //Variable sets up NPC's hitbox
                if (MB.Intersects(NB))
                {
                       int weakNPCs = INT; //Input IDs of desired NPCs here
                       float damageMult = FLOAT;  //Input desired damage multiplier here
                       if (N.type == weakNPCs)
                       {
                                projectile.damage *= damageMult;
                       }
                }
       }
}
In the projectile's CS file

Hmm, I don't know about the "int weakNPCs" part. Maybe have it as a list or an array instead, as int and other variables only store one object at a time. Say for example...

Code:
int[] weakNPCs = { NPCDef.byName["InternalModName:NPCName"].type, int ID, .... }; //dots to show that it may continue off of it.

Code:
NPCDef.byName["InternalModName:NPCName"].type //Finding the ID of a mod NPC
int ID //The integer ID of a Vanilla NPC

You would have to search through the array to make sure that the types are the same so, you would need to make a for loop to look through that array you just made. For example if you have 5 enemy IDs within the array...

Code:
for(int i = 0; i < 5; i++)
{
         if(weakNPCs[i] == NPC.type)
         {
                  projectile.damage *= dmgMult;
         }
}
 
Last edited:
Back
Top Bottom