Standalone [1.3] tModLoader - A Modding API

Bluemagic123 I man this :
public override void AddCraftGroups()
{
AddCraftGrouop("Lasers", Lang.misc[37] + " " + ...
}
Oh, Lang.misc[37] basically just translates the word "Any" for you, just in case someone is using a different language.

Yeah, yeah, I should have known my expression going ambiguously again, sorry about that.
Buy this "ammo", I mean, what a gun shoots does not decide on what its "item.shoot" is, but decide on the ammo it's using. So, if this is the case, how should I create the projectile of the ammo-decided projectile in Shoot hook? Now normally regarding some laser weapons, they have their own projectile. If I'm to modify their lasers, it's quite simple. And if I'm to modify what a gun shoots, that can be a lot of works to do, since I don't know how to refer to what a gun is shooting, I can only use "if" to judge this type by type. Maybe you could give me some examples about how to create a projectile (same as a gun is shooting) in Shoot hook.
And in a NewProjectile call:
Code:
Projectile.NewProjectile(float, float, float, float, int, int, float, int, float, float)
There seems not to be a value that defines the update times, How should I call this ExtraUpdates?
I have it so that you don't have to call Projectile.NewProjectile if you want the weapon to decide what's fired. You just need to modify the type parameter in the Shoot hook to the type of the projectile you want to shoot.
 
There seems not to be a value that defines the update times, How should I call this ExtraUpdates?
It is a field of projectile. You set it in modprojectile.setdefaults(). You don't call it because it is a number(int) not a function.

What should i do if mod cannot be build because of extraUpdate ?
It make this error : Cannot implicitly convert type 'bool' to 'int'
The error there explains it perfectly. Set it to an int not a bool
 
Yeah, yeah, I should have known my expression going ambiguously again, sorry about that.
Buy this "ammo", I mean, what a gun shoots does not decide on what its "item.shoot" is, but decide on the ammo it's using. So, if this is the case, how should I create the projectile of the ammo-decided projectile in Shoot hook? Now normally regarding some laser weapons, they have their own projectile. If I'm to modify their lasers, it's quite simple. And if I'm to modify what a gun shoots, that can be a lot of works to do, since I don't know how to refer to what a gun is shooting, I can only use "if" to judge this type by type. Maybe you could give me some examples about how to create a projectile (same as a gun is shooting) in Shoot hook.
And in a NewProjectile call:
Code:
Projectile.NewProjectile(float, float, float, float, int, int, float, int, float, float)
There seems not to be a value that defines the update times, How should I call this ExtraUpdates?
If you check the vanilla ammos, you'll notice they have a shoot field. Essentially, whenever a weapon uses an ammo, it uses the ammo's shoot field, shootSpeed too iirc. So you essentially want your weapon to have multiple ammos with multiple different shoot IDs so that they will shoot different projectiles depending on the ammo.

As jopojelly pointed out, extraUpdates is a projectile field. You can, however, have your gun set it instead if you create the weapon's projectile manually, then change its extraUpdates from there, like this
Code:
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
        int proj = Projectile.NewProjectile(position.X,position.Y,speedX,speedY,type,damage,knockBack,player.whoAmI);
        Main.projectile[proj].extraUpdates = 2;
        return false;
}
Of course, if you plan on using the same projectile multiple times with the same extraUpdates value, you might want to change the projectile instead if it's a custom one.
 
The error there explains it perfectly. Set it to an int not a bool
But i just add extraUpdate and it wryte this error
or how do i make projectile look like laser i want to make it to just appear like with shoot speed unlimited
 
Last edited:
But i just add extraUpdate and it wryte this error
or how do i make projectile look like laser i want to make it to just appear like with shoot speed unlimited
If you mean hit instantly, make your weapon shoot very slowly (like maybe a shootSpeed of 1 or 2), then give the projectile a number of extraUpdates equal to speed*X pixels of distance you want your laser to reach. In the projectile's preAI or postAI, make it create dusts, so it will not look completely invisible.
 
Is it possible to make a clentaminator/solution?
Sure. I found this old post from this very thread. ( I searched this thread only for clentaminator and it was in the results.)

Also a couple pages back I posted code for someone trying to combat corruption. A solution is the same code, just on a projectile instead of a tile. I think on ai. Check the vanilla item fields values spreadsheet for the specifics on the solutions.

