tModLoader Help to figure out sword projectile going through enemies and not damaging

Luxxadin

Terrarian
Heya! I'm pretty new to terraria modding and to C# in general, i was following a tutorial video for a basic custom weapon and a basic custom projectile, but even though the code was the same, my projectile's going through enemies and not damaging them, it seems to be colliding with tiles normally though, the sword's also doing melee damage as normal.
Here's the code for the weapon and the projectile:
1739319751306.png


1739319766601.png


I appreciate any help or insight!
 
I believe it’s because of the line ‘Projectile.aiStyle = 0;’

You can find a list of aiStyles here.
 
I believe it’s because of the line ‘Projectile.aiStyle = 0;’

You can find a list of aiStyles here.
Thank you for your reply, i've tested with ai.style 1 and 18 as well, to the same result.
Here's a printscreen of what it looks like in-game (the damage on their hp was done by the guide)
1739327769403.png
 
try getting rid of the Projectile.damage = 10; line in the projectile's code and see if that does anything

also, the Projectile.tileCollide = true; and Projectile.ignoreWater = false lines are superfluous, they default to true and false respectively, unless you plan on changing that. Projectile.hostile = false; might also be unnecessary, but i don't remember what that one defaults to

for the item file, Item.shootSpeed and Item.knockback both use float, so the proper lines would be Item.shootSpeed = 10f; and Item.knockback = 6f;, although you said the sword works fine, so that might not be causing it
 
try getting rid of the Projectile.damage = 10; line in the projectile's code and see if that does anything

also, the Projectile.tileCollide = true; and Projectile.ignoreWater = false lines are superfluous, they default to true and false respectively, unless you plan on changing that. Projectile.hostile = false; might also be unnecessary, but i don't remember what that one defaults to

for the item file, Item.shootSpeed and Item.knockback both use float, so the proper lines would be Item.shootSpeed = 10f; and Item.knockback = 6f;, although you said the sword works fine, so that might not be causing it
It's a bit late here but i'll try that tomorrow, if anything i'll probably rebuild the whole code from scratch following another guide to see what happens, mainly posted this to check if it an easy to spot issue, i'll keep this thread posted, thanks for the insight!
 
In your projectile, you have the defaults in SetStaticDefaults() but they should be in SetDefaults() instead.
 
Oh my god i didn't even notice that
1000009835.png


I'm actually kinda surprised the game didn't throw an error when compiling the mod
 
In your projectile, you have the defaults in SetStaticDefaults() but they should be in SetDefaults() instead.
That worked! Thank you! What's the diference between staticdefaults and defaults?

On another newbie question, i made a custom sprite for the project that's like the Terra blade projectile, was wondering how to make it rotate depending on the direction you shoot it
 
On another newbie question, i made a custom sprite for the project that's like the Terra blade projectile, was wondering how to make it rotate depending on the direction you shoot it

if you're talking about the long range projectile the terra blade fires out (it fires out 2 different projectiles that are coded very differently) then i'm pretty sure this is how that projectile's rotation is coded:

C#:
public override void AI() {
    Projectile.rotation = Projectile.velocity.ToRotation();
}

which is also how most projectiles that face the direction they travel in are coded

the terra blade swinging projectile that's similar to the excalibur/t. excalibur and horseman's blade swinging projectile is alot more complex in how it operates
 
if you're talking about the long range projectile the terra blade fires out (it fires out 2 different projectiles that are coded very differently) then i'm pretty sure this is how that projectile's rotation is coded:

C#:
public override void AI() {
    Projectile.rotation = Projectile.velocity.ToRotation();
}

which is also how most projectiles that face the direction they travel in are coded

the terra blade swinging projectile that's similar to the excalibur/t. excalibur and horseman's blade swinging projectile is alot more complex in how it operates
That's perfect, thank you!
They're now rotating as i wanted them to:
1739416552193.png

1739416563414.png

1739416576515.png


I'll use this idea for a pretty simple custom Bleach progression for homebrew use only, again, thank you for all the help!
 
Back
Top Bottom