Standalone [1.3] tModLoader - A Modding API

Unpacking the client with regular debuggers isn't hard. Fixing the errors neither.
The time where the client itself gets settled without any further updates (e.g. last hotfix at v1.4.0.5), that is the thing modders and programmers are waiting for.
No one willing to go through that tedious process of readjusting hundreds of offsets, opcodes and declarations, if the next patch inserts a simple addition in the beginning, in the middle and the end of the entire assembly code line which pushes borders far away from known spots.
Truth. The code changes slightly every single patch.
 
So I've already got an idea of what my issue is from other sources but I wanted to post here and get other people's opinions. So tmodloader runs just fine and smooth and max graphics. When I tried installing the 64 bit version and tried playing the game, even with 0 mods installed my fps dropped to 30-45FPS on the lowest graphics setting. These are my PC's specs, anyone know what the issue may be?
Intel i7-8750H CPU @ 2.20GHz
16GB Ram
64 bit OS Windows 10
GeForce® GTX 1070 with 8GB GDDR5
 
So I've already got an idea of what my issue is from other sources but I wanted to post here and get other people's opinions. So tmodloader runs just fine and smooth and max graphics. When I tried installing the 64 bit version and tried playing the game, even with 0 mods installed my fps dropped to 30-45FPS on the lowest graphics setting. These are my PC's specs, anyone know what the issue may be?
Intel i7-8750H CPU @ 2.20GHz
16GB Ram
64 bit OS Windows 10
GeForce® GTX 1070 with 8GB GDDR5
Maybe try a different driver for gtx?
 
uhhhhh..... help? like, how
Annotation 2020-06-04 132107.png
 
