[ACS] actorSetSpeed(x, tid) script, aka A_SetSpeed

Post your example zscripts/ACS scripts/etc here.

[ACS] actorSetSpeed(x, tid) script, aka A_SetSpeed

Postby determin1st » Thu Dec 02, 2021 8:48 am

A_SetSpeed() doesn't work in zandronum, so, here is the script that will set it:

Code: Select allExpand view
script "actorSetSpeed" (int speed, int tid) CLIENTSIDE
{
   // desired value is multiplied by 100,
   // convert it to fixed number
   speed = 0.01 * speed;
   // get currents
   int pitch = GetActorPitch(tid);// [-0.25, 0.25]
   int angle = GetActorAngle(tid);// [0.0, 1.0]
   // determine vectors
   int vx,vy,vz;
   vx = FixedMul(speed, Cos(pitch));
   vz = FixedMul(-speed, Sin(pitch));
   vy = FixedMul(vx, Sin(angle));
   vx = FixedMul(vx, Cos(angle));
   //Log(s:"pitch=",f:pitch,s:" angle=",f:angle);
   //Log(s:"speed=",f:speed,s:" vx=",f:vx,s:" vy=",f:vy,s:" vz=",f:vz);
   SetActorVelocity(tid, vx, vy, vz, false, false);
}


usage:

Code: Select allExpand view
TNT1 A 0 ACS_NamedExecuteAlways("actorSetSpeed", 0, 1) // speed=0.01
TNT1 A 0 ACS_NamedExecuteAlways("actorSetSpeed", 0, 100) // speed=1.0
TNT1 A 0 ACS_NamedExecuteAlways("actorSetSpeed", 0, 1000) // speed=10.0
...
User avatar
determin1st
 
Joined: 06 Oct 2021

Return to Script Library

Who is online

Users browsing this forum: No registered users and 1 guest