HoS_PRC8/_mod/_module/nss/lib_hos2_team.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

695 lines
24 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// lib_hos2_team - Team Support Functions
// By Deva B. Winblood. March 31st, 2008
////////////////////////////////////////////////////////////////////////////////
#include "nbde_inc"
#include "lib_hos2_pc"
#include "lib_hos2_data"
#include "lib_nais_persist"
/////////////////////////////////
// CONSTANTS
/////////////////////////////////
const int RESOURCE_TYPE_GOLD = 0;
const int RESOURCE_TYPE_MANA = 1;
const int RESOURCE_TYPE_SOUL = 2;
const int RESOURCE_TYPE_WOOD = 3;
const int RESOURCE_TYPE_IRON = 4;
const int RESOURCE_TYPE_MITHRIL = 5;
const int RESOURCE_TYPE_ADAMANTIUM = 6;
const int RESOURCE_TYPE_GOLDBAR = 7;
////////////////////////////////
// PROTOTYPES
////////////////////////////////
// FILE: lib_hos2_team FUNCTION: Team_SetResource()
// This function wll enable you to set what the current resource for this team
// is.
void Team_SetResource(string sTeamID,int nResourceType,int nAmount);
// FILE: lib_hos2_team FUNCTION: Team_GetResource()
// This function will return what the specified teams resources are now.
int Team_GetResource(string sTeamID,int nResourceType);
// FILE: lib_hos2_team FUNCTION: Team_ProcessResourceHour()
// This function will process an hour of resource collection for the specified
// team and will update the journal for what the team has stored. It will
// also inform PC team members of the results if bVerbose is set to TRUE.
void Team_ProcessResourceHour(string sTeamID,int bVerbose=TRUE);
// FILE: lib_hos2_team FUNCTION: Team_GiveStartingResources()
// This function will give the specified team its starting resources.
void Team_GiveStartingResources(string sTeamID,int bStartingAdvantage=FALSE);
// FILE: lib_hos2_team FUNCTION: Team_SetRelation()
// This function will get the relation between nTeamNum1 and nTeamNum2.
// 0 = Neutral, 1 = Friend, -1 = Enemy
void Team_SetRelation(int nTeamNum1,int nTeamNum2,int nRelation);
// FILE: lib_hos2_team FUNCTION: Team_GetRelation()
// This function will return the relation between two teams.
// 0 Neutral, 1 = Friend, -1 = Enemy
int Team_GetRelation(int nTeamNum1,int nTeamNum2);
// FILE: lib_hos2_team FUNCTION: Team_AIReactPerception()
// This will cause oAI to check factional relationships with oPerceived and
// if they are enemy or otherwise it will adjust it's reactions to them
// accordingly.
void Team_AIReactPerception(object oAI,object oPerceived);
// FILE: lib_hos2_team FUNCTION: Team_GetTeamLeader()
// This will return who the team leader is.
object Team_GetTeamLeader(int nTeamNum);
// FILE: lib_hos2_team FUNCTION: Team_SetTeamLeader()
// Set who the leader for the team is.
void Team_SetTeamLeader(int nTeamNum,object oLeader);
// FILE: lib_hos2_team FUNCTION: Team_SetBuildingRights()
// This will grant oCreature with the right to construct objects or not.
void Team_SetBuildingRights(object oCreature,int bCanBuild=TRUE);
// FILE: lib_hos2_team FUNCTION: Team_GetBuildingRights()
// This will return whether oCreature has building rights.
int Team_GetBuildingRights(object oCreature);
// FILE: lib_hos2_team FUNCTION: Team_SetCreationRights()
// This will set whether oCreature can create units or not.
void Team_SetCreationRights(object oCreature,int bCanCreate=TRUE);
// FILE: lib_hos2_team FUNCTION: Team_GetCreationRights()
// This will return whether oCreature can create units or not.
int Team_GetCreationRights(object oCreature);
// FILE: lib_hos2_team FUNCTION: Team_SetPCRelation()
// This will setup how each team perceives this PC.
void Team_SetPCRelation(object oPC);
// FILE: lib_hos2_team FUNCTION: Team_SetAllPCRelations()
// This will adjust the relations of ALL PCs.
void Team_SetAllPCRelations();
////////////////////////////////
// FUNCTIONS
////////////////////////////////
void Team_SetResource(string sTeamID,int nResourceType,int nAmount)
{ // PURPOSE: Set the stored resource amount for the specified team.
string sDB=GetTag(GetModule())+"TM";
string sVar="n"+sTeamID+IntToString(nResourceType);
int nN=nAmount;
if (nN<1) nN=0;
NBDE_SetCampaignInt(sDB,sVar,nN);
} // Team_SetResource()
int Team_GetResource(string sTeamID,int nResourceType)
{ // PURPOSE: Return the amount of resources
string sDB=GetTag(GetModule())+"TM";
string sVar="n"+sTeamID+IntToString(nResourceType);
return NBDE_GetCampaignInt(sDB,sVar);
} // Team_GetResource()
int fnTeam_GetTax(string sTeamID)
{ // PURPOSE: Get Taxes
int nRet;
int nTeamNum=lib_DataGetTeamNumber(sTeamID);
int nUnit=1;
string sTag;
int nTax;
int nN;
object oUnit;
sTag=Unit_GetUnitTag(nTeamNum,nUnit);
while(GetStringLength(sTag)>0)
{ // check for tax units
nTax=Unit_GetUnitTax(nTeamNum,nUnit);
if (nTax>0)
{ // unit type has tax
nN=0;
oUnit=GetObjectByTag(sTag,nN);
while(GetIsObjectValid(oUnit))
{ // get tax for each
nRet=nRet+nTax;
nN++;
oUnit=GetObjectByTag(sTag,nN);
} // get tax for each
} // unit type has tax
nUnit++;
sTag=Unit_GetUnitTag(nTeamNum,nUnit);
} // check for tax units
nRet=nRet+GetLocalInt(GetModule(),"nAreaTax"+IntToString(nTeamNum));
string sDB=GetTag(GetModule())+"SU";
nN=NBDE_GetCampaignInt(sDB,"nGSManaMult");
if (nN>0) nRet=nRet*(nN+1);
return nRet;
} // fnTeam_GetTax
int fnTeam_GetMana(string sTeamID)
{ // PURPOSE: Get Mana production
int nRet;
int nN;
object oPool;
object oVault=GetWaypointByTag("MANA_VAULT_"+sTeamID);
if (GetIsObjectValid(oVault))
{ // mana vault found
nN=1;
oPool=GetNearestObjectByTag("plc_res_mana5",oVault,nN);
while(GetIsObjectValid(oPool)&&GetDistanceBetween(oVault,oPool)<15.0)
{ // count 5
nRet=nRet+5;
nN++;
oPool=GetNearestObjectByTag("plc_res_mana5",oVault,nN);
} // count 5
nN=1;
oPool=GetNearestObjectByTag("plc_res_mana2",oVault,nN);
while(GetIsObjectValid(oPool)&&GetDistanceBetween(oVault,oPool)<15.0)
{ // count 5
nRet=nRet+2;
nN++;
oPool=GetNearestObjectByTag("plc_res_mana2",oVault,nN);
} // count 5
nN=1;
oPool=GetNearestObjectByTag("plc_res_mana1",oVault,nN);
while(GetIsObjectValid(oPool)&&GetDistanceBetween(oVault,oPool)<15.0)
{ // count 5
nRet=nRet+1;
nN++;
oPool=GetNearestObjectByTag("plc_res_mana1",oVault,nN);
} // count 5
} // mana vault found
else
{ // not found
PrintString("ERROR [lib_hos2_team]: Waypoint 'MANA_VAULT_"+sTeamID+"' not found!");
} // not found
string sDB=GetTag(GetModule())+"SU";
nN=NBDE_GetCampaignInt(sDB,"nGSManaMult");
if (nN>0) nRet=nRet*(nN+1);
return nRet;
} // fnTeam_GetMana
string fnArea_GetAreaController(object oArea)
{ // PURPOSE: To return the team ID that is currently controlling this area
object oWP=GetWaypointByTag("AREA_"+GetTag(oArea));
string sDB=GetTag(GetModule())+"TM";
object oControl=GetNearestObjectByTag("CAPTURE_POINT",oWP,1);
string sRet="";
if (GetIsObjectValid(oControl))
{ // control point exists
sRet=NBDE_GetCampaignString(sDB,"sCtrl_"+GetTag(oArea));
} // control point exists
return sRet;
} // fnArea_GetAreaController()
string fnArea_GetDefaultController(object oArea)
{ // PURPOSE: Return who the default controller of this area is
object oWP=GetWaypointByTag("AREA_"+GetTag(oArea));
string sDB=GetTag(GetModule())+"TM";
object oControl=GetNearestObjectByTag("CAPTURE_POINT",oWP,1);
string sRet="";
if (GetIsObjectValid(oControl))
{ // control point exists
sRet=GetLocalString(oControl,"sStart");
} // control point exists
return sRet;
} // fnArea_GetDefaultController()
void fnTeam_SetupAreaTaxes()
{ // PURPOSE: Set Tax values for areas
int nTeamNum=1;
int nN;
int nV;
object oWP;
string sS=lib_DataGetStoredTeamID(nTeamNum);
while(GetStringLength(sS)>0)
{ // zero out area taxes
DeleteLocalInt(GetModule(),"nAreaTax"+IntToString(nTeamNum));
nTeamNum++;
sS=lib_DataGetStoredTeamID(nTeamNum);
} // zero out area taxes
nN=0;
oWP=GetObjectByTag("CAPTURE_POINT",nN);
while(GetIsObjectValid(oWP))
{ // check each capture point
nV=GetLocalInt(oWP,"nTax");
if (nV>0)
{ // tax
sS=fnArea_GetAreaController(GetArea(oWP));
if (GetStringLength(sS)<1) sS=fnArea_GetDefaultController(GetArea(oWP));
if (GetStringLength(sS)>0)
{ // determine tax
nTeamNum=lib_DataGetTeamNumber(sS);
sS="nAreaTax"+IntToString(nTeamNum);
SetLocalInt(GetModule(),sS,GetLocalInt(GetModule(),sS)+nV);
} // determine tax
} // tax
nN++;
oWP=GetObjectByTag("CAPTURE_POINT",nN);
} // check each capture point
} // fnTeam_SetupAreaTaxes()
void fnTeam_SetTeamResourceJournal(string sTeamID,string sJournal,int nTeamNum)
{ // PURPOSE: Set and update the journal entry
object oPC=GetFirstPC();
SetCustomToken(112680+nTeamNum,sJournal);
while(GetIsObjectValid(oPC))
{ // set journal on each team member
if (PC_GetTeamID(oPC)==sTeamID)
{ // member
RemoveJournalQuestEntry("TEAMRESOURCES",oPC,FALSE,FALSE);
DelayCommand(1.0,AddJournalQuestEntry("TEAMRESOURCES",nTeamNum,oPC,FALSE,FALSE,TRUE));
} // member
oPC=GetNextPC();
} // set journal on each team member
} // fnTeam_SetTeamResourceJournal()
void Team_ProcessResourceHour(string sTeamID,int bVerbose=TRUE)
{ // PURPOSE: Process an hour of resource processing for the team
string sMsg;
object oMod=GetModule();
int nTeamNum=GetLocalInt(oMod,"nTeamID_"+sTeamID);
int nCurrResource;
int nN;
string sS;
object oOb;
float fF;
string sJournalEntry;
if (nTeamNum>0)
{ // valid team
sS=GetLocalString(oMod,"sTeamName_"+IntToString(nTeamNum));
sS=lib_SetStringColor(sS,"363");
sMsg=sS+": Wood:";
nN=Team_GetResource(sTeamID,RESOURCE_TYPE_WOOD);
sS=lib_SetStringColor(IntToString(nN),"446");
sMsg=sMsg+sS+", Iron:";
nN=Team_GetResource(sTeamID,RESOURCE_TYPE_IRON);
sS=lib_SetStringColor(IntToString(nN),"446");
sMsg=sMsg+sS+", Souls:";
nN=Team_GetResource(sTeamID,RESOURCE_TYPE_SOUL);
sS=lib_SetStringColor(IntToString(nN),"446");
sMsg=sMsg+sS+", Gold Bars:";
nN=Team_GetResource(sTeamID,RESOURCE_TYPE_GOLDBAR);
sS=lib_SetStringColor(IntToString(nN),"555");
sMsg=sMsg+sS+", Mithril Bars:";
nN=Team_GetResource(sTeamID,RESOURCE_TYPE_MITHRIL);
sS=lib_SetStringColor(IntToString(nN),"555");
sMsg=sMsg+sS+", Adamantium Bars:";
nN=Team_GetResource(sTeamID,RESOURCE_TYPE_ADAMANTIUM);
sS=lib_SetStringColor(IntToString(nN),"555");
sMsg=sMsg+sS+", Gold:";
nCurrResource=Team_GetResource(sTeamID,RESOURCE_TYPE_GOLD);
nN=fnTeam_GetTax(sTeamID);
nCurrResource=nCurrResource+nN;
if (nCurrResource<1) nCurrResource=0;
Team_SetResource(sTeamID,RESOURCE_TYPE_GOLD,nCurrResource);
sS=lib_SetStringColor(IntToString(nCurrResource),"446");
sMsg=sMsg+sS+" [Produced:";
if (nN>=0) sS=lib_SetStringColor(IntToString(nN),"066");
else { sS=lib_SetStringColor(IntToString(nN),"622"); }
sMsg=sMsg+sS+"], Mana:";
nCurrResource=Team_GetResource(sTeamID,RESOURCE_TYPE_MANA);
nN=fnTeam_GetMana(sTeamID);
nCurrResource=nCurrResource+nN;
if (nCurrResource<1) nCurrResource=0;
Team_SetResource(sTeamID,RESOURCE_TYPE_MANA,nCurrResource);
sS=lib_SetStringColor(IntToString(nCurrResource),"446");
sMsg=sMsg+sS+" [Produced:";
if (nN>=0) sS=lib_SetStringColor(IntToString(nN),"066");
else { sS=lib_SetStringColor(IntToString(nN),"622"); }
sMsg=sMsg+sS+"].";
if (bVerbose)
{ // send message
DelayCommand(2.0,Msg_Team(oMod,"[== HOURLY RESOURCE REPORT ==] "+sMsg,"","",sTeamID,FALSE));
} // send message
sJournalEntry="[== LAST TEAM RESOURCE REPORT ==] "+sMsg;
DelayCommand(4.0,fnTeam_SetTeamResourceJournal(sTeamID,sJournalEntry,nTeamNum));
} // valid team
} // Team_ProcessResourceHour()
void Team_GiveStartingResources(string sTeamID,int bStartingAdvantage=FALSE)
{ // PURPOSE: Give starting resources
object oMod=GetModule();
int nTeamNum=GetLocalInt(oMod,"nTeamID_"+sTeamID);
int nN=GetLocalInt(oMod,"nTeamStartMana_"+IntToString(nTeamNum));
if (bStartingAdvantage) nN=FloatToInt(IntToFloat(nN)*1.25);
Team_SetResource(sTeamID,RESOURCE_TYPE_MANA,nN);
nN=GetLocalInt(oMod,"nTeamStartGold_"+IntToString(nTeamNum));
if (bStartingAdvantage) nN=FloatToInt(IntToFloat(nN)*1.25);
Team_SetResource(sTeamID,RESOURCE_TYPE_GOLD,nN);
nN=GetLocalInt(oMod,"nTeamStartSoul_"+IntToString(nTeamNum));
if (bStartingAdvantage) nN=FloatToInt(IntToFloat(nN)*1.25);
Team_SetResource(sTeamID,RESOURCE_TYPE_SOUL,nN);
nN=GetLocalInt(oMod,"nTeamStartIron_"+IntToString(nTeamNum));
if (bStartingAdvantage) nN=FloatToInt(IntToFloat(nN)*1.25);
Team_SetResource(sTeamID,RESOURCE_TYPE_IRON,nN);
nN=GetLocalInt(oMod,"nTeamStartWood_"+IntToString(nTeamNum));
if (bStartingAdvantage) nN=FloatToInt(IntToFloat(nN)*1.25);
Team_SetResource(sTeamID,RESOURCE_TYPE_WOOD,nN);
} // Team_GiveStartingResources()
void Team_SetRelation(int nTeamNum1,int nTeamNum2,int nRelation)
{ // PURPOSE: Set Factional Relationship of teams
object oProxy1;
object oProxy2;
string sTeamID1=lib_DataGetStoredTeamID(nTeamNum1);
string sTeamID2=lib_DataGetStoredTeamID(nTeamNum2);
string sDB=GetTag(GetModule())+"SU";
int nN;
int nDiff;
if (GetStringLength(sTeamID1)>0&&GetStringLength(sTeamID2)>0&&sTeamID1!=sTeamID2)
{ // set factional relationships
oProxy1=GetObjectByTag("proxy_"+sTeamID1);
oProxy2=GetObjectByTag("proxy_"+sTeamID2);
NBDE_SetCampaignInt(sDB,"nFactionRel"+IntToString(nTeamNum1)+"_"+IntToString(nTeamNum2),nRelation);
NBDE_SetCampaignInt(sDB,"nFactionRel"+IntToString(nTeamNum2)+"_"+IntToString(nTeamNum1),nRelation);
if (GetIsObjectValid(oProxy1)&&GetIsObjectValid(oProxy2))
{ // proxies exist
nN=GetReputation(oProxy1,oProxy2);
if (nN==0)
{ // neutral
nDiff=50-nN;
AdjustReputation(oProxy1,oProxy2,nDiff);
AdjustReputation(oProxy2,oProxy1,nDiff);
} // neutral
else if (nN==1)
{ // friend
AdjustReputation(oProxy1,oProxy2,100);
AdjustReputation(oProxy2,oProxy1,100);
} // friend
else if (nN==-1)
{ // enemy
AdjustReputation(oProxy1,oProxy2,-100);
AdjustReputation(oProxy2,oProxy1,-100);
} // enemy
} // proxies exist
} // set factional relationships
} // Team_SetRelation()
int Team_GetRelation(int nTeamNum1,int nTeamNum2)
{ // PURPOSE: Return team relation
string sDB=GetTag(GetModule())+"SU";
return NBDE_GetCampaignInt(sDB,"nFactionRel"+IntToString(nTeamNum2)+"_"+IntToString(nTeamNum1));
} // Team_GetRelation()
void Team_AIReactPerception(object oAI,object oPerceived)
{ // PURPOSE: Handle Perception
int nTeamAI=GetLocalInt(oAI,"nTeamNum");
int nTeamPerc=GetLocalInt(oPerceived,"nTeamNum");
int nRep;
int bPassive=GetLocalInt(oAI,"bPassive"); // 0 = normal react, 1 = passive
if (bPassive) return;
if (GetIsPC(oPerceived)) nTeamPerc=PC_GetTeamNum(oPerceived);
if (nTeamAI!=nTeamPerc)
{ // other teams
nRep=Team_GetRelation(nTeamAI,nTeamPerc);
if (nRep==1)
{ // friend
SetIsTemporaryFriend(oAI,oPerceived);
SetIsTemporaryFriend(oPerceived,oAI);
SetLocalObject(oAI,"oLastFriendlyTarget",oPerceived);
ExecuteScript("npc_e_startfr",oAI);
} // friend
else if (nRep==-1)
{ // enemy
if (!GetIsInCombat(oAI))
{ // not in combat
SetIsTemporaryEnemy(oAI,oPerceived);
SetIsTemporaryEnemy(oPerceived,oAI);
SetLocalObject(oAI,"oLastEnemyTarget",oPerceived);
ExecuteScript("npc_e_startcmb",oAI);
} // not in combat
else
{ // make sure perceived as enemy
SetIsTemporaryEnemy(oAI,oPerceived);
SetIsTemporaryEnemy(oPerceived,oAI);
SetLocalObject(oAI,"oLastEnemyTarget",oPerceived);
} // make sure perceived as enemy
} // enemy
else
{ // neutral
SetIsTemporaryNeutral(oAI,oPerceived);
SetIsTemporaryNeutral(oPerceived,oAI);
} // neutral
} // other teams
else if (nTeamAI!=0)
{ // same team and not zero
SetIsTemporaryFriend(oAI,oPerceived);
SetIsTemporaryFriend(oPerceived,oAI);
SetLocalObject(oAI,"oLastFriendlyTarget",oPerceived);
ExecuteScript("npc_e_startfr",oAI);
} // same team and not zero
else
{ // standard
} // standard
} // Team_AIReactPerception()
string GetTeamID(object oTarget)
{ // PURPOSE: To return the sTeamID of oTarget
string sID=GetLocalString(oTarget,"sTeamID");
if (GetIsPC(oTarget))
{ // PC
sID=PC_GetTeamID(oTarget);
} // PC
return sID;
} // GetTeamID()
string Team_GetTeamID(object oTarget)
{ // PURPOSE: Wraps GetTeamID()
return GetTeamID(oTarget);
} // Team_GetTeamID()
object Team_GetTeamLeader(int nTeamNum)
{ // PURPOSE: Get Team Leader
string sTeamID=lib_DataGetStoredTeamID(nTeamNum);
object oMod=GetModule();
object oLead=GetLocalObject(oMod,"oLead_"+sTeamID);
if (GetIsObjectValid(oLead)) return oLead;
string sDB=GetTag(oMod)+"TM";
string sLead=NBDE_GetCampaignString(sDB,"sLead_"+sTeamID);
if (GetStringLeft(sLead,1)=="P")
{ // PC
sLead=GetStringRight(sLead,GetStringLength(sLead)-1);
object oPC=GetFirstPC();
string sID;
while(GetIsObjectValid(oPC))
{ // return leader
sID=GetPCPublicCDKey(oPC)+"_"+GetName(oPC);
if (sID==sLead)
{ // leader
SetLocalObject(oMod,"oLead_"+sTeamID,oPC);
return oPC;
} // leader
oPC=GetNextPC();
} // return leader
} // PC
else if (GetStringLeft(sLead,1)=="N")
{ // NPC
sLead=GetStringRight(sLead,GetStringLength(sLead)-1);
int nUID=StringToInt(sLead);
if (nUID>0)
{ // find leader
oLead=NPC_GetNPCObjectByID(nUID);
if (GetIsObjectValid(oLead))
{ // found
SetLocalObject(oMod,"oLead_"+sTeamID,oLead);
return oLead;
} // found
} // find leader
} // NPC
return OBJECT_INVALID;
} // Team_GetTeamLeader()
void Team_SetTeamLeader(int nTeamNum,object oLeader)
{ // PURPOSE: Set the Team Leader
string sTeamID=lib_DataGetStoredTeamID(nTeamNum);
object oMod=GetModule();
object oLead=Team_GetTeamLeader(nTeamNum);
string sDB=GetTag(oMod)+"TM";
string sID;
if (oLeader==oLead) return;
if (GetTeamID(oLeader)!=sTeamID) return;
if (GetIsPC(oLeader))
{ // PC
sID=GetPCPublicCDKey(oLeader)+"_"+GetName(oLeader);
NBDE_SetCampaignString(sDB,"sLead_"+sTeamID,"P"+sID);
SetLocalObject(oMod,"oLead_"+sTeamID,oLeader);
NBDE_FlushCampaignDatabase(sDB);
} // PC
else
{ // NPC
sID=IntToString(GetLocalInt(oLeader,"nUID"));
NBDE_SetCampaignString(sDB,"sLead_"+sTeamID,"N"+sID);
SetLocalObject(oMod,"oLead_"+sTeamID,oLeader);
NBDE_FlushCampaignDatabase(sDB);
} // NPC
} // Team_SetTeamLeader()
void Team_SetBuildingRights(object oCreature,int bCanBuild=TRUE)
{ // PURPOSE: Set Building Rights
string sDB=GetTag(GetModule())+"TM";
string sID;
if (GetIsPC(oCreature))
{ // PC
sID=GetPCPublicCDKey(oCreature)+"_"+GetName(oCreature);
NBDE_SetCampaignInt(sDB,"bBR_"+sID,bCanBuild);
} // PC
else
{ // NPC
sID=IntToString(GetLocalInt(oCreature,"nUID"));
NBDE_SetCampaignInt(sDB,"bBR_"+sID,bCanBuild);
} // NPC
} // Team_SetBuildingRights()
int Team_GetBuildingRights(object oCreature)
{ // PURPOSE: Get Building Rights
int nTeamNum;
string sID;
string sDB=GetTag(GetModule())+"TM";
if (GetIsPC(oCreature))
{ // PC
nTeamNum=PC_GetTeamNum(oCreature);
if (Team_GetTeamLeader(nTeamNum)==oCreature) return TRUE;
sID=GetPCPublicCDKey(oCreature)+"_"+GetName(oCreature);
return NBDE_GetCampaignInt(sDB,"bBR_"+sID);
} // PC
else
{ // NPC
nTeamNum=GetLocalInt(oCreature,"nTeamNum");
if (Team_GetTeamLeader(nTeamNum)==oCreature) return TRUE;
sID=IntToString(GetLocalInt(oCreature,"nUID"));
return NBDE_GetCampaignInt(sDB,"bBR_"+sID);
} // NPC
return FALSE;
} // Team_SetBuildingRights()
void Team_SetCreationRights(object oCreature,int bCanBuild=TRUE)
{ // PURPOSE: Set Creation Rights
string sDB=GetTag(GetModule())+"TM";
string sID;
if (GetIsPC(oCreature))
{ // PC
sID=GetPCPublicCDKey(oCreature)+"_"+GetName(oCreature);
NBDE_SetCampaignInt(sDB,"bCR_"+sID,bCanBuild);
} // PC
else
{ // NPC
sID=IntToString(GetLocalInt(oCreature,"nUID"));
NBDE_SetCampaignInt(sDB,"bCR_"+sID,bCanBuild);
} // NPC
} // Team_SetCreationRights()
int Team_GetCreationRights(object oCreature)
{ // PURPOSE: Get Creation Rights
int nTeamNum;
string sID;
string sDB=GetTag(GetModule())+"TM";
if (GetIsPC(oCreature))
{ // PC
nTeamNum=PC_GetTeamNum(oCreature);
if (Team_GetTeamLeader(nTeamNum)==oCreature) return TRUE;
sID=GetPCPublicCDKey(oCreature)+"_"+GetName(oCreature);
return NBDE_GetCampaignInt(sDB,"bCR_"+sID);
} // PC
else
{ // NPC
nTeamNum=GetLocalInt(oCreature,"nTeamNum");
if (Team_GetTeamLeader(nTeamNum)==oCreature) return TRUE;
sID=IntToString(GetLocalInt(oCreature,"nUID"));
return NBDE_GetCampaignInt(sDB,"bCR_"+sID);
} // NPC
return FALSE;
} // Team_SetCreationRights()
void Team_SetPCRelation(object oPC)
{ // PURPOSE: Adjust the relations of all teams with regards to this PC
string sTeamID=PC_GetTeamID(oPC);
int nTeamNum=PC_GetTeamNum(oPC);
int nTN=1;
string sTID;
object oProxy;
int nR;
sTID=lib_DataGetStoredTeamID(nTN);
while(GetStringLength(sTID)>0)
{ // process each team
oProxy=GetObjectByTag("proxy_"+sTID);
if (GetIsObjectValid(oProxy))
{ // proxy found
nR=Team_GetRelation(nTeamNum,nTN);
if (nTeamNum==nTN) nR=1;
if (nR==0)
{ // neutral
nR=GetReputation(oProxy,oPC);
if (nR<21) AdjustReputation(oPC,oProxy,50-nR);
else if (nR>79) AdjustReputation(oPC,oProxy,50-nR);
} // neutral
else if (nR==1)
{ // friend
AdjustReputation(oPC,oProxy,100);
} // friend
else if (nR==-1)
{ // enemy
AdjustReputation(oPC,oProxy,-100);
} // enemy
} // proxy found
nTN++;
sTID=lib_DataGetStoredTeamID(nTN);
} // process each team
} // Team_SetPCRelation()
void Team_SetAllPCRelations()
{ // PURPOSE: Adjust all PC relations
object oPC=GetFirstPC();
float fDelay=0.1;
while(GetIsObjectValid(oPC))
{ // all PCs
DelayCommand(fDelay,Team_SetPCRelation(oPC));
oPC=GetNextPC();
fDelay=fDelay+0.25;
} // all PCs
} // Team_SetAllPCRelations()
//void main(){}