I've already bitched about it a bit on the ZDoom forums but we'll see if I have any more luck here! I took Torm's Pogostick mod and am trying to make it fit my own Mega Man-inspired purposes. For the moment this involves, primarily, dashing and wall-sliding & jumping ala Mega Man X. I've gone through several iterations of code for both but there are still a lot of kinks and it's all very clunky. Not at all smooth like it is in the game I'm trying to imitate.
Of course sprites will have to all be fancied up and adjusted later (which speaking of I have no fuckin clue what I'm gonna do there exactly, but anyway), but for the moment I'm really just concerned about the mechanics.
Here's the code for both the dash and wall-slide/jump in their current states.
[spoiler]
Code: Select all
Script "Dash" (void) // currently only works on ground!
{
int buttons;
int oldbuttons;
int maxairdashes;//will figure out how to use this later
bool dashedonce = false;
while (TRUE)
{
buttons = GetPlayerInput(-1, INPUT_BUTTONS);
oldbuttons = GetPlayerInput(-1, INPUT_OLDBUTTONS);
int startpos;
int newpos;
int startvelx;
int startvelz;
if (onground(0))
{
if (buttons & BT_USER1 && oldbuttons & BT_USER1) //holding down dash
{
newpos = GetActorX(0);
if ( ( (abs(newpos - startpos)/65536) < 256) && (dashedonce == false) )
{
if(forward[PlayerNumber()] == On)
{
SetActorVelocity(0,(40*65536),0,0,0,0);
}
if(forward[PlayerNumber()] == Off)
{
SetActorVelocity(0,-(40*65536),0,0,0,0);
}
}
else if((abs(newpos - startpos)/65536) >= 256)
{
SetActorVelocity(0,0,0,0,0,0);
startpos = newpos;
dashedonce = true;
}
}
if ( (buttons & BT_USER1) && !(oldbuttons & BT_USER1) ) //just pressed dash
{
startpos = GetActorX(0);
startvelx = GetActorVelX(0);
startvelz = GetActorVelZ(0);
dashedonce = true;
if(forward[PlayerNumber()] == On)
{
SetActorVelocity(0,(50*65536),0,0,0,0);
}
if(forward[PlayerNumber()] == Off)
{
SetActorVelocity(0,-(50*65536),0,0,0,0);
}
}
if ( (oldbuttons & BT_USER1) && !(buttons & BT_USER1) ) //just released dash
{
SetActorVelocity(0,0,0,0,0,0);
startpos = newpos;
dashedonce = false;
}
delay(1);
}
delay(1);
}
}
///////////////////////////////
////////// WALL CLING /////////
///////////////////////////////
Script "WallCheck" (void) //making this only work past the apex of the jump should fix the problem maybe? i dunno
{
int buttons;
int z = GetActorVelZ(0);
// int oldgrav = GetActorProperty(0, APROP_GRAVITY);
while (TRUE)
{
buttons = GetPlayerInput(-1, INPUT_BUTTONS);
// SetActorProperty(0, APROP_GRAVITY, 0);
if (buttons & BT_FORWARD)
{
GiveInventory("MegaCheckN", 1);
Delay(1);
if (CheckInventory("CanWallCling") /*&& FixedMul(z, z) <= 0*/) //also add condition for if off the ground
{
if (buttons & BT_USER2)
{
SetActorVelocity(0,0,0,0,0,0);
}
else
{
SetActorVelocity(0, 0,0,-1.6, 0, 0);
}
}
}
// SetActorProperty(0, APROP_GRAVITY, oldgrav);
Delay(LOOPTIC);
TakeInventory("CanWallCling", 0x7FFFFFFF);
}
//Delay(LOOPTIC);
}
Script "WallJump" (void) // credits to Agent ME and Isle for all of this code basically
{
int maxDblJumps = 1;
int dblJumpThrust = 80;
int lastZ = GetActorZ(0);
int olderZ;
int counter = 0;
int x, y, ang;
while( true )
{
olderZ = lastZ;
lastZ = GetActorZ(0);
delay(1);
if( (GetPlayerInput(-1, MODINPUT_BUTTONS) & BT_JUMP) && !(GetPlayerInput(-1, INPUT_OLDBUTTONS) & BT_JUMP) )
{
if( (GetActorZ(0) > lastZ) && (lastZ <= olderZ) )
{
counter = 0;
} else {
if( (counter < maxDblJumps) && ( CheckInventory("CanWallCling") ) )
{
ThrustThing(-(GetActorAngle(0)),15, 0, 0);
ThrustThingZ(0, dblJumpThrust, 0, 0);
Delay(1);
TakeInventory("CanWallCling", 0x7FFFFFFF);
/*if(forward[PlayerNumber()] == Off)
{
ACS_NamedExecute("FaceRight", 0,0,0,0);
ThrustThing(GetActorAngle(0),60, 1, 0);
ThrustThingZ(0, dblJumpThrust, 0, 0);
}
if(forward[PlayerNumber()] == On)
{
ACS_NamedExecute("FaceLeft", 0,0,0,0);
ThrustThing(GetActorAngle(0),60, 1, 0);
ThrustThingZ(0, dblJumpThrust, 0, 0);
}
/*thing_stop(0);
x = GetPlayerInput(-1, INPUT_FORWARDMOVE);
y = -GetPlayerInput(-1, INPUT_SIDEMOVE);
ang = getactorangle(0)+vectorangle(x, y);
if(x || y) ThrustThing (ang>>8, 16, 1, 0);
ThrustThingZ(0, dblJumpThrust, 0, 0);
//counter++;*/
}
}
} else if( (olderZ == lastZ) && (lastZ == GetActorZ(0)) )
{ counter = 0; }
}
}
The problem with the wall stuff is that it's completely broken, nonresponsive, and also broken. Pretty stuck there. The problem with the dash is that it's also randomly sometimes not responsive... a la MMX, when you hold down the dash key, you dash a certain distance. The only condition in which you stop dashing is if you either release the key, or your complete the full distance. It basically functions that way now, but if you start from neutral and rapidly tap the dash key, I would expect that you keep starting and stopping based on how long the key is pressed, when it's released, etc. You should really be stuttering. Push it even semi-rapidly though, and things get all fucked up and it stops being responsive.
I think my methods for doing both of these functions are not as efficient and clearly not as seamless as they need to be. If anyone feels like taking a look, here is the resource wad (major thanks to TZK for the movement script and the overhaul of Pogostick's general mechanics), and here is a small testmap.
You will need to bind the specified move left & right keys in the new keysection, as well as dash. Everything else you can keep bound the way it was, really.