small question about the steam version of TML.
it doesn't seem to handle high DPI settings at all.
with vanilla Terraria i just rightclicked the executable and changed the DPI Settings to "extended" so everything is scaled up, but that same method doesn't work for TML.
obviously i can still use the sliders ingame to adjust the scaling of the UI and the Zoom, but the main menu and everything there is still much smaller than it should be.
Pcrgl1L.jpg
1LsZPWr.jpg
(i put the images inside spoilers because i don't like giant pictures taking up half the screen when just scrolling through a page.)

otherwise it works perfectly fine.
 
I have a question. I've had someone contact me to do a translation of my mod. I like the idea of a translation, but I don't want to just give away the source code of my mod. Is there a way that I could make it easy for someone to make a dependant mod that translates everything in my mod? Thanks.
 
So I've already got an idea of what my issue is from other sources but I wanted to post here and get other people's opinions. So tmodloader runs just fine and smooth and max graphics. When I tried installing the 64 bit version and tried playing the game, even with 0 mods installed my fps dropped to 30-45FPS on the lowest graphics setting. These are my PC's specs, anyone know what the issue may be?
Intel i7-8750H CPU @ 2.20GHz
16GB Ram
64 bit OS Windows 10
GeForce® GTX 1070 with 8GB GDDR5
it may be because your cpu is 2.20 ghz, im not sure because mine is 2.59 ghz, but can go up to 3 ghz, i know terraria is a cpu intensive game which is why i was thinking it could be the cpu
 
So I've already got an idea of what my issue is from other sources but I wanted to post here and get other people's opinions. So tmodloader runs just fine and smooth and max graphics. When I tried installing the 64 bit version and tried playing the game, even with 0 mods installed my fps dropped to 30-45FPS on the lowest graphics setting. These are my PC's specs, anyone know what the issue may be?
Intel i7-8750H CPU @ 2.20GHz
16GB Ram
64 bit OS Windows 10
GeForce® GTX 1070 with 8GB GDDR5

Sounds like Windows is being silly and is using your Intel cpu's integrated graphics to run the game, a laptop with that spec should be able to max out this game like its nothing.
 
This issue has been getting annoying. Error CS0103: The name 'player' does not exist in the current context. Like, how?

C:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader.IO;
using Terraria.UI;
using Terraria.Utilities;
using NewJourney.Tiles;
using Terraria;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using NewJourney.Projectiles;

namespace NewJourney.NPCs
{
    public class StuffedSlime : ModNPC
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Stuffed Slime");
    }
        public override void SetDefaults()
        {
            npc.width = 20;
            npc.height = 20;
            npc.damage = 6;
            npc.defense = 4;
            npc.lifeMax = 60;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.value = 50f;
            npc.knockBackResist = 1f;
        npc.noGravity = false;
        npc.scale = 1f;
        npc.aiStyle = -1;
        npc.buffImmune[20] = true;
        npc.buffImmune[24] = true;
            Main.npcFrameCount[npc.type] = 2;
            animationType = 535;
        }

        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
        if (spawnInfo.player.ZoneOverworldHeight && Main.dayTime)
           return SpawnCondition.OverworldDaySlime.Chance * 0.1f;
            return SpawnCondition.OverworldNight.Chance * 0.05f;   
        }

        public override void NPCLoot()
        {
            Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 23, Main.rand.Next(1, 20));
    }

    private const int AI_State_Slot = 0;
    private const int AI_Timer_Slot = 1;
    private const int AI_Shoot_Time_Slot = 2;

    private const int State_Asleep = 0;
    private const int State_Slime = 1;
    private const int State_ShootSlime = 2;

    public float AI_State {
        get => npc.ai[AI_State_Slot];
        set => npc.ai[AI_State_Slot] = value;
    }
    public float AI_Timer {
        get => npc.ai[AI_Timer_Slot];
        set => npc.ai[AI_Timer_Slot] = value;
    }

    public float AI_ShootTime {
        get => npc.ai[AI_Shoot_Time_Slot];
        set => npc.ai[AI_Shoot_Time_Slot] = value;
    }

    public override void AI()
        {
        if (AI_State == State_Asleep) {
            npc.TargetClosest(true);
            if (npc.HasValidTarget && Main.player[npc.target].Distance(npc.Center) < 500f) {
                AI_State = State_Slime;
                AI_Timer = 0;
                Main.PlaySound(SoundID.NPCHit1, npc.position);
            }
        }
        else if (AI_State == State_Slime) {
            if (Main.player[npc.target].Distance(npc.Center) < 750f) {
                AI_Timer++;
                if (AI_Timer == 1) {
                    npc.TargetClosest(true);
                    npc.velocity = new Vector2(npc.direction * 2, -2f);
                }
                else if (AI_Timer >= 360) {
                    Vector2 velocity = player.Center - npc.Center;
                    float magnitude = Magnitude(velocity);
                    int type = 468;
                    if (magnitude > 0)
                    {
                        velocity *= 18 / magnitude;
                    }
                    else
                    {
                        velocity = new Vector2(0f, 5f);
                    }
                        Projectile.NewProjectile((int)npc.position.X, (int)npc.position.Y, 0, -1, mod.ProjectileType("SlimeBall"), 30, 3f, Main.myPlayer, 1, 8);
                        Projectile.NewProjectile((int)npc.position.X, (int)npc.position.Y, 0, -1, 605, 30, 3f, Main.myPlayer, 4, 4);
                    AI_State = State_ShootSlime;
                    AI_Timer = 0;
                    Main.PlaySound(SoundID.NPCHit1, npc.position);
                }
            }
        }
        else if (AI_State == State_ShootSlime) {
            npc.aiStyle = -1;
            AI_Timer += 1;
            if (AI_Timer == 1 && Main.netMode != NetmodeID.MultiplayerClient) {
                AI_ShootTime = Main.rand.NextBool() ? 150 : 200;
                npc.netUpdate = true;
                Vector2 velocity = player.Center - npc.Center;
                float magnitude = Magnitude(velocity);
                int type = 468;
                if (magnitude > 0)
                {
                    velocity *= 18 / magnitude;
                }
                else
                {
                velocity = new Vector2(0f, 5f);
                }
                Projectile.NewProjectile((int)npc.position.X, (int)npc.position.Y, 0, -1, mod.ProjectileType("SlimeBall"), 30, 3f, Main.myPlayer, 1, 8);
                Projectile.NewProjectile((int)npc.position.X, (int)npc.position.Y, 0, -1, 605, 30, 3f, Main.myPlayer, 4, 4);
            }
            if (AI_Timer > AI_ShootTime) {
                AI_State = State_Slime;
                AI_Timer = 0;
                Main.PlaySound(SoundID.NPCHit1, npc.position);
            }
        }
    }
    private const int Frame_Slime_1 = 0;
    private const int Frame_Slime_2 = 1;

    public override void FindFrame(int frameHeight) {
        npc.spriteDirection = npc.direction;
        npc.frameCounter++;
        if (npc.frameCounter < 10) {
            npc.frame.Y = Frame_Slime_1 * frameHeight;
        }
        else if (npc.frameCounter < 20) {
            npc.frame.Y = Frame_Slime_2 * frameHeight;
        }
        else {
            npc.frameCounter = 0;
        }
    }
    }
}
Apparently, the code doesn't like it when I replace 'player' with 'Player', because it gives me another error. Error CS0120: An object reference was required for the non-static field, method, or property, 'Entity.Center'

And just in case you are asking: Yes, I have had this issue a few times before.
 
This issue has been getting annoying. Error CS0103: The name 'player' does not exist in the current context. Like, how?

C:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader.IO;
using Terraria.UI;
using Terraria.Utilities;
using NewJourney.Tiles;
using Terraria;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using NewJourney.Projectiles;

