Debriefing > Questions, Help, & How To's

Health Amount

(1/1)

markpeterjameslegg:
Hi people. I wanted to ask if there is any way to lower character health for offline play?

killermonkey:
Modify the python gamemode you are playing on so that in OnPlayerSpawn it calls:

player.SetMaxHealth( ### )

markpeterjameslegg:
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:-

killermonkey:
Not in OnLoadGameplay.... I said OnPlayerSpawn:


--- Code: ---
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()

--- End code ---

Do note that Python is extremly sensitive to whitespace indentation. GES uses tabs for it's whitespace.

markpeterjameslegg:

--- Quote from: killermonkey on November 22, 2012, 07:07:25 pm ---Not in OnLoadGameplay.... I said OnPlayerSpawn:

--- End quote ---

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

Navigation

[0] Message Index

Go to full version