tAPI [Discontinued] tAPI - A Mod To Make Mods

Status
Not open for further replies.
Sure, here you go:
Hm, first of all, for your item's .json, you'll want the useStyle to be 5, noUseGraphic to be true, and noMelee to be true. You'll also want to use the shoot and shootSpeed properties to for your spear's projectile (since spears are actually projectiles).

For the projectile (not the item), you want the spear's tip to be pointing to the top left. Then you'll want the following properties:
Code:
{
    "displayName": "Weapon Name",
    "width": 18,
    "height": 18,
    "melee": true,
    "friendly": true,
    "tileCollide": false,
    "ignoreWater": true,
    "penetrate": -1,
    "hide": true,
    "ownerHitCheck": true,
    "melee": true
}
Finally, you'll need a .cs file for your projectile:
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using TAPI;

namespace ModName.Projectiles {
public class WeaponName : ModProjectile
{
    public override void AI()
    {
        Player player = Main.player[projectile.owner];
        projectile.direction = player.direction;
        player.heldProj = projectile.whoAmI;
        player.itemTime = player.itemAnimation;
        projectile.position = player.Center - projectile.Size / 2f;

        if(!player.frozen)
        {
            if(projectile.ai[0] == 0f)
            {
                projectile.ai[0] = 3f;//spear's starting distance
                projectile.netUpdate = true;
            }
            if(player.itemAnimation < player.itemAnimationMax / 3)
            {
                projectile.ai[0] -= 2.4f;//spear's retreating speed
            }
            else
            {
                projectile.ai[0] += 2.1f;//spear's forward speed
            }
        }
        projectile.position += projectile.velocity * projectile.ai[0];

        if(player.itemAnimation == 0)
        {
            projectile.Kill();
        }
        projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 2.355f;
        if(projectile.spriteDirection == -1)
        {
            projectile.rotation -= 1.57f;
        }
    }

    public override bool PreDraw(SpriteBatch sb)
    {
        projectile.aiStyle = 19;
        return true;
    }

    public override void PostDraw(SpriteBatch sb)
    {
        projectile.aiStyle = 0;
    }
}}
 
Hm, first of all, for your item's .json, you'll want the useStyle to be 5, noUseGraphic to be true, and noMelee to be true. You'll also want to use the shoot and shootSpeed properties to for your spear's projectile (since spears are actually projectiles).

For the projectile (not the item), you want the spear's tip to be pointing to the top left. Then you'll want the following properties:
Code:
{
    "displayName": "Weapon Name",
    "width": 18,
    "height": 18,
    "melee": true,
    "friendly": true,
    "tileCollide": false,
    "ignoreWater": true,
    "penetrate": -1,
    "hide": true,
    "ownerHitCheck": true,
    "melee": true
}
Finally, you'll need a .cs file for your projectile:
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using TAPI;

namespace ModName.Projectiles {
public class WeaponName : ModProjectile
{
    public override void AI()
    {
        Player player = Main.player[projectile.owner];
        projectile.direction = player.direction;
        player.heldProj = projectile.whoAmI;
        player.itemTime = player.itemAnimation;
        projectile.position = player.Center - projectile.Size / 2f;

        if(!player.frozen)
        {
            if(projectile.ai[0] == 0f)
            {
                projectile.ai[0] = 3f;//spear's starting distance
                projectile.netUpdate = true;
            }
            if(player.itemAnimation < player.itemAnimationMax / 3)
            {
                projectile.ai[0] -= 2.4f;//spear's retreating speed
            }
            else
            {
                projectile.ai[0] += 2.1f;//spear's forward speed
            }
        }
        projectile.position += projectile.velocity * projectile.ai[0];

        if(player.itemAnimation == 0)
        {
            projectile.Kill();
        }
        projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 2.355f;
        if(projectile.spriteDirection == -1)
        {
            projectile.rotation -= 1.57f;
        }
    }

    public override bool PreDraw(SpriteBatch sb)
    {
        projectile.aiStyle = 19;
        return true;
    }

