// Inprogress join team #include "header_sounds" void fnAnnounce(string sMsg="",int nOption=0) { // announce message to players object oNext=GetFirstPC(); while(oNext!=OBJECT_INVALID) { // announce SendMessageToPC(oNext,"ANNOUNCEMENT:"+sMsg); if (nOption==0) AssignCommand(oNext,fnSoundAlert("as_an_owlhoot1")); else if (nOption==1) AssignCommand(oNext,fnSoundAlert("as_cv_lute1")); oNext=GetNextPC(); } // announce } // fnAnnounce() 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() void fnSetFactionToFriendly(object oPC,string sID) { // Set faction that you control to friendly object oMember=GetObjectByTag(sID+"0"); object oWP; int nCreate=FALSE; if(oMember==OBJECT_INVALID) { // create dummy nCreate=TRUE; oWP=GetWaypointByTag(sID+"_START"); oMember=CreateObject(OBJECT_TYPE_CREATURE,sID+"0",GetLocation(oWP)); } // create dummy if (oMember!=OBJECT_INVALID) { // !OI AdjustReputation(oPC,oMember,100); } // !OI else { SendMessageToPC(oPC,"CRITICAL AREA: A creature placed with tag "+sID+"0 could not be found and is required to set faction you control to friendly!!!"); } if (nCreate==TRUE) DestroyObject(oMember); } // fnSetFactionToFriendly() void main() { object oPC=GetPCSpeaker(); string sID=GetLocalString(oPC,"sTeamID"); object oMod=GetModule(); object oLead=GetLocalObject(oMod,"oTeamLead"+sID); int nC; object oH; string sS; string sTeamName; object oItem; object oWP=GetWaypointByTag(sID+"_START"); int nMana=GetLocalInt(oMod,"nManaStore"+sID); int nSouls=GetLocalInt(oMod,"nSoulStore"+sID); int nStartSouls=GetLocalInt(oMod,"nStartSoul"+sID); int nGold=GetLocalInt(oMod,"nGoldStore"+sID); string sResources; string sParse; int nTeamN=1; AddJournalQuestEntry(sID,1,oPC,FALSE,FALSE); AddJournalQuestEntry(sID+"UNITS",1,oPC,FALSE,FALSE); ExecuteScript("adjust_alignment",oPC); if (sID=="UND") nTeamN=4; if (sID=="DWF") nTeamN=2; if (sID=="UNC") nTeamN=3; if (sID=="SPID")sTeamName="Spider Cultists."; else if (sID=="DWF") sTeamName=sTeamName+"Dwarves."; else if (sID=="UND") sTeamName=sTeamName+"Undead."; else if (sID=="UNC") sTeamName=sTeamName+"Unclean."; if (GetItemPossessedBy(oPC,"rts_it_vote")==OBJECT_INVALID) oItem=CreateItemOnObject("rts_it_vote",oPC); if (oLead==OBJECT_INVALID||GetIsPC(oLead)!=TRUE) { // no leader - assume leadership sS=GetName(oPC)+" has assumed leadership of the "+sTeamName; 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_manual")==OBJECT_INVALID) oItem=CreateItemOnObject("rts_it_manual",oPC); if (GetItemPossessedBy(oPC,"rts_it_teamwand")==OBJECT_INVALID) { // create team wand oItem=CreateItemOnObject("rts_it_teamwand",oPC); } // create team wand fnAnnounce(sS); SetLocalObject(oMod,"oTeamLead"+sID,oPC); if (oLead!=OBJECT_INVALID) { // there was an NPC leader if (nStartSouls!=0) { // stored resources SetLocalInt(oPC,"nManaStore",nMana); SetLocalInt(oPC,"nSoulStore",nSouls); SetLocalInt(oPC,"nStartSoul",nStartSouls); GiveGoldToCreature(oPC,nGold); } // stored resources else { // parse resources 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)); } // !OI } // parse resources SetLocalString(oMod,"sResNPCLead"+sID,GetResRef(oLead)); if (GetLocalObject(oMod,"oGUARD5"+sID)==OBJECT_INVALID) { // set guard markers 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); } // set guard markers SendMessageToPC(oPC,"You have "+IntToString(nMana)+" mana, "+IntToString(nSouls)+", and "+IntToString(GetGold(oPC))+" gold at your disposal."); DestroyObject(oLead); } // there was an NPC leader else if (nStartSouls!=0) { // get stored resources SetLocalInt(oPC,"nManaStore",nMana); SetLocalInt(oPC,"nSoulStore",nSouls); SetLocalInt(oPC,"nStartSoul",nStartSouls); GiveGoldToCreature(oPC,nGold); if (GetLocalObject(oMod,"oGUARD5"+sID)==OBJECT_INVALID) { // set guard markers 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); } // set guard markers SendMessageToPC(oPC,"You have "+IntToString(nMana)+" mana, "+IntToString(nSouls)+", and "+IntToString(GetGold(oPC))+" gold at your disposal."); } // get stored resources else { // parse resources 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"); if (GetLocalObject(oMod,"oGUARD5"+sID)==OBJECT_INVALID) { // set guard markers 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); } // set guard markers } // !OI } // parse resources } // no leader - assume leadership else { // there is a leader sS=GetName(oPC)+" has joined the "+sTeamName; fnAnnounce(sS,1); oH=GetFirstPC(); while(oH!=OBJECT_INVALID) { // set enemies & friends if (GetIsFriend(oH,oLead)==TRUE||GetIsNeutral(oH,oLead)==TRUE||GetLocalString(oPC,"sTeamID")==GetLocalString(oH,"sTeamID")||oH==oLead) { // friend if (oPC!=oH&&GetIsFriend(oH,oPC)==FALSE) { // not yourself SetPCLike(oPC,oH); } // not yourself } // friend else { // enemy if (oH!=oPC&&GetIsEnemy(oH,oPC)==FALSE) { // not yourself SetPCDislike(oPC,oH); } // not yourself } // enemy oH=GetNextPC(); } // set enemies & friends } // there is a leader // set reputation of creatures towards you SetLocalInt(oPC,"nTeamNum",nTeamN); SetLocalInt(oMod,"n"+sID+"Num",nTeamN); fnSetFactionToFriendly(oPC,sID); sS=GetName(oPC)+GetPCPlayerName(oPC); oH=GetLocalObject(oMod,sS+"loc"); AssignCommand(oPC,JumpToObject(oWP)); if (oWP==OBJECT_INVALID) { // OI SendMessageToPC(oPC,"ERROR: Cannot move you team start location. Moving you to the city."); oWP=GetWaypointByTag("PLANESHIFT_PRIME"); AssignCommand(oPC,JumpToObject(oWP)); } // OI ExecuteScript("rts_save_player",oPC); } ////////////////////////////////// // FUNCTIONS ////////////////////////////////// void fnTeamSelect(object oPC) { // select team string sID=GetLocalString(oPC,"sTeamID"); object oMod=GetModule(); object oLead=GetLocalObject(oMod,"oTeamLead"+sID); int nC; object oH; string sS; string sTeamName; object oItem; object oWP=GetWaypointByTag(sID+"_START"); int nMana=GetLocalInt(oMod,"nManaStore"+sID); int nSouls=GetLocalInt(oMod,"nSoulStore"+sID); int nStartSouls=GetLocalInt(oMod,"nStartSoul"+sID); int nGold=GetLocalInt(oMod,"nGoldStore"+sID); string sResources; string sParse; int nTeamN=1; if (sID=="UND") nTeamN=4; if (sID=="DWF") nTeamN=2; if (sID=="UNC") nTeamN=3; if (sID=="SPID") sTeamName="Spider Cultists."; else if (sID=="DWF") sTeamName=sTeamName+"Dwarves."; else if (sID=="UND") sTeamName=sTeamName+"Undead."; else if (sID=="UNC") sTeamName=sTeamName+"Unclean."; oItem=CreateItemOnObject("rts_it_vote",oPC); if (oLead==OBJECT_INVALID||GetIsPC(oLead)!=TRUE) { // no leader - assume leadership sS=GetName(oPC)+" has assumed leadership of the "+sTeamName; oItem=CreateItemOnObject("rtsunit_creation",oPC); oItem=CreateItemOnObject("rtscreation_tool",oPC); fnAnnounce(sS); SetLocalObject(oMod,"oTeamLead"+sID,oPC); if (oLead!=OBJECT_INVALID) { // there was an NPC leader if (nStartSouls!=0) { // stored resources SetLocalInt(oPC,"nManaStore",nMana); SetLocalInt(oPC,"nSoulStore",nSouls); SetLocalInt(oPC,"nStartSoul",nStartSouls); GiveGoldToCreature(oPC,nGold); } // stored resources else { // parse resources 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)); } // !OI } // parse resources SetLocalString(oMod,"sResNPCLead"+sID,GetResRef(oLead)); if (GetLocalObject(oMod,"oGUARD5"+sID)==OBJECT_INVALID) { // set guard markers 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); } // set guard markers SendMessageToPC(oPC,"You have "+IntToString(nMana)+" mana, "+IntToString(nSouls)+", and "+IntToString(GetGold(oPC))+" gold at your disposal."); DestroyObject(oLead); } // there was an NPC leader else if (nStartSouls!=0) { // get stored resources SetLocalInt(oPC,"nManaStore",nMana); SetLocalInt(oPC,"nSoulStore",nSouls); SetLocalInt(oPC,"nStartSoul",nStartSouls); GiveGoldToCreature(oPC,nGold); if (GetLocalObject(oMod,"oGUARD5"+sID)==OBJECT_INVALID) { // set guard markers 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); } // set guard markers SendMessageToPC(oPC,"You have "+IntToString(nMana)+" mana, "+IntToString(nSouls)+", and "+IntToString(GetGold(oPC))+" gold at your disposal."); } // get stored resources else { // parse resources 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"); if (GetLocalObject(oMod,"oGUARD5"+sID)==OBJECT_INVALID) { // set guard markers 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); } // set guard markers } // !OI } // parse resources } // no leader - assume leadership else { // there is a leader sS=GetName(oPC)+" has joined the "+sTeamName; fnAnnounce(sS,1); oH=GetFirstPC(); while(oH!=OBJECT_INVALID) { // set enemies & friends if (GetIsFriend(oH,oLead)==TRUE||GetIsNeutral(oH,oLead)==TRUE) { // friend if (oPC!=oH) { // not yourself SetPCLike(oPC,oH); } // not yourself } // friend else { // enemy if (oH!=oPC) { // not yourself SetPCDislike(oPC,oH); } // not yourself } // enemy oH=GetNextPC(); } // set enemies & friends } // there is a leader // set reputation of creatures towards you SetLocalInt(oPC,"nTeamNum",nTeamN); SetLocalInt(oMod,"n"+sID+"Num",nTeamN); fnSetFactionToFriendly(oPC,sID); } // fnTeamSelect()