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

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
Post Reply
User avatar
determin1st
Posts: 57
Joined: Wed Oct 06, 2021 11:23 am
Contact:

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

Post by determin1st »

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

Code: Select all

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 all

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
...
i6g9o5r1
Posts: 5
Joined: Sat Dec 24, 2022 2:36 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10

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

Post by i6g9o5r1 »

tysm
Post Reply

Return to “Script Library”