public override void UpdateBadLifeRegen()
{
if (eyezor)
{
if (player.lifeRegen > 2)
{
if (vheal = true)
{
player.lifeRegen = -2 * player.lifeRegen;
}
}
player.lifeRegenTime = 0;
}
if (mystic)
{
if (player.lifeRegen > 0)
{
player.lifeRegen = 2 * player.lifeRegen;
}
player.lifeRegenTime = 0;
}
}
public virtual bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore)
{
if (corrupted)
{
playSound = false;
Main.PlaySound(SoundID.NPCDeath1, player.Center);
}
if (eyezor)
{
playSound = false;
Main.PlaySound(SoundID.NPCDeath1, player.Center);
}
if (mystic)
{
playSound = false;
Main.PlaySound(SoundID.NPCDeath49, player.Center);
}
if (psychosis)
{
playSound = false;
Main.PlaySound(SoundID.NPCDeath11, player.Center);
}
return true;
}
1. See Potion.cs in ExampleMod,I have 3 questions I need answered.
Question 1:
I was trying to make something similar to the "Undead" debuff from the example mod in my own mod, but it only works on slow, drawn-out healing, not instantaneous healing. Can someone help me out with that?
Code:
Code:public override void UpdateBadLifeRegen() { if (eyezor) { if (player.lifeRegen > 2) { if (vheal = true) { player.lifeRegen = -2 * player.lifeRegen; } } player.lifeRegenTime = 0; } if (mystic) { if (player.lifeRegen > 0) { player.lifeRegen = 2 * player.lifeRegen; } player.lifeRegenTime = 0; } }
Question 2:
Is there a way to make it look like the player has no eyes? Essentially, a way to make them look like this: View attachment 196817
This is because an armor set I'm making requires the player's eyes to be hidden in order to look right.
Question 3: I was trying to change the player's hurt and death sounds when they had certain buffs, but it didn't work.
Code:public virtual bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore) { if (corrupted) { playSound = false; Main.PlaySound(SoundID.NPCDeath1, player.Center); } if (eyezor) { playSound = false; Main.PlaySound(SoundID.NPCDeath1, player.Center); } if (mystic) { playSound = false; Main.PlaySound(SoundID.NPCDeath49, player.Center); } if (psychosis) { playSound = false; Main.PlaySound(SoundID.NPCDeath11, player.Center); } return true; }
c:\Users\Joshua\Documents\My Games\Terraria\ModLoader\Mod Sources\JoshuasMod\Items\DivineRage.cs(17,46) : error CS0246: The type or namespace name 'DrawAnimationVertical' could not be found (are you missing a using directive or an assembly reference?)
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace ExampleMod.Items
{
public class Face : ModItem
{
public override void SetStaticDefaults()
{
// See here for help on using Tags: http://terraria.wiki.gg/Chat#Tags
Tooltip.SetDefault("How are you feeling today?"
+ string.Format("\n[c/FF0000:Colors ][c/00FF00:are ][c/0000FF:fun ]and so are items: [i:{0}][i:{1}][i/s123:{2}]", item.type, mod.ItemType<CarKey>(), ItemID.Ectoplasm));
Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(30, 4));
ItemID.Sets.ItemNoGravity[item.type] = true;
}
public override void SetDefaults()
{
item.width = 20;
item.height = 20;
item.value = 100;
item.rare = 1;
}
public override Color? GetAlpha(Color lightColor)
{
return Color.White;
}
public override void ModifyTooltips(List<TooltipLine> tooltips)
{
TooltipLine line = new TooltipLine(mod, "Face", "I'm feeling just fine!");
line.overrideColor = new Color(100, 100, 255);
tooltips.Add(line);
foreach (TooltipLine line2 in tooltips)
{
if (line2.mod == "Terraria" && line2.Name == "ItemName")
{
line2.overrideColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB);
}
}
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null, "ExampleItem");
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace JoshuasMod.Items
{
public class DivineRage : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Divine Rage");
Tooltip.SetDefault("Rains down a shower of meteors!");
Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(12, 10));
//Have no idea what the numbers in "new DrawAnimationVertical(#, #)" mean. :(
ItemID.Sets.ItemNoGravity[item.type] = true;
}
public override void SetDefaults()
{
item.damage = 200;
item.width = 54;
item.height = 56;
item.scale = 0.90f;
item.melee = true;
item.useTime = 14;
item.useAnimation = 14;
item.useStyle = 1;
item.noMelee = false;
item.knockBack = 10;
item.value = Item.buyPrice(1, 20, 0, 0);
item.rare = 11;
item.UseSound = SoundID.Item71;
item.autoReuse = true;
item.shoot = 0;
item.useTurn = true;
}
}
}
I assume your code looks like this:I have EVERY SINGLE BIT of my mod done except for the Expert mode treasure bags. I've made it so that they drop in expert and don't drop in normal, but in expert it drops both the contents of the bag AND the bag. So for example, It drops a minion staff, then you open the bag and it contains a minion staff. If you would like code examples, please tell me so I can give them.
public override void NPCLoot()
{
if (Main.expert) //idk the bool for expert but I think this is it
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TreasureBag"));
}
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.BossDrop);
}
public override void NPCLoot()
{
if (Main.expert) //idk the bool for expert but I think this is it
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TreasureBag"));
}
else{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.BossDrop);
}
}
Your world isn't on the cloud, is it?every modded item from my ing world is gone. my town had a power outage last night due to storms, so i exited my world and unplugged my pc. now every modded item, block, and npc not in my inventory is gone. what do i do?
no.Your world isn't on the cloud, is it?
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace JoshuasMod.Projectiles
{
public class CelicaProj : ModProjectile
{
public override void SetStaticDefaults()
{
Main.projFrames[projectile.type] = 32;
}
public override void SetDefaults()
{
projectile.damage = 100;
projectile.scale = 1f;
projectile.friendly = true;
projectile.melee = true;
projectile.tileCollide = false;
projectile.timeLeft = 320;
projectile.width = 66;
projectile.height = 66;
projectile.penetrate = -1;
projectile.extraUpdates = 1;
projectile.ignoreWater = true;
}
public override void AI()
{
//Making sure the projectile faces the correct way.
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.75f;
//Loop through the 32 animation frames, spending 10 ticks on each.
if (++projectile.frameCounter >= 32)
{
projectile.frameCounter = 0;
if (++projectile.frame >= 10)
{
projectile.frame = 0;
}
}
//This is the dust used, it is the size of the projectile.
projectile.velocity.Y += projectile.ai[0];
for (int d = 0; d < 1; d++)
{
Dust.NewDust(projectile.position, projectile.width, projectile.height, 15, 0f, 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.05f);
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.OnFire, 5 * 60);
target.AddBuff(BuffID.Frostburn, 5 * 60);
target.AddBuff(BuffID.CursedInferno, 5 * 60);
target.AddBuff(BuffID.ShadowFlame, 5 * 60);
target.immune[projectile.owner] = 1;
}
}
}
item.damage = 180;
item.width = 66;
item.height = 66;
item.scale = 0.85f;
item.melee = true;
item.useTime = 18;
item.useAnimation = 18;
item.useStyle = 1;
item.noMelee = false;
item.knockBack = 8;
item.value = Item.buyPrice(1, 20, 0, 0);
item.rare = 11;
item.UseSound = SoundID.Item71;
item.autoReuse = true;
item.shoot = mod.ProjectileType("CelicaProj");
item.shootSpeed = 10f;
item.useTurn = true;
It's probably because you aren't increasing projectile.frameCounter anywhere meaningful. Put projectile.frameCounter++; before your if statement and remove ++ from inside your if statements.Got a problem.
So, when I fire my projectile, it doesn't change through its frames, it just stays on the first frame. Why's that?
Code:using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace JoshuasMod.Projectiles { public class CelicaProj : ModProjectile { public override void SetStaticDefaults() { Main.projFrames[projectile.type] = 32; } public override void SetDefaults() { projectile.damage = 100; projectile.scale = 1f; projectile.friendly = true; projectile.melee = true; projectile.tileCollide = false; projectile.timeLeft = 320; projectile.width = 66; projectile.height = 66; projectile.penetrate = -1; projectile.extraUpdates = 1; projectile.ignoreWater = true; } public override void AI() { //Making sure the projectile faces the correct way. projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.75f; //Loop through the 32 animation frames, spending 10 ticks on each. if (++projectile.frameCounter >= 32) { projectile.frameCounter = 0; if (++projectile.frame >= 10) { projectile.frame = 0; } } //This is the dust used, it is the size of the projectile. projectile.velocity.Y += projectile.ai[0]; for (int d = 0; d < 1; d++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, 15, 0f, 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.05f); } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.OnFire, 5 * 60); target.AddBuff(BuffID.Frostburn, 5 * 60); target.AddBuff(BuffID.CursedInferno, 5 * 60); target.AddBuff(BuffID.ShadowFlame, 5 * 60); target.immune[projectile.owner] = 1; } } }
I didn't have this problem on another projectile with multiple frames. Is it because there's simply too many frames on this projectile?Code:item.damage = 180; item.width = 66; item.height = 66; item.scale = 0.85f; item.melee = true; item.useTime = 18; item.useAnimation = 18; item.useStyle = 1; item.noMelee = false; item.knockBack = 8; item.value = Item.buyPrice(1, 20, 0, 0); item.rare = 11; item.UseSound = SoundID.Item71; item.autoReuse = true; item.shoot = mod.ProjectileType("CelicaProj"); item.shootSpeed = 10f; item.useTurn = true;
Removed the "++"'s from the if statements and placed a "projectile.frameCounter++;" before he if statements (Don't know if it's in the right place though, since 'before' could mean anywhere before said if statements). Still stuck on its first frame.It's probably because you aren't increasing projectile.frameCounter anywhere meaningful.
public override void AI()
{
//Making sure the projectile faces the correct way.
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.75f;
//Loop through the 32 animation frames, spending 10 ticks on each.
projectile.frameCounter++; //"projectile.frameCounter++;" statement must go before the "if" statement. That's before the "if" statement, right? O_o
if (projectile.frameCounter >= 32)
{
projectile.frameCounter = 0;
if (projectile.frame >= 10)
{
projectile.frame = 0;
}
}
//This is the dust used, it is the size of the projectile.
projectile.velocity.Y += projectile.ai[0];
for (int d = 0; d < 1; d++)
{
Dust.NewDust(projectile.position, projectile.width, projectile.height, 15, 0f, 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.05f);
}
}
Thanks.Removed the "++"'s from the if statements and placed a "projectile.frameCounter++;" before he if statements (Don't know if it's in the right place though, since 'before' could mean anywhere before said if statements). Still stuck on its first frame.
Also, what did you mean by "increasing projectile.frameCounter anywhere meaningful"?Code:public override void AI() { //Making sure the projectile faces the correct way. projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.75f; //Loop through the 32 animation frames, spending 10 ticks on each. projectile.frameCounter++; //"projectile.frameCounter++;" statement must go before the "if" statement. That's before the "if" statement, right? O_o if (projectile.frameCounter >= 32) { projectile.frameCounter = 0; if (projectile.frame >= 10) { projectile.frame = 0; } } //This is the dust used, it is the size of the projectile. projectile.velocity.Y += projectile.ai[0]; for (int d = 0; d < 1; d++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, 15, 0f, 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.05f); } }
P.S Happy birthday
projectile.frameCounter = 0;
projectile.frame++; //<--new line of code here
if (projectile.frame >= 10)
{
projectile.frame = 0;
}