Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
I'm working on a jetpack item/ability inspired by Cave Story's Booster 2.0, for which I decided to use ACS (I want the player to be able to access this at any time via a keybind, and inventory items are not complex enough). I currently only have the vertical boost, which works remarkably well, but my attempts to limit the amount of time the player can spend in the air are not working in the slightest. Here's the code for both the KEYCONF and ACS (I'm using LOADACS to load the BOOSTER library at startup):
ACS:
Spoiler:
#library "Booster"
#include "zcommon.acs"
int TimeLeft; //Boost time left, in tics
int FloatHeight; //Player's height off of floor
Script 800 (void) //Vertical Thrust
{
FloatHeight = (GetActorZ(0) - GetActorFloorZ(0)); //This ensures the Booster won't activate
//unless the player is off the ground
while (TimeLeft > 0 && FloatHeight > 0)
{
ThrustThingZ (0, 10, 0, 1);
TimeLeft--;
print(s:TimeLeft);
delay(1);
}
}
Script 801 (void)
{
ACS_Terminate (800, 0);
}
Script 802 ENTER //Resets timer when player touches the ground
{
FloatHeight = (GetActorZ(0) - GetActorFloorZ(0));
while (FloatHeight == 0 && TimeLeft != 35*5)
{
TimeLeft = 35*5;
delay(1);
}
}
KEYCONF:
Spoiler:
addkeysection "Booster 2.0" Booster2
addmenukey "Jump/Boost" +booster
alias +booster "puke 800"
alias -booster "puke 801"
Last edited by Loki on Mon Jul 02, 2007 5:17 pm, edited 1 time in total.
I used a method of counting down time by simply subtracting an actor who works as the 'timer', once the actor runs out in the player's inventory, said event starts/stops.
Well, I have a new problem. The upwards motion works great, but sideways not so much: It appears ThrustThing is not configured for relative motion, and always sends things to an absolute angle (i.e. press the "left" button to go west). My guess is that I'll need to create a function to compute relative thrust angles from my absolute angle. Hmmm. I hate writing functions. Any suggestions? Oh, here's the code:
ACS:
Spoiler:
#library "Booster"
#include "zcommon.acs"
int TimeLeft; //Boost time left, in tics
int FloatHeight; //Player's height off of floor
Script 802 ENTER //Resets timer when player touches the ground
{
FloatHeight = (GetActorZ(0) - GetActorFloorZ(0));
TimeLeft = CheckInventory ("TimeLeft");
What I suggest is for going left and right, is possibly bitshifting the player's current X/Y axis or his angle with >>8 or such. Not really sure on this one.
Well, I have an idea that might work, assuming that byte angles are in modulo 255 (i.e. 256=0, 257=1, etc.): I could add the desired direction to the byte angle value for the player's GetActorAngle(). Here goes nothing.