Standalone [1.3] tModLoader - A Modding API

jopojelly

Retinazer
tModLoader
So now first ignore my guard issues, let me focus on some projectiles.
I'm trying to make myself a kind of bullet, maybe some sorta Purification Bullet, I guess.
Basically it will create a purification powder when it hits tiles.
I do it like this, in OnTileCollide hook:
Code:
            Projectile.NewProjectile(projectile.position.X, projectile.position.Y, projectile.velocity.X, projectile.velocity.Y, 10, (int)((double)projectile.damage * 0.1), 0f, projectile.owner, ProjectileID.PurificationPowder);
It works fine both on damage and purifiaction function, but there is still something wrong with the projectile. When the purification powder reaches the end, it will stay there and keep doing damage for up to 20 times. I guess this may have something to do with the timeLeft of the projectile, maybe the lasting time of purification is longer than the usual. So, how can I change lating time of a New Projectile? Or just how should I fix this?
By the way, upon this function, is it possible to adjust the purification range? The purification range seems to have nothing to do with the actual projectile.
https://github.com/bluemagic123/tMo...virtual-bool-ontilecollidevector2-oldvelocity
Are you returning true or false in your OnTileCollide? My guess is the projectile isn't being killed because you return false, so it keeps spawning purification powders as it sits there, colliding each frame. Either kill it or return true to kill it.
Changing purification range would probably mean making your own purifying projectile, not just spawning one. Maybe you can spawn more than one? One at position and the second further along the velocity vector?
 

wch

Terrarian
https://github.com/bluemagic123/tMo...virtual-bool-ontilecollidevector2-oldvelocity
Are you returning true or false in your OnTileCollide? My guess is the projectile isn't being killed because you return false, so it keeps spawning purification powders as it sits there, colliding each frame. Either kill it or return true to kill it.
Changing purification range would probably mean making your own purifying projectile, not just spawning one. Maybe you can spawn more than one? One at position and the second further along the velocity vector?
Take a lot of efforts to cut this picture:
x.gif

It seems to have nothing to do with return true or false.
And your idea of changing the range is really brilliant! I think it's gonna work, but still, I think this attack problem has something to do with the lasting time.
 

jopojelly

Retinazer
tModLoader
Take a lot of efforts to cut this picture:
View attachment 89778
It seems to have nothing to do with return true or false.
And your idea of changing the range is really brilliant! I think it's gonna work, but still, I think this attack problem has something to do with the lasting time.
Oh, I just noticed something in your code:
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, projectile.velocity.X, projectile.velocity.Y, 10, (int)((double)projectile.damage * 0.1), 0f, projectile.owner, ProjectileID.PurificationPowder);

Method: NewProjectile(float X, float Y, float SpeedX, float SpeedY, int Type, int Damage, float KnockBack, int Owner = 255, float ai0 = 0f, float ai1 = 0f)

You are setting damage of the new projectile based off of the damage of the bullet projectile! Don't you just want it to be 0? Also, no need to set ai0 to ProjectileID.PurificationPowder. You can swap out the 10 for ProjectileID.PurificationPowder though, since they are the same.

Or did you want the purification powder to damage? The problem is the projectile has penetrate set to -1, which means it will penetrate infinitely until it times out. I think you can do this
int a = Projectile.NewProjectile(....
Main.projectile[a].penetrate = 1;

But yeah, just set damage to 0.
 

wch

Terrarian
Oh, I just noticed something in your code:
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, projectile.velocity.X, projectile.velocity.Y, 10, (int)((double)projectile.damage * 0.1), 0f, projectile.owner, ProjectileID.PurificationPowder);

Method: NewProjectile(float X, float Y, float SpeedX, float SpeedY, int Type, int Damage, float KnockBack, int Owner = 255, float ai0 = 0f, float ai1 = 0f)

You are setting damage of the new projectile based off of the damage of the bullet projectile! Don't you just want it to be 0? Also, no need to set ai0 to ProjectileID.PurificationPowder. You can swap out the 10 for ProjectileID.PurificationPowder though, since they are the same.

