Navigation

 No Falling Damage Feature Type: Coding Tutorials     Added: 21/01  
  Author: Corven 

Player doesn't take damage from falls.

Code to be Deleted or Commented out
Code to be Added or Changed

g_active.c

Search for ClientEvents in g_active.c, and look down the events until you see the lines:

case EV_FALL_MEDIUM:
case EV_FALL_FAR:
if ( ent->s.eType != ET_PLAYER ) {
break; // not in the player model
}
if ( g_dmflags.integer & DF_NO_FALLING ) {
break;
}
if (!g_fallingdamage.integer) {
break;
}
if ( event == EV_FALL_FAR ) {
damage = 10;
} else {
damage = 5;
}
VectorSet (dir, 0, 0, 1);
ent->pain_debounce_time = level.time + 200; // no normal pain sound
G_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING);
break;

This says, in either of those cases, do the falling damage, so all you have to add is take out the damage

code:

case EV_FALL_MEDIUM:
case EV_FALL_FAR:
if ( ent->s.eType != ET_PLAYER ) {
break; // not in the player model
}
if ( g_dmflags.integer & DF_NO_FALLING ) {
break;
}
if ( event == EV_FALL_FAR ) {
damage = 10;
} else {
damage = 5;
}
VectorSet (dir, 0, 0, 1);
ent->pain_debounce_time = level.time + 200; // no normal pain sound
G_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING);

break;

Alternatively, as always you could just put in a cvar, so you could toggle on/off wether you wanted to

use falling damage, like this example where I've used g_nofallingdamage:

case EV_FALL_MEDIUM:
case EV_FALL_FAR:
if ( ent->s.eType != ET_PLAYER ) {
break; // not in the player model
}
if ( g_dmflags.integer & DF_NO_FALLING ) {
break;
}
if (!g_nofallingdamage.integer) {
break;
}

if ( event == EV_FALL_FAR ) {
damage = 10;
} else {
damage = 5;
}
VectorSet (dir, 0, 0, 1);
ent->pain_debounce_time = level.time + 200; // no normal pain sound
G_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING);
break;

Comments »



  Page 1

  Comments ( 0 )


  Features Index

  Home

Copyright 2001 MGON International AB - Privacy statement