namespace NewJourney.NPCs
{
    public class StuffedSlime : ModNPC
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Stuffed Slime");
    }
        public override void SetDefaults()
        {
            npc.width = 20;
            npc.height = 20;
            npc.damage = 6;
            npc.defense = 4;
            npc.lifeMax = 60;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.value = 50f;
            npc.knockBackResist = 1f;
        npc.noGravity = false;
        npc.scale = 1f;
        npc.aiStyle = -1;
        npc.buffImmune[20] = true;
        npc.buffImmune[24] = true;
            Main.npcFrameCount[npc.type] = 2;
            animationType = 535;
        }

        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
        if (spawnInfo.player.ZoneOverworldHeight && Main.dayTime)
           return SpawnCondition.OverworldDaySlime.Chance * 0.1f;
            return SpawnCondition.OverworldNight.Chance * 0.05f;  
        }

        public override void NPCLoot()
        {
            Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, 23, Main.rand.Next(1, 20));
    }

    private const int AI_State_Slot = 0;
    private const int AI_Timer_Slot = 1;
    private const int AI_Shoot_Time_Slot = 2;

    private const int State_Asleep = 0;
    private const int State_Slime = 1;
    private const int State_ShootSlime = 2;

    public float AI_State {
        get => npc.ai[AI_State_Slot];
        set => npc.ai[AI_State_Slot] = value;
    }
    public float AI_Timer {
        get => npc.ai[AI_Timer_Slot];
        set => npc.ai[AI_Timer_Slot] = value;
    }

    public float AI_ShootTime {
        get => npc.ai[AI_Shoot_Time_Slot];
        set => npc.ai[AI_Shoot_Time_Slot] = value;
    }

    public override void AI()
        {
        if (AI_State == State_Asleep) {
            npc.TargetClosest(true);
            if (npc.HasValidTarget && Main.player[npc.target].Distance(npc.Center) < 500f) {
                AI_State = State_Slime;
                AI_Timer = 0;
                Main.PlaySound(SoundID.NPCHit1, npc.position);
            }
        }
        else if (AI_State == State_Slime) {
            if (Main.player[npc.target].Distance(npc.Center) < 750f) {
                AI_Timer++;
                if (AI_Timer == 1) {
                    npc.TargetClosest(true);
                    npc.velocity = new Vector2(npc.direction * 2, -2f);
                }
                else if (AI_Timer >= 360) {
                    Vector2 velocity = player.Center - npc.Center;
                    float magnitude = Magnitude(velocity);
                    int type = 468;
                    if (magnitude > 0)
                    {
                        velocity *= 18 / magnitude;
                    }
                    else
                    {
                        velocity = new Vector2(0f, 5f);
                    }
                        Projectile.NewProjectile((int)npc.position.X, (int)npc.position.Y, 0, -1, mod.ProjectileType("SlimeBall"), 30, 3f, Main.myPlayer, 1, 8);
                        Projectile.NewProjectile((int)npc.position.X, (int)npc.position.Y, 0, -1, 605, 30, 3f, Main.myPlayer, 4, 4);
                    AI_State = State_ShootSlime;
                    AI_Timer = 0;
                    Main.PlaySound(SoundID.NPCHit1, npc.position);
                }
            }
        }
        else if (AI_State == State_ShootSlime) {
            npc.aiStyle = -1;
            AI_Timer += 1;
            if (AI_Timer == 1 && Main.netMode != NetmodeID.MultiplayerClient) {
                AI_ShootTime = Main.rand.NextBool() ? 150 : 200;
                npc.netUpdate = true;
                Vector2 velocity = player.Center - npc.Center;
                float magnitude = Magnitude(velocity);
                int type = 468;
                if (magnitude > 0)
                {
                    velocity *= 18 / magnitude;
                }
                else
                {
                velocity = new Vector2(0f, 5f);
                }
                Projectile.NewProjectile((int)npc.position.X, (int)npc.position.Y, 0, -1, mod.ProjectileType("SlimeBall"), 30, 3f, Main.myPlayer, 1, 8);
                Projectile.NewProjectile((int)npc.position.X, (int)npc.position.Y, 0, -1, 605, 30, 3f, Main.myPlayer, 4, 4);
            }
            if (AI_Timer > AI_ShootTime) {
                AI_State = State_Slime;
                AI_Timer = 0;
                Main.PlaySound(SoundID.NPCHit1, npc.position);
            }
        }
    }
    private const int Frame_Slime_1 = 0;
    private const int Frame_Slime_2 = 1;

    public override void FindFrame(int frameHeight) {
        npc.spriteDirection = npc.direction;
        npc.frameCounter++;
        if (npc.frameCounter < 10) {
            npc.frame.Y = Frame_Slime_1 * frameHeight;
        }
        else if (npc.frameCounter < 20) {
            npc.frame.Y = Frame_Slime_2 * frameHeight;
        }
        else {
            npc.frameCounter = 0;
        }
    }
    }
}
Apparently, the code doesn't like it when I replace 'player' with 'Player', because it gives me another error. Error CS0120: An object reference was required for the non-static field, method, or property, 'Entity.Center'

And just in case you are asking: Yes, I have had this issue a few times before.
Looking through your code, you have several different references to player. Main.player[npc.target] and player.Center. Main.player[npc.target] is a reference to a specific player in the player array, but player.Center has nothing before it to say which player is being targeted. I don't know exactly what all of your code is for, but you may want to use Main.player[npc.target].Center.
 
Back
Top Bottom