This sample code tracks how much damage you've taken during the map, overrides the normal exit with a -nointermission mapchange to Intermap where Important stats are displayed. The result of this DamageTaken is important for a calculation.
Problem: When I click the exit switch, I can instantly see the number jumping from like 15 to 2402011050124102 and my score is ruined because of this. Gfy included.
https://gfycat.com/PoliticalUnfinishedBilby
To see the DamageTaken attribute, type "ERS 1" in console
Code: Select all
#library "RS"
#Import "NoExit.acs"
#include "zcommon.acs"
#define D_DMGCAP 99999 // The total damaage is capped to this number
// -----------------------------------------------------------------------------
global int 11:DamageTaken;
// -----------------------------------------------------------------------------
Script "Damage Taken" Enter
{
IF(!StrIcmp(CurrentMap,"INTERMAP") == 0 ) DamageTaken = 0; //Values get reset to 0 in every level except on Intermap
int OldHealth = GetActorProperty(0, APROP_Health);
While(TRUE)
{
int SustainedDamage = OldHealth - GetActorProperty(0, APROP_Health);
//DamageTaken[PlayerNumber()]
If(SustainedDamage > 0)
{
DamageTaken += SustainedDamage;
If(DamageTaken > D_DMGCAP) DamageTaken = D_DMGCAP;
}
SetHudSize(1920,1080,0);
If(GetCvar("ERS")){
HudMessage(s:"Damage Received: ",d:DamageTaken; // Display Damage Received [Debug]
HUDMSG_PLAIN , 115, CR_GREEN,
380.0, 40.0, 0); }
OldHealth = GetActorProperty(0, APROP_Health);
Delay(1);
}
}
Code: Select all
for (int i = 0; i < level.Lines.Size(); i++) // iterate through all lines in the current map
{
Line l = level.Lines[i]; // get current line
int spec = l.special; // get the special assigned to the current line
if ( spec == 243 || spec == 244 ) // if the line is an Exit_Normal line (243), overwrite it with an ACS script (7777)
{
l.special = 226; // special 226 = ACS_ExecuteAlways
// set the args
l.args[0] = 7777;
l.args[1] = 0;
l.args[2] = 0;
l.args[3] = 0;
l.args[4] = 0;
l.flags |= Line.ML_REPEAT_SPECIAL; // be sure to make the line repeatable
}
}
Code: Select all
Script 7777 (void)
{
CurrentSkill = GameSkill();
NextLevel = strParam(n:PRINTNAME_NEXTLEVEL);
str NextSecret = strParam(n:PRINTNAME_NEXTSECRET);
ChangeLevel("INTERMAP",0,CHANGELEVEL_NOINTERMISSION,CurrentSkill);
}