tModLoader How do I fix these 3 errors for my modded boss?

Huyino2

Skeletron
So im working on a boss for my mod and I got 39 errors and cut it down to 4 but I cant seem to figure out how to fix these 4. Anybody know a fix?

Here are the errors

Error 1:TURTLE.cs(82,20) : error CS7036: There is no argument given that corresponds to the required formal parameter 'turnResistance' of 'TURTLE.MoveTowards(NPC, Vector2, float, float)'
Error 2:TURTLE.cs(95,38) : error CS0131: The left-hand side of an assignment must be a variable, property or indexer
Error 3(similar to error 2):TURTLE.cs(96,38) : error CS0131: The left-hand side of an assignment must be a variable, property or indexer

Code: (error 2 & 3)
Code:
if((double)npc.ai[0] % 50 == 0)
                        {
                            float speed = 12f;
                            Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                            float x = player.position.X + (float)(player.width / 2) = vector.X;
                            float y = player.position.Y + (float)(player.height / 2) = vector.Y;
                            float distance2 = (float)Math.Sqrt(x * x + y * y);
                            float factor = speed / distance;
                            npc.velocity.X = x * factor;
                            npc.velocity.Y = y * factor;
Code: (error 1)
Code:
private void MoveTowards(NPC npc, Vector2 playerTarget, float speed, float turnResistance)
        {
            var move = playerTarget - npc.Center;
            float length = move.Length();
            if(length > speed)
            {
                move *= speed / length;
            }
            move = (npc.velocity * turnResistance + move) / (turnResistance + 1f);
            length = move.Length();
            if(length > speed)
            {
                move *= speed / length;
            }
            npc.velocity = move;
        }

(Edit: I fixed error 4 I just needed to add some using tags)
 
Last edited:
The first one should be pretty simple, and if I'm not missunderstanding anything here this code should work.

C#:
if((double)npc.ai[0] % 50 == 0)
                        {
                            float speed = 12f;
                            Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                            float x = player.position.X + (float)(player.width / 2) + vector.X;
                            float y = player.position.Y + (float)(player.height / 2) + vector.Y;
                            float distance2 = (float)Math.Sqrt(x * x + y * y);
                            float factor = speed / distance;
                            npc.velocity.X = x * factor;
                            npc.velocity.Y = y * factor;

The second one is a bit harder, how do you call it? You can try with this code, but as I don't know the context so I'm not sure it will work.

C#:
private void MoveTowards(NPC npc, Vector2 playerTarget, float speed, float turnResistance = 1f)
        {
            Vector2 move = playerTarget - npc.Center;
            float length = move.Length();
            if(length > speed)
            {
                move *= speed / length;
            }
            move = (npc.velocity * turnResistance + move) / (turnResistance + 1f);
            length = move.Length();
            if(length > speed)
            {
                move *= speed / length;
            }
            npc.velocity = move;
        }
 
The first one should be pretty simple, and if I'm not missunderstanding anything here this code should work.

C#:
if((double)npc.ai[0] % 50 == 0)
                        {
                            float speed = 12f;
                            Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                            float x = player.position.X + (float)(player.width / 2) + vector.X;
                            float y = player.position.Y + (float)(player.height / 2) + vector.Y;
                            float distance2 = (float)Math.Sqrt(x * x + y * y);
                            float factor = speed / distance;
                            npc.velocity.X = x * factor;
                            npc.velocity.Y = y * factor;

The second one is a bit harder, how do you call it? You can try with this code, but as I don't know the context so I'm not sure it will work.

C#:
private void MoveTowards(NPC npc, Vector2 playerTarget, float speed, float turnResistance = 1f)
        {
            Vector2 move = playerTarget - npc.Center;
            float length = move.Length();
            if(length > speed)
            {
                move *= speed / length;
            }
            move = (npc.velocity * turnResistance + move) / (turnResistance + 1f);
            length = move.Length();
            if(length > speed)
            {
                move *= speed / length;
            }
            npc.velocity = move;
        }
I didnt get the errors anymore but the boss didnt work as intended. It just stayed stationary even though its supposed to move around but i can work with it. Thanks for the help!
 
Last edited:
Back
Top Bottom