Standalone [1.3] tModLoader - A Modding API

This was basically the weapons I was trying to get a glow on. I think I might be able to look through the code in which glow files are used to acquire the aesthetic I need :D
GraniteSwords.gif
 
Ugh one last bit of help. With this code, I am trying to spawn 2 mobs with the same item. What I did wa
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;
        }
    }
}
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.
Why are you trying to spawn an NPC called trio that doesn't exist?
 
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("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 did that and only Angel Spawned
[DOUBLEPOST=1453528137,1453527702][/DOUBLEPOST]
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("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 did that and only Angel Spawned
i switch the order of the OnPlayers and then the demon one spawned
 
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("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 did that and only Angel Spawned
[DOUBLEPOST=1453528137,1453527702][/DOUBLEPOST]
i switch the order of the OnPlayers and then the demon one spawned
Look up what "return;" does and you'll figure it out.

What is the code for an npc to only spawn during hardmode?
Just check Main.hardmode.
 
Look up what "return;" does and you'll figure it out.


Just check Main.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;

EDIT: It says that "Terraria.Main does not contain a definition for 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;

EDIT: It says that "Terraria.Main does not contain a definition for hardmode."
Guess it's hardMode then, I don't have everything memorized.
 
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.

Oh sorry, i meant i want to spawn multiple minions using that summoning item. How does one go about doing that?
 
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.


That fixed on problem, but there is another one:



Missing sound Tremor/Title
at Terraria.ModLoader.ModLoader.GetSound (System.String name) [0x00000] in <filename unknown>:0
at Tremor.Tremor.Load () [0x00000] in <filename unknown>:0
at Terraria.ModLoader.ModLoader.do_Load (System.Object threadContext) [0x00000] in <filename unknown>:0


Sorry!
 
So finally I found out how I can draw a projectile with predraw and denied vanilla drawing.
I put these codes I found in ExampleMod:
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);
Still questions never end.
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:
Code:
       public Color GetColor()
        {
            return new Color(0, 0, 0);
        }
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?

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:
SuperStarCannonProjectile.png

And what if I want it to spin, let's say 180°:
SuperStarCannonProjectile.png

So I found two settings in the reference of projectile:
Projectile.rotation
Projectile.spriteDirection
Which one is used to determine the direction?
 
So finally I found out how I can draw a projectile with predraw and denied vanilla drawing.
I put these codes I found in ExampleMod:
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);
Still questions never end.
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:
Code:
       public Color GetColor()
        {
            return new Color(0, 0, 0);
        }
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?

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?
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]
Oh sorry, i meant i want to spawn multiple minions using that summoning item. How does one go about doing that?
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.)
 
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.)
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:
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;
And it ain't working.
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°.
 
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:
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;
And it ain't working.
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°.
2am 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.
 
2am 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.
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;
 
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;
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.
 
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.
Well:
Code:
            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;
But it only rotates 0.1f. What if I want it to rotate 0.1f on every fame, i.e. keep spinning?
 
How do I get rid of my minion when I right click the buff?

Code:
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;
            }
        }

If I understand the code correctly then the first "if" in Update checks if player has got the minion.
The 2nd "if" deleted the buff when player doesn't have the minion
 
Back
Top Bottom