MysticSandvich
Terrarian
I just learnt how to make NPC drops but I want to know how to make a specific NPC drop an item with a specific chance of that item dropping from that NPC, if anyone can help it will be greatly appreciated. Thanks!
I just learnt how to make NPC drops but I want to know how to make a specific NPC drop an item with a specific chance of that item dropping from that NPC, if anyone can help it will be greatly appreciated. Thanks!
If you want something to function identical to a bomb, just set its AI Style to 16. Or do you want something specific, like area damage or destroying tiles?Does anyone know how to code for a bomb, if so plz halp
Yeah I'd like to up the area damage a bitIf you want something to function identical to a bomb, just set its AI Style to 16. Or do you want something specific, like area damage or destroying tiles?
Yeah I'd like to up the area damage a bit
[doublepost=1467543360,1467542961][/doublepost]and how would you apply an ai style to an item, i thought they were only for npcs?
Ok thanks, I'll try it outProjectiles have AIs too, usually something simple like going in a straight path, but something like the Razorblade Typhoon for instance has a relatively complicated AI.
If all you want to do is up the damage, just make a new ModProjectile, set its AI Style to 16 and the damage to whatever you like. Remember you also need to make an item to create the projectile.
If you get stuck, the Example Mod has some good examples.
Thanks.In the class where is your block just add this line of code in the SetDefults
you should find both mythril anvil and the forge there.Code:adjTiles = new int[] { TileID.Anvils };
So I tried it out and I got it to be used correctly but when the bomb is thrown the it's invisible, you can only see the bomb smoke, and it doesn't explode. I have the png file in both folders and the names all match.
here is the projectile code:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace GintamaMod.Projectiles
{
public class JustAway : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "JustAway";
projectile.width = 29;
projectile.height = 25;
projectile.aiStyle = 16;
projectile.friendly = true;
projectile.penetrate = 5;
projectile.timeLeft = 60;
projectile.thrown = true;
projectile.alpha = 255;
projectile.light = 0.5f;
projectile.extraUpdates = 1;
aiType = ProjectileID.Bomb;
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
projectile.penetrate--;
if (projectile.penetrate <= 0)
{
projectile.Kill();
}
else
{
if (projectile.velocity.X != oldVelocity.X)
{
projectile.velocity.X = -oldVelocity.X;
}
if (projectile.velocity.Y != oldVelocity.Y)
{
projectile.velocity.Y = -oldVelocity.Y;
}
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 10);
}
return false;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f);
for (int k = 0; k < projectile.oldPos.Length; k++)
{
Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY);
Color color = projectile.GetAlpha(lightColor) * ((float)(projectile.oldPos.Length - k) / (float)projectile.oldPos.Length);
spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f);
}
return true;
}
}
}
So I can see them now but now the explosion is invisible and if the bomb lands on the ground w/o bouncing it just stays there then disappears after a while.The reason it's invisible is because you set alpha to 255, which makes it fully transparent. Set it to a lower value, or just remove it outright.
As for it not exploding, that's presumably caused by your OnTileCollide killing the projectile. Instead of projectile.Kill();, try projectile.timeLeft = 3;.
It might be a specific mod that your using, try them all out separatly and see which one is brokenI am not sure how to fix this, but a lot of mods are not working for me. I have latest versions of the mods and tmodloader. I make a Large, Expert world. And when it loads, it stops at "Generating Structures...Minecart Tracks." But when I don't use mods it works fine. How do i fix this?
So I can see them now but now the explosion is invisible and if the bomb lands on the ground w/o bouncing it just stays there then disappears after a while.
Heres the code im left with now:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace GintamaMod.Projectiles
{
public class JustAway : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "JustAway";
projectile.width = 29;
projectile.height = 25;
projectile.aiStyle = 16;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.thrown = true;
projectile.light = 0.5f;
projectile.extraUpdates = 1;
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
projectile.penetrate--;
if (projectile.penetrate <= 0)
{
projectile.timeLeft = 5;
}
else
{
if (projectile.velocity.X != oldVelocity.X)
{
projectile.velocity.X = -oldVelocity.X;
}
if (projectile.velocity.Y != oldVelocity.Y)
{
projectile.velocity.Y = -oldVelocity.Y;
}
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 10);
}
return false;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f);
for (int k = 0; k < projectile.oldPos.Length; k++)
{
Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY);
Color color = projectile.GetAlpha(lightColor) * ((float)(projectile.oldPos.Length - k) / (float)projectile.oldPos.Length);
spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f);
}
return true;
}
}
}
public override bool PreKill(int timeLeft)
{
projectile.maxPenetrate = -1;
projectile.penetrate = -1;
int area = 60;
projectile.position.X = projectile.position.X - (float)(area / 2);
projectile.position.Y = projectile.position.Y - (float)(area / 2);
projectile.width += area;
projectile.height += area;
projectile.tileCollide = false;
projectile.velocity *= 0.01f;
projectile.Damage();
projectile.scale = 0.01f;
return true;
}
Ok I'll try that, thanks for all your helpSo as I feared, some of the bomb code is type-locked, and I don't exactly know how much. If this doesn't work, then you'll have to dig into the source code yourself:
- Change projectile.timeLeft = 5; back to projectile.Kill();
- Put this in your code:
Code:public override bool PreKill(int timeLeft) { projectile.maxPenetrate = -1; projectile.penetrate = -1; int area = 60; projectile.position.X = projectile.position.X - (float)(area / 2); projectile.position.Y = projectile.position.Y - (float)(area / 2); projectile.width += area; projectile.height += area; projectile.tileCollide = false; projectile.velocity *= 0.01f; projectile.Damage(); projectile.scale = 0.01f; return true; }
This is a very long shot, and I doubt it will work, but it's the best I can do without transcribing the entire Projectile class.