// OE - AG - Central - spawn guards #include "antistuck_h" void fnWander(); // wandering AI string fnSpawnType(); // return resref of stage 2 evil fanatics void fnCleanStreets(); const string slStage1="SLAVER_HUNT2"; const string slStage2="SLAVER_HUNT3"; const string slStage3="MAGEASS_RALLY"; const string slStage4="S_AGCWN1"; const string slStage5="ET_S_AGCWS"; const string slStage6="S_AGCEN1"; const string slLeader="PLANAR_BREACH"; void main() { object oPC=GetEnteringObject(); object oArea=GetArea(oPC); object oWP=GetWaypointByTag("POST_CityGuard"); object oUnit; object oMod=GetModule(); int nEvilStage=GetLocalInt(oMod,"nEvilStage"); if (nEvilStage<2) { // evil does not reign here if (GetIsPC(oPC)==TRUE) { // spawn guards if none present oUnit=GetLocalObject(oArea,"CityGuard1"); if (oUnit==OBJECT_INVALID) { // spawn guard oUnit=CreateObject(OBJECT_TYPE_CREATURE,"cityguard",GetLocation(oWP)); SetLocalObject(oArea,"CityGuard1",oUnit); } // spawn guard oUnit=GetLocalObject(oArea,"CityGuard2"); if (oUnit==OBJECT_INVALID) { // spawn guard oUnit=CreateObject(OBJECT_TYPE_CREATURE,"cityguard",GetLocation(oWP)); SetLocalObject(oArea,"CityGuard2",oUnit); } // spawn guard oUnit=GetLocalObject(oArea,"CityGuard3"); if (oUnit==OBJECT_INVALID) { // spawn guard oUnit=CreateObject(OBJECT_TYPE_CREATURE,"cityguard",GetLocation(oWP)); SetLocalObject(oArea,"CityGuard3",oUnit); } // spawn guard oUnit=GetLocalObject(oArea,"CityGuard4"); if (oUnit==OBJECT_INVALID) { // spawn guard oUnit=CreateObject(OBJECT_TYPE_CREATURE,"cityguardcaptain",GetLocation(oWP)); SetLocalObject(oArea,"CityGuard4",oUnit); } // spawn guard oWP=oUnit; oUnit=GetLocalObject(oArea,"CityGuard1"); AssignCommand(oUnit,ActionForceFollowObject(oWP,2.5)); oUnit=GetLocalObject(oArea,"CityGuard2"); AssignCommand(oUnit,ActionForceFollowObject(oWP,2.5)); oUnit=GetLocalObject(oArea,"CityGuard3"); AssignCommand(oUnit,ActionForceFollowObject(oWP,2.5)); } // spawn guards if none present } // evil does not reign here if (nEvilStage>0) { // spawn a few fanatics oWP=GetWaypointByTag(slStage1); oUnit=GetLocalObject(oArea,"fanatic1"); if (oUnit==OBJECT_INVALID) { // spawn a fanatic oUnit=CreateObject(OBJECT_TYPE_CREATURE,"fanatic1",GetLocation(oWP)); SetLocalObject(oArea,"fanatic1",oUnit); AssignCommand(oUnit,fnWander()); } // spawn a fanatic oWP=GetWaypointByTag(slStage2); oUnit=GetLocalObject(oArea,"fanatic2"); if (oUnit==OBJECT_INVALID) { // spawn a fanatic oUnit=CreateObject(OBJECT_TYPE_CREATURE,"fanatic2",GetLocation(oWP)); SetLocalObject(oArea,"fanatic2",oUnit); AssignCommand(oUnit,fnWander()); } // spawn a fanatic } // spawn a few fanatics if (nEvilStage>1) { // stage 2 oWP=GetNearestObjectByTag(slStage3,oPC,1); oUnit=GetLocalObject(oArea,"fanatic3"); if (oUnit==OBJECT_INVALID) { // spawn a fanatic oUnit=CreateObject(OBJECT_TYPE_CREATURE,fnSpawnType(),GetLocation(oWP)); SetLocalObject(oArea,"fanatic3",oUnit); AssignCommand(oUnit,fnWander()); } // spawn a fanatic oWP=GetNearestObjectByTag(slStage4,oPC,1); oUnit=GetLocalObject(oArea,"fanatic4"); if (oUnit==OBJECT_INVALID) { // spawn a fanatic oUnit=CreateObject(OBJECT_TYPE_CREATURE,fnSpawnType(),GetLocation(oWP)); SetLocalObject(oArea,"fanatic4",oUnit); AssignCommand(oUnit,fnWander()); } // spawn a fanatic oWP=GetNearestObjectByTag(slStage5,oPC,1); oUnit=GetLocalObject(oArea,"fanatic5"); if (oUnit==OBJECT_INVALID) { // spawn a fanatic oUnit=CreateObject(OBJECT_TYPE_CREATURE,fnSpawnType(),GetLocation(oWP)); SetLocalObject(oArea,"fanatic5",oUnit); AssignCommand(oUnit,fnWander()); } // spawn a fanatic oWP=GetNearestObjectByTag(slStage6,oPC,1); oUnit=GetLocalObject(oArea,"fanatic6"); if (oUnit==OBJECT_INVALID) { // spawn a fanatic oUnit=CreateObject(OBJECT_TYPE_CREATURE,fnSpawnType(),GetLocation(oWP)); SetLocalObject(oArea,"fanatic6",oUnit); AssignCommand(oUnit,fnWander()); } // spawn a fanatic } // stage 2 if (nEvilStage>2) { // evil leader oWP=GetNearestObjectByTag(slLeader,oPC,1); oUnit=GetLocalObject(oArea,"fanaticl"); if (oUnit==OBJECT_INVALID) { // spawn a fanatic leader oUnit=CreateObject(OBJECT_TYPE_CREATURE,"fanatic5",GetLocation(oWP)); SetLocalObject(oArea,"fanaticl",oUnit); //AssignCommand(oUnit,fnWander()); } // spawn a fanatic leader oUnit=GetLocalObject(oArea,"slaad"); if (oUnit==OBJECT_INVALID) { // possibly summon a slaad if (d100()<6) { // summon a slaad oUnit=CreateObject(OBJECT_TYPE_CREATURE,"slaadgray001",GetLocation(oWP)); SetLocalObject(oArea,"slaad",oUnit); AssignCommand(oUnit,fnWander()); } // summon a slaad } // possibly summon a slaad } // evil leader ///// street cleaner oUnit=GetLocalObject(oArea,"StreetCleaner"); if (oUnit==OBJECT_INVALID||GetIsDead(oUnit)==TRUE) { // spawn street cleaner oWP=GetNearestObjectByTag("PLANAR_BREACH",oPC,1); oUnit=CreateObject(OBJECT_TYPE_CREATURE,"streetcleaner",GetLocation(oWP)); SetLocalObject(oArea,"StreetCleaner",oUnit); SetAILevel(oUnit,AI_LEVEL_NORMAL); //AssignCommand(oUnit,fnCleanStreets()); } // spawn street cleaner oUnit=GetLocalObject(oArea,"Beggar"); if (oUnit==OBJECT_INVALID) { // spawn beggar oWP=GetNearestObjectByTag("POST_Beggar",oPC,1); oUnit=CreateObject(OBJECT_TYPE_CREATURE,"beggar",GetLocation(oWP)); SetLocalObject(oArea,"Beggar",oUnit); } // spawn beggar if (GetIsPC(oPC)==TRUE&&GetIsDM(oPC)==FALSE) ExecuteScript("rts_save_player",oPC); ExecuteScript("area_visit",OBJECT_SELF); } void fnCleanStreets() { // clean streets of non-plot items dropped int nC; object oStore=GetObjectByTag("MercGuildOther"); object oItem; object oCItem; object oDest; int nR; int nS; float fDist; string sRes; object oTarget=GetLocalObject(OBJECT_SELF,"oTarget"); object oMe=OBJECT_SELF; float fSpeed=18.0; if (GetIsInCombat(oMe)==FALSE&&IsInConversation(oMe)==FALSE) { // not fighting or talking if (GetCurrentAction()!=ACTION_MOVETOPOINT) { // not moving so look for items to pick up... if none found move if (oTarget==OBJECT_INVALID) { // no target - find one nC=1; oItem=GetNearestObject(OBJECT_TYPE_ITEM,oMe,nC); fDist=GetDistanceBetween(oItem,oMe); while(oItem!=OBJECT_INVALID&&fDist<15.0&&oTarget==OBJECT_INVALID) { // looking for items on ground if (GetPlotFlag(oItem)==FALSE) oTarget=oItem; nC++; oItem=GetNearestObject(OBJECT_TYPE_ITEM,oMe,nC); fDist=GetDistanceBetween(oItem,oMe); } // looking for items on ground nC=1; oItem=GetNearestObject(OBJECT_TYPE_PLACEABLE,oMe,nC); fDist=GetDistanceBetween(oItem,oMe); while(oItem!=OBJECT_INVALID&&fDist<15.0&&oTarget==OBJECT_INVALID) { // look for containers if (GetPlotFlag(oItem)==FALSE&&GetHasInventory(oItem)==TRUE) oTarget=oItem; nC++; oItem=GetNearestObject(OBJECT_TYPE_PLACEABLE,oMe,nC); fDist=GetDistanceBetween(oItem,oMe); } // look for containers if (oTarget==OBJECT_INVALID) { // no targets - move to another location oDest=GetNearestObject(OBJECT_TYPE_WAYPOINT,oMe,d20()); AssignCommand(oMe,ASActionMoveToObject(oDest,TRUE,1.5)); fSpeed=18.0; } // no targets - move to another location else { // target found SetLocalObject(oMe,"oTarget",oTarget); fSpeed=2.0; } // target found } // no target - find one else { // move to and pickup/destroy target fDist=GetDistanceBetween(oMe,oTarget); fSpeed=6.0; if (fDist>2.2) { AssignCommand(oMe,ASActionMoveToObject(oTarget,TRUE,1.2)); } else { // close enough to item AssignCommand(oMe,ClearAllActions()); AssignCommand(oMe,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,4.0)); sRes=GetResRef(oTarget); nR=GetObjectType(oTarget); DelayCommand(4.1,DestroyObject(oTarget)); if (nR!=OBJECT_TYPE_PLACEABLE) { nC=GetGoldPieceValue(oTarget); nS=GetItemStackSize(oTarget); if (nC>49) { // put item in merc guild other store oItem=CreateItemOnObject(sRes,oStore,nS); } // put item in merc guild other store else { // add gold available to merc guild other nS=GetStoreGold(oStore); nS=nS+GetGoldPieceValue(oTarget); SetStoreGold(oStore,nS); } // add gold available to merc guild other } else { // container check contents oCItem=GetFirstItemInInventory(oTarget); while(oCItem!=OBJECT_INVALID) { // put items in store nC=GetGoldPieceValue(oCItem); nS=GetItemStackSize(oCItem); sRes=GetResRef(oCItem); if (nC>49) { // put item in merc guild other store oItem=CreateItemOnObject(sRes,oStore,nS); } // put item in merc guild other store else { // add gold available to merc guild other nS=GetStoreGold(oStore); nS=nS+GetGoldPieceValue(oCItem); SetStoreGold(oStore,nS); } // add gold available to merc guild other oCItem=GetNextItemInInventory(oTarget); } // put items in store } // container check contents SetLocalObject(oMe,"oTarget",OBJECT_INVALID); } // close enough to item } // move to and pickup/destroy target } // not moving so look for items to pick up... if none found move } // not fighting or talking DelayCommand(fSpeed,fnCleanStreets()); } // fnCleanStreets() string fnSpawnType() { // return resref of stage 2 spawn type int nR=d100(); if (nR<26) return "fanatic1"; else if (nR<51) return "fanatic2"; else if (nR<66) return "fanaticcm"; else if (nR<81) return "fanaticcf"; else if (nR<96) return "fanatic3"; return "fanatic4"; } // return resref of stage 2 spawn type void fnWander() { // wandering AI object oMe=OBJECT_SELF; object oDest; int nR; if (GetIsInCombat(oMe)==FALSE&&IsInConversation(oMe)==FALSE) { // move AI if(GetCurrentAction()!=ACTION_MOVETOPOINT) { // needs a new action nR=d6(); if (nR==1) { // sit crosslegged AssignCommand(oMe,ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS,1.0,17.0)); } // sit crosslegged else { // move oDest=GetNearestObject(OBJECT_TYPE_WAYPOINT,oMe,d20()); AssignCommand(oMe,ASActionMoveToObject(oDest,FALSE,1.0)); } // move } // needs a new action } // move AI DelayCommand(18.0,fnWander()); } // fnWander()