// control_point_hb void main() { object oMe = OBJECT_SELF; object oCreature; int bChangeTeams = FALSE; string sNewTeam = "NA"; string sID = GetLocalString(oMe, "sTeamID"); object oNew; int nC; int nL; int bDefendersPresent = FALSE; int nNum = GetLocalInt(oMe, "nNum"); int nEnemiesNear = 0; int nUnaffiliatedNear = 0; int bSPID = FALSE; int bDWF = FALSE; int bUNC = FALSE; int bUND = FALSE; string sEnemyID = ""; object oWP = GetWaypointByTag("CONTROL_POINT" + IntToString(nNum)); object oGarrison = GetLocalObject(oWP, "oGarrison"); float fDist; string sS; int bDestroyed = FALSE; // Flag to prevent multiple destruction calls SetLocalString(oWP, "sTeamID", sID); nC = 1; oCreature = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, oMe, nC); while (oCreature != OBJECT_INVALID) { fDist = GetDistanceBetween(oMe, oCreature); // Recalculate distance if (fDist >= 10.0) break; // Exit if the creature is out of range sS = GetLocalString(oCreature, "sTeamID"); if (sS == sID) { bDefendersPresent = TRUE; } else if (sS == "SPID") { nEnemiesNear++; bSPID = TRUE; } else if (sS == "UNC") { nEnemiesNear++; bUNC = TRUE; } else if (sS == "UND") { nEnemiesNear++; bUND = TRUE; } else if (sS == "DWF") { nEnemiesNear++; bDWF = TRUE; } else if (GetMaster(oCreature) == OBJECT_INVALID && GetTag(oCreature) != "listener") { nUnaffiliatedNear++; } nC++; oCreature = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, oMe, nC); // Get next creature } if (bDefendersPresent == FALSE) { if (nUnaffiliatedNear != 0 || (nEnemiesNear < 3 && nEnemiesNear > 0)) { // Change to FREE control point if (oGarrison != OBJECT_INVALID) DestroyObject(oGarrison); oNew = CreateObject(OBJECT_TYPE_PLACEABLE, "controlna", GetLocation(oWP)); SetLocalObject(oWP, "oShaft", oNew); SetLocalString(oWP, "sTeamID", "NA"); SetLocalString(oNew, "sTeamID", "NA"); SetLocalInt(oNew, "nNum", nNum); if (!bDestroyed) { DelayCommand(1.0, DestroyObject(oMe)); bDestroyed = TRUE; } } else if (nEnemiesNear > 2 && nUnaffiliatedNear == 0) { // Possibly controlled by a new team nC = 0; if (bSPID == TRUE) { nC++; sEnemyID = "SPID"; } if (bDWF == TRUE) { nC++; sEnemyID = "DWF"; } if (bUNC == TRUE) { nC++; sEnemyID = "UNC"; } if (bUND == TRUE) { nC++; sEnemyID = "UND"; } if (nC == 1) { // Change control if (oGarrison != OBJECT_INVALID) DestroyObject(oGarrison); oNew = CreateObject(OBJECT_TYPE_PLACEABLE, "control" + sEnemyID, GetLocation(oWP)); SetLocalObject(oWP, "oShaft", oNew); SetLocalString(oWP, "sTeamID", sEnemyID); SetLocalString(oNew, "sTeamID", sEnemyID); SetLocalInt(oNew, "nNum", nNum); oGarrison = CreateObject(OBJECT_TYPE_PLACEABLE, "garrison" + sEnemyID, GetLocation(oWP)); SetLocalObject(oWP, "oGarrison", oGarrison); if (!bDestroyed) { DelayCommand(1.0, DestroyObject(oMe)); bDestroyed = TRUE; } } } } } /* // control_point_hb void main() { object oMe=OBJECT_SELF; object oCreature; int bChangeTeams=FALSE; string sNewTeam="NA"; string sID=GetLocalString(oMe,"sTeamID"); object oNew; int nC; int nL; int bDefendersPresent=FALSE; int nNum=GetLocalInt(oMe,"nNum"); int nEnemiesNear=0; int nUnaffiliatedNear=0; int bSPID=FALSE; int bDWF=FALSE; int bUNC=FALSE; int bUND=FALSE; string sEnemyID; object oWP=GetWaypointByTag("CONTROL_POINT"+IntToString(nNum)); object oGarrison=GetLocalObject(oWP,"oGarrison"); float fDist; string sS; SetLocalString(oWP,"sTeamID",sID); nC=1; oCreature=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,nC); fDist=GetDistanceBetween(oMe,oCreature); while(oCreature!=OBJECT_INVALID&&fDist<10.0) { // near sS=GetLocalString(oCreature,"sTeamID"); if (sS==sID) { bDefendersPresent=TRUE; } else if (sS=="SPID") { nEnemiesNear++; bSPID=TRUE; } else if (sS=="UNC") { nEnemiesNear++; bUNC=TRUE; } else if (sS=="UND") { nEnemiesNear++; bUND=TRUE; } else if (sS=="DWF") { nEnemiesNear++; bDWF=TRUE; } else if (GetMaster(oCreature)==OBJECT_INVALID&&GetTag(oCreature)!="listener") { nUnaffiliatedNear++; } nC++; oCreature=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,nC); fDist=GetDistanceBetween(oMe,oCreature); } // near if (bDefendersPresent==FALSE) { // check to see if change control if (nUnaffiliatedNear!=0||(nEnemiesNear<3&&nEnemiesNear>0)) { // change to FREE control point if (oGarrison!=OBJECT_INVALID) DestroyObject(oGarrison); oNew=CreateObject(OBJECT_TYPE_PLACEABLE,"controlna",GetLocation(oWP)); SetLocalObject(oWP,"oShaft",oNew); SetLocalString(oWP,"sTeamID","NA"); SetLocalString(oNew,"sTeamID","NA"); SetLocalInt(oNew,"nNum",nNum); DelayCommand(1.0,DestroyObject(oMe)); } // change to FREE control point else if (nEnemiesNear>2&&nUnaffiliatedNear==0) { // possibly controlled by a new team nC=0; if (bSPID==TRUE) { nC++; sEnemyID="SPID"; } if (bDWF==TRUE) { nC++; sEnemyID="DWF"; } if (bUNC==TRUE) { nC++; sEnemyID="UNC"; } if (bUND==TRUE) { nC++; sEnemyID="UND"; } if (nC==1) { // change control if (oGarrison!=OBJECT_INVALID) DestroyObject(oGarrison); oNew=CreateObject(OBJECT_TYPE_PLACEABLE,"control"+sEnemyID,GetLocation(oWP)); SetLocalObject(oWP,"oShaft",oNew); SetLocalString(oWP,"sTeamID",sEnemyID); SetLocalString(oNew,"sTeamID",sEnemyID); SetLocalInt(oNew,"nNum",nNum); oGarrison=CreateObject(OBJECT_TYPE_PLACEABLE,"garrison"+sEnemyID,GetLocation(oWP)); SetLocalObject(oWP,"oGarrison",oGarrison); DelayCommand(1.0,DestroyObject(oMe)); } // change control } // possibly controlled by a new team } // check to see if change control } */