using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace SacredTools.NPCs
{
public class PandolarTrader : ModNPC
{
public override bool Autoload(ref string name, ref string texture)
{
name = "PandolarTrader";
return mod.Properties.Autoload;
}
public override void SetDefaults()
{
npc.name = "PandolarTrader";
npc.displayName = "Pandolar Trader";
npc.townNPC = true;
npc.friendly = true;
npc.width = 18;
npc.height = 40;
npc.aiStyle = 7;
npc.damage = 30;
npc.defense = 50;
npc.lifeMax = 500;
npc.soundHit = 1;
npc.soundKilled = 1;
npc.knockBackResist = 0.5f;
Main.npcFrameCount[npc.type] = 25;
animationType = NPCID.Guide;
}
public override bool CanTownNPCSpawn(int numTownNPCs, int money)
{
return false;// this make that he will spawn when a house is available
}
public override string TownNPCName()
{ //NPC names
switch (WorldGen.genRand.Next(4))
{
case 0:
return "Mural";
case 1:
return "Reggie";
case 2:
return "Waglington";
default:
return "Tucker";
}
}
public override string GetChat()
{ //npc chat
switch (Main.rand.Next(10))
{
case 0:
return "its a beautiful day outside...";
case 1:
return "all hail Pandolar.";
case 2:
return "you got some spare ice blocks maybe?? its really hot right now.";
case 3:
return "my old home looked way better than this";
case 4:
return "sometimes i think about licking ice cubes...";
case 5:
return "you wanna buy something??";
case 6:
return "you want something??";
case 7:
return "my race was very powerful a long time ago, but now we are almost extinct";
case 8:
return "Eseduh ohuht edahyay emecuh elyay eruhahl ah es et";
default:
return "sup scrub";
}
}
public override void SetChatButtons(ref string button, ref string button2)
{
button = Lang.inter[28];
}
public override void OnChatButtonClicked(bool firstButton, ref bool shop)
{
if (firstButton)
{
shop = true;
}
}
public override void SetupShop(Chest shop, ref int nextSlot)
{
shop.item[nextSlot].SetDefaults(mod.ItemType("PandolarBow")); //items that he sells
nextSlot++;
shop.item[nextSlot].SetDefaults(mod.ItemType("Pandolance"));
nextSlot++;
shop.item[nextSlot].SetDefaults (ItemID.Snowball);
nextSlot++;
}
public override void TownNPCAttackStrength(ref int damage, ref float knockback)
{
damage = 20;
knockback = 4f;
}
public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown)
{
cooldown = 30;
randExtraCooldown = 30;
}
public override void TownNPCAttackProj(ref int projType, ref int attackDelay)
{
projType = mod.ProjectileType("FrostBeamProjectile");
attackDelay = 1;
}
public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)
{
multiplier = 12f;
randomOffset = 2f;
}
}
}
oh, ok, srry that im a big noob at C# ^-^
[doublepost=1468179309,1468179049][/doublepost]the only thing now i need help at is this:
Code:using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace SacredTools.NPCs { public class PandolarTrader : ModNPC { public override bool Autoload(ref string name, ref string texture) { name = "PandolarTrader"; return mod.Properties.Autoload; } public override void SetDefaults() { npc.name = "PandolarTrader"; npc.displayName = "Pandolar Trader"; npc.townNPC = true; npc.friendly = true; npc.width = 18; npc.height = 40; npc.aiStyle = 7; npc.damage = 30; npc.defense = 50; npc.lifeMax = 500; npc.soundHit = 1; npc.soundKilled = 1; npc.knockBackResist = 0.5f; Main.npcFrameCount[npc.type] = 25; animationType = NPCID.Guide; } public override bool CanTownNPCSpawn(int numTownNPCs, int money) { return false;// this make that he will spawn when a house is available } public override string TownNPCName() { //NPC names switch (WorldGen.genRand.Next(4)) { case 0: return "Mural"; case 1: return "Reggie"; case 2: return "Waglington"; default: return "Tucker"; } } public override string GetChat() { //npc chat switch (Main.rand.Next(10)) { case 0: return "its a beautiful day outside..."; case 1: return "all hail Pandolar."; case 2: return "you got some spare ice blocks maybe?? its really hot right now."; case 3: return "my old home looked way better than this"; case 4: return "sometimes i think about licking ice cubes..."; case 5: return "you wanna buy something??"; case 6: return "you want something??"; case 7: return "my race was very powerful a long time ago, but now we are almost extinct"; case 8: return "Eseduh ohuht edahyay emecuh elyay eruhahl ah es et"; default: return "sup scrub"; } } public override void SetChatButtons(ref string button, ref string button2) { button = Lang.inter[28]; } public override void OnChatButtonClicked(bool firstButton, ref bool shop) { if (firstButton) { shop = true; } } public override void SetupShop(Chest shop, ref int nextSlot) { shop.item[nextSlot].SetDefaults(mod.ItemType("PandolarBow")); //items that he sells nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("Pandolance")); nextSlot++; shop.item[nextSlot].SetDefaults (ItemID.Snowball); nextSlot++; } public override void TownNPCAttackStrength(ref int damage, ref float knockback) { damage = 20; knockback = 4f; } public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown) { cooldown = 30; randExtraCooldown = 30; } public override void TownNPCAttackProj(ref int projType, ref int attackDelay) { projType = mod.ProjectileType("FrostBeamProjectile"); attackDelay = 1; } public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset) { multiplier = 12f; randomOffset = 2f; } } }
i coded him to use the FrostBeamProjectile when an enemy is near, but the only thing he does is run away, pls help me find the issue
[doublepost=1468179716][/doublepost]and 3 extra things i forgot:
-How to play a dust on an NPC (no buff)
-How to display a Sprite above a buffed NPC/Player
-How to make a Beam Projectile (like the Shadowbeamstaff but without the ricochet)
1)argh, forgot another two:
-How do i make my debuff drain more HP (only does 1, no matter how much negative life regen i put)
-How do i make an Accessory give more maxhealth
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
Player player = spawnInfo.player;
int x = spawnInfo.spawnTileX;
int y = spawnInfo.spawnTileY;
int tile = (int)Main.tile[x, y].type;
return (Main.hardMode && !spawnInfo.playerSafe && (y > Main.maxTilesY - 190) ) ? 1f : 0f;
}
H'ok... The Solarius item wasn't working because item.useAnimation was 1. I don't know how small it can be, but vanilla uses 25 there. Also, in the projectile, you've got 'projectile.type = ProjectileID.Arkhalis;' which will make the item a cosmetic clone of Arkhalis. If you want to use your own sprite, you'll need 'aiType = ProjectileID.Arkhalis;' instead.
Now, if you want to delay the projectile from homing in on enemies, then create an int to use as a timer, then place your homing code inside an if statement that checks if your int is above a specific value, and if it isn't, increase the timer. To adjust how quickly your projectile accelerates, change the 1.5f in the line 'projectile.velocity += acceleration * 1.5f;'
To make the projectile return to the player when it hits something, set 'projectile.ai[0]' to 1. The hooks onHitNPC, onHitPVP and onTileCollide are where you'll want to do this.
public override bool OnTileCollide(Vector2 oldVelocty)
{
projectile.ai[0] = 1;
}
In public override bool ontilecollide, you have "bool" or void, or other. this is the value than you need return.I tried to use onTileCollide, but it failed
code
Code:public override bool OnTileCollide(Vector2 oldVelocty) { projectile.ai[0] = 1; }
error
not all code paths return a value.
and the line numbers are pointing to OnTileCollide
In public override bool ontilecollide, you have "bool" or void, or other. this is the value than you need return.
Void: you do not need return a value.
Bool: You need return true or false.
Etc
projectile.aiType = ProjectileID.Arkhalis;
Opening the mod browser is causing my game to freeze. Any ideas why?
You are probably looking on the wrong menu or you haven't built it yet.Um, I can't find the publish button for my mod anywhere on tmod. It's nowhere to be found. Just vanished. I asked for help once and nobody replied.
im on steamAre you on steam or cracked
but i dont have any experience in modding and that was my first try myabe you could take a look at my codes and see whats wrongAre you on steam or cracked
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace SacredTools.Projectiles
{
public class MoonBeam : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "Moon Beam"; //projectile name
projectile.width = 20; //projectile width
projectile.height = 28; //projectile height
projectile.friendly = true; //make that the projectile will not damage you
projectile.melee = true; //
projectile.tileCollide = true; //make that the projectile will be destroed if it hits the terrain
projectile.penetrate = 5; //how many npc will penetrate
projectile.timeLeft = 200; //how many time this projectile has before disepire
projectile.light = 0.75f; // projectile light
projectile.extraUpdates = 1;
projectile.ignoreWater = true;
}
public override void AI() //this make that the projectile will face the corect way
{ // |
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
projectile.velocity.Y += projectile.ai[0];
if (projectile.localAI[0] == 0f)
{
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20);
projectile.localAI[0] = 1f;
}
int num666 = 8;
int num667 = Dust.NewDust(new Vector2(projectile.position.X + (float)num666 + 6, projectile.position.Y + (float)num666), projectile.width - num666 * 2, projectile.height - num666 * 2, 66, 0f, 0f, 0, new Color(36, 158, 184), 1.5f); //projectile dust color
Main.dust[num667].velocity *= 0.5f;
Main.dust[num667].velocity += projectile.velocity * 0.5f;
Main.dust[num667].noGravity = true;
Main.dust[num667].noLight = false;
Main.dust[num667].scale = 2.4f;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(mod.BuffType("MoonCurse"), 500);
}
}
}
im back with another question:
how i display multiple different dusts with different colors on one single projectile??
(i want all the 4 different moon colors: orange, purple, blue and green)
[doublepost=1468240491,1468240474][/doublepost]how do i*Code:using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace SacredTools.Projectiles { public class MoonBeam : ModProjectile { public override void SetDefaults() { projectile.name = "Moon Beam"; //projectile name projectile.width = 20; //projectile width projectile.height = 28; //projectile height projectile.friendly = true; //make that the projectile will not damage you projectile.melee = true; // projectile.tileCollide = true; //make that the projectile will be destroed if it hits the terrain projectile.penetrate = 5; //how many npc will penetrate projectile.timeLeft = 200; //how many time this projectile has before disepire projectile.light = 0.75f; // projectile light projectile.extraUpdates = 1; projectile.ignoreWater = true; } public override void AI() //this make that the projectile will face the corect way { // | projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; projectile.velocity.Y += projectile.ai[0]; if (projectile.localAI[0] == 0f) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); projectile.localAI[0] = 1f; } int num666 = 8; int num667 = Dust.NewDust(new Vector2(projectile.position.X + (float)num666 + 6, projectile.position.Y + (float)num666), projectile.width - num666 * 2, projectile.height - num666 * 2, 66, 0f, 0f, 0, new Color(36, 158, 184), 1.5f); //projectile dust color Main.dust[num667].velocity *= 0.5f; Main.dust[num667].velocity += projectile.velocity * 0.5f; Main.dust[num667].noGravity = true; Main.dust[num667].noLight = false; Main.dust[num667].scale = 2.4f; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(mod.BuffType("MoonCurse"), 500); } } }
Color color = new Color(0,0,0)
Int rand = Main.rand.Next(4);
switch (rand)
{
case 0:
color = new Color(..,..,..)
break;
case 1:
color = new Color(..,..,..)
break;
case 2:
color = new Color(..,..,..)
break;
case 3:
color = new Color(..,..,..)
break;
int num667 = Dust.NewDust(..., 66, ..., color,...);
}