Standalone [1.3] tModLoader - A Modding API

would you kindly not spam? theres an edit button, use it

not sure how to trow in this game, its probably not supported. and bows can shoot arrows by making it useAmmo = 1;
sorry for spaming and i found everything i wannted well I still dont know hot to make trowing weapons but still thanks
 
I'm a bit stuck right now with something AI related. Basically, I took the vanilla Skeletron Prime ai and set it up so the mod would compile, and I wanted to tinker with it for a better understanding of how the AIs worked and stuff, but it completely backfired. First, it just flung the NPC across the screen at lightspeed, and despawned within about 3 seconds, and instead of spawning with the Skeletron Prime hands, it spawned with 3 NPCs from my mod, all different ones. If I'm allowed to, I will post the code, but I am aware things from source are not really allowed to be posted. I could PM someone if they wish to see it, if that is allowed.

It might have something to do with my other boss's coding, here's the snippet that I think may be the offender.
Code:
public override void PostAI()
    {
        if(npc.ai[1] % 360 ==0)
        {
            NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("StealthBomber"));
        }
        if(npc.ai[1] % 360 ==0)
        {
            NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Apache"));
        }
        if(npc.ai[1] % 360 ==0)
        {
            NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Abrams"));
        }
        npc.ai[1] += 1f;
    }
 
public override void ModifyHitNPC(Player player, NPC target, ref int damage, ref float knockBack, ref bool crit)

this can change damage
but is there a way to change swing speed in the same way as this one does damage
 
Can someone please explain this to me. I have the mac GoG version, no hate please just prefer it over steam. I don't have the steam folder in my application support folder. Can anyone help me to install tmodloader into my game or can it not be done? Thanks in advance.
 
Can someone please explain this to me. I have the mac GoG version, no hate please just prefer it over steam. I don't have the steam folder in my application support folder. Can anyone help me to install tmodloader into my game or can it not be done? Thanks in advance.

if i am not wrong tmodloader only works with steam

i think this is true for mac to but not sure
 
I've met with a horrible bug (maybe for me it's horrible) with my throwing knife's durability system in multiplayer... I dunno whether it is a exclusive bug for the multiplayer or whether it is fixable for now.
First I'd give a brief description of my throwing knife's durability system.
Every throwing knife is supposed to have 3 "items/parts":
Code:
    public class IchorKnife : ModItem
    {
        public int durability = 1000;

        public override void SetDefaults()
        {
            item.name = "Ichor Knife";
            item.toolTip = "Decreases target's defense";
            item.autoReuse = true;
            item.useStyle = 1;
            item.shootSpeed = 12f;
            item.damage = 29;
            item.width = 18;
            item.height = 20;
            item.useSound = 39;
            item.useAnimation = 16;
            item.useTime = 16;
            item.noUseGraphic = true;
            item.noMelee = true;
            item.value = Item.sellPrice(0, 20, 0, 0);
            item.knockBack = 2.75f;
            item.melee = true;
            item.rare = 8;
            item.shoot = mod.ProjectileType("IchorKnifeProjectile");
        }

        public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
        {
            Main.spriteBatch.DrawString(Main.fontItemStack, durability.ToString(), new Vector2(position.X - 8f, position.Y + 11f), Color.White, 0f, default(Vector2), scale, SpriteEffects.None, 0f);
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            durability--;
            return true;
        }

        public override bool CanUseItem(Player player)
        {
            return durability > 0;
        }

        public override void SaveCustomData(BinaryWriter writer)
        {
            writer.Write(durability);
        }

        public override void LoadCustomData(BinaryReader reader)
        {
            durability = reader.ReadInt32();
        }
Code:
    public class IchorKnifeProjectile : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Ichor Knife";
            projectile.alpha = 0;
            projectile.scale = 1f;
            projectile.width = 14;
            projectile.height = 28;
            projectile.aiStyle = 2;
            projectile.friendly = true;
            projectile.penetrate = 3;
            projectile.melee = true;
            //projectile.light = 0.2f;
            projectile.ignoreWater = true;
            //aiType = 48;
        }

        public override bool PreAI()
        {
            Lighting.AddLight((int)((projectile.position.X + (float)(projectile.width / 2)) / 16f), (int)((projectile.position.Y + (float)(projectile.height / 2)) / 16f), 1f, 1f, 0f);

            int d = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 169, 0f, 0f, 100, default(Color), 1f);
            if (Main.rand.Next(2) == 0)
            {
                Main.dust[d].noGravity = true;
                Main.dust[d].scale *= 1.5f;
            }

            projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;

            projectile.ai[0] += 1f;
            if (projectile.ai[0] >= 35f)
            {
                projectile.velocity.Y = projectile.velocity.Y + 0.4f;
                projectile.velocity.X = projectile.velocity.X * 0.97f;
            }

            if (projectile.velocity.Y > 16f)
            {
                projectile.velocity.Y = 16f;
            }
            return false;
        }

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(69, 600, false);
        }

        public override bool OnTileCollide(Vector2 oldVelocity)
        {
            Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y, 1);
            return true;
        }
