• PC NEWS: 1.4.2.3 update is out! More info here. Report bugs here
  • CONSOLE 1.4 NEWS: The current plan is to have Terraria: Journey's End out for Xbox and PlayStation in Q3 2021 (Jul-Sep). Switch will follow shortly afterwards. More info here. Stay up to date with console news here
  • MOBILE NEWS: Stay up to date with the latest mobile news here. Report mobile bugs here

tModLoader Official tModLoader Help Thread

willcocobo

The Destroyer
so i tried what you said, maybe i just did it wrong but it didnt work. Did i do the sprite sheet right?


what the code is now:

class cursedball : ModProjectile
{
public override void SetStaticDefaults()
{
Main.projFrames[projectile.type] = 4;
}
public override void SetDefaults()
{
projectile.Name = "cursedball";
projectile.width = 28;
projectile.height = 28;
projectile.friendly = true;
projectile.tileCollide = true;
projectile.magic = true;
projectile.timeLeft = 600;
projectile.aiStyle = 0;
projectile.ignoreWater = true;

}
public override void AI()
{
// projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
projectile.frameCounter = 0;
if (++projectile.frameCounter >= 5)
{
projectile.frameCounter = 0;
if (++projectile.frame >= 4)
{
projectile.frame = 0;
 

Solo-Ion

Dungeon Spirit
so i tried what you said, maybe i just did it wrong but it didnt work. Did i do the sprite sheet right?


what the code is now:

class cursedball : ModProjectile
{
public override void SetStaticDefaults()
{
Main.projFrames[projectile.type] = 4;
}
public override void SetDefaults()
{
projectile.Name = "cursedball";
projectile.width = 28;
projectile.height = 28;
projectile.friendly = true;
projectile.tileCollide = true;
projectile.magic = true;
projectile.timeLeft = 600;
projectile.aiStyle = 0;
projectile.ignoreWater = true;

}
public override void AI()
{
// projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
projectile.frameCounter = 0;
if (++projectile.frameCounter >= 5)
{
projectile.frameCounter = 0;
if (++projectile.frame >= 4)
{
projectile.frame = 0;
Hang on, I've read the animation code more carefully and spotted some more errors. Don't have ++ inside if brackets. You use them to increase a value by one. In this case you want to increase frame counter every frame, and increase the frame and reset the frame counter once the frame counter reaches a certain number. You are currently resetting both the frame and the frame counter every frame without increasing either of them.
You want something that looks more like this.
Code:
projectile.frameCounter++; //increase the frame counter
if (projectile.frameCounter >= 5) //once frameCounter reaches the target
{
    projectile.frameCounter = 0; //reset the counter
    projectile.frame++; //and increase the frame
}
if (projectile.frame >= 4) //once past the end of the amination
{
    projectile.frame = 0; //reset the animation
}

I haven't tested this, but it should work. I also can't tell if your closing brackets match up with your opening ones, so there may be mistakes there.
 

kyllinglove

Official Terrarian
I'm new to modding and can't understand what is wrong with this. Both projectiles fire, but the "HarpyBowProjectile" doesn't hit enemies, dummies etc
The code:

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Fmod.Items.Weapons.Ranged.Bows
{
class HarpyBow : ModItem
{
public override void SetStaticDefaults()
{
Tooltip.SetDefault("Shoots arrows and feathers");
}
public override void SetDefaults()
{
item.damage = 200;
item.noMelee = true;
item.ranged = true;
item.width = 11;
item.height = 32;
item.useStyle = ItemUseStyleID.HoldingOut;
item.useAmmo = AmmoID.Arrow;
item.useTime = 50;
item.useAnimation= 50;
item.shootSpeed = 2f;
item.autoReuse = true;
item.shoot = AmmoID.Arrow;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("HarpyBowProjectile"), 300, 2f, player.whoAmI);
return true;
}
}
}




This might be the wrong place to ask questions, but I don't know, so I'm posting here
 

willcocobo

The Destroyer
Hang on, I've read the animation code more carefully and spotted some more errors. Don't have ++ inside if brackets. You use them to increase a value by one. In this case you want to increase frame counter every frame, and increase the frame and reset the frame counter once the frame counter reaches a certain number. You are currently resetting both the frame and the frame counter every frame without increasing either of them.
You want something that looks more like this.
Code:
projectile.frameCounter++; //increase the frame counter
if (projectile.frameCounter >= 5) //once frameCounter reaches the target
{
    projectile.frameCounter = 0; //reset the counter
    projectile.frame++; //and increase the frame
}
if (projectile.frame >= 4) //once past the end of the amination
{
    projectile.frame = 0; //reset the animation
}

I haven't tested this, but it should work. I also can't tell if your closing brackets match up with your opening ones, so there may be mistakes there.
sorry for late reply, man you are amazing it did work. kinda feels like a dumb mistake. thank you so, so much!
 

willcocobo

The Destroyer
I'm new to modding and can't understand what is wrong with this. Both projectiles fire, but the "HarpyBowProjectile" doesn't hit enemies, dummies etc
The code:

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Fmod.Items.Weapons.Ranged.Bows
{
class HarpyBow : ModItem
{
public override void SetStaticDefaults()
{
Tooltip.SetDefault("Shoots arrows and feathers");
}
public override void SetDefaults()
{
item.damage = 200;
item.noMelee = true;
item.ranged = true;
item.width = 11;
item.height = 32;
item.useStyle = ItemUseStyleID.HoldingOut;
item.useAmmo = AmmoID.Arrow;
item.useTime = 50;
item.useAnimation= 50;
item.shootSpeed = 2f;
item.autoReuse = true;
item.shoot = AmmoID.Arrow;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("HarpyBowProjectile"), 300, 2f, player.whoAmI);
return true;
}
}
}




This might be the wrong place to ask questions, but I don't know, so I'm posting here

you should post the code of the projectile its self, it could be a problem there
 

Will-Banksy

Skeletron Prime
Hello, I'm trying to make an NPC, and I don't know how I would make the actual hitbox of the NPC smaller than the sprite?
I know I can change npc.width and npc.height, but I'm hesitant to in case that breaks the animation. Plus I'm wanting the hitbox offset from (0, 0) on the sprite anyway.
Help would be greatly appreciated, thanks
 

kyllinglove

Official Terrarian
you should post the code of the projectile its self, it could be a problem there
Here it is:

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Fmod.Projectiles.WeaponProjectiles.Ranged
{
class HarpyBowProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Feather");
}
public override void SetDefaults()
{
projectile.width = 16;
projectile.height = 12;
projectile.ranged = true;
projectile.aiStyle = 0;
aiType = ProjectileID.HarpyFeather;
projectile.timeLeft = 1200;
}
}
}
 

Will-Banksy

Skeletron Prime
Here it is:

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Fmod.Projectiles.WeaponProjectiles.Ranged
{
class HarpyBowProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Feather");
}
public override void SetDefaults()
{
projectile.width = 16;
projectile.height = 12;
projectile.ranged = true;
projectile.aiStyle = 0;
aiType = ProjectileID.HarpyFeather;
projectile.timeLeft = 1200;
}
}
}
I think you need to set projectile.friendly to true
 

willcocobo

The Destroyer
Here it is:

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Fmod.Projectiles.WeaponProjectiles.Ranged
{
class HarpyBowProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Feather");
}
public override void SetDefaults()
{
projectile.width = 16;
projectile.height = 12;
projectile.ranged = true;
projectile.aiStyle = 0;
aiType = ProjectileID.HarpyFeather;
projectile.timeLeft = 1200;
}
}
}
aight so there are a few thing. first of the problem you were having was because of you not having

projectile.friendly = true;

that will hopfully fix the problem.
depending on what you want it to do you might want to add it so it stops when it hits a block like for example an arrow

projectile.tileCollide = true; ( or if you want it to go through blocks you dont have to)

and finally all projectiles go away if they touch water to change this you type

projectile.ignoreWater = true;

all of the things i showed go under
public override void SetStatic Defaults

which is where you had your other code.
i hope this helps
 

willcocobo

The Destroyer
Hello, I'm trying to make an NPC, and I don't know how I would make the actual hitbox of the NPC smaller than the sprite?
I know I can change npc.width and npc.height, but I'm hesitant to in case that breaks the animation. Plus I'm wanting the hitbox offset from (0, 0) on the sprite anyway.
Help would be greatly appreciated, thanks

im not to wise on the subject. but if you are scared of it breaking the animation, you could make an exact copy of the npc ( add a "1" or something at the end of the name or it will override the pre-existing npc)
then you can mess around with it and not worry about it breaking. if it does break swap the file out with the back-up.

sorry i could not give a straight answere
 

Johan32123

Steampunker
ok so I have a projectile that is shot out of a staff. once the projectile hits the ground, it disappears and spawns in a consumable heart. I tried this in singleplayer, it works just fine, the consumable spawns in and you can use it to heal yourself. However, I wanted to test this with a friend, but for some reason although the projectile spawns, the consumable does NOT spawn after the projectile hits the ground. This issue only occurs in a multiplayer world. Any ideas on what's wrong here?
 

direwolf420

Terrarian
ok so I have a projectile that is shot out of a staff. once the projectile hits the ground, it disappears and spawns in a consumable heart. I tried this in singleplayer, it works just fine, the consumable spawns in and you can use it to heal yourself. However, I wanted to test this with a friend, but for some reason although the projectile spawns, the consumable does NOT spawn after the projectile hits the ground. This issue only occurs in a multiplayer world. Any ideas on what's wrong here?
Look a this example in the projectiles Kill hook: tModLoader/tModLoader and look at line 89 onwards, it shows how to spawn items
 

Will-Banksy

Skeletron Prime
im not to wise on the subject. but if you are scared of it breaking the animation, you could make an exact copy of the npc ( add a "1" or something at the end of the name or it will override the pre-existing npc)
then you can mess around with it and not worry about it breaking. if it does break swap the file out with the back-up.

sorry i could not give a straight answere
I'm using git, so I can always revert if things go badly.
Thanks though
 

Goldblitzx

Skeletron
Can someone please help me wit how to make a bow split arrows into several more arrows, sort of the tsunami?
Thanks in advance!
 

hyperdyne

Terrarian
greetings from linux debian ubuntu 20.04!
the mods work naticelt with steam launcher and tmod after running terraria once..

but the mods cant be found throught the browser or autodownloaded using the modpacks json file

it lists all the mods old and new on the mod browser
info button works

but when you click the download button it literally does nothing.

can someone fix this please?
 

willcocobo

The Destroyer
i dont know why but the worlds in tmodloader wont load, this is the error im getting

Load Failed!
No back-up found

ive never had this problem before, if anyone knows how to fix this, help would be appreciated
 

willcocobo

The Destroyer
i dont know why but the worlds in tmodloader wont load, this is the error im getting

Load Failed!
No back-up found

ive never had this problem before, if anyone knows how to fix this, help would be appreciated

so apparently an enemy npc i added screwed up the game
fixed now though
 

Mr.Oofity

Skeletron
Question, how can you modify a enemies name? I am making a mod where certain enemies can become Elite enemies, having higher stats and inflict different effects. So far everything works alright, color change, stat up. Other than 2 problems being spiders when switching gaining new elite affixes and regenning health and the name. I want to have elite enemies have a slightly changed name, like "Overloading Blue Slime" and "Blazing Eye of Cthulhu." I know this is possible with "Prefixes for Enemies" existing, but have no idea how to do it.
 

FlyingAnanab

Terrarian
Hello, i've recently been getting really bad framerate on modded multiplayer terraria and i have no idea why. I was doing fine, and then i played using fargo's soul mod and my fps was really bad during boss fights, only on multiplayer. Even after disabling the mod i continued to get bad frames. my game runs fine on singleplayer, but is bad in multiplayer whether i am hosting or joining another person's world. I would get around 40-50 fps just chilling at my base, and tank to 10-20 during most bossfights (some fights are fine, but plaugebringer goliath was especially bad). I can gather more info on this if needed. thanks in advance.
 
Top Bottom