Everybody
Terrarian
Okay, good. What about healing items?
If you want an item to work like a potion or mushroom or be eaten, then just set the useStyle to 2 or 4. I forget which one it is.
Okay, good. What about healing items?
And to decide the health value?If you want an item to work like a potion or mushroom or be eaten, then just set the useStyle to 2 or 4. I forget which one it is.
And to decide the health value?
you also needNo idea. Never really made a potion. Lemme check... "healLife": INT
public override void End(Player player, int index) {} //called when the buff ends.How do I make an effect at the end of a buff?
How do I make an item act like a soul?
Another day, another server crash. This happens whenever someone uses any flail from a mod, but it's very similar to the crash I got from NeoMods:
Is there any fix aside from Yoraiz0r overhauling tAPI?
But that just makes the item float in the air. If you want the item to pulsate and glow you need another piece of code. But don't worry, I got the codeThe way we did it was to add -1 to the y velocity of the item every frame. Seemed to work pretty well!
public override void MidUpdate(ref float gravity, ref float maxVelocity)
{
gravity = 0f;
item.velocity.Y *= 0.95f;
if ((double)item.velocity.Y < 0.1 && (double)item.velocity.Y > -0.1)
{
item.velocity.Y = 0f;
}
float num10 = (float)Main.rand.Next(90, 111) * 0.01f;
num10 *= Main.essScale;
Lighting.AddLight((int)((item.position.X + (float)(item.width / 2)) / 16f), (int)((item.position.Y + (float)(item.height / 2)) / 16f), 0.4f * num10, 0.3f * num10, 0.4f * num10);
}
public override bool PreWorldDraw(SpriteBatch sb)
{
float rotation = item.velocity.X * 0.2f;
Color alpha = new Color(255, 255, 255, 50); //This is what soul items return for their GetAlpha method
alpha *= Main.essScale;
float offsetY = (float)(item.height - Main.itemTexture[item.type].Height);
float offsetX = (float)(item.width / 2 - Main.itemTexture[item.type].Width / 2);
Main.spriteBatch.Draw(Main.itemTexture[item.type], new Vector2(item.position.X - Main.screenPosition.X + (float)(Main.itemTexture[item.type].Width / 2) + offsetX, item.position.Y - Main.screenPosition.Y + (float)(Main.itemTexture[item.type].Height / 2) + offsetY + 2f), new Rectangle?(new Rectangle(0, 0, Main.itemTexture[item.type].Width, Main.itemTexture[item.type].Height)), alpha, rotation, new Vector2((float)(Main.itemTexture[item.type].Width / 2), (float)(Main.itemTexture[item.type].Height / 2)), Main.essScale, SpriteEffects.None, 0f);
return false; //This is important since we're doing the actual drawing now.
}
the PreWorldDraw hook already gives you a SpriteBatch, so there's no need to use Main.spriteBatchBut that just makes the item float in the air. If you want the item to pulsate and glow you need another piece of code. But don't worry, I got the code
With a huge help of @bluemagic123 I managed to get it to work. 80% credit to him. This code should do the trick but if you throw your soul out of your inventory when your inventory is open the item will just fall upwards(I know it's strange).Code:public override void MidUpdate(ref float gravity, ref float maxVelocity) { gravity = 0f; item.velocity.Y *= 0.95f; if ((double)item.velocity.Y < 0.1 && (double)item.velocity.Y > -0.1) { item.velocity.Y = 0f; } float num10 = (float)Main.rand.Next(90, 111) * 0.01f; num10 *= Main.essScale; Lighting.AddLight((int)((item.position.X + (float)(item.width / 2)) / 16f), (int)((item.position.Y + (float)(item.height / 2)) / 16f), 0.4f * num10, 0.3f * num10, 0.4f * num10); } public override bool PreWorldDraw(SpriteBatch sb) { float rotation = item.velocity.X * 0.2f; Color alpha = new Color(255, 255, 255, 50); //This is what soul items return for their GetAlpha method alpha *= Main.essScale; float offsetY = (float)(item.height - Main.itemTexture[item.type].Height); float offsetX = (float)(item.width / 2 - Main.itemTexture[item.type].Width / 2); Main.spriteBatch.Draw(Main.itemTexture[item.type], new Vector2(item.position.X - Main.screenPosition.X + (float)(Main.itemTexture[item.type].Width / 2) + offsetX, item.position.Y - Main.screenPosition.Y + (float)(Main.itemTexture[item.type].Height / 2) + offsetY + 2f), new Rectangle?(new Rectangle(0, 0, Main.itemTexture[item.type].Width, Main.itemTexture[item.type].Height)), alpha, rotation, new Vector2((float)(Main.itemTexture[item.type].Width / 2), (float)(Main.itemTexture[item.type].Height / 2)), Main.essScale, SpriteEffects.None, 0f); return false; //This is important since we're doing the actual drawing now. }
In ModNPC's CanSpawn() hook, you can check if the player is within a given biome (I think it was player.zone["<biome name>"]?). You can also define your own custom biomes, which I think can be as simple as having a only single tile/tile type, and in any amount.Hmm.. is there a way to force the monster to appear only where there are certain tiles? If possible, please help =)
Not sure if it's been complained before. But I try to click on the tAPI shortcut on my desktop and it says "This app cannot run on your PC.".
Meaning I can't make anything. Which sucks cause I had an awesome idea for a 'More Wires' mod.
I run Windows 8.1. I also tried running it in compatibility mode for Windows 7, Vista(ew), XP, and even 98 .-. Nothing.
Halp?
It turns out that the SpriteBatch that gets passed actually is Main.spriteBatch. But yeah, it would be better practice to use the parameter instead of Main.spriteBatch. (This is what happens when you copy/paste source code, lol)the PreWorldDraw hook already gives you a SpriteBatch, so there's no need to use Main.spriteBatch