Standalone [1.3] tModLoader - A Modding API

Okay just going to show off the 'Cyclogenesis Scythe' here..
Merely playing around, I think it's a fun weapon.
 
Just few suggestions for the GIT, you can actually move your little documentation tab on the original post to a wiki style page on your GIT repository.

I would also recommend you separate into a master branch which would be the current version that is open to everyone and a development branch which you use for updates so you don't mix up the code and have a fallback in case of severe errors.

Finally, you should create a readme.md file on the git repository containing the information you have provided in the original post to help people viewing the page out and to provide some additional information regarding the project, I went ahead and pull requested a sample one for you to use on the git page.

If you have any questions regarding GIT, I can help you out with those.
 
@bluemagic123 @JABofNeurospine

(code below)
I need your help over here. My weapon is getting there, but not just quite yet.
It shoots demon scythes where you point your cursor, which is really cool. But for now it is really OP. I want the range of where you can click to be decreased so you can't just use the weapon all over your screen. And on top of that, would it be possible to add a little internal cooldown before the demon scythes can be created again? (to prevent op spam?

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace Cyclogenesis.Items {
    public class Scythe : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Cyclogenesis Scythe";
            item.damage = 100;
            item.magic = true;
            item.width = 60;
            item.height = 56;
            item.toolTip = "Shoots scythes, may deal inaccurate damage.";
            item.toolTip2 = "Increases damage the more armor you have.";
            item.useTime = 45;
            item.useAnimation = 45;
            item.useStyle = 1;
            item.knockBack = 2;
            item.value = 0;
            item.rare = 10;
            item.useSound = 1;
            item.autoReuse = true;
            item.mana = 14;
            item.useSound = 8;
          
            item.shoot = 45;
            item.shootSpeed = 1f;
        }

        public override void MeleeEffects(Player player, Rectangle hitbox)
        {
            int dust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 27, player.velocity.X * 0.2f + (float)(player.direction * 3), player.velocity.Y * 0.2f, 100, default(Color), 1.75f);
            Main.dust[dust].noGravity = true;
            Main.dust[dust].velocity *= 1.66f;

            var FrontLightPos = new Vector2((float)player.position.X + 55, (float)player.position.Y);
            var BackLightPos = new Vector2((float)player.position.X - 55, (float)player.position.Y);

            Lighting.AddLight(FrontLightPos, 0.75f, 0f, 0f);
            Lighting.AddLight(BackLightPos, 0f, 0f, 0.75f);
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            int damageCalculation = (int)((item.damage * 0.8) / 2) * Main.rand.Next(3);
            int armorIncrement = (int)(player.statDefense * 1.33);

            float spread = 45f * 0.0174f;
            double startAngle = Math.Atan2(speedX, speedY)- spread/2;
            double deltaAngle = spread/8f;
            double offsetAngle;
            Vector2 pos = GetPos(player);

            for (int i = 0; i < 4; i++ )
            {
                offsetAngle = (startAngle + deltaAngle * (i + i*i) / 2f) + 32f * i;
                Projectile.NewProjectile((int)(pos.X), (int)(pos.Y), (float)(Math.Sin(offsetAngle) * 2f), (float)(Math.Cos(offsetAngle) * 2f), 45, damageCalculation + armorIncrement, knockBack, item.owner);
                Projectile.NewProjectile((int)(pos.X), (int)(pos.Y), (float)(-Math.Sin(offsetAngle) * 2f), (float)(-Math.Cos(offsetAngle) * 3f), 45, damageCalculation + armorIncrement, knockBack, item.owner);

                //Projectile.NewProjectile(position.X, position.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), 263, damage, knockBack, item.owner);
                //Projectile.NewProjectile(position.X, position.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), 263, damage, knockBack, item.owner);
            }
            return false;
        }

        static float NextFloat(Random random)
        {
            double mantissa = (random.NextDouble() * 2.0) - 1.0;
            double exponent = Math.Pow(2.0, random.Next(-126, 128));
            return (float)(mantissa * exponent);
        }

        public override void Update(ref float gravity, ref float maxFallSpeed)
        {
            Lighting.AddLight(item.position, 1f, 0.25f, 1f);
        }

        private Vector2 GetPos(Player player)
        {
            Vector2 position = Main.screenPosition;
            position.X += Main.mouseX;
            position.Y += player.gravDir == 1 ? Main.mouseY : Main.screenHeight - Main.mouseY;
            return position;
        }
    }
}
 
