Add debug command "damage me" to facilitate debugging issues related to

damage level.
Note: you can't kill a droid / structure with this command.
Used to debug retreat levels & autorepair issues & ...
master
vexed 2012-03-25 20:08:18 -04:00
parent 0c5aebfdc1
commit 2f1e063ec8
3 changed files with 46 additions and 1 deletions

View File

@ -78,6 +78,7 @@ static CHEAT_ENTRY cheatCodes[] =
{"power info", kf_PowerInfo},
{"reload me", kf_Reload}, // reload selected weapons immediately
{"desync me", kf_ForceDesync},
{"damage me", kf_DamageMe},
};
bool attemptCheatCode(const char* cheat_name)

View File

@ -125,7 +125,6 @@ static void kfsf_SetSelectedDroidsState( SECONDARY_ORDER sec, SECONDARY_STATE St
*/
bool runningMultiplayer(void)
{
// NOTE: may want to only allow this for DEBUG builds?? -- Buginator
if (!bMultiPlayer || !NetPlay.bComms)
return false;
@ -179,6 +178,50 @@ void kf_PowerInfo( void )
}
}
void kf_DamageMe(void)
{
#ifndef DEBUG
// Bail out if we're running a _true_ multiplayer game (to prevent MP cheating)
if (runningMultiplayer())
{
noMPCheatMsg();
return;
}
#endif
for(DROID *psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext)
{
if (psDroid->selected)
{
int val = psDroid->body - ((psDroid->originalBody / 100) *20);
if (val > 0)
{
psDroid->body = val;
addConsoleMessage(_("Ouch! Droid's health is down 20%!"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
}
else
{
psDroid->body = 0;
}
}
}
for(STRUCTURE *psStruct = apsStructLists[selectedPlayer]; psStruct; psStruct = psStruct->psNext)
{
if (psStruct->selected)
{
int val = psStruct->body - ((structureBody(psStruct) / 100) *20);
if (val > 0)
{
psStruct->body = val;
addConsoleMessage(_("Ouch! Structure's health is down 20%!"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
}
else
{
psStruct->body = 0;
}
}
}
}
void kf_TraceObject( void )
{
DROID *psCDroid, *psNDroid;

View File

@ -263,5 +263,6 @@ void kf_ForceDesync(void);
void kf_PowerInfo( void );
void kf_BuildNextPage( void );
void kf_BuildPrevPage( void );
extern void kf_DamageMe(void);
#endif // __INCLUDED_SRC_KEYBIND_H__