//////////////////////////////////////////////////////////////////////////////// // // Siege Bricole - Initiates Load Sequence // os_arm_bri // by Don Anderson // dandersonru@msn.com // //////////////////////////////////////////////////////////////////////////////// #include "os_inc" void main() { object oBricole = OBJECT_SELF; int nSelfFaction = GetLocalInt(oBricole,"FACTION"); int nLoaded = GetLocalInt(oBricole,"LOADED"); location lLoc = GetLocation(oBricole); //Find closest related Switch object oSwitch = GetNearestObjectByTag("SiegeSwitch",oBricole,1); float fSDist = GetDistanceToObject(oSwitch); if(fSDist > SIEGE_SWITCH) return; int nFaction; object oTarget; object oAcquire; string sTarget; //Check for Active Fire Mode int nFMode = GetLocalInt(oSwitch,"FIREMODE"); if(nFMode < 1) { AssignCommand(oBricole,SpeakString("Bricole standing down!")); SetLocalInt(oBricole,"LOADED",0); SetLocalInt(oBricole,"ACQUIRED",0); return; } //Find a Valid Stone Pile object oStone = GetNearestObjectByTag("SiegeStones",oBricole,1); if(oStone != OBJECT_INVALID && nLoaded == 0) { float fDist = GetDistanceToObject(oStone); if(fDist <= SIEGE_SUPPLY) { //Check for Available Stones int nStones = GetLocalInt(oStone,"AMMOQTY"); if(nStones > 0) { nStones--; SetLocalInt(oStone,"AMMOQTY",nStones); SetLocalInt(oBricole,"LOADED",1); SetLocalInt(oBricole,"ACQUIRED",0); } else { //Destroy Existing and Find Another DestroyObject(oStone,0.1); DelayCommand(1.0,ExecuteScript("os_arm_bri",oBricole)); } } } else { DelayCommand(1.0,SpeakString("Bricole standing down....no Stones available!")); SetLocalInt(oBricole,"LOADED",0); SetLocalInt(oBricole,"ACQUIRED",0); return; } /*******************************************************************************/ //: SIEGE BRICOLE //Now the ammunition is properly loaded and the firing sequence takes place if(GetLocalInt(oBricole,"LOADED") == 1) { //Now we look for doors if(GetLocalInt(oBricole,"ACQUIRED") == 0) { object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEBRICOLE, lLoc, TRUE, OBJECT_TYPE_DOOR); while (GetIsObjectValid(oTarget)) { location lType = GetLocation(oTarget); string sType = GetTag(oTarget); fSDist = GetDistanceToObject(oTarget); if(fSDist >= MINRANGE_SIEGEBRICOLE) { //OK to Fire On? if(GetPlotFlag(oTarget) == FALSE) { int nNPCHP = GetCurrentHitPoints(oTarget); if(nNPCHP >= 1) { SetLocalInt(oBricole,"ACQUIRED",1); oAcquire = oTarget; break;//Acquired Target } } } oTarget = GetNextObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEBRICOLE, lLoc, TRUE, OBJECT_TYPE_DOOR); } } //Now we check for Siege Weapons if(GetLocalInt(oBricole,"ACQUIRED") == 0) { object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEBRICOLE, lLoc, TRUE, OBJECT_TYPE_PLACEABLE); while (GetIsObjectValid(oTarget)) { location lType = GetLocation(oTarget); string sType = GetTag(oTarget); fSDist = GetDistanceToObject(oTarget); if((fSDist >= MINRANGE_SIEGEBRICOLE) && (sType == SIEGEARBALEST_LGT || sType == SIEGEARBALEST_HVY || sType == SIEGECATAPULT_LGT || sType == SIEGECATAPULT_HVY || sType == SIEGEBRICOLE || sType == SIEGECOUILLARD || sType == SIEGEPERRIERE || sType == SIEGEONAGER)) { //OK to Fire On? if(GetPlotFlag(oTarget) == FALSE) { nFaction = GetLocalInt(oTarget,"FACTION"); int nNPCHP = GetCurrentHitPoints(oTarget); if(nNPCHP >= 1 && (nFaction != nSelfFaction)) { SetLocalInt(oBricole,"ACQUIRED",1); oAcquire = oTarget; break;//Acquired Target } } } oTarget = GetNextObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEBRICOLE, lLoc, TRUE, OBJECT_TYPE_PLACEABLE); } } //Now we look for creatures if(GetLocalInt(oBricole,"ACQUIRED") == 0) { object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEBRICOLE, lLoc, TRUE, OBJECT_TYPE_CREATURE); while (GetIsObjectValid(oTarget)) { location lType = GetLocation(oTarget); string sType = GetTag(oTarget); fSDist = GetDistanceToObject(oTarget); if(fSDist >= MINRANGE_SIEGEBRICOLE) { //OK to Fire On? if(GetPlotFlag(oTarget) == FALSE) { nFaction = GetLocalInt(oTarget,"FACTION"); int nNPCHP = GetCurrentHitPoints(oTarget); if(nNPCHP >= 1 && (nFaction != nSelfFaction)) { SetLocalInt(oBricole,"ACQUIRED",1); oAcquire = oTarget; break;//Acquired Target } } } oTarget = GetNextObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEBRICOLE, lLoc, TRUE, OBJECT_TYPE_CREATURE); } } } //: SIEGE BRICOLE /*******************************************************************************/ if(GetLocalInt(oBricole,"LOADED") == 1) { //Now we either stand down or range and face the target if(GetLocalInt(oBricole,"ACQUIRED") == 0) { AssignCommand(oBricole,DelayCommand(1.0,SpeakString("Bricole standing down....no valid targets!"))); SetLocalInt(oBricole,"LOADED",0); return; } else { sTarget = GetName(oAcquire); float fDTarget = GetDistanceToObject(oAcquire); SetLocalFloat(oBricole,"RANGE",fDTarget); SetFacingObject(oAcquire); } //Get Range in Integer Format int nDTarget = FloatToInt(GetLocalFloat(oBricole,"RANGE")); //Now we start the Firing Process if(GetLocalInt(oBricole,"LOADED") == 1) { AssignCommand(oBricole,DelayCommand(1.0,SpeakString("Bricole has acquired "+ sTarget +" as a Target!"))); AssignCommand(oBricole,DelayCommand(3.0,SpeakString("Range: "+ IntToString(nDTarget) +" Meters"))); AssignCommand(oBricole,DelayCommand(5.0,SpeakString("Siege Stone Ammunition Received!"))); AssignCommand(oBricole,DelayCommand(TIME_SIEGEBRICOLE - 10.0,PlaySound("as_cv_ropepully1"))); AssignCommand(oBricole,DelayCommand(TIME_SIEGEBRICOLE - 8.0,PlaySound("as_cv_ropecreak2"))); AssignCommand(oBricole,DelayCommand(TIME_SIEGEBRICOLE - 6.0,SpeakString("Loaded!"))); AssignCommand(oBricole,DelayCommand(TIME_SIEGEBRICOLE - 3.0,SpeakString("Ready!"))); AssignCommand(oBricole,DelayCommand(TIME_SIEGEBRICOLE - 0.5,SpeakString("FIRE!"))); AssignCommand(oBricole,DelayCommand(TIME_SIEGEBRICOLE,ExecuteScript("os_fire_cou",oBricole))); AssignCommand(oBricole,DelayCommand(TIME_SIEGEBRICOLE + 10.0,ExecuteScript("os_arm_bri",oBricole))); } } }