@bluemagic123 @JABofNeurospine

(code below)
I need your help over here. My weapon is getting there, but not just quite yet.
It shoots demon scythes where you point your cursor, which is really cool. But for now it is really OP. I want the range of where you can click to be decreased so you can't just use the weapon all over your screen. And on top of that, would it be possible to add a little internal cooldown before the demon scythes can be created again? (to prevent op spam?

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace Cyclogenesis.Items {
    public class Scythe : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Cyclogenesis Scythe";
            item.damage = 100;
            item.magic = true;
            item.width = 60;
            item.height = 56;
            item.toolTip = "Shoots scythes, may deal inaccurate damage.";
            item.toolTip2 = "Increases damage the more armor you have.";
            item.useTime = 45;
            item.useAnimation = 45;
            item.useStyle = 1;
            item.knockBack = 2;
            item.value = 0;
            item.rare = 10;
            item.useSound = 1;
            item.autoReuse = true;
            item.mana = 14;
            item.useSound = 8;
         
            item.shoot = 45;
            item.shootSpeed = 1f;
        }

        public override void MeleeEffects(Player player, Rectangle hitbox)
        {
            int dust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 27, player.velocity.X * 0.2f + (float)(player.direction * 3), player.velocity.Y * 0.2f, 100, default(Color), 1.75f);
            Main.dust[dust].noGravity = true;
            Main.dust[dust].velocity *= 1.66f;

            var FrontLightPos = new Vector2((float)player.position.X + 55, (float)player.position.Y);
            var BackLightPos = new Vector2((float)player.position.X - 55, (float)player.position.Y);

            Lighting.AddLight(FrontLightPos, 0.75f, 0f, 0f);
            Lighting.AddLight(BackLightPos, 0f, 0f, 0.75f);
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            int damageCalculation = (int)((item.damage * 0.8) / 2) * Main.rand.Next(3);
            int armorIncrement = (int)(player.statDefense * 1.33);

            float spread = 45f * 0.0174f;
            double startAngle = Math.Atan2(speedX, speedY)- spread/2;
            double deltaAngle = spread/8f;
            double offsetAngle;
            Vector2 pos = GetPos(player);

            for (int i = 0; i < 4; i++ )
            {
                offsetAngle = (startAngle + deltaAngle * (i + i*i) / 2f) + 32f * i;
                Projectile.NewProjectile((int)(pos.X), (int)(pos.Y), (float)(Math.Sin(offsetAngle) * 2f), (float)(Math.Cos(offsetAngle) * 2f), 45, damageCalculation + armorIncrement, knockBack, item.owner);
                Projectile.NewProjectile((int)(pos.X), (int)(pos.Y), (float)(-Math.Sin(offsetAngle) * 2f), (float)(-Math.Cos(offsetAngle) * 3f), 45, damageCalculation + armorIncrement, knockBack, item.owner);

                //Projectile.NewProjectile(position.X, position.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), 263, damage, knockBack, item.owner);
                //Projectile.NewProjectile(position.X, position.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), 263, damage, knockBack, item.owner);
            }
            return false;
        }

        static float NextFloat(Random random)
        {
            double mantissa = (random.NextDouble() * 2.0) - 1.0;
            double exponent = Math.Pow(2.0, random.Next(-126, 128));
            return (float)(mantissa * exponent);
        }

        public override void Update(ref float gravity, ref float maxFallSpeed)
        {
            Lighting.AddLight(item.position, 1f, 0.25f, 1f);
        }

        private Vector2 GetPos(Player player)
        {
            Vector2 position = Main.screenPosition;
            position.X += Main.mouseX;
            position.Y += player.gravDir == 1 ? Main.mouseY : Main.screenHeight - Main.mouseY;
            return position;
        }
    }
}
For the range problem, first you could try calculating the offset between the mouse and the player as a Vector2. Vector2 structs have a Length method to help you decide whether the mouse is out of range; if it is then you could use the Vector2.Normalize method to turn the offset into a unit vector, then multiply that by the max range, and add it back to the player's center.
For the cooldown problem, there is a reuseDelay field in the Item class, although I haven't looked much into how it works. You could also create a field in the ModItem class, set it whenever the item is used, use the UpdateInventory hook to change the field, and override CanUseItem. (I'd personally see how the first way works first :guidetongue:)
 