Or did you want the purification powder to damage? The problem is the projectile has penetrate set to -1, which means it will penetrate infinitely until it times out. I think you can do this
int a = Projectile.NewProjectile(....
Main.projectile[a].penetrate = 1;

But yeah, just set damage to 0.
Yeah, thanks for the tips.
Acutally the damage is quite OK, that's actually what I need. The problem is that it attacks too much times, and after set the penetration it works fine!
So another thing, how can I add a new gun firing sound to the game and apply it to my new rifle? Like the AWP I've made for myself?
 

jopojelly

Retinazer
tModLoader
Yeah, thanks for the tips.
Acutally the damage is quite OK, that's actually what I need. The problem is that it attacks too much times, and after set the penetration it works fine!
So another thing, how can I add a new gun firing sound to the game and apply it to my new rifle? Like the AWP I've made for myself?
In Mod Sources/(modname)/Sounds/Item place a .wav file.
In the ModItem.SetDefaults: "item.useSound = mod.GetSoundSlot(SoundType.Item, "Sounds/Item/SoundFilenameNoExtensionHere");"
Make sure the Mod.setModInfo has: "properties.AutoloadSounds = true;"
Should work. If it doesn't, the wav file might be incorrectly formatted.
 

wch

Terrarian
In Mod Sources/(modname)/Sounds/Item place a .wav file.
In the ModItem.SetDefaults: "item.useSound = mod.GetSoundSlot(SoundType.Item, "Sounds/Item/SoundFilenameNoExtensionHere");"
Make sure the Mod.setModInfo has: "properties.AutoloadSounds = true;"
Should work. If it doesn't, the wav file might be incorrectly formatted.
OK, I'll give it a shot. And do you have an idea about my guard stuff problem I've posted yesterday?
 

jopojelly

Retinazer
tModLoader
OK, I'll give it a shot. And do you have an idea about my guard stuff problem I've posted yesterday?
no idea, i haven't gotten around to doing a town npc yet, so I've no experience. The suggestion I gave earlier was just me looking up the numbers used by the Dye Trader for that variable that seemed off to me.
 

wch

Terrarian
no idea, i haven't gotten around to doing a town npc yet, so I've no experience. The suggestion I gave earlier was just me looking up the numbers used by the Dye Trader for that variable that seemed off to me.
So, I put a SG550.WAV in MOD(wch)\Sounds
And set my AWP like this:
Code:
            item.useSound = mod.GetSoundSlot(SoundType.Item, "Sounds/SG550");
But it ain't working. It can be compiled but my AWP simply goes silent. Is there a strict restriction of this WAV file? How should I format it?
 

jopojelly

Retinazer
tModLoader
So, I put a SG550.WAV in MOD(wch)\Sounds
And set my AWP like this:
Code:
            item.useSound = mod.GetSoundSlot(SoundType.Item, "Sounds/SG550");
But it ain't working. It can be compiled but my AWP simply goes silent. Is there a strict restriction of this WAV file? How should I format it?
That's not what I told you to do. Put it in the Item folder. (Otherwise, you need to add the sound manually)
https://github.com/bluemagic123/tModLoader/wiki/ModProperties#public-bool-autoloadsounds

If, for some reason, you want to do it manually, you can:
https://github.com/bluemagic123/tMo...type-string-soundpath-modsound-modsound--null

Sorry, mod files.

.cs and such.

I don't know what I need for modding
If you want the most frustration-free coding (after a bit of setup), use Visual Studio Community 2015.
If you want the simplest setup, use Notepad++.
Either way, do you know how to program? Do you know c# syntax?
Get started by looking at Items in the Example Mod, try changing some values, building in game, and seeing how your changes appear in-game. From there, work on making whatever you feel like.

Images you can use Photoshop, Paint.net, whatever.
 

raptor722

Terrarian
I have problem : the laser i was doind is good but the animation is wierd because the little dusts i created are randomly rotated so it look like explosions of red dots what should i do
Can anyone help pls it was 2 day and nothing i tryed change everythink but it dont work
 

jopojelly

Retinazer
tModLoader
Can anyone help pls it was 2 day and nothing i tryed change everythink but it dont work
Some vanilla dusts have default velocities, maybe that's the problem? Either try a different one, make your own dust, or try to circumvent that by manually setting things to zero.
Code:
int dustIndex = Dust.NewDust(......);
Dust dust = Main.dust[dustIndex];
dust.velocity = Vector2.Zero;
dust.rotation = 0;
dust.scale = 1;

If that doesn't help, a video or screenshot would be useful. Code as well.
 

wch

Terrarian
That's not what I told you to do. Put it in the Item folder. (Otherwise, you need to add the sound manually)
https://github.com/bluemagic123/tModLoader/wiki/ModProperties#public-bool-autoloadsounds

If, for some reason, you want to do it manually, you can:
https://github.com/bluemagic123/tMo...type-string-soundpath-modsound-modsound--null


If you want the most frustration-free coding (after a bit of setup), use Visual Studio Community 2015.
If you want the simplest setup, use Notepad++.
Either way, do you know how to program? Do you know c# syntax?
Get started by looking at Items in the Example Mod, try changing some values, building in game, and seeing how your changes appear in-game. From there, work on making whatever you feel like.

Images you can use Photoshop, Paint.net, whatever.
Code:
        public void AddSound(SoundType type, string soundPath, ModSound modSound = null)
        {
            type = SoundType.Item;
            soundPath = "Sounds/SG550";
        }
Yeah, I want to put it in different folders.
So I set it like this, am I right? And is it necessary to change the "item.usesound" that I've put in AWP item.cs?

By the way, I also have some problems in changing the vanilla texture...
I'm trying to change the projectile texture of Crystal Bullet, so I did it like how I've changed the vanilla item texture:
Code:
        Texture2D vanillaCobaltShieldTexture;
        Texture2D vanillaCrystalBulleProjectileTexture;

        public override void Load()
        {
            vanillaCobaltShieldTexture = Main.itemTexture[ItemID.CobaltShield];
            Main.itemTexture[ItemID.CobaltShield] = ModLoader.GetTexture("wch/VanillaRedesign/CobaltShieldRedesign");
            vanillaCrystalBulleProjectileTexture = Main.projectileTexture[ProjectileID.CrystalBullet];
            Main.projectileTexture[ProjectileID.CrystalBullet] = ModLoader.GetTexture("wch/VanillaRedesign/CrystalBulletProjectileRedesign");

        }

        public override void Unload()
        {
            Main.itemTexture[ItemID.CobaltShield] = vanillaCobaltShieldTexture;
            Main.projectileTexture[ProjectileID.CrystalBullet] = vanillaCrystalBulleProjectileTexture;
        }
Then it won't work out like the item does. What's wrong?
 

ojwiajdioajdoiawjoiadj

Official Terrarian
Where are we supposed to report stuff that is wrong or incorrect? It seems that the ingame mod browser states that eld Accessories is version 0.3.0 however i compared the file size and the the ingame items and the mod browser version eld accessoriers is actually 0.1.0, could you change it?
 

samufinland

Empress of Light
That's not what I told you to do. Put it in the Item folder. (Otherwise, you need to add the sound manually)
https://github.com/bluemagic123/tModLoader/wiki/ModProperties#public-bool-autoloadsounds

If, for some reason, you want to do it manually, you can:
https://github.com/bluemagic123/tMo...type-string-soundpath-modsound-modsound--null


If you want the most frustration-free coding (after a bit of setup), use Visual Studio Community 2015.
If you want the simplest setup, use Notepad++.
Either way, do you know how to program? Do you know c# syntax?
Get started by looking at Items in the Example Mod, try changing some values, building in game, and seeing how your changes appear in-game. From there, work on making whatever you feel like.

Images you can use Photoshop, Paint.net, whatever.
Thank you, it was probably Notepad++ I was using but my laptop broke and I didn't remember the name of the peogram. And yeah, I know nothing about programming so changing values it is!
 

Raii Ichi

Steampunker
Merry Christmas everyone!

So I have a problem: I dont know how to make throwing weapons
It would be very nice from you if someone of you could just tell me how to <3
 

samufinland

Empress of Light
Merry Christmas everyone!

So I have a problem: I dont know how to make throwing weapons
It would be very nice from you if someone of you could just tell me how to <3


I have very little experience but it is like a gun that does not display the gun and shows a throwing animation as using animation, deals thrown damage, stacks and uses itself as ammunition. And usually has the spinning, heavily affected by gravity projectile ID. That's my guess. A real professional will probably reply soon
 
Last edited:

Raii Ichi

Steampunker
I have very little experience but it is like a gun that does not display the gun and shows a throwing animation as using animation, deals ranged damage, stacks and uses itself as ammunition. And usually has the spinning, heavily affected by gravity projectile ID. That's my guess. A real professional will probably reply soon
Sounds good!
Thank you
 

samufinland

Empress of Light
Hey, does this have world generation affecting mods yet or are they possible? If so, what happens if two of them are used at the sane time and a new world is created?
[DOUBLEPOST=1451002420,1451002376][/DOUBLEPOST]
Sounds good!
Thank you

I meant thrown damage. That was just a guess, it might be more complicated.
 
Top Bottom