Code:
    public class IchorKnifeOnPickup : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Ichor Knife";
            item.consumable = true;
            item.maxStack = 1000;
            item.width = 18;
            item.height = 20;
            item.rare = 8;
        }

        public override bool OnPickup(Player player)
        {
            for (int i = 0; i < 51; i++)
            {
                Item item2 = player.inventory[i];
                if (item2.stack > 0 && item2.type > 0 && item2.type == mod.ItemType("IchorKnife"))
                {
                    if (((IchorKnife)item2.modItem).durability <= 999)
                    {
                        Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 0);
                        ItemText.NewText(item, item.stack, false, false);
                        ((IchorKnife)item2.modItem).durability += item.stack;
                        break;
                    }
                }
                if (i == 50)
                {
                    int a = Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("IchorKnifeOnPickup"), item.stack, false, 0, false, false);
                    Main.item[a].noGrabDelay = 60;
                }
            }
            return false;
        }
  • Every throwing knife will be crafted with a maximum durability 1000.
  • The durability will be reduced upon using. (conduct by shoot hook)
  • The throwing knife will act like the vanilla throwing weapons. It has its 50% chance to drop the ammo when killed.
  • In this case, it won't drop the weapon itself, which is "IchorKnife". It will drop the exclusive item "IchorKnifeOnPickup" instead.
  • When the "IchorKnifeOnPickup" was picked up by a player,
  • if the player has the apt throwing knife and the durability was not full, he will pick it up, and increase the durability of the particular throwing knife, but the item won't appear in his inventory (the OnPickup hook returns false);
  • if the player does not has the throwing knife, he will also pick it up, but meanwhile a new and totally identical item will be created on his face, which makes it look like that he cannot pick up the item (I swear, this is the best case I can think out after several days' rocking my head).
However, this made-look-like-cannot-pickup function went dead when it comes to multiplayer. The player will pick up the "IchorKnifeOnPickup" regardless of their having the apt throwing knife facts. If a player possesses the throwing knife, yeah, the durability will get increased damn nice. But every player without the knife will swallow the "IchorKnifeOnPickup" as if they love to eat it...
This is the first time that I ever found that something worked like a charm in single player will end up screwing up in the multiplayer. This is frustrating and I have totally totally no idea about what's going on, and I need help!!!

EDIT: @jopojelly I duuno whether you're online but your profit pic is green. If you see this, well, please give a quick look. Thx:)
Yeah, I know that multiplayer can be an order of magnitude more difficult than singleplayer. I had a :redmunch:of a time with one of my items and multiplayer. I can't give you any specific help because my problem was completely different, but I can give you some general advice. You can use Main.NewText(/*stuff*/); to see what's happening on a client and Console.WriteLine(/*stuff*/); to see the same thing in the console window of your server.

For example, you could try the following inside your onPickup's first if statement:
Code:
Main.NewText("onPickup, Durability: " + ((IchorKnife)item2.modItem).durability);
Console.WriteLine("onPickup, Durability: " + ((IchorKnife)item2.modItem).durability);
 
Well,i still have a few bugs.
I think i mentioned it before but the more You play,the more messed up the sound/music becomes in Terraria tModLoader (not sure if only on mac)
Like few sounds disappear the more i play and either the music: doesn't play after a while,doesn't switch music tracks.
 
How to fix this?:
Code:
Missing mod: ThatMod/Items/Weapons/ExampleHammer
   at Terraria.ModLoader.ModLoader.GetTexture(String name)
   at Terraria.ModLoader.Mod.SetupContent()
   at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

(when building mod)
 
How to fix this?:
Code:
Missing mod: ThatMod/Items/Weapons/ExampleHammer
   at Terraria.ModLoader.ModLoader.GetTexture(String name)
   at Terraria.ModLoader.Mod.SetupContent()
   at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

(when building mod)
make sure you wrote the sprite name right in the code and if its in the right folder
 
Back
Top Bottom