For the range problem, first you could try calculating the offset between the mouse and the player as a Vector2. Vector2 structs have a Length method to help you decide whether the mouse is out of range; if it is then you could use the Vector2.Normalize method to turn the offset into a unit vector, then multiply that by the max range, and add it back to the player's center.

Erm what. I'm trying to understand, but to read it is always difficult. Examples always work, but I'm trying!

there is a reuseDelay field in the Item class

I use that, it does work (in ticks I believe, so 60=1second) but it :red:s up the swing animation.
 
Does anyone know of a way to get chat messages when they are sent, in order to do things such as commands? I've looked around, can't seem to find it.
 
For the range problem, first you could try calculating the offset between the mouse and the player as a Vector2. Vector2 structs have a Length method to help you decide whether the mouse is out of range; if it is then you could use the Vector2.Normalize method to turn the offset into a unit vector, then multiply that by the max range, and add it back to the player's center.

Here's what I got out of your story XD

Code:
        private bool GetPlayerOffset(Player player)
        {
            Vector2 pos = GetPos(player);
            Vector2 plr = player.position;

            float diff = (pos - plr).Length();

            if (diff < 500)
                return true;
            else
                return false;
        }
 
Here's what I got out of your story XD

Code:
        private bool GetPlayerOffset(Player player)
        {
            Vector2 pos = GetPos(player);
            Vector2 plr = player.position;

            float diff = (pos - plr).Length();

            if (diff < 500)
                return true;
            else
                return false;
        }
Yes, that gets whether or not it's in range. You'll want to keep the (pos - plr) Vector2 so you can adjust its length to be in range.
 
Where is it saying that?

Microsoft Visual Studio.

Y8HGb1T.png
 
The "Vector2 diff" part is supposed to be "float diff" like in your original code. (Maybe we should continue this in a private conversation :guidetongue:)
 
I actually took a look at the lighting they use themselves on souls and it's pretty neat because it updates as the soul is moving ('animating') .. a sort of breathing
Using this: (this is a red one)
Code:
        public override void Update(ref float gravity, ref float maxFallSpeed)
        {
            float num = (float)Main.rand.Next(90, 111) * 0.01f;
            num *= Main.essScale;
            Lighting.AddLight((int)((item.position.X + (float)(item.width / 2)) / 16f), (int)((item.position.Y + (float)(item.height / 2)) / 16f), 0.5f * num, 0.3f * num, 0.05f * num);
        }

green one:
Code:
        public override void Update(ref float gravity, ref float maxFallSpeed)
        {
            float num = (float)Main.rand.Next(90, 111) * 0.01f;
            num *= Main.essScale;
            Lighting.AddLight((int)((item.position.X + (float)(item.width / 2)) / 16f), (int)((item.position.Y + (float)(item.height / 2)) / 16f), 0.1f * num, 0.5f * num, 0.2f * num);
        }
 
I hate to be the clueless, but i cant figure out why when i use SetGlobalItem(new HuntersModItem()); i get an error and when i do anything to do with recipe.Addrecipe(); etc etc. in RecipeHelper i get another error. (dont know how else to upload the compile errors) thanks for helping.
 

Attachments

  • Compile Errors.txt
    962 bytes · Views: 220
I hate to be the clueless, but i cant figure out why when i use SetGlobalItem(new HuntersModItem()); i get an error and when i do anything to do with recipe.Addrecipe(); etc etc. in RecipeHelper i get another error. (dont know how else to upload the compile errors) thanks for helping.
For the first one, are you sure that either HuntersModItem is in the same namespace as your mod, or that your mod is using the namespace that contains HuntersModItem?
For the RecipeHelper errors, did you remember to declare a variable called recipe?
 
For the first one, are you sure that either HuntersModItem is in the same namespace as your mod, or that your mod is using the namespace that contains HuntersModItem?
For the RecipeHelper errors, did you remember to declare a variable called recipe?
There we go, progress. fixed the recipe errors, it was a simple spelling error. Now when i do using HuntersMod.Items it says the items type or namespace does not exist, where do i call/declare items, or am i going about this the wrong way. thank you again.
 
Last edited:
Back
Top Bottom