ACS script :
Code: Select all
PWAD ° #library "sharlive"
#include "zcommon.acs"
int maxLives=0;
int maxPlayers=0;
int currentLives[4]={0, 0, 0, 0};
world int 40: currentLivesSurvival;
#DEFINE SHARELIVES_OPEN 700
#DEFINE SHARELIVES_DEATH 701
#DEFINE SHARELIVES_PRINT 702
#DEFINE SHARELIVES_PRINT_RESPAWN 703
#DEFINE SHARELIVES_PRINT_SPECTATE 704
#DEFINE MODE_NULL 0
#DEFINE MODE_TLMS 1
#DEFINE MODE_SURV 2
script SHARELIVES_OPEN OPEN
{
Delay(1);
if(GetLivesMode()==MODE_NULL)
{
PrintBold(s:"TLMS or Survival must be enabled to use pooled lives.");
terminate;
}
maxLives = GetCVar("sv_maxlives");
if(maxLives<2)
{
PrintBold(s:"Set sv_maxlives larger than 1 to use pooled lives.");
terminate;
}
if(GetLivesMode()==MODE_SURV&&GetGameModeState()!=2)
{
currentLivesSurvival = maxLives;
}
currentLives[0] = maxLives;
currentLives[1] = maxLives;
currentLives[2] = maxLives;
currentLives[3] = maxLives;
int roundReset = 0;
while(GetLivesMode()==MODE_SURV)
{
if(GetGameModeState()!=2)
{
if(roundReset==0)
{
currentLivesSurvival = maxLives;
}
}
else
{
roundReset = 0;
}
Delay(1);
}
}
script SHARELIVES_DEATH DEATH
{
int mode = GetLivesMode();
maxPlayers = GetCVar("sv_maxclients");
if(mode==MODE_NULL)terminate;
int pln = PlayerNumber();
int team = GetPlayerInfo(pln, PLAYERINFO_TEAM);
if(mode==MODE_TLMS)
{
if(currentLives[team]>0)currentLives[team] -= 1;
SetTeamLivesLeft(team, currentLives[team]);
}
if(mode==MODE_SURV)
{
if(GetGameModeState()==2)
{
if(currentLivesSurvival>0)currentLivesSurvival -= 1;
SetAllLivesLeft(currentLivesSurvival);
}
}
}
function int GetLivesMode(void)
{
if(GetCVar("Survival")>0)Return MODE_SURV;
if(GetCVar("TeamLMS")>0)Return MODE_TLMS;
Return MODE_NULL;
}
function void SetTeamLivesLeft(int team, int number)
{
for(int i=0; i<maxPlayers; i++)
{
if(GetPlayerInfo(i, PLAYERINFO_TEAM)==team)
{
SetPlayerLivesLeft(i, number);
//PrintBold(s:"Setting player ", i:i, s:"'s lives to ", i:number);
}
}
}
function void SetAllLivesLeft(int number)
{
for(int i=0; i<maxPlayers; i++) SetPlayerLivesLeft(i, number);
}
script SHARELIVES_PRINT ENTER
{
if(GetLivesMode()==MODE_NULL)terminate;
Delay(5);
int pln = PlayerNumber();
int team = GetPlayerInfo(pln, PLAYERINFO_TEAM);
int diff = 0;
int mode = GetLivesMode();
Thing_ChangeTID(0, pln+1000);
int printLives;
bool stopUpdates = false;
str numcolor = "\c-";
SetHudSize(600,380,0);
if(printLives <= 0)numcolor = "\cg";
else numcolor = "\c-";
if(mode == MODE_TLMS)
{
printLives = currentLives[team]-1;
if(printLives<0)printLives=0;
HudMessage(s:"\caRespawns: ", s:numcolor, i:printlives, s:" / ", i:maxLives-1; HUDMSG_PLAIN, 45, CR_GREEN, 90.0, 315.0, 0);
while(GetActorProperty(0, APROP_HEALTH)>0)
{
if(printLives!=currentLives[team]-1 && !stopUpdates)
{
diff = printLives-(currentLives[team]-1);
printLives = currentLives[team]-1;
if(printLives<0){printLives=0; stopUpdates=true;}
if(printLives <= 0)numcolor = "\cg";
else numcolor = "\c-";
HudMessage(s:"\caRespawns: ", s:numcolor, i:printlives, s:" / ", i:maxLives-1; HUDMSG_PLAIN, 45, CR_GREEN, 90.0, 315.0, 0);
if(diff>0)HudMessage(s:"\cg-", i:diff; HUDMSG_FADEOUT, 46, CR_GREEN, 150.0, 315.0, 1.0, 1.0);
}
Delay(1);
}
HudMessage(s:""; HUDMSG_PLAIN, 45, CR_GREEN, 90.0, 315.0, 0);
}
else if(mode == MODE_SURV)
{
printLives = currentLivesSurvival-1;
if(printLives<0)printLives=0;
HudMessage(s:"\caRespawns: ", s:numcolor, i:printlives, s:" / ", i:maxLives-1; HUDMSG_PLAIN, 45, CR_GREEN, 90.0, 315.0, 0);
while(GetActorProperty(0, APROP_HEALTH)>0)
{
if(printLives!=currentLivesSurvival-1 && !stopUpdates)
{
diff = printLives-(currentLivesSurvival-1);
printLives = currentLivesSurvival-1;
if(printLives<0){printLives=0; stopUpdates=true;}
if(printLives <= 0)numcolor = "\cg";
else numcolor = "\c-";
HudMessage(s:"\caRespawns: ", s:numcolor, i:printlives, s:" / ", i:maxLives-1; HUDMSG_PLAIN, 45, CR_GREEN, 90.0, 315.0, 0);
if(diff>0)HudMessage(s:"\cg-", i:diff; HUDMSG_FADEOUT, 46, CR_GREEN, 150.0, 315.0, 1.0, 1.0);
}
Delay(1);
}
HudMessage(s:""; HUDMSG_PLAIN, 45, CR_GREEN, 90.0, 315.0, 0);
}
}
script SHARELIVES_PRINT_RESPAWN RESPAWN
{
ACS_ExecuteAlways(SHARELIVES_PRINT, 0);
}
script SHARELIVES_PRINT_SPECTATE (int who) DISCONNECT
{
SetActivator(0);
HudMessage(s:""; HUDMSG_PLAIN, 45, CR_GREEN, 90.0, 315.0, 0);
}
Script 721 (void) { SetAllLivesLeft(++currentLivesSurvival); }
ACS 0 Ë § O U§áWe§áð§O3 U§áWeË §ðo k §FOJ (§ Ð §Ð §Ð §Ð § 4‘ ðo k §O‹ § O† (4 § Ë §5k Ë §áð § O² ð§ ðV §Oâ Ï § OÚ §Ò Ï Ì §O ðo k §O (§ O §$((ÌË § O ð § ðV§ Ë § è °§ §áX | § ð§ Od §á4i §á§Oˆ Ï §§ OŠ § U§ áWWX§
áW§XŸ± - Z ;§ ¡4_ Ï §KFO] Ï §Ï §§ Oð § §§ O §á4 §áU§ áWWX§
áW§XŸ± - Z ;§ ¡§ O] U§áWXŸ±. – ; ¡° ð§ 5¶ U§ áWŸ± - Z ;§ ¡4š §Oš (§§ O§ § U§ áWWX§
áW§XŸ± - Z ;§ ¡4v (§KFOt (§(§§ O § §§ O §á4 §áU§ áWWX§
áW§XŸ± - Z ;§ ¡§ Ot U§áWXŸ±. – ; ¡° ð§ 5Ó U§ áWŸ± - Z ;§ ¡ â¾ § ðo 6U§ áWŸ± - Z ;§ ¡0((̧áð§ OÙ §Î§áð§ Oé §Î§ Χ 4 § ðV O
ðoi 6.5õ ͧ 4/ ðoi 6.5# ÍSPTR0 ¼ ½ œ ¾ ¿ › À¢ Ñ Â FUNC É ì FNAM@ . getlivesmode setteamlivesleft setalllivesleft STRLð < = s ² À É Ñ Õ Ù ç ë TLMS or Survival must be enabled to use pooled lives. sv_maxlives Set sv_maxlives larger than 1 to use pooled lives. sv_maxclients Survival TeamLMS \c- \cg \caRespawns: / \cg- ARAY MEXP4 & currentlives maxlives maxplayers ALIB < ACSe SHARLIVE d SHARLIVEp A_START p 8 SHARLIVE¨ A_END ¨ LOADACS