Quick ACS Question
Posted: Fri May 30, 2008 1:43 am
I want to make a script that thrusts the player to it's left. How would I acquire the current direction of the player, then tell ThrustThing or whatever how to do what I want? Thanks.
Code: Select all
int move_n = 0;
int move_e = 0;
int move_s = 0;
int move_w = 0;
// catch movement keypresses
script 401 (void) { move_n = 1; }
script 402 (void) { move_n = 0; }
script 403 (void) { move_e = 1; }
script 404 (void) { move_e = 0; }
script 405 (void) { move_s = 1; }
script 406 (void) { move_s = 0; }
script 407 (void) { move_w = 1; }
script 408 (void) { move_w = 0; }
int move_counter = 0;
function void movePlayer(void) // called by player loop script
{
int moving = 1;
int direction = 0.0;
if (move_n && move_e)
direction = 0.125;
else if (move_n && move_w)
direction = 0.375;
else if (move_n)
direction = 0.25;
else if (move_s && move_e)
direction = 0.875;
else if (move_s && move_w)
direction = 0.625;
else if (move_s)
direction = 0.75;
else if (move_e)
direction = 0.0;
else if (move_w)
direction = 0.5;
else
moving = 0;
if (moving && isPlayerAlive())
{
if (move_counter % 16 == 0)
SetActorState (999, "Run", true);
SetActorAngle(999, direction);
ThrustThing(direction>>8, 1, 0, 999);
}
else
move_counter = -1;
if (++move_counter >= 256)
move_counter = 0;
}
Code: Select all
script 802 (void)
{
Log(s:"DIVING TO THE RIGHT");
ThrustThing (GetActorAngle (100) >> 8 + 90, 20, 1, 0);
ThrustThingZ (0, 32, 0, 0);
}
Tried both, no luck.bagheadspidey wrote:Maybe GetActorAngle (100) >> 8 - 90 or GetActorAngle (100) >> 8 + 90 + 180?
No, in neither "- 90", "+ -90" or "-(GetActorAngle (100) >> 8 + 90)" flavors.bagheadspidey wrote:negative thrust doesn't work either?
Code: Select all
function int fixangle(int amount, int pnum) //amount is how much you're subtracting. Pnum is the playernumber
{ //amount can be positive or negative, and you'll still get the proper results.
int check = getactorangle(100 + pnum) >> 8;
if ((check - amount) < 0)
{
return 255 + (check - amount); // add's the negative value (or leftover rotation) to the top of the byte angle
}
if ((check - amount) > 255)
{
return (check - amount) - 255; // resets to 0 and then adds the spill over if it's above 255
}
else
{
return check - amount;
}
return getactorangle(100+ pnum) >> 8; //if all else fails, it returns the actors current angle
}
Code: Select all
thrustthing(fixangle( 64, playernumber()), 20, 1, 0);
by negative thrust i mean setting the "force" param to a negative value. I know it works for ThrustThingZ...Kinsie wrote:No, in neither "- 90", "+ -90" or "-(GetActorAngle (100) >> 8 + 90)" flavors.bagheadspidey wrote:negative thrust doesn't work either?
Code: Select all
script 801 (void)
{
Log(s:"DIVING TO THE LEFT");
thrustthing(fixangle(128, 100), 20, 1, 0);
ThrustThingZ (0, 32, 0, 0);
}
script 802 (void)
{
Log(s:"DIVING TO THE RIGHT");
thrustthing(fixangle(0, 100), 20, 1, 0);
ThrustThingZ (0, 32, 0, 0);
}