Jump to content
  • 0

Increase movement speed by increasing level


Guest

Question

Currently I took the speed increase when leveling speed, yes I left this attribute to archers, to increase the damage with bows.

However, I would like to use the same mechanism to increase speed as the character increases in level,
currently i found this function that changes the speed.

Quote

public virtual float GetMovementTime()

{

var time = 1000f / (float) (1 + Math.Log(Stat[(int) Stats.Speed].Value()));

if (Blocking)

{

time += time * Options.BlockingSlow;

}

return Math.Min(1000f, time);

}

And I left it just like that, for everyone to have the same speed

Quote

        public virtual float GetMovementTime()
        {
            var time = 400f;
            if (Blocking)
            {
                time += time * Options.BlockingSlow;
            }

            return Math.Min(400f, time);
        }

 

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0
2 hours ago, Celtos said:

My formula works, and 

 

Taken 1000 divided by 1.5 and subtracted by the player's level

 

1000 / 1,5 = 666

666 - 8 = 658

666 - 47 = 619

 

How would this formula be applied?

 

Oh ok, equations in parenthesis are done first so you need to remove the ones between "1.5 - Level".

Something like this should work: "var time = (float)(1000f / 1.5 - Level);"

 

Actually I am the one who came up with the parenthesis first lol. I thought you wanted to do it that way.
 

Link to comment
Share on other sites

  • 0
Quote

public virtual float GetMovementTime()

{

var time = 1000f / Level;

if (Blocking)

{

time += time * Options.BlockingSlow;

}

return Math.Min(1000f, time);

}

that way?

 

I want to calc 

 

1000f / 1.5 - Level;

 

= Player FInal Speed

 

How do I put this in the function?

Link to comment
Share on other sites

  • 0
1 hour ago, Celtos said:

that way?

 

I want to calc 

 

1000f / 1.5 - Level;

 

= Player FInal Speed

 

How do I put this in the function?

Replace "var time = 1000f / Level;"

By "var time = 1000f / (1.5 - Level);"

Link to comment
Share on other sites

  • 0
1 hour ago, Celtos said:

I tried to compile it here, and it seems to me that you need the float

 

https://prnt.sc/t1lz7c

 

EDIT

 

Any way to set a maximum speed for the player? If the player reaches level 1000 he will be super fast

 

Something like this should work:

var time = (float)(1000f / (1.5 - Level));
if (Blocking)
{
    time += time * (float) Options.BlockingSlow;
}

return Math.Min(1000f, Math.Max(time, 500)); // Replace 500 by the maximum movement time you want

 

Link to comment
Share on other sites

  • 0

i put

Quote

        public virtual float GetMovementTime()
        {
            var time = (float)(1000f / (1.5 - Level));
            if (Blocking)
            {
                time += time * (float)Options.BlockingSlow;
            }
            return Math.Min(1000f, Math.Max(time, 200));
        }

 

and a player level 8 and 47 have the same Speed :/

Link to comment
Share on other sites

  • 0
1 hour ago, Celtos said:

i put

 

and a player level 8 and 47 have the same Speed :/

The issue is your formula.

 

1000 / (1.5 - 8 ) = -153.846

1000 / (1.5 - 47) = -21.978

The maximum between -153 and 200 is 200.

The maximum between -21.978 and 200 is 200.

The minimum between 1000 and 200 is 200.

So the value is always 200.

 

You should verify your formula logic before implementing it.

You should also check out how debugging works in Visual Studio it would've helped in this case.

Link to comment
Share on other sites

  • 0

My formula works, and 

 

Taken 1000 divided by 1.5 and subtracted by the player's level

 

1000 / 1,5 = 666

666 - 8 = 658

666 - 47 = 619

 

How would this formula be applied?

 

Link to comment
Share on other sites

×
×
  • Create New...