    public override void PostDraw(SpriteBatch sb)
    {
        projectile.aiStyle = 0;
    }
}}
This is what I ended up with and my mod's .jsons won't load in tAPI.
 

Attachments

  • HeroicaMod.zip
    20.5 KB · Views: 106
What .cs file?
This one:
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using TAPI;

namespace ModName.Projectiles {
public class WeaponName : ModProjectile
{
public override void AI()
{
Player player = Main.player[projectile.owner];
projectile.direction = player.direction;
player.heldProj = projectile.whoAmI;
player.itemTime = player.itemAnimation;
projectile.position = player.Center - projectile.Size / 2f;

if(!player.frozen)
{
if(projectile.ai[0] == 0f)
{
projectile.ai[0] = 3f;//spear's starting distance
projectile.netUpdate = true;
}
if(player.itemAnimation < player.itemAnimationMax / 3)
{
projectile.ai[0] -= 2.4f;//spear's retreating speed
}
else
{
projectile.ai[0] += 2.1f;//spear's forward speed
}
}
projectile.position += projectile.velocity * projectile.ai[0];

if(player.itemAnimation == 0)
{
projectile.Kill();
}
projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 2.355f;
if(projectile.spriteDirection == -1)
{
projectile.rotation -= 1.57f;
}
}

public override bool PreDraw(SpriteBatch sb)
{
projectile.aiStyle = 19;
return true;
}

public override void PostDraw(SpriteBatch sb)
{
projectile.aiStyle = 0;
}
}}
Also posted it earlier, that version has indentations. Guess for some reason copying it over to here removed the indentations.
 
This one:
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using TAPI;

namespace ModName.Projectiles {
public class WeaponName : ModProjectile
{
public override void AI()
{
Player player = Main.player[projectile.owner];
projectile.direction = player.direction;
player.heldProj = projectile.whoAmI;
player.itemTime = player.itemAnimation;
projectile.position = player.Center - projectile.Size / 2f;

if(!player.frozen)
{
if(projectile.ai[0] == 0f)
{
projectile.ai[0] = 3f;//spear's starting distance
projectile.netUpdate = true;
}
if(player.itemAnimation < player.itemAnimationMax / 3)
{
projectile.ai[0] -= 2.4f;//spear's retreating speed
}
else
{
projectile.ai[0] += 2.1f;//spear's forward speed
}
}
projectile.position += projectile.velocity * projectile.ai[0];

if(player.itemAnimation == 0)
{
projectile.Kill();
}
projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 2.355f;
if(projectile.spriteDirection == -1)
{
projectile.rotation -= 1.57f;
}
}

public override bool PreDraw(SpriteBatch sb)
{
projectile.aiStyle = 19;
return true;
}

public override void PostDraw(SpriteBatch sb)
{
projectile.aiStyle = 0;
}
}}
Also posted it earlier, that version has indentations. Guess for some reason copying it over to here removed the indentations.
Here is what I have now, the game loads but no projectile is being produced when I activate the spear.
[DOUBLEPOST=1432171051,1432170994][/DOUBLEPOST]Sorry, the .zip files are both the same. It doubled my post for some reason..
 

Attachments

  • HeroicaMod.zip
    21.2 KB · Views: 176
  • HeroicaMod.zip
    21.2 KB · Views: 137
Here is what I have now, the game loads but no projectile is being produced when I activate the spear.
[DOUBLEPOST=1432171051,1432170994][/DOUBLEPOST]Sorry, the .zip files are both the same. It doubled my post for some reason..
Try renaming Aegos.cs to AegosProj.cs (and the same name change for the class name), then moving that file to the Projectiles folder.
 
Try renaming Aegos.cs to AegosProj.cs (and the same name change for the class name), then moving that file to the Projectiles folder.
Okay, it is producing a projectile now, but it is going super far like an anti-gravity arrow.
upload_2015-5-20_21-28-0.png
 
One more thing, do you know of a place where I can get a list of all the .cs effect lines? Examples would be p.maxMinions += 1; or p.thorns = 1.5f;.
 
Status
Not open for further replies.
Back
Top Bottom