Changing runspeed via script

aL BeasTie

Well-known member
I made a basic didhitscript for a powerup item that will add +1 to the players speed. Default speed is 5 default run speed is 10

Code:
void main()
{
  void self = getlocalvar("self");
  void target = getlocalvar("damagetaker");
  int spd = getentityproperty(target, "speed");
  int rspd = getentityproperty(target, "running", 0);
  
  changeentityproperty(target, "speed", spd+0.1);
  changeentityproperty(target, "running", +2);
}

I think I have the walking sorted but I'm not sure exactly how to control running effectively. It is working but it adds too much speed. I recall using speed from script is more like speedf so we can use decimals, not sure if running does thou. I also tried using run.speed.x which still worked fine but I wasn't sure how to get run.speed.x value using script. Also I started adding so it has a maxspeed cap so you can't raise it too high but again I had problems storing the 'running' values.
 
Yeah it seemed to be still increasing just the same. It might be working, it's hard to test the effect with lower settings but I can easily see the change in game with higher ones. Just trying to get the sweet spot now.
 
@Bloodbane

I added a settextobject to the players onspawnscript to display the values of speed and running in game

Here's what it shows
model settings speed 6 = in game value 0.6000000
model settings running 10 = 3.000000

Then I tried to display them again after pickup but just get 'VT_Empty ' and I've totally forgotten how to initialize the values to prevent that.

Edit: What I really don't understand is adding +2 to running is definitely working, in game the speed up is obvious. But +1 seems to has no effect at all and picking up multiple items and gaining another +1 doesn't seem to affect it either.
 
Last edited:
Back
Top Bottom