Jump to content
The website was recently updated, and consequently some things are broken. We will be fixing minor theme bugs in the background over the course of the next few days.

Adding Force fall sp/mp


Serenity937

Recommended Posts

This is an easy one as you only need to alter bg_pmove.cpp (sp) or bg_pmove.c (mp)

 

 

first locate this piece of code in bg_pmove.cpp (sp) or bg_pmove.c (mp)

void PM_GrabWallForJump( int anim )
{//NOTE!!! assumes an appropriate anim is being passed in!!!
 under this add the following in bg_pmove.cpp (sp)



//[FORCE FALL]
//The FP cost of Force Fall
#define FM_FORCEFALL			10

//the velocity to which Force Fall activates and tries to slow you to.
#define FORCEFALLVELOCITY		-250

//Rate at which the player brakes
int ForceFallBrakeRate[NUM_FORCE_POWER_LEVELS] =
{
	0, //Can't brake with zero Force Jump skills
	60,
	80,
	100,
};

//time between Force Fall braking actions.
#define FORCEFALLDEBOUNCE		100

qboolean PM_CanForceFall()
{	
	return (!PM_InRoll(pm->ps) // not rolling
		&& !PM_InKnockDown(pm->ps) // not knocked down
		&& !PM_InDeathAnim() // not dead
		&& !PM_SaberInSpecialAttack( pm->ps->torsoAnim) // not doing special attack
		&& !PM_SaberInAttack(pm->ps->saberMove) // not attacking
		&& !(pm->ps->pm_flags&PMF_JUMP_HELD) // have to have released jump since last press
		&& pm->cmd.upmove > 10 // pressing the jump button
		&& pm->ps->velocity[2] < FORCEFALLVELOCITY // falling
		&& pm->ps->groundEntityNum == ENTITYNUM_NONE // in the air
		&& pm->ps->forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_1 //have force jump level 2 or above
		&& pm->ps->forcePower > FM_FORCEFALL // have atleast 5 force power points
		&& pm->waterlevel < 2 // above water level
		&& pm->ps->gravity > 0); // not in zero-g
}

qboolean PM_InForceFall()
{
	int ForceManaModifier = 0;
	int FFDebounce = pm->ps->forcePowerDebounce[FP_LEVITATION] - (pm->ps->forcePowerLevel[FP_LEVITATION] * 100);

	// can player force fall?
	if (PM_CanForceFall())	
	{
		// play special animation when player has the saber or melee
		if (pm->ps->weapon == WP_MELEE || pm->ps->weapon == WP_SABER)
		{
			PM_SetAnim( pm, SETANIM_LEGS, BOTH_FORCEINAIR1, SETANIM_FLAG_OVERRIDE, 150);
		}
		else
		{
			PM_SetAnim( pm, SETANIM_LEGS, BOTH_FORCEINAIRBACK1, SETANIM_FLAG_OVERRIDE, 150);
		}

		// reduce falling velocity to a safe speed at set intervals
		//Warning: Dirty Hack ahead!
		if (FFDebounce + FORCEFALLDEBOUNCE < pm->cmd.serverTime)
		{
			if (pm->ps->velocity[2] < FORCEFALLVELOCITY)
			{
				if( (FORCEFALLVELOCITY - pm->ps->velocity[2]) < ForceFallBrakeRate[pm->ps->forcePowerLevel[FP_LEVITATION]])
				{
					pm->ps->velocity[2] = FORCEFALLVELOCITY;
				}
				else
				{
					pm->ps->velocity[2] += ForceFallBrakeRate[pm->ps->forcePowerLevel[FP_LEVITATION]];
				}
			}
		}

		// is it time to reduce the players force power
		if (pm->ps->forcePowerDebounce[FP_LEVITATION] < pm->cmd.serverTime)
		{// FP_LEVITATION drains force mana only when player 
			// has an upward velocity, so I used FP_HEAL instead
			WP_ForcePowerDrain(pm->gent, FP_HEAL, FM_FORCEFALL + ForceManaModifier); 

			// removes force power at a rate of 0.1 secs * force jump level
			pm->ps->forcePowerDebounce[FP_LEVITATION] = pm->cmd.serverTime + (pm->ps->forcePowerLevel[FP_LEVITATION] * 100);
		}

		// player is force falling
		return qtrue;
	}

	// player is not force falling
	return qfalse;
}
//[/FORCE FALL] 
or this bg_pmove.c (mp)


//[FORCE FALL]
//The FP cost of Force Fall//serenity
#define FM_FORCEFALL			10

//the velocity to which Force Fall activates and tries to slow you to.
#define FORCEFALLVELOCITY		-250

//Rate at which the player brakes
int ForceFallBrakeRate[NUM_FORCE_POWER_LEVELS] =
{
	0, //Can't brake with zero Force Jump skills
	60,
	80,
	100,
};

//time between Force Fall braking actions.
#define FORCEFALLDEBOUNCE		100

qboolean PM_CanForceFall()
{	
	return (!BG_InRoll(pm->ps, pm->ps->legsAnim) // not rolling
		&& !PM_InKnockDown(pm->ps) // not knocked down
		&& !BG_InDeathAnim(pm->ps->legsAnim) // not dead
		&& !BG_SaberInSpecialAttack(pm->ps->torsoAnim) // not doing special attack
		&& !BG_SaberInAttack(pm->ps->saberMove) // not attacking
		&& BG_CanUseFPNow(pm->gametype, pm->ps, pm->cmd.serverTime, FP_HEAL) // can use force power
		&& !(pm->ps->pm_flags & PMF_JUMP_HELD) // have to have released jump since last press
		&& pm->cmd.upmove > 10 // pressing the jump button
		&& pm->ps->velocity[2] < FORCEFALLVELOCITY // falling
		&& pm->ps->groundEntityNum == ENTITYNUM_NONE // in the air
		&& pm->ps->fd.forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_1 //have force jump level 2 or above
		&& pm->ps->fd.forcePower > FM_FORCEFALL // have atleast 5 force power points
		&& pm->waterlevel < 2 // above water level
		&& pm->ps->gravity > 0); // not in zero-g
}

qboolean PM_InForceFall()
{
	int ForceManaModifier = 0;
	int FFDebounce = pm->ps->fd.forcePowerDebounce[FP_LEVITATION] - (pm->ps->fd.forcePowerLevel[FP_LEVITATION] * 100);

	// can player force fall?
	if (PM_CanForceFall())	
	{
		// play special animation when player has the saber or melee
		if (pm->ps->weapon == WP_MELEE || pm->ps->weapon == WP_SABER)
			PM_SetAnim(SETANIM_BOTH, BOTH_FORCEINAIR1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD, 150);

		// reduce falling velocity to a safe speed at set intervals
		//Warning: Dirty Hack ahead!
		if (FFDebounce + FORCEFALLDEBOUNCE < pm->cmd.serverTime)
		{
			if (pm->ps->velocity[2] < FORCEFALLVELOCITY)
			{
				if( (FORCEFALLVELOCITY - pm->ps->velocity[2]) < ForceFallBrakeRate[pm->ps->fd.forcePowerLevel[FP_LEVITATION]])
				{
					pm->ps->velocity[2] = FORCEFALLVELOCITY;
				}
				else
				{
					pm->ps->velocity[2] += ForceFallBrakeRate[pm->ps->fd.forcePowerLevel[FP_LEVITATION]];
				}
			}
		}

		// creates that cool Force Speed effect
		//pm->ps->powerups[PW_SPEED] = pm->cmd.serverTime + 100;

		// is it time to reduce the players force power
		if (pm->ps->fd.forcePowerDebounce[FP_LEVITATION] < pm->cmd.serverTime)
		{
			// reduced the use of force power for duel and power duel matches
			if (pm->gametype == GT_DUEL || pm->gametype == GT_POWERDUEL)
				ForceManaModifier = -4;

			// FP_LEVITATION drains force mana only when player 
			// has an upward velocity, so I used FP_HEAL instead
			BG_ForcePowerDrain(pm->ps, FP_HEAL, FM_FORCEFALL + ForceManaModifier);
			pm->ps->fd.forceJumpSound = 1;

			// removes force power at a rate of 0.1 secs * force jump level
			pm->ps->fd.forcePowerDebounce[FP_LEVITATION] = pm->cmd.serverTime + (pm->ps->fd.forcePowerLevel[FP_LEVITATION] * 100);
		}

		// player is force falling
		return qtrue;
	}

	// player is not force falling
	return qfalse;
}
 Now we have to add 2 more check s

 

Locate this piece of code in bg_pmove.cpp (sp) or bg_pmove.c (mp)

static qboolean PM_CheckJump( void ) 
{
and now add this

static qboolean PM_CheckJump( void ) 
{	

	//[FORCE FALL]
	if (PM_InForceFall())
		return qfalse;
	//[/FORCE FALL]
 and finally  Locate this piece of code in bg_pmove.cpp (sp) or bg_pmove.c (mp)

static void PM_CrashLand( void ) 
{
at the very bottom of this piece of code add this


	if(PM_InForceFall())
	{
		return;
	}
 Now compile the code and do some Massive jumps  :)
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...