160 lines
5.9 KiB
Plaintext
160 lines
5.9 KiB
Plaintext
// game_override - kickstart this game it is stuck
|
|
// modified 5-29-2004: allowed use of override if game controller has left the game. JG
|
|
|
|
//---------------------- Setup Game ----------
|
|
void fnSetupGame()
|
|
{ // Start any needed DelayLoops
|
|
int nSetup=GetLocalInt(GetModule(),"nSetupDelaysOk");
|
|
if (nSetup!=TRUE)
|
|
{
|
|
DelayCommand(HoursToSeconds(1),ExecuteScript("rts_taxes",GetModule()));
|
|
DelayCommand(15.0,ExecuteScript("rts_rep_fix",GetModule()));
|
|
if (GetLocalInt(GetModule(),"nGameType")==0) DelayCommand(18.0,ExecuteScript("rts_elim_victory",GetModule()));
|
|
SetLocalInt(GetModule(),"nSetupDelaysOk",TRUE);
|
|
}
|
|
} // fnSetupGame()
|
|
|
|
string fnParsePeriod(string sIn)
|
|
{ // Parse period
|
|
string sH=sIn;
|
|
string sR="";
|
|
while (GetStringLength(sH)>0&&GetStringLeft(sH,1)!=".")
|
|
{ // build string
|
|
sR=sR+GetStringLeft(sH,1);
|
|
sH=GetStringRight(sH,GetStringLength(sH)-1);
|
|
} // build string
|
|
return sR;
|
|
} // fnParsePeriod()
|
|
|
|
string fnRemParsed(string sO, string sP)
|
|
{ // Remove parsed portion from sO
|
|
string sR="";
|
|
if (GetStringLength(sO)>=GetStringLength(sP))
|
|
sR=GetStringRight(sO,GetStringLength(sO)-GetStringLength(sP));
|
|
if (GetStringLeft(sR,1)==".") sR=GetStringRight(sR,GetStringLength(sR)-1);
|
|
return sR;
|
|
} // fnRemParsed()
|
|
|
|
|
|
//---------------------- Start Players -------
|
|
void fnStartAllPlayers()
|
|
{ // Start the game
|
|
effect eVFX=EffectVisualEffect(VFX_IMP_LIGHTNING_M);
|
|
object oPC=GetFirstPC();
|
|
string sID;
|
|
object oWP;
|
|
object oItem;
|
|
string sResources;
|
|
object oMod=GetModule();
|
|
string sParse;
|
|
SetLocalInt(GetModule(),"nInProgress",TRUE);
|
|
while(oPC!=OBJECT_INVALID)
|
|
{
|
|
if (GetIsDM(oPC)!=TRUE)
|
|
{ // not DM
|
|
oItem=GetItemPossessedBy(oPC,"RTSGame_Settings");
|
|
if (oItem!=OBJECT_INVALID) DestroyObject(oItem);
|
|
sID=GetLocalString(oPC,"sTeamID");
|
|
oWP=GetWaypointByTag(sID+"_START");
|
|
if (oWP!=OBJECT_INVALID)
|
|
{ // teleport
|
|
DelayCommand(1.0,ApplyEffectToObject(DURATION_TYPE_INSTANT,eVFX,oPC,1.0));
|
|
if (GetItemPossessedBy(oPC,"RTSUnit_Creation")==OBJECT_INVALID)
|
|
oItem=CreateItemOnObject("rtsunit_creation",oPC);
|
|
if (GetItemPossessedBy(oPC,"RTSCreation_Tool")==OBJECT_INVALID)
|
|
oItem=CreateItemOnObject("rtscreation_tool",oPC);
|
|
if (GetItemPossessedBy(oPC,"rts_it_vote")==OBJECT_INVALID)
|
|
oItem=CreateItemOnObject("rts_it_vote",oPC);
|
|
if (GetItemPossessedBy(oPC,"rts_it_teamwand")==OBJECT_INVALID)
|
|
{ // create team wand
|
|
oItem=CreateItemOnObject("rts_it_teamwand",oPC);
|
|
} // create team wand
|
|
oItem=GetObjectByTag(sID+"_RESOURCES");
|
|
if (oItem!=OBJECT_INVALID)
|
|
{ // !OI
|
|
sResources=GetName(oItem);
|
|
sParse=fnParsePeriod(sResources);
|
|
sResources=fnRemParsed(sResources,sParse);
|
|
SendMessageToPC(oPC,"You have "+sParse+" mana at your disposal.");
|
|
SetLocalInt(oPC,"nManaStore",StringToInt(sParse));
|
|
SetLocalInt(oMod,"nManaStore"+sID,StringToInt(sParse));
|
|
sParse=fnParsePeriod(sResources);
|
|
sResources=fnRemParsed(sResources,sParse);
|
|
GiveGoldToCreature(oPC,StringToInt(sParse));
|
|
SetLocalInt(oMod,"nGoldStore"+sID,StringToInt(sParse));
|
|
SendMessageToPC(oPC,"You have "+sResources+" souls at your disposal.");
|
|
SetLocalInt(oPC,"nStartSoul",StringToInt(sResources));
|
|
SetLocalInt(oPC,"nSoulStore",StringToInt(sResources));
|
|
SetLocalInt(oMod,"nSoulStore"+sID,StringToInt(sResources));
|
|
SetLocalInt(oMod,"nStartSoul"+sID,StringToInt(sResources));
|
|
oItem=GetObjectByTag(sID+"_START");
|
|
oItem=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_marker",GetLocation(oItem));
|
|
SetLocalObject(oMod,"oGUARD5"+sID,oItem);
|
|
oItem=GetObjectByTag(sID+"_VAULT");
|
|
oItem=CreateObject(OBJECT_TYPE_PLACEABLE,"rts_marker",GetLocation(oItem));
|
|
SetLocalObject(oMod,"oGUARD4"+sID,oItem);
|
|
|
|
} // !OI
|
|
else
|
|
{
|
|
SendMessageToPC(oPC,"Your resources waypoint could not be found!");
|
|
}
|
|
AssignCommand(oPC,ClearAllActions());
|
|
AssignCommand(oPC,JumpToObject(oWP));
|
|
} // teleport
|
|
else
|
|
{
|
|
oWP=GetWaypointByTag("INPROGRESS_JOIN");
|
|
AssignCommand(oPC,ClearAllActions());
|
|
AddJournalQuestEntry("Introduction",1,oPC,FALSE,FALSE);
|
|
AddJournalQuestEntry("GeneralInfo",1,oPC,FALSE,FALSE);
|
|
AddJournalQuestEntry("TheStory",1,oPC,FALSE,FALSE);
|
|
ExecuteScript("setupteam_tokens",oPC);
|
|
DelayCommand(6.5,AssignCommand(oPC,ActionStartConversation(oPC,"inprogress_join",TRUE,FALSE)));
|
|
}
|
|
} // not DM
|
|
oPC=GetNextPC();
|
|
}
|
|
} // fnStartAllPlayers()
|
|
|
|
|
|
void fnMsgPlayers(string sMsg)
|
|
{ // send message to all Players
|
|
object oPC=GetFirstPC();
|
|
while (oPC!=OBJECT_INVALID)
|
|
{
|
|
SendMessageToPC(oPC,sMsg);
|
|
oPC=GetNextPC();
|
|
}
|
|
} // fnMsgPlayers()
|
|
|
|
///////////////////////////////////////////////////////////////////////// MAIN
|
|
void main()
|
|
{
|
|
object oPC=GetLastUsedBy();
|
|
int nFirst=GetLocalInt(oPC,"nFirstPlayer");
|
|
int nCount;
|
|
if (nFirst==TRUE||!GetIsObjectValid(GetLocalObject(GetModule(),"oFirstPlayer")))
|
|
{ // first player, or first player has left the game
|
|
nCount=GetLocalInt(oPC,"nOverrideCount");
|
|
nCount++;
|
|
SetLocalInt(oPC,"nOverrideCount",nCount);
|
|
if (nCount==1)
|
|
{ // speak warning
|
|
AssignCommand(OBJECT_SELF,SpeakString("*WARNING: You have initiated the override process. If you wish the game to be force started now simply use me again.*"));
|
|
} // speak warning
|
|
else if (nCount==2)
|
|
{ // override
|
|
AssignCommand(OBJECT_SELF,SpeakString("*OVERRIDE!*"));
|
|
AssignCommand(GetModule(),fnSetupGame());
|
|
fnStartAllPlayers();
|
|
DeleteLocalInt(oPC,"OverrideCount");
|
|
} // override
|
|
} // first player
|
|
else
|
|
{
|
|
AssignCommand(OBJECT_SELF,SpeakString("*"+GetName(oPC)+" you are not the game settings player. You cannot use me.*"));
|
|
}
|
|
}
|
|
//////////////////////////////////////////////////////////////////////// MAIN
|