I've been trying to create player-controlled vehicles in the form of complex polyobjects. I've successfully managed to control the angle and linear movement of the polyobject, but when I went to add inertia, I messed up badly, to the point where the polyobject would behave entirely erratically. I tried many things to try and correct the behavior, but in doing so I made it even more broken and messy. I have sent hours pouring over the ZDoom Wiki, but nothing in there seems to directly address my use case.
Working ACS (pardon the mess):
Code: Select all
#include "zcommon.acs"
int rc_car_angle = 0;
int rc_car_speed = 0;
int rc_car_max_speed = 16;
int rc_car_momentum = 0;
int rc_car_rotate_speed = 4;
bool rc_car_active = 0;
// Proper starting and Stopping.
Script "RCStart" (void)
{
SetPlayerProperty (0, 1, PROP_TOTALLYFROZEN);
ChangeCamera (1, 0, 0);
rc_car_active = 1;
ACS_NamedExecute ("RCLogic",0);
}
Script "RCStop" (void)
{
SetPlayerProperty (0, 0, PROP_TOTALLYFROZEN);
ChangeCamera (0, 0, 0);
}
// Main logic loop.
Script "RCLogic" (void)
{
while ( rc_car_active == 1 )
{
int buttons = GetPlayerInput(-1, INPUT_BUTTONS);
Delay (1);
if (buttons & BT_MOVELEFT)
{
ACS_NamedExecute ("RCTurnLeft",0);
}
if (buttons & BT_MOVERIGHT)
{
ACS_NamedExecute ("RCTurnRight",0);
}
if (buttons & BT_FORWARD)
{
ACS_NamedExecute ("RCMoveForward",0);
}
if (buttons & BT_BACK)
{
ACS_NamedExecute ("RCMoveBackward",0);
}
if (buttons & BT_USE)
{
rc_car_active = 0;
}
}
ACS_NamedExecute ("RCStop",0);
}
// RC functions.
Script "RCTurnLeft" (void)
{
Polyobj_OR_RotateLeft (0, 32, 0+rc_car_rotate_speed);
rc_car_angle+=rc_car_rotate_speed;
}
Script "RCTurnRight" (void)
{
Polyobj_OR_RotateRight (0, 32, 0+rc_car_rotate_speed);
rc_car_angle-=rc_car_rotate_speed;
}
Script "RCMoveForward" (void)
{
Polyobj_OR_Move (0, 16, rc_car_angle, rc_car_max_speed);
}
Script "RCMoveBackward" (void)
{
Polyobj_OR_Move (0, 16, rc_car_angle+128, rc_car_max_speed);
}
Code: Select all
#include "zcommon.acs"
int rc_car_angle = 0;
int rc_car_speed = 0;
int rc_car_max_speed = 16;
int rc_car_is_moving = 0; // 0 (Not moving.), 1 (Moving forward.), -1 (Moving backward.)
int rc_car_momentum = 0;
int rc_car_rotate_speed = 0;
int rc_car_rotate_dividend = 4; //rotation will be divided by this variable's value.
bool rc_car_active = 0;
// Proper starting and Stopping.
Script "RCStart" (void)
{
SetPlayerProperty (0, 1, PROP_TOTALLYFROZEN);
ChangeCamera (1, 0, 0);
rc_car_active = 1;
ACS_NamedExecute ("RCLogic",0);
}
Script "RCStop" (void)
{
SetPlayerProperty (0, 0, PROP_TOTALLYFROZEN);
ChangeCamera (0, 0, 0);
}
// Main logic loop.
Script "RCLogic" (void)
{
while ( rc_car_active == 1 )
{
int buttons = GetPlayerInput(-1, INPUT_BUTTONS);
Delay (1);
if (buttons & BT_MOVELEFT)
{
ACS_NamedExecute ("RCTurnLeft",0);
}
if (buttons & BT_MOVERIGHT)
{
ACS_NamedExecute ("RCTurnRight",0);
}
if (buttons & BT_FORWARD)
{
ACS_NamedExecute ("RCMoveForward",0);
}
if (buttons & BT_BACK)
{
ACS_NamedExecute ("RCMoveBackward",0);
}
if (buttons & BT_USE)
{
rc_car_active = 0;
}
if ( rc_car_is_moving == 0 )
{
if ( rc_car_speed >= 0 )
{
rc_car_rotate_speed = rc_car_speed / rc_car_rotate_dividend;
rc_car_speed-=1;
}
}
rc_car_is_moving = 0;
}
ACS_NamedExecute ("RCStop",0);
}
// RC functions.
Script "RCTurnLeft" (void)
{
Polyobj_OR_RotateLeft (0, rc_car_rotate_speed, rc_car_angle);
rc_car_angle+=rc_car_rotate_speed;
}
Script "RCTurnRight" (void)
{
Polyobj_OR_RotateRight (0, rc_car_rotate_speed, rc_car_angle);
rc_car_angle-=rc_car_rotate_speed;
}
Script "RCMoveForward" (void)
{
rc_car_is_moving = 1;
if ( rc_car_speed <= rc_car_max_speed )
{
rc_car_speed+=1;
}
Polyobj_OR_Move (0, rc_car_speed, rc_car_angle, rc_car_speed);
}
Script "RCMoveBackward" (void)
{
rc_car_is_moving = -1;
if ( rc_car_speed <= rc_car_max_speed )
{
rc_car_speed+=1;
}
Polyobj_OR_Move (0, rc_car_speed, rc_car_angle+128, rc_car_speed);
}
https://drive.google.com/open?id=1reulc ... 4XudfoNcl7
You'll need to run
Code: Select all
pukename RCStart