Why are you trying to spawn an NPC called trio that doesn't exist?Ugh one last bit of help. With this code, I am trying to spawn 2 mobs with the same item. What I did wa
s i put the NPCs (Angel and Demonic) into a folder called Trio. The game loaded it, but it just says "Has awoken1" and nothing else.Code:using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace Enderuim.Items { public class DoomWhistle : ModItem { public override void SetDefaults() { item.name = "Doom Whistle"; item.width = 60; item.height = 48; item.maxStack = 99; item.value = 100; item.rare = 10; item.useAnimation = 45; item.useTime = 45; item.useStyle = 4; item.useSound = 44; item.consumable = true; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(1006); recipe.SetResult(this); recipe.AddRecipe(); } public override bool CanUseItem(Player player) { return !NPC.AnyNPCs(mod.NPCType("Angelic")) && !NPC.AnyNPCs(mod.NPCType("Demonic")); } public override bool UseItem(Player player) { NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Trio")); Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0); return true; } } }
Im trying to spawn 2 monsters, eventuly 3, with one item. I put all of the monsters in a folder inside of NPC called TrioWhy are you trying to spawn an NPC called trio that doesn't exist?
OK, just call spawnonplayer 2 or 3 times. The folder structure has nothing to do with it.Im trying to spawn 2 monsters, eventuly 3, with one item. I put all of the monsters in a folder inside of NPC called Trio
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace Enderuim.Items
{
public class DoomWhistle : ModItem
{
public override void SetDefaults()
{
item.name = "Doom Whistle";
item.width = 60;
item.height = 48;
item.maxStack = 99;
item.value = 100;
item.rare = 10;
item.useAnimation = 45;
item.useTime = 45;
item.useStyle = 4;
item.useSound = 44;
item.consumAble = true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(1006);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override bool CanUseItem(Player player)
{
return !NPC.AnyNPCs(mod.NPCType("Angel")) && !NPC.AnyNPCs(mod.NPCType("Demonic"));
}
public override bool UseItem(Player player)
{
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Angel"));
Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);
return true;
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Demonic"));
Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);
return true;
}
}
}
i switch the order of the OnPlayers and then the demon one spawnedI did that and only Angel SpawnedCode:using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace Enderuim.Items { public class DoomWhistle : ModItem { public override void SetDefaults() { item.name = "Doom Whistle"; item.width = 60; item.height = 48; item.maxStack = 99; item.value = 100; item.rare = 10; item.useAnimation = 45; item.useTime = 45; item.useStyle = 4; item.useSound = 44; item.consumAble = true; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(1006); recipe.SetResult(this); recipe.AddRecipe(); } public override bool CanUseItem(Player player) { return !NPC.AnyNPCs(mod.NPCType("Angel")) && !NPC.AnyNPCs(mod.NPCType("Demonic")); } public override bool UseItem(Player player) { NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Angel")); Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0); return true; NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Demonic")); Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0); return true; } } }
What is the code for an npc to only spawn during hardmode?OK, just call spawnonplayer 2 or 3 times. The folder structure has nothing to do with it.
Look up what "return;" does and you'll figure it out.I did that and only Angel SpawnedCode:using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace Enderuim.Items { public class DoomWhistle : ModItem { public override void SetDefaults() { item.name = "Doom Whistle"; item.width = 60; item.height = 48; item.maxStack = 99; item.value = 100; item.rare = 10; item.useAnimation = 45; item.useTime = 45; item.useStyle = 4; item.useSound = 44; item.consumAble = true; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(1006); recipe.SetResult(this); recipe.AddRecipe(); } public override bool CanUseItem(Player player) { return !NPC.AnyNPCs(mod.NPCType("Angel")) && !NPC.AnyNPCs(mod.NPCType("Demonic")); } public override bool UseItem(Player player) { NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Angel")); Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0); return true; NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Demonic")); Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0); return true; } } }
[DOUBLEPOST=1453528137,1453527702][/DOUBLEPOST]
i switch the order of the OnPlayers and then the demon one spawned
Just check Main.hardmode.What is the code for an npc to only spawn during hardmode?
So I do this or no? (WalrusMod.NormalSpawn(spawnInfo) && (tile == 53 || tile == 112 || tile == 116 || tile == 234) && WalrusMod.NoZoneAllowWater(spawnInfo) && spawnInfo.water) && y < Main.rockLayer && (x < 250 || x > Main.maxTilesX - 250) && !spawnInfo.playerSafe && Main.hardmode ? 0.5f : 0f;Look up what "return;" does and you'll figure it out.
Just check Main.hardmode.
Guess it's hardMode then, I don't have everything memorized.So I do this or no? (WalrusMod.NormalSpawn(spawnInfo) && (tile == 53 || tile == 112 || tile == 116 || tile == 234) && WalrusMod.NoZoneAllowWater(spawnInfo) && spawnInfo.water) && y < Main.rockLayer && (x < 250 || x > Main.maxTilesX - 250) && !spawnInfo.playerSafe && Main.hardmode ? 0.5f : 0f;
EDIT: It says that "Terraria.Main does not contain a definition for hardmode."
I'm not exactly sure what you mean... Do you want to use your summoning item and then spawn multiple minions, or do you want to increase the amount of minions the player can control?
projectile.minionSlots (on your minion I assume) determines how many slots the minion should take up. So if you have... Say room for 4 minions and you spawn two minions that have minionSlots set to 2, you won't be able to spawn any more, since your available slots have been filled.
I was unable to solve this issue. I have to use wine to play Terraria on Mac with Tremor Remastered mod. It is probably because of a log statement in the mod's source, but I'm obviously unable to confirm or solve that myself.
EDIT: I was wrong. The new Tremor Remastered 1.2.1 works with the Steam Terraria on Mac. I put the new tmod into the wrong folder previously.
Vector2 drawPos = projectile.Center - Main.screenPosition;
Color alpha = GetColor();
spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, alpha, 0, new Vector2(2, 2), 1f, SpriteEffects.None, 0f);
public Color GetColor()
{
return new Color(0, 0, 0);
}
1. First result on google for SpriteBatch: https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw.aspxSo finally I found out how I can draw a projectile with predraw and denied vanilla drawing.
I put these codes I found in ExampleMod:
Still questions never end.Code:Vector2 drawPos = projectile.Center - Main.screenPosition; Color alpha = GetColor(); spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, alpha, 0, new Vector2(2, 2), 1f, SpriteEffects.None, 0f);
1. What does spriteBatch mean specifically?
Since I can't find a reference for this spriteBatch in my object browser, I can't even figure out what those factors behind it mean. where can I find a reference of this function? Or maybe how many factors does spriteBatch.Draw have?
Like projectile, I can get access to what I should fill:
public static int NewProjectile(float X, float Y, float SpeedX, float SpeedY, int Type, int Damage, float KnockBack, [int Owner = 255], [float ai0 = 0], [float ai1 = 0]).
2. How to make it become white?
I actually also duplicate a snippet of codes which help to determine the color:
And ofc. it looks like a chunk of black stuff. When I change this to (255, 255, 255), it appears to be its original color. Any luck make it look whiter?Code:public Color GetColor() { return new Color(0, 0, 0); }
3.How to change its direction!
I think my dream about making the projectile spin will eventually come true here.
This projectile I'm making is actually a star, which appears like this when shot out:
View attachment 93673
And what if I want it to spin, let's say 180°:
View attachment 93674
So I found two settings in the reference of projectile:
Projectile.rotation
Projectile.spriteDirection
Which one is used to determine the direction?
Have you tried just calling Projectile.NewProjectile in ModItem.Shoot? (You can call it as many times as you want, but I imagine if you go over the limit they should just die.)Oh sorry, i meant i want to spawn multiple minions using that summoning item. How does one go about doing that?
Thx, but would there be 1 or 2 a.m. on your side? Still not sleeping?1. First result on google for SpriteBatch: https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw.aspx
Also, the word you are looking for is typically refered to as "parameters" not "factors"
2. I'm not sure if you can...color is for a tint, and full color, white, would mean no tint, just the real colors. Just extract the texture and adjust the balance in a image editor.
3. SpriteDirection is just -1 or 1 I believe, it flips the projectile horizontally around the vertical axis. You don't want to use this unless your projectile isn't symmetrical along the horizontal axis, like a stardust dragon head.(Imagine rotating the stardust dragon head till it is pointing up, then keep going. It's upside down now.) You'll want to modify Projectile.rotation. It is in radians. You can either set it when you spawn the projectile or maybe have it rotate at a constant rate each frame, up to you and what you want.
[DOUBLEPOST=1453539239,1453539028][/DOUBLEPOST]
Have you tried just calling Projectile.NewProjectile in ModItem.Shoot? (You can call it as many times as you want, but I imagine if you go over the limit they should just die.)
projectile.rotation += 1f;
Vector2 drawPos = projectile.Center - Main.screenPosition;
Color alpha = GetColor();
spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, alpha, 0, new Vector2(2, 2), 1f, SpriteEffects.None, 0f);
return false;
2am is nothing.Thx, but would there be 1 or 2 a.m. on your side? Still not sleeping?
Now if that is the case (I mean I should use rotation to make projectile spin), I put like this:
And it ain't working.Code:projectile.rotation += 1f; Vector2 drawPos = projectile.Center - Main.screenPosition; Color alpha = GetColor(); spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, alpha, 0, new Vector2(2, 2), 1f, SpriteEffects.None, 0f); return false;
Isn't this preDraw triggered every frame? Then it's supposed to spin 60° per sec. Question is that it doesn't even move 1°.
Haha, I rarely stayed up that late2am is nothing.
That first 0 in your Draw call is the rotation, plug in projectile.rotation there.
Also, 1 radian a frame would equate to....
1 rad = 57 degrees
60 frames/second * 57 degrees/ frame = 3437 degrees per second. Pretty fast rotation.
Vector2 drawPos = projectile.Center - Main.screenPosition;
Color alpha = GetColor();
float Rotation = 0;
Rotation += 0.1f
spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, alpha, Rotation, new Vector2(2, 2), 1f, SpriteEffects.None, 0f);
return false;
Why are you making a new variable. Keep it as projectile.rotation. They way you have it, rotation is 0, then .1, on every frame.Haha, I rarely stayed up that late
3437 degrees is horrible, but I still don't get it to work:
Code:Vector2 drawPos = projectile.Center - Main.screenPosition; Color alpha = GetColor(); float Rotation = 0; Rotation += 0.1f spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, alpha, Rotation, new Vector2(2, 2), 1f, SpriteEffects.None, 0f); return false;
Well:Why are you making a new variable. Keep it as projectile.rotation. They way you have it, rotation is 0, then .1, on every frame.
projectile.rotation += 0.1f;
Vector2 drawPos = projectile.Center - Main.screenPosition;
Color alpha = GetColor();
spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, alpha, projectile.rotation, new Vector2(2, 2), 1f, SpriteEffects.None, 0f);
return false;
How do I get rid of my minion when I right click the buff?
public override void SetDefaults()
{
Main.buffName[Type] = "Baby Flesh Slime";
Main.buffTip[Type] = "The baby flesh slime will fight for you";
Main.buffNoSave[Type] = true;
Main.buffNoTimeDisplay[Type] = true;
}
public override void Update(Player player, ref int buffIndex)
{
TEPlayer modPlayer = (TEPlayer)player.GetModPlayer(mod, "TEPlayer");
if (player.ownedProjectileCounts[mod.ProjectileType("FleshBabySlime")] > 0)
{
modPlayer.slimeMinion = true;
}
if (!modPlayer.slimeMinion)
{
player.DelBuff(buffIndex);
buffIndex--;
}
else
{
player.buffTime[buffIndex] = 18000;
}
}