Andromeda9a
Terrarian
Can anyone give me a working sword code i cant seem to find one
I have oneCan anyone give me a working sword code i cant seem to find one
You can use adjtiles to have your custom tile act as other tiles. https://github.com/bluemagic123/tModLoader/search?utf8=✓&q=adjtilesCan someone help me make a tile count as station for various other ones too? Like, if there is xxx block here, you can use it as both an Anvil and a workbench, etc. I would like to use a Campfire for mine. Thanks!
You can use adjtiles to have your custom tile act as other tiles. https://github.com/bluemagic123/tModLoader/search?utf8=✓&q=adjtiles
It sounds like you want a vanilla campfire to work as anvil and workbenches, I think you can do that with globaltile in a similar manner to all the examples I linked you to.
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using imkSushisMod.Items;
using imkSushisMod.NPCs;
namespace imkSushisMod {
public class imkSushisMod : Mod
{
public override void SetModInfo(out string name, ref ModProperties properties)
{
name = "imkSushisMod";
properties.Autoload = true;
}
public override void AddRecipes()
{
RecipeHelper.AddInterchangeableRecipes(this);
RecipeHelper.AddMelterRecipes(this);
RecipeHelper.AddExtraRecipes(this);
RecipeHelper.AddItemRecipes(this);
}
public override void Load()
{
RegisterHotKey("sushi", "O");
}
public virtual void HotKeyPressed(string name)
{
if (name == "sushi")
{
Main.player[Main.myPlayer].KillMe(999, 0, true, "Oops");
}
}
}}
Why isn't this hotkey working?
Code:using System; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using imkSushisMod.Items; using imkSushisMod.NPCs; namespace imkSushisMod { public class imkSushisMod : Mod { public override void SetModInfo(out string name, ref ModProperties properties) { name = "imkSushisMod"; properties.Autoload = true; } public override void AddRecipes() { RecipeHelper.AddInterchangeableRecipes(this); RecipeHelper.AddMelterRecipes(this); RecipeHelper.AddExtraRecipes(this); RecipeHelper.AddItemRecipes(this); } public override void Load() { RegisterHotKey("sushi", "O"); } public virtual void HotKeyPressed(string name) { if (name == "sushi") { Main.player[Main.myPlayer].KillMe(999, 0, true, "Oops"); } } }}
Thanks. It works.There might be more wrong with this, but I'm pretty sure at least the virtual keyword isn't right. That should be override.
How would I check whether an NPC was behind the player, and if so, make sure a homing projectile does not target them, even if the player turns and faces the NPC after firing the projectile?
if ( ( npc.Center.X < player.Center.X && player.direction == 1) || ( npc.Center.X > player.Center.X && player.direction == -1) )
{
// true if the NPC is not being faced, false if it is.
}
// Alternatively:
if ( ( npc.Center.X > player.Center.X && player.direction == 1) || ( npc.Center.X < player.Center.X && player.direction == -1) )
{
// true if the NPC is being faced, false if it's not.
}
//Inside the GlobalNPC
public virtual void PostDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor)
{
GNPCInfo info = (GNPCInfo)npc.GetModInfo(mod, "GNPCInfo");
//56x56 is the batch image size.
while(info.Frost)
{
Vector2 drawPos = new Vector2(npc.position.X,npc.position.Y);
spriteBatch.Draw(mod.GetTexture("Extras/Frozen"), drawPos, null, default(Color), 0f, drawPos, npc.scale * 2 , SpriteEffects.None, 0f);
}
}
Someone knows how to draw a sprite batch while a mob is under a buff?
My Code:
Code://Inside the GlobalNPC public virtual void PostDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor) { GNPCInfo info = (GNPCInfo)npc.GetModInfo(mod, "GNPCInfo"); //56x56 is the batch image size. while(info.Frost) { Vector2 drawPos = new Vector2(npc.position.X,npc.position.Y); spriteBatch.Draw(mod.GetTexture("Extras/Frozen"), drawPos, null, default(Color), 0f, drawPos, npc.scale * 2 , SpriteEffects.None, 0f); } }
public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor)
{
if(npc.hasBuff(mod.BuffType("Frost")) != -1)
{
Vector2 drawPos = new Vector2(npc.position.X,npc.position.Y);
spriteBatch.Draw(mod.GetTexture("Extras/Frozen"), drawPos, null, default(Color), 0f, drawPos, npc.scale * 2 , SpriteEffects.None, 0f);
return false;
}
return true;
}
WORKED! thanks budy, buuuut... when the mod is with the buff, he turns invisibleTry this:
Code:public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor) { if(npc.hasBuff(mod.BuffType("Frost")) != -1) { Vector2 drawPos = new Vector2(npc.position.X,npc.position.Y); spriteBatch.Draw(mod.GetTexture("Extras/Frozen"), drawPos, null, default(Color), 0f, drawPos, npc.scale * 2 , SpriteEffects.None, 0f); return false; } return true; }
Untested, should (highly) theoretically work. If default(Color) gives an error, just change it to Color.white and that should work.