After checking the AI Style list myself, the AI itself does not contain the code necessary for the damage multiplier, rather, it is in Damage function for the Projectile. It is, however basically set up the same as the code Berberborscing has set up.If you wanna find the code to deal extra damage to enemies just download the Projectile Ai Styles File Sin Costan has and look for the steak. They deal extra damage 2 vampires so U can copy that code. Replace the id of the vampire and add your own Ai/vanilla Ai
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using TAPI;
using Terraria;
namespace MaxsMod.Projectiles
{
public class CopperLanceProj : ModProjectile
{
public override void AI()
{
projectile.light = 0.9f;
int DustID = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width, projectile.height, 24, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 0.5f);
Main.player[projectile.owner].direction = projectile.direction; //Make's the owner face the direction the spear
Main.player[projectile.owner].heldProj = projectile.whoAmI;
Main.player[projectile.owner].itemTime = Main.player[projectile.owner].itemAnimation;
projectile.position.X = Main.player[projectile.owner].position.X + (float)(Main.player[projectile.owner].width / 2) - (float)(projectile.width / 2);
projectile.position.Y = Main.player[projectile.owner].position.Y + (float)(Main.player[projectile.owner].height / 2) - (float)(projectile.height / 2);
projectile.position += projectile.velocity * projectile.ai[0];
if (projectile.ai[0] == 0f)
{
projectile.ai[0] = 3f;
projectile.netUpdate = true;
}
if (Main.player[projectile.owner].itemAnimation < Main.player[projectile.owner].itemAnimationMax / 3)
{
projectile.ai[0] -= 1.1f; //How far back it goes
if (projectile.localAI[0] == 0f && Main.myPlayer == projectile.owner)
{
projectile.localAI[0] = 1f;
if (Collision.CanHit(Main.player[projectile.owner].position, Main.player[projectile.owner].width, Main.player[projectile.owner].height, new Vector2(projectile.center().X + projectile.velocity.X * projectile.ai[0], projectile.center().Y + projectile.velocity.Y * projectile.ai[0]), projectile.width, projectile.height)) //The if statement to make a projectile after the spear point reaaches it's max distance; you can remove the if statements and the things it contains to make it a normal spear
{
Projectile.NewProjectile(projectile.center().X + projectile.velocity.X , projectile.center().Y + projectile.velocity.Y , projectile.velocity.X * 1.5f, projectile.velocity.Y * 1.5f, "COFP:MiniAncientSpear", projectile.damage , projectile.knockBack * 0.85f, projectile.owner, 0f, 0f); //Spawning the projectile
}
}
}
else
{
projectile.ai[0] += 0.75f; //How Far It Goes
}
if (Main.player[projectile.owner].itemAnimation == 0)
{
projectile.Kill(); //Kills projectile after it is done
}
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 2.355f; //Rotates the spear based on where you shoot
if (projectile.spriteDirection == -1)
{
projectile.rotation -= 1.57f;
}
}
}
}
I think you have to create a whole new projectileWow this is really nice!
Now time to go make the gravity gun from Half Life...
MWHAHAHAHAHHA
EDIT: How do I change the colour of vanilla projectiles? Like changing the heat ray projectile to blue?
NOOO! Oh well... how would I make a projectile like the heat ray? Thanks!I think you have to create a whole new projectile![]()
Isnt heat ray like projectiles listed on this tutorial?!?!NOOO! Oh well... how would I make a projectile like the heat ray? Thanks!
Validating Jsons...
Compiling code...
GlassShard.cs (33,24)
'Terraria.Main' does not contain a definition for 'NPC'
foreach (NPC N in Main.NPC)
^
Failed to build TestMod.
The "NPC" part of "Main.NPC" should be all lowercase instead. so it would be "Main.npc".I tried building your code today, it tells me to add brackets and so I did but then this error appear,
Any clue?Code:Validating Jsons... Compiling code... GlassShard.cs (33,24) 'Terraria.Main' does not contain a definition for 'NPC' foreach (NPC N in Main.NPC) ^ Failed to build TestMod.
Haven't tried the Projectile Ai Styles File yet, just having a glimpse of it already made me go @.@ So many questions I wanted to ask but feel uncomfortable in doing so. Why is it so hard to place furniture on tables properly!? etc etc. I really wish there's more guide like this, can't find the things that I wanted online.
How would I make Vilethorn Like weapons?The "NPC" part of "Main.NPC" should be all lowercase instead. so it would be "Main.npc".
You would modify the projectile's velocity within the projectile's cs file (I guess you would already know that...). It all depends on how you want to modify the projectile... Do you want it to go faster as time goes? Do you want it to go slower as the projectile goes? Well here's an example of how you would do either of those.I have the very distinct feeling that this question has a very obvious answer, but how do you modify a projectile's velocity?
public override void AI()
{
projectile.velocity *= 2;
}
public override void AI()
{
projectile.velocity /= 2;
}
public override void AI()
{
projectile.velocity.Y += 0.1f; //Positive goes downwards, and negative goes upwards, just how Terraria handles Y coordinates.
}
[CODE]
Of course there are other ways you can manipulate projectile's velocity through AI, but these are the most simple ones.
how far out do I make a spear go in relation to the sprite size. Like _f for a sprite 22 by 22. I don't know what the number should be.
How would I make Vilethorn Like weapons?
You misunderstand. I want the projectile to have a constant velocity, but I want that velocity to be faster. (This is the kind of thing that I expected to have a .json attribute, but I can't find any that correspond to velocity.)You would modify the projectile's velocity within the projectile's cs file (I guess you would already know that...). It all depends on how you want to modify the projectile... Do you want it to go faster as time goes? Do you want it to go slower as the projectile goes? Well here's an example of how you would do either of those.
Multiplying velocity
Code:public override void AI() { projectile.velocity *= 2; }
Dividing Velocity
Code:public override void AI() { projectile.velocity /= 2; }
Or if you want to have some sort of gravity effect...
Gravitizing Projectile
Code:public override void AI() { projectile.velocity.Y += 0.1f; //Positive goes downwards, and negative goes upwards, just how Terraria handles Y coordinates. } [CODE] Of course there are other ways you can manipulate projectile's velocity through AI, but these are the most simple ones.
What do you mean by constant and faster?You misunderstand. I want the projectile to have a constant velocity, but I want that velocity to be faster. (This is the kind of thing that I expected to have a .json attribute, but I can't find any that correspond to velocity.)
Right now, my projectile travels X speed at all times. I, instead, want it to travel X + 2 speed at all times.What do you mean by constant and faster?
Never mind, I was being a scrub, and I figured out how to change it. There was, in fact, a very obvious answer - I had to change "shootSpeed" in the ammo's .json.Right now, my projectile travels X speed at all times. I, instead, want it to travel X + 2 speed at all times.
By constant, I mean that I want it to travel at the same speed through the air at all times.
By faster, I mean that when I fire it, it's moving slower than I want it to move at all times.
{
"displayName": "Weapons",
"author": "Someone",
"info": "Testing certain equipment",
"version": "0.1.0",
"internalName": "Mod",
"includePDB": true
}
{
"displayName": "Swordzee",
"texture": "Items/Swordzee",
"size": [60, 60],
"maxStack": 1,
"value": [0, 0, 0, 2],
"rare": 9,
"tooltip": "Creating a projectile sword",
"useStyle": 1,
"useAnimation": 10,
"useTime": 10,
"damage": 100,
"knockback": 9,
"crit": 25,
"useSound": 1,
"autoReuse": true,
"useTurn": true,
"melee": true,
"range": true,
"shoot": "Mod:SwordzeeProj",
"shootSpeed": 8,
"recipes": [{
"items":{ "Dirt Block": 1 },
"tiles":[ "Work Bench"],
"creates": 1
}]
}
{
"displayName": "SwordzeeBeam",
"size": [28,84],
"scale": 1,
"aiStyle": 0,
"timeLeft": 3600,
"friendly": true,
"hostile": false,
"tileCollide": false,
"penetrate": -1,
"ranged": true
}
Looking for some help with creating a projectile sword.
I checked all the .json files on jsonlint and no errors were found.
Essentially, the problem is that the sword itself does damage, but it does not shoot a projectile and there is no projectile damage.
I'm aiming for a Terra Blade style projectile that simply shoots a sword in a straight line that does not require mana or ammo.
Code for ModInfo:
Code:{ "displayName": "Weapons", "author": "Someone", "info": "Testing certain equipment", "version": "0.1.0", "internalName": "Mod", "includePDB": true }
Code for weapon:
Code:{ "displayName": "Swordzee", "texture": "Items/Swordzee", "size": [60, 60], "maxStack": 1, "value": [0, 0, 0, 2], "rare": 9, "tooltip": "Creating a projectile sword", "useStyle": 1, "useAnimation": 10, "useTime": 10, "damage": 100, "knockback": 9, "crit": 25, "useSound": 1, "autoReuse": true, "useTurn": true, "melee": true, "range": true, "shoot": "Mod:SwordzeeProj", "shootSpeed": 8, "recipes": [{ "items":{ "Dirt Block": 1 }, "tiles":[ "Work Bench"], "creates": 1 }] }
Code for projectile:
Code:{ "displayName": "SwordzeeBeam", "size": [28,84], "scale": 1, "aiStyle": 0, "timeLeft": 3600, "friendly": true, "hostile": false, "tileCollide": false, "penetrate": -1, "ranged": true }
Images of file locations: