How do you change the move speed of characters?[SOLVED :)]

IronsoulIronsoul Join Date: 2011-03-12 Member: 86048Members
edited July 2013 in Modding
Hey guys, I'm pretty new to modding, I'm actually doing a little project where I try to implement one small mechanic every week.

Anyway, I don't understand very well how NS2 works code wise and I cannot for the life of me figure out how to change the base speed of a character. It looks like there's some crazy calculation going on, rather than a set number.

Any help on how to do so would be greatly appreciated, I'm trying to increase the marine walk speed for now in case anyone is interested.

Comments

  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, NS2 Playtester, Squad Five Blue
    Hi Ironsoul.

    The max speed of a class (eg marine) is determined by its two sets of acceleration and its friction, one for ground movement, and one for air movement.

    If you look in Marine.lua, you can find these two attributes:

    Marine.kAcceleration = 100
    Marine.kGroundFrictionForce = 16

    Divide kAcceleration by kGroundFrictionForce and you get the maximum ground speed of Marine: 100/16 = 6.25.

    "But I never reach that walking speed as a marine!" I hear you say.

    That is because marine weapon and equipment have "weight", and limit the marine's maximum speed. Have a look in the function Marine:GetMaxSpeed:
    maxSpeed is multiplied by inventorySpeedScalar, which reduces marine's maximum speed cap.

    Marine's sprint maximum speed is found by dividing Marine.kSprintAcceleration (120) by Marine.kGroundFrictionForce. Similar to the default ground movement speed, sprint max speed is also reduced by equipment weight.
  • IronsoulIronsoul Join Date: 2011-03-12 Member: 86048Members
    edited July 2013
    Awesome, I tried hooking into it with this code:
    Script.Load("lua/Marine.lua")
    Marine.kAcceleration = 1000
    

    I loaded that little script in a shared script loader (as mentioned in Rio's tutorial). It gave me a bunch of errors and a memory leak, so that's fun. I'm guessing I am only supposed to load the Marine.Lua in predict, client and server.lua and not loading.lua.

    Anyway, I found the maxwalkspeed cap of 5 is also used (obviously). So I increased that to something ridiculous like 500, this was the result:


    The modification is currently in a Marine.lua copy which is overwriting the official ns2 one. Hopefully my hooking in was simply because i tried to run it in too many places at once.

    update: forgot to explicitly say it: thanks for the help!
Sign In or Register to comment.