339 lines
11 KiB
Plaintext
339 lines
11 KiB
Plaintext
////////////////////////////////////////////////////////////////////////////////
|
|
// Real Time Strategy - NWN - End Game
|
|
//==============================================================================
|
|
// By Deva Bryson Winblood. 03/01/2003
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
#include "rtsh_multiplay"
|
|
#include "dla_i0_strings"
|
|
|
|
int fnGetLevel(object oPC)
|
|
{ // return levels of creature
|
|
int nLevel=GetLevelByPosition(1,oPC);
|
|
nLevel=nLevel+GetLevelByPosition(2,oPC);
|
|
nLevel=nLevel+GetLevelByPosition(3,oPC);
|
|
return nLevel;
|
|
} // fnGetLevel()
|
|
|
|
int fnCountUnitType(string sTag)
|
|
{ // return how many objects with this tag are in the module
|
|
int nRet=0;
|
|
int nC=0;
|
|
object oCR=GetObjectByTag(sTag,nC);
|
|
while (oCR!=OBJECT_INVALID)
|
|
{ // !OI
|
|
nRet++;
|
|
nC++;
|
|
oCR=GetObjectByTag(sTag,nC);
|
|
} // !OI
|
|
return nRet;
|
|
} // fnCountUnitType()
|
|
|
|
|
|
int fnUnitCount(object oPC)
|
|
{ // count units
|
|
int nRet=0;
|
|
string sID=GetLocalString(oPC,"sTeamID");
|
|
int nC=0;
|
|
int nT=0;
|
|
object oHandle;
|
|
while(nC<30)
|
|
{
|
|
nT=fnCountUnitType(sID+IntToString(nC));
|
|
if (nT>0)
|
|
{ // there are some of these
|
|
oHandle=GetObjectByTag(sID+IntToString(nC));
|
|
nT=nT*FloatToInt(4.0*GetChallengeRating(oHandle));
|
|
nRet=nRet+nT;
|
|
} // there are some of these
|
|
nC++;
|
|
}
|
|
return nRet;
|
|
} // fnUnitCount()
|
|
|
|
string fnTeamName(object oPC)
|
|
{ // get team name
|
|
string sRet="";
|
|
sRet=GetLocalString(oPC,"sTeamID");
|
|
sRet=GetLocalString(GetModule(),"sTeamName"+sRet);
|
|
return sRet;
|
|
} // fnTeamName()
|
|
|
|
void fnVictoryJournal()
|
|
{ // setup victory journal -- also print to Game Over Log
|
|
int nC=0;
|
|
object oPC=GetFirstPC();
|
|
object oMod=GetModule();
|
|
object oWinner=GetLocalObject(oMod,"oWinner");
|
|
int nN;
|
|
string sID;
|
|
int nGT=GetLocalInt(oMod,"nGameType");
|
|
string sMsg;
|
|
string sTopPlayer;
|
|
int nTopScore=0;
|
|
int nScore;
|
|
PrintString("+---------------------------------------+");
|
|
PrintString("| RTS - Harvest of Souls |");
|
|
PrintString("| End of Game Scores and Results |");
|
|
PrintString("+---------------------------------------+");
|
|
PrintString("Winner: "+GetName(oWinner));
|
|
|
|
SetCustomToken(20,GetName(oWinner));
|
|
SetCustomToken(21,"- dwarf team -");
|
|
SetCustomToken(22,"- undead team -");
|
|
SetCustomToken(23,"- unclean team -");
|
|
SetCustomToken(24,"- spider team -");
|
|
SetCustomToken(25,"1 -no player-");
|
|
SetCustomToken(26,"2 -no player-");
|
|
SetCustomToken(27,"3 -no player-");
|
|
SetCustomToken(28,"4 -no player-");
|
|
SetCustomToken(29,"5 -no player-");
|
|
SetCustomToken(30,"6 -no player-");
|
|
SetCustomToken(31,"7 -no player-");
|
|
SetCustomToken(32,"8 -no player-");
|
|
SetCustomToken(33,"9 -no player-");
|
|
SetCustomToken(34,"10-no player-");
|
|
SetCustomToken(35,"11-no player-");
|
|
SetCustomToken(36,"12-no player-");
|
|
SetCustomToken(37,"13-no player-");
|
|
SetCustomToken(38,"14-no player-");
|
|
SetCustomToken(39,"15-no player-");
|
|
SetCustomToken(40,"16-no player-");
|
|
SetCustomToken(41,"17-no player-");
|
|
SetCustomToken(42,"18-no player-");
|
|
SetCustomToken(43,"19-no player-");
|
|
SetCustomToken(44,"20-no player-");
|
|
SetCustomToken(45,"21-no player-");
|
|
SetCustomToken(46,"22-no player-");
|
|
SetCustomToken(47,"23-no player-");
|
|
SetCustomToken(48,"24-no player-");
|
|
SetCustomToken(49,"25-no player-");
|
|
SetCustomToken(50,"26-no player-");
|
|
SetCustomToken(51,"27-no player-");
|
|
SetCustomToken(52,"28-no player-");
|
|
SetCustomToken(53,"29-no player-");
|
|
SetCustomToken(54,"30-no player-");
|
|
SetCustomToken(55,"31-no player-");
|
|
SetCustomToken(56,"32-no player-");
|
|
SetCustomToken(57,"33-no player-");
|
|
SetCustomToken(58,"34-no player-");
|
|
SetCustomToken(59,"35-no player-");
|
|
SetCustomToken(60,"36-no player-");
|
|
SetCustomToken(61,"37-no player-");
|
|
SetCustomToken(62,"38-no player-");
|
|
SetCustomToken(63,"39-no player-");
|
|
SetCustomToken(64,"40-no player-");
|
|
SetCustomToken(65,"41-no player-");
|
|
SetCustomToken(66,"42-no player-");
|
|
SetCustomToken(67,"43-no player-");
|
|
SetCustomToken(68,"44-no player-");
|
|
SetCustomToken(69,"45-no player-");
|
|
oPC=GetFirstPC();
|
|
nC=0;
|
|
while(oPC!=OBJECT_INVALID)
|
|
{ // !OI
|
|
if (GetIsDM(oPC)==FALSE)
|
|
{ // !DM
|
|
nScore=0;
|
|
sMsg="["+GetName(oPC)+"]:";
|
|
sID=GetLocalString(oPC,"sTeamID");
|
|
sMsg=sMsg+"Team("+fnTeamName(oPC)+")";
|
|
nN=GetLocalInt(oPC,"nKills");
|
|
sMsg=sMsg+"Kills:"+IntToString(nN);
|
|
nScore=nScore+nN;
|
|
nN=GetLocalInt(oPC,"nPKills");
|
|
sMsg=sMsg+" PKills:"+IntToString(nN);
|
|
if (nGT==0) nScore=nScore+25;
|
|
nN=GetLocalInt(oPC,"nDeaths");
|
|
sMsg=sMsg+" Deaths:"+IntToString(nN);
|
|
if (nGT==0) nScore=nScore-5;
|
|
else { nScore=nScore-1; }
|
|
nN=fnGetLevel(oPC);
|
|
sMsg=sMsg+" Level:"+IntToString(nN);
|
|
nScore=nScore+((nN-1)*10);
|
|
nN=GetLocalInt(oPC,"nSoulsCaptured");
|
|
sMsg=sMsg+" Souls Captured:"+IntToString(nN);
|
|
if (nGT==0) nScore=nScore+nN;
|
|
else { nScore=nScore+(nN*10); }
|
|
nN=GetLocalInt(oPC,"nManaCaptured");
|
|
sMsg=sMsg+" Mana Found:"+IntToString(nN);
|
|
nScore=nScore+(nN*2);
|
|
nN=GetGold(oPC);
|
|
sMsg=sMsg+" Gold:"+IntToString(nN);
|
|
nN=GetLocalInt(oPC,"nAreasDiscovered");
|
|
sMsg=sMsg+" Exploration:"+IntToString(nN);
|
|
nScore=nScore+(nN*2);
|
|
sMsg=sMsg+" [SCORE:"+IntToString(nScore)+"]";
|
|
PrintString(sMsg);
|
|
SetCustomToken(25+nC,sMsg);
|
|
if (nTopScore<nScore) {
|
|
nTopScore=nScore;
|
|
sTopPlayer=GetName(oPC);
|
|
}
|
|
} // !DM
|
|
nC++;
|
|
oPC=GetNextPC();
|
|
} // !OI
|
|
oPC=GetLocalObject(oMod,"oTeamLeadDWF");
|
|
sMsg="Leader '"+GetName(oPC)+"'(Level:";
|
|
nN=fnGetLevel(oPC);
|
|
sMsg=sMsg+IntToString(nN);
|
|
if (GetIsPC(oPC)==FALSE) sMsg=sMsg+" NPC)";
|
|
else {sMsg=sMsg+")"; }
|
|
nN=fnGetTeamMana(oPC);
|
|
sMsg=sMsg+" Mana:"+IntToString(nN);
|
|
nN=fnGetTeamSouls(oPC);
|
|
sMsg=sMsg+" Souls:"+IntToString(nN);
|
|
nN=GetLocalInt(oMod,"nTeamKillsDWF");
|
|
sMsg=sMsg+" Kills by Team:"+IntToString(nN);
|
|
sMsg=sMsg+" UNITS[";
|
|
nN=GetLocalInt(oMod,"nTeamDeathsDWF");
|
|
sMsg=sMsg+" Lost:"+IntToString(nN);
|
|
nN=fnUnitCount(oPC);
|
|
sMsg=sMsg+" Power:"+IntToString(nN)+"]";
|
|
nN=GetLocalInt(oMod,"nDWFPower");
|
|
sMsg=sMsg+" Power Reservoir Points:"+IntToString(nN);
|
|
nN=GetLocalInt(oMod,"nTeamExplorationDWF");
|
|
sMsg=sMsg+" Team Exploration:"+IntToString(nN);
|
|
sMsg=sMsg+" ("+IntToString((nN*100)/137)+"% explored)";
|
|
nN=GetLocalInt(oMod,"nDWFGoldIncome");
|
|
sMsg=sMsg+" INCOME: "+IntToString(nN)+" gold/hour, ";
|
|
nN=GetLocalInt(oMod,"nDWFManaIncome");
|
|
sMsg=sMsg+IntToString(nN)+" mana/hour.";
|
|
PrintString("DWARVES: "+sMsg);
|
|
SetCustomToken(21,"DWARVES: "+sMsg);
|
|
//
|
|
oPC=GetLocalObject(oMod,"oTeamLeadUND");
|
|
sMsg="Leader '"+GetName(oPC)+"'(Level:";
|
|
nN=fnGetLevel(oPC);
|
|
sMsg=sMsg+IntToString(nN);
|
|
if (GetIsPC(oPC)==FALSE) sMsg=sMsg+" NPC)";
|
|
else {sMsg=sMsg+")"; }
|
|
nN=fnGetTeamMana(oPC);
|
|
sMsg=sMsg+" Mana:"+IntToString(nN);
|
|
nN=fnGetTeamSouls(oPC);
|
|
sMsg=sMsg+" Souls:"+IntToString(nN);
|
|
nN=GetLocalInt(oMod,"nTeamKillsUND");
|
|
sMsg=sMsg+" Kills by Team:"+IntToString(nN);
|
|
sMsg=sMsg+" UNITS[";
|
|
nN=GetLocalInt(oMod,"nTeamDeathsUND");
|
|
sMsg=sMsg+" Lost:"+IntToString(nN);
|
|
nN=fnUnitCount(oPC);
|
|
sMsg=sMsg+" Power:"+IntToString(nN)+"]";
|
|
nN=GetLocalInt(oMod,"nUNDPower");
|
|
sMsg=sMsg+" Power Reservoir Points:"+IntToString(nN);
|
|
nN=GetLocalInt(oMod,"nTeamExplorationUND");
|
|
sMsg=sMsg+" Team Exploration:"+IntToString(nN);
|
|
sMsg=sMsg+" ("+IntToString((nN*100)/137)+"% explored)";
|
|
nN=GetLocalInt(oMod,"nUNDGoldIncome");
|
|
sMsg=sMsg+" INCOME: "+IntToString(nN)+" gold/hour, ";
|
|
nN=GetLocalInt(oMod,"nUNDManaIncome");
|
|
sMsg=sMsg+IntToString(nN)+" mana/hour.";
|
|
PrintString("UNDEAD: "+sMsg);
|
|
SetCustomToken(22,"UNDEAD: "+sMsg);
|
|
//
|
|
oPC=GetLocalObject(oMod,"oTeamLeadUNC");
|
|
sMsg="Leader '"+GetName(oPC)+"'(Level:";
|
|
nN=fnGetLevel(oPC);
|
|
sMsg=sMsg+IntToString(nN);
|
|
if (GetIsPC(oPC)==FALSE) sMsg=sMsg+" NPC)";
|
|
else {sMsg=sMsg+")"; }
|
|
nN=fnGetTeamMana(oPC);
|
|
sMsg=sMsg+" Mana:"+IntToString(nN);
|
|
nN=fnGetTeamSouls(oPC);
|
|
sMsg=sMsg+" Souls:"+IntToString(nN);
|
|
nN=GetLocalInt(oMod,"nTeamKillsUNC");
|
|
sMsg=sMsg+" Kills by Team:"+IntToString(nN);
|
|
sMsg=sMsg+" UNITS[";
|
|
nN=GetLocalInt(oMod,"nTeamDeathsUNC");
|
|
sMsg=sMsg+" Lost:"+IntToString(nN);
|
|
nN=fnUnitCount(oPC);
|
|
sMsg=sMsg+" Power:"+IntToString(nN)+"]";
|
|
nN=GetLocalInt(oMod,"nUNCPower");
|
|
sMsg=sMsg+" Power Reservoir Points:"+IntToString(nN);
|
|
nN=GetLocalInt(oMod,"nTeamExplorationUNC");
|
|
sMsg=sMsg+" Team Exploration:"+IntToString(nN);
|
|
sMsg=sMsg+" ("+IntToString((nN*100)/137)+"% explored)";
|
|
nN=GetLocalInt(oMod,"nUNCGoldIncome");
|
|
sMsg=sMsg+" INCOME: "+IntToString(nN)+" gold/hour, ";
|
|
nN=GetLocalInt(oMod,"nUNCManaIncome");
|
|
sMsg=sMsg+IntToString(nN)+" mana/hour.";
|
|
PrintString("UNCLEAN: "+sMsg);
|
|
SetCustomToken(23,"UNCLEAN: "+sMsg);
|
|
//
|
|
oPC=GetLocalObject(oMod,"oTeamLeadSPID");
|
|
sMsg="Leader '"+GetName(oPC)+"'(Level:";
|
|
nN=fnGetLevel(oPC);
|
|
sMsg=sMsg+IntToString(nN);
|
|
if (GetIsPC(oPC)==FALSE) sMsg=sMsg+" NPC)";
|
|
else {sMsg=sMsg+")"; }
|
|
nN=fnGetTeamMana(oPC);
|
|
sMsg=sMsg+" Mana:"+IntToString(nN);
|
|
nN=fnGetTeamSouls(oPC);
|
|
sMsg=sMsg+" Souls:"+IntToString(nN);
|
|
nN=GetLocalInt(oMod,"nTeamKillsSPID");
|
|
sMsg=sMsg+" Kills by Team:"+IntToString(nN);
|
|
sMsg=sMsg+" UNITS[";
|
|
nN=GetLocalInt(oMod,"nTeamDeathsSPID");
|
|
sMsg=sMsg+" Lost:"+IntToString(nN);
|
|
nN=fnUnitCount(oPC);
|
|
sMsg=sMsg+" Power:"+IntToString(nN)+"]";
|
|
nN=GetLocalInt(oMod,"nSPIDPower");
|
|
sMsg=sMsg+" Power Reservoir Points:"+IntToString(nN);
|
|
nN=GetLocalInt(oMod,"nTeamExplorationSPID");
|
|
sMsg=sMsg+" Team Exploration:"+IntToString(nN);
|
|
sMsg=sMsg+" ("+IntToString((nN*100)/137)+"% explored)";
|
|
nN=GetLocalInt(oMod,"nSPIDGoldIncome");
|
|
sMsg=sMsg+" INCOME: "+IntToString(nN)+" gold/hour, ";
|
|
nN=GetLocalInt(oMod,"nSPIDManaIncome");
|
|
sMsg=sMsg+IntToString(nN)+" mana/hour.";
|
|
PrintString("SPIDER CULTISTS: "+sMsg);
|
|
SetCustomToken(24,"SPIDERS: "+sMsg);
|
|
PrintString("+-------------------------------->");
|
|
PrintString("| TOP PLAYER: "+sTopPlayer);
|
|
PrintString("| SCORE: "+IntToString(nTopScore));
|
|
PrintString("+-------------------------------->");
|
|
SetCustomToken(500,sTopPlayer);
|
|
SetCustomToken(501,IntToString(nTopScore));
|
|
} // fnVictoryJournal()
|
|
|
|
void fnJumpMe()
|
|
{
|
|
object oPC=OBJECT_SELF;
|
|
object oWP=GetWaypointByTag("END_GAME_POINT");
|
|
if (GetNearestObjectByTag("END_GAME_POINT",oPC,1)==OBJECT_INVALID)
|
|
{
|
|
AssignCommand(oPC,ClearAllActions(TRUE));
|
|
AssignCommand(oPC,JumpToObject(oWP));
|
|
DelayCommand(2.0,fnJumpMe());
|
|
}
|
|
}
|
|
|
|
void fnJumpAllPlayers()
|
|
{
|
|
object oPC=GetFirstPC();
|
|
object oMod=GetModule();
|
|
object oWinner=GetLocalObject(oMod,"oWinner");
|
|
while (oPC!=OBJECT_INVALID)
|
|
{ // !OI
|
|
SendMessageToPC(oPC,DLA_SetStringColor(GetName(oWinner)+" is victorious and has won this game!","262"));
|
|
AssignCommand(oPC,fnJumpMe());
|
|
oPC=GetNextPC();
|
|
} // !OI
|
|
}
|
|
|
|
//----------------------------------------------------------- MAIN -------------
|
|
void main()
|
|
{
|
|
object oMod=GetModule();
|
|
object oWinner=GetLocalObject(oMod,"oWinner");
|
|
if (oWinner==OBJECT_INVALID) oWinner=GetFirstPC();
|
|
SetLocalObject(oMod,"oWinner",oWinner);
|
|
if (GetLocalInt(oMod,"nGameOver")!=TRUE)
|
|
{ // game over hasn't been called already
|
|
SetLocalInt(oMod,"nGameOver",TRUE);
|
|
fnVictoryJournal();
|
|
DelayCommand(4.0,fnJumpAllPlayers());
|
|
DelayCommand(5.0,AddJournalQuestEntry("GAMEOVER",1,oWinner,TRUE,TRUE,TRUE));
|
|
} // game over not already called
|
|
}
|