generated from Jaysyn/ModuleTemplate
Initial commit
Initial commit
This commit is contained in:
208
_module/nss/os_arm_arbh.nss
Normal file
208
_module/nss/os_arm_arbh.nss
Normal file
@@ -0,0 +1,208 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Siege Arbalest Heavy - Initiates Load Sequence
|
||||
// os_arm_arbh
|
||||
// by Don Anderson
|
||||
// dandersonru@msn.com
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "os_inc"
|
||||
|
||||
void main()
|
||||
{
|
||||
object oArbalest = OBJECT_SELF;
|
||||
|
||||
int nSelfFaction = GetLocalInt(oArbalest,"FACTION");
|
||||
int nLoaded = GetLocalInt(oArbalest,"LOADED");
|
||||
location lLoc = GetLocation(oArbalest);
|
||||
|
||||
//Find closest related Switch
|
||||
object oSwitch = GetNearestObjectByTag("SiegeSwitch",oArbalest,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(oArbalest,SpeakString("Heavy Arbalest standing down!"));
|
||||
SetLocalInt(oArbalest,"LOADED",0);
|
||||
SetLocalInt(oArbalest,"ACQUIRED",0);
|
||||
return;
|
||||
}
|
||||
|
||||
//Find a Valid Spear Rack
|
||||
object oBSpear = GetNearestObjectByTag("ArbalestSpears",oArbalest,1);
|
||||
if(oBSpear != OBJECT_INVALID && nLoaded == 0)
|
||||
{
|
||||
float fDist = GetDistanceToObject(oBSpear);
|
||||
if(fDist <= SIEGE_SUPPLY)
|
||||
{
|
||||
//Check for Available Spears
|
||||
int nSpears = GetLocalInt(oBSpear,"AMMOQTY");
|
||||
if(nSpears > 0)
|
||||
{
|
||||
nSpears--;
|
||||
SetLocalInt(oBSpear,"AMMOQTY",nSpears);
|
||||
SetLocalInt(oArbalest,"LOADED",1);
|
||||
SetLocalInt(oArbalest,"ACQUIRED",0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Destroy Existing and Find Another
|
||||
DestroyObject(oBSpear,0.1);
|
||||
DelayCommand(1.0,ExecuteScript("os_arm_arbh",oArbalest));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DelayCommand(1.0,SpeakString("Heavy Arbalest standing down....no Spears available!"));
|
||||
SetLocalInt(oArbalest,"LOADED",0);
|
||||
SetLocalInt(oArbalest,"ACQUIRED",0);
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
//: SIEGE ARBALEST HEAVY
|
||||
|
||||
//Now the ammunition is properly loaded and the firing sequence takes place
|
||||
if(GetLocalInt(oArbalest,"LOADED") == 1)
|
||||
{
|
||||
//Now we look for creatures
|
||||
if(GetLocalInt(oArbalest,"ACQUIRED") == 0)
|
||||
{
|
||||
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEARBALEST_HVY, lLoc, TRUE, OBJECT_TYPE_CREATURE);
|
||||
while (GetIsObjectValid(oTarget))
|
||||
{
|
||||
location lType = GetLocation(oTarget);
|
||||
string sType = GetTag(oTarget);
|
||||
|
||||
fSDist = GetDistanceToObject(oTarget);
|
||||
if(fSDist >= MINRANGE_SIEGEARBALEST_HVY)
|
||||
{
|
||||
//OK to Fire On?
|
||||
if(GetPlotFlag(oTarget) == FALSE)
|
||||
{
|
||||
nFaction = GetLocalInt(oTarget,"FACTION");
|
||||
int nNPCHP = GetCurrentHitPoints(oTarget);
|
||||
if(nNPCHP >= 1 && (nFaction != nSelfFaction))
|
||||
{
|
||||
SetLocalInt(oArbalest,"ACQUIRED",1);
|
||||
oAcquire = oTarget;
|
||||
break;//Acquired Target
|
||||
}
|
||||
}
|
||||
}
|
||||
oTarget = GetNextObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEARBALEST_HVY, lLoc, TRUE, OBJECT_TYPE_CREATURE);
|
||||
}
|
||||
}
|
||||
|
||||
//Now we check for Siege Weapons
|
||||
if(GetLocalInt(oArbalest,"ACQUIRED") == 0)
|
||||
{
|
||||
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEARBALEST_HVY, lLoc, TRUE, OBJECT_TYPE_PLACEABLE);
|
||||
while (GetIsObjectValid(oTarget))
|
||||
{
|
||||
location lType = GetLocation(oTarget);
|
||||
string sType = GetTag(oTarget);
|
||||
|
||||
fSDist = GetDistanceToObject(oTarget);
|
||||
if((fSDist >= MINRANGE_SIEGEARBALEST_HVY) &&
|
||||
(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(oArbalest,"ACQUIRED",1);
|
||||
oAcquire = oTarget;
|
||||
break;//Acquired Target
|
||||
}
|
||||
}
|
||||
}
|
||||
oTarget = GetNextObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEARBALEST_HVY, lLoc, TRUE, OBJECT_TYPE_PLACEABLE);
|
||||
}
|
||||
}
|
||||
|
||||
//Now we look for doors
|
||||
if(GetLocalInt(oArbalest,"ACQUIRED") == 0)
|
||||
{
|
||||
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEARBALEST_HVY, lLoc, TRUE, OBJECT_TYPE_DOOR);
|
||||
while (GetIsObjectValid(oTarget))
|
||||
{
|
||||
location lType = GetLocation(oTarget);
|
||||
string sType = GetTag(oTarget);
|
||||
|
||||
fSDist = GetDistanceToObject(oTarget);
|
||||
if(fSDist >= MINRANGE_SIEGEARBALEST_HVY)
|
||||
{
|
||||
//OK to Fire On?
|
||||
if(GetPlotFlag(oTarget) == FALSE)
|
||||
{
|
||||
int nNPCHP = GetCurrentHitPoints(oTarget);
|
||||
if(nNPCHP >= 1)
|
||||
{
|
||||
SetLocalInt(oArbalest,"ACQUIRED",1);
|
||||
oAcquire = oTarget;
|
||||
break;//Acquired Target
|
||||
}
|
||||
}
|
||||
}
|
||||
oTarget = GetNextObjectInShape(SHAPE_SPHERE, MAXRANGE_SIEGEARBALEST_HVY, lLoc, TRUE, OBJECT_TYPE_DOOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//: SIEGE ARBALEST HEAVY
|
||||
/*******************************************************************************/
|
||||
|
||||
if(GetLocalInt(oArbalest,"LOADED") == 1)
|
||||
{
|
||||
//Now we either stand down or range and face the target
|
||||
if(GetLocalInt(oArbalest,"ACQUIRED") == 0)
|
||||
{
|
||||
AssignCommand(oArbalest,DelayCommand(1.0,SpeakString("Heavy Arbalest standing down....no valid targets!")));
|
||||
SetLocalInt(oArbalest,"LOADED",0);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
sTarget = GetName(oAcquire);
|
||||
float fDTarget = GetDistanceToObject(oAcquire);
|
||||
SetLocalFloat(oArbalest,"RANGE",fDTarget);
|
||||
|
||||
SetFacingObject(oAcquire);
|
||||
}
|
||||
|
||||
//Get Range in Integer Format
|
||||
int nDTarget = FloatToInt(GetLocalFloat(oArbalest,"RANGE"));
|
||||
|
||||
//Now we start the Firing Process
|
||||
if(GetLocalInt(oArbalest,"LOADED") == 1)
|
||||
{
|
||||
AssignCommand(oArbalest,DelayCommand(1.0,SpeakString("Heavy Arbalest has acquired "+ sTarget +" as a Target!")));
|
||||
AssignCommand(oArbalest,DelayCommand(3.0,SpeakString("Range: "+ IntToString(nDTarget) +" Meters")));
|
||||
AssignCommand(oArbalest,DelayCommand(5.0,SpeakString("Arbalest Spear Ammunition Received!")));
|
||||
AssignCommand(oArbalest,DelayCommand(TIME_SIEGEARBALEST_HVY - 10.0,PlaySound("as_cv_ropepully1")));
|
||||
AssignCommand(oArbalest,DelayCommand(TIME_SIEGEARBALEST_HVY - 8.0,PlaySound("as_cv_ropecreak2")));
|
||||
AssignCommand(oArbalest,DelayCommand(TIME_SIEGEARBALEST_HVY - 6.0,SpeakString("Loaded!")));
|
||||
AssignCommand(oArbalest,DelayCommand(TIME_SIEGEARBALEST_HVY - 3.0,SpeakString("Ready!")));
|
||||
AssignCommand(oArbalest,DelayCommand(TIME_SIEGEARBALEST_HVY - 0.5,SpeakString("FIRE!")));
|
||||
AssignCommand(oArbalest,DelayCommand(TIME_SIEGEARBALEST_HVY,ExecuteScript("os_fire_arb",oArbalest)));
|
||||
AssignCommand(oArbalest,DelayCommand(TIME_SIEGEARBALEST_HVY + 10.0,ExecuteScript("os_arm_arbh",oArbalest)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user