GoldenEye: Source Forums

Debriefing => Questions, Help, & How To's => Topic started by: markpeterjameslegg on November 22, 2012, 04:33:44 pm

Title: Health Amount
Post by: markpeterjameslegg on November 22, 2012, 04:33:44 pm
Hi people. I wanted to ask if there is any way to lower character health for offline play?
Title: Re: Health Amount
Post by: killermonkey on November 22, 2012, 05:09:29 pm
Modify the python gamemode you are playing on so that in OnPlayerSpawn it calls:

player.SetMaxHealth( ### )
Title: Re: Health Amount
Post by: markpeterjameslegg on November 22, 2012, 06:16:57 pm
Hmmm... Not sure where to place the code, had a go but it errors in the console. Sorry KM, I used to program back in the days of B.A.S.I.C, don't know much about C++ or Python, although there are similarities.

I put images of the Python code and the error:-

Title: Re: Health Amount
Post by: killermonkey on November 22, 2012, 07:07:25 pm
Not in OnLoadGameplay.... I said OnPlayerSpawn:

Code: [Select]
from GamePlay import GEScenario
import GEEntity, GEPlayer, GEUtil, GEWeapon, GEMPGameRules, GEGlobal

USING_API = GEGlobal.API_VERSION_1_0_0

class DeathMatch( GEScenario ):
def GetPrintName( self ):
return "#GES_GP_DEATHMATCH_NAME"

def GetScenarioHelp( self, help_obj ):
help_obj.SetDescription( "#GES_GP_DEATHMATCH_HELP" )

def GetGameDescription( self ):
if GEMPGameRules.IsTeamplay():
return "Team Deathmatch"
else:
return "Deathmatch"

def GetTeamPlay( self ):
return GEGlobal.TEAMPLAY_TOGGLE

def OnLoadGamePlay( self ):
GEMPGameRules.SetAllowTeamSpawns( False )
self.CreateCVar( "dm_fraglimit", "0", "Enable frag limit for DeathMatch." )

# CUSTOM: Lowers the player's max health
def OnPlayerSpawn( self, player ):
  # Default max health is 160
player.SetMaxHealth( 120 )
# END CUSTOM

def OnThink( self ):
fragLimit = int( GEUtil.GetCVarValue( "dm_fraglimit" ) )
if fragLimit != 0:
if GEMPGameRules.IsTeamplay():

teamJ = GEMPGameRules.GetTeam( GEGlobal.TEAM_JANUS );
teamM = GEMPGameRules.GetTeam( GEGlobal.TEAM_MI6 );

jScore = teamJ.GetRoundScore() + teamJ.GetMatchScore()
mScore = teamM.GetRoundScore() + teamM.GetMatchScore()

if jScore >= fragLimit or mScore >= fragLimit:
GEMPGameRules.EndMatch()
else:
for i in range( 32 ):

if not GEPlayer.IsValidPlayerIndex( i ):
continue

player = GEPlayer.GetMPPlayer( i )

if  ( player.GetMatchScore() + player.GetScore() ) >= fragLimit:
GEMPGameRules.EndMatch()

Do note that Python is extremly sensitive to whitespace indentation. GES uses tabs for it's whitespace.
Title: Re: Health Amount
Post by: markpeterjameslegg on November 22, 2012, 07:50:52 pm
Not in OnLoadGameplay.... I said OnPlayerSpawn:

Sorry about that. It's sorted, thanks KM.