This reminds me, I need to make a spreadsheet for projectiles too.

Underground desert? more like giant bee hive!!


another:

last one:

heh, I've never used the Clentaminator until a few days ago, it's pretty cool. Any ideas for a cool solution?
 
Sure. I found this old post from this very thread. ( I searched this thread only for clentaminator and it was in the results.)

Also a couple pages back I posted code for someone trying to combat corruption. A solution is the same code, just on a projectile instead of a tile. I think on ai. Check the vanilla item fields values spreadsheet for the specifics on the solutions.

This reminds me, I need to make a spreadsheet for projectiles too.
Any idea of how to do it in the code?
 
can someone help me i cant return to vanilla please i need help and fast please

C:\Program Files (x86)\Steam\steamapps\common\Terraria

then use the terraria_v1.3.0.8 or what els its called

try that
[DOUBLEPOST=1450665137,1450665070][/DOUBLEPOST]so its possible to give a effect on hit enemy

and possible to spawn item on hit enemy

but is it possible to spawn a enemy on hit enemy?
 
thats all well and good but i got no idea how to use these codes

need code thats made that i then can change some things on
Oops, I thought you said spawn item on hit. Here is the method you'll call instead of Item.newItem:
public static int NewNPC(int X, int Y, int Type, int Start = 0, float ai0 = 0f, float ai1 = 0f, float ai2 = 0f, float ai3 = 0f, int Target = 255)

As for code, it's like this in your ModNPC: (I'm assuming the npc is the one spawning the other npc, but for an item or projectile to have the same effect, there are similar hooks you can use. The GitHub wiki knows all)
Code:
        public override void OnHitByItem(Player player, Item item, int damage, float knockback, bool crit)
        {
            NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("ModNPCNameHere"));
           // OR
            NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, Terraria.ID.NPCID.Bunny);
        }

        public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit)
        {
            NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("ModNPCNameHere"));
           // OR
            NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, Terraria.ID.NPCID.Bunny);
        }
 
Oops, I thought you said spawn item on hit. Here is the method you'll call instead of Item.newItem:
public static int NewNPC(int X, int Y, int Type, int Start = 0, float ai0 = 0f, float ai1 = 0f, float ai2 = 0f, float ai3 = 0f, int Target = 255)

As for code, it's like this in your ModNPC: (I'm assuming the npc is the one spawning the other npc, but for an item or projectile to have the same effect, there are similar hooks you can use. The GitHub wiki knows all)
Code:
        public override void OnHitByItem(Player player, Item item, int damage, float knockback, bool crit)
        {
            NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("ModNPCNameHere"));
            NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, Terraria.ID.NPCID.Bunny);
        }

        public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit)
        {
            NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("ModNPCNameHere"));
            NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, Terraria.ID.NPCID.Bunny);
        }

it looks like u miss read the 2 top lines

i just stated that u can aply a effect to enemy on hit

and item drop of enemy on hit aswell with the weapon that has the code

so what i wanted was spawn another enemy(greenslime for example) when useing like example sword to hit any mob and spawn it on the other mobs spot so noth mobs are there

EDIT just so u know all these things are on the weapon not the NPC
 
useing like example sword to hit any mob and spawn it on the other mobs spot so noth mobs are there

EDIT just so u know all these things are on the weapon not the NPC
K, I assumed you wanted an npc that kept multiplying itself when hit.

Here is what you can add to ExampleSword.cs
Code:
        public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(BuffID.OnFire, 60);
            //NPC.NewNPC((int)target.Center.X, (int)target.Center.Y, mod.NPCType("ModNPCNameHere"));
            NPC.NewNPC((int)target.Center.X, (int)target.Center.Y, NPCID.LostGirl);
        }

 
  • Like
Reactions: W1K
K, I assumed you wanted an npc that kept multiplying itself when hit.

Here is what you can add to ExampleSword.cs
Code:
        public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(BuffID.OnFire, 60);
            //NPC.NewNPC((int)target.Center.X, (int)target.Center.Y, mod.NPCType("ModNPCNameHere"));
            NPC.NewNPC((int)target.Center.X, (int)target.Center.Y, NPCID.LostGirl);
        }


this looks good

side note how do u add those soundless videos
 
Back
Top Bottom