| |
|
|
THE MODS: MAKING A HIGH-JUMPING PREDATOR
In this tutorial, I'll show you how to make a really simple mod to this game: we'll make the Predator jumping higher than before, as in the films. Concerning the mod itself, you'll need neither knowledge of the core, nor understanding of the exposed source file.
1) Let's prepare the ground
Sometimes, when you want to make a mod, you can have 2 situations:
- You know exactly what kind of mod you want to do, then you spend your time finding the portion of code that handles what you want to manipulate. Once you've got it, you can begin to experiment.
- The other situation is when you're mad enought to spend your time READING source codes and then *BINGO*, you see the magical portion of code that brings you an idea. After that, you experiment with the code itself, or add/modify it to suits your idea.
The second situation is the one that brings me the idea of doing such a mod: I didn't wanted to do anything, but when I arrived at line 715 of the file Pmove.c, here's how I reacted: "Damn! I never remarked that the Alien guy jumped in front of him !".
2) How to begin ?
In fact, I was so interrested by the gameplay itself, that I've never noticed such a thing !!! So I launched the game, selected the Alien and played with it. "Yes! It's the case !". So I returned to the code and studied it a bit. I looked above:
if(playerStatusPtr->Mvt_InputRequests.Flags.Rqst_Jump)
So in this case, the player "is requesting a jump", ie the Alien. Then I looked at:
if ((playerStatusPtr->ShapeState == PMph_Crouching) && (DotProduct(&viewDir,&dynPtr->GravityDirection)<-32768))
{
dynPtr->LinImpulse.vx += MUL_FIXED(viewDir.vx,jumpSpeed*3);
dynPtr->LinImpulse.vy += MUL_FIXED(viewDir.vy,jumpSpeed*3);
dynPtr->LinImpulse.vz += MUL_FIXED(viewDir.vz,jumpSpeed*3);
}
Here we're talking about crouching, view direction and jump speed. Let's resume: when we're the Alien, if we're crouching, then viewing at a direction and requesting a jump, then the jump itself is multiplied by 3 ? I relaunched the game, then realized that if you look above yourself as an Alien, then crouch an jump, you simply make an extra jump in this direction !
The idea was born: I know how to test the player's specie, how to know if he's crouching and I can modify the jump speed: I'll try to make a high-jumping Predator, like in AvP2 !!!
Note: AvP 2's got it in-game, so now AvP GE will too ;).
3) How to proceed ?
Here's the interresting part of the code:
/* alien can jump in the direction it's looking */
if (AvP.PlayerType == I_Alien) // This is for the alien
{
VECTORCH viewDir;
viewDir.vx = Global_VDB_Ptr->VDB_Mat.mat13;
viewDir.vy = Global_VDB_Ptr->VDB_Mat.mat23;
viewDir.vz = Global_VDB_Ptr->VDB_Mat.mat33;
if ((playerStatusPtr->ShapeState == PMph_Crouching) && (DotProduct(&viewDir,&dynPtr->GravityDirection)<-32768))
{
dynPtr->LinImpulse.vx += MUL_FIXED(viewDir.vx,jumpSpeed*3);
dynPtr->LinImpulse.vy += MUL_FIXED(viewDir.vy,jumpSpeed*3);
dynPtr->LinImpulse.vz += MUL_FIXED(viewDir.vz,jumpSpeed*3);
}
else
{
dynPtr->LinImpulse.vx -= MUL_FIXED(dynPtr->GravityDirection.vx,jumpSpeed);
dynPtr->LinImpulse.vy -= MUL_FIXED(dynPtr->GravityDirection.vy,jumpSpeed);
dynPtr->LinImpulse.vz -= MUL_FIXED(dynPtr->GravityDirection.vz,jumpSpeed);
dynPtr->LinVelocity.vz += jumpSpeed;
}
dynPtr->TimeNotInContactWithFloor = -1;
}
// NEW CODE FOR THE PREDATOR HERE
else // This was for the Predator & the marine, now only for the marine
{
dynPtr->LinImpulse.vx -= MUL_FIXED(dynPtr->GravityDirection.vx,jumpSpeed);
dynPtr->LinImpulse.vy -= MUL_FIXED(dynPtr->GravityDirection.vy,jumpSpeed);
dynPtr->LinImpulse.vz -= MUL_FIXED(dynPtr->GravityDirection.vz,jumpSpeed);
dynPtr->TimeNotInContactWithFloor = 0;
}
Now for the Predator code, you must add:
// If this is a crouching Predator (no need to look above like the Alien)
else if((AvP.PlayerType == I_Predator)&&(playerStatusPtr->ShapeState == PMph_Crouching))
{
// We'll multiply the jump by 2, which seems enough:
dynPtr->LinImpulse.vx -= MUL_FIXED(dynPtr->GravityDirection.vx,jumpSpeed*2);
dynPtr->LinImpulse.vy -= MUL_FIXED(dynPtr->GravityDirection.vy,jumpSpeed*2);
dynPtr->LinImpulse.vz -= MUL_FIXED(dynPtr->GravityDirection.vz,jumpSpeed*2);
dynPtr->TimeNotInContactWithFloor = 0;
}
Here's the typical example of a simple mod: only 7 lines to add a new fonctionnality to the Predator !!! Sure, it can be best than that (ex.: adding a new sound for the jump, ...), but it's easy enough to let you enjoy this 3D motor...
Now, repeat after me: "AvP GE is cool !!!"
|