Standalone [1.3] tModLoader - A Modding API

Can someone help me here please? :(

Is there something wrong with the sprite? The code? Both?
I had this problem when modding with tAPI, I tried switching animation types and different results happened, if tModLoader is similar, try switching animation styles?
 
can anyone make a mod that adds console/mobile specific items/npcs/etc. to pc? that'd be awesome :D
 
can anyone make a mod that adds console/mobile specific items/npcs/etc. to pc? that'd be awesome :D

No, that would be copyright infringement and against the modding rules.
 
No, that would be copyright infringement and against the modding rules.
can you add the same items with different sprites and names?
 
can you add the same items with different sprites and names?

Well, if it is a different sprite and a different name, then it isn't the same item, so...
 
Well, if it is a different sprite and a different name, then it isn't the same item, so...
same functionality stats and recipe
 
As for a homing projectile, either you'll need to use the aiType and aiStyle of a projectile that already behaves the way you want, or if none do, write your own homing AI.
what are the type and style of chlorophyte bullets?
 
same functionality stats and recipe

In that case, the only answer I can give you is that porting console or mobile content to the PC is against the rules.
 
ID 207, aiStyle 1, its homing isnt in its ai style, but in the bullet itself
what would I do, maybe try to find close enemies and then change the velocity to go towards that, but all those velocity, vector things don't make much sense to me, and I think I would have to use those to do that

someone pls help me
 
what would I do, maybe try to find close enemies and then change the velocity to go towards that, but all those velocity, vector things don't make much sense to me, and I think I would have to use those to do that

someone pls help me
so, what are you trrying to do that you need a homing projctile
 
How do I download the Tremor mudpack
 
How do I download the Tremor mudpack
download tmodloader, then at the main menu hit mod browser, then type Tremor, then, hit download, go into mods(from main menu) and hit reload
 
so, what are you trrying to do that you need a homing projctile
I Have this weapon that shoots this slow projectile, and so It usually misses, so I want to make it a more viable choice by making it home in on enemies. I have no code in any of it attempting homing accept for
Code:
ProjectileID.Sets.Homing[projectile.type] = true;
which doesn't do any thing
 
i can't download tmodloader from mediafire is there any other way to download it
 
Help how to fix this if my npc stay on the grass and its hammered come so thin black line above him and if he come to normal dirt block it disappears??
 
How to add a light effect to my sword like the excalibur one?
 
I Have this weapon that shoots this slow projectile, and so It usually misses, so I want to make it a more viable choice by making it home in on enemies. I have no code in any of it attempting homing accept for
Code:
ProjectileID.Sets.Homing[projectile.type] = true;
which doesn't do any thing
You'll probably need to write your own AI then, but I can show you some code snippets to get you started. When I wanted to make a homing projectile of my own, I started by writing a function that iterates through all NPCs to select which one to target.
//Find the nearest NPC
public NPC FindNearest(Vector2 pos)
{
NPC nearest = null;
float oldDist = 1001;
float newDist = 1000;
for (int i = 0; i < Terraria.Main.npc.Length - 1; i++) //Do once for each NPC in the world
{
if (Terraria.Main.npc.friendly == true)//Don't target town NPCs
continue;
if (Terraria.Main.npc.active == false)//Don't target dead NPCs
continue;
if (Terraria.Main.npc.damage == 0)//Don't target non-aggressive NPCs
continue;
if (nearest == null) //if no NPCs have made it past the previous few checks
nearest = Terraria.Main.npc; //become the nearest NPC
else
{
oldDist = Vector2.Distance(pos, nearest.position);//Check the distance to the nearest NPC that's earlier in the loop
newDist = Vector2.Distance(pos, Terraria.Main.npc.position);//Check the distance to the current NPC in the loop
if (newDist < oldDist)//If closer than the previous NPC in the loop
nearest = Terraria.Main.npc;//Become the nearest NPC
}
}
return nearest; //return the npc that is nearest to the vector 'pos'
}
Then I'd simply need to write "NPC nearestNPC = FindNearest(projectile.Center);" in my AI to find which NPC is nearest to the projectile's center. But recently I looked through the games code, and found the following code snippet.
int num3;
for (int num33 = 0; num33 < 200; num33 = num3 + 1)
{
if (Main.npc[num33].CanBeChasedBy(this, false))
{
float num34 = Main.npc[num33].position.X + (float)(Main.npc[num33].width / 2);
float num35 = Main.npc[num33].position.Y + (float)(Main.npc[num33].height / 2);
float num36 = Math.Abs(this.position.X + (float)(this.width / 2) - num34) + Math.Abs(this.position.Y + (float)(this.height / 2) - num35);
if (num36 < 800f && Collision.CanHit(new Vector2(this.position.X + (float)(this.width / 2), this.position.Y + (float)(this.height / 2)), 1, 1, Main.npc[num33].position, Main.npc[num33].width, Main.npc[num33].height))
{
num31 = num34;
num32 = num35;
flag = true;
}
}
num3 = num33;
}
This uses NPC.CanBeChasedBy() to exclude any NPC's that you don't want to target and Collision.CanHit() to check if it has line of sight with each NPC, which my function didn't.

Once I know which NPC I'm targeting, I like to spawn dust at it's location simply so that I have a visual indication of which NPC is being targeted.

Also, here's some code that makes a projectile home in on the mouse's position. It's not quite self contained, but there's enough there to work with.
//mPos = Main.mouseWorld;//get the mouses position in the world
targPos = findTarget(); //Find the thing I want to home in on -- use your target's position instead
toMouse = (float)Math.Atan2(targPos.Y - projectile.position.Y, targPos.X - projectile.position.X); //calculate a bearing to that thing

if (Main.player[projectile.owner].gravDir == -1f) //if my player is upside down
targPos.Y = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY;//reverse the vertical position of my mouse

//accelerate towards my target
projectile.velocity.X += (float)Math.Cos(toMouse) * acel * randVel; //acel is a float that controls how fast the projectile accelerates. randVel is a random modifier to the acceleration.
projectile.velocity.Y += (float)Math.Sin(toMouse) * acel * randVel;

if (Math.Sqrt(projectile.velocity.X * projectile.velocity.X + projectile.velocity.Y * projectile.velocity.Y) > maxSpeed) //if going too fast
{
//Main.NewText("Max!");
projectile.velocity *= 1 - (acel / maxSpeed); //slow down a little bit
}
None of this code is going to work straight off, it will all need work to suit your needs. But I hope you find it helpful.

Edit: huh, looks like spoiler tags aren't the things to put code into.
 
Last edited:
Back
Top Bottom