Rune_PRC8/_module/nss/os_fire_ona.nss
Jaysyn904 d1c309ae63 Initial commit
Initial commit
2024-09-13 09:10:39 -04:00

111 lines
3.0 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
//
// Siege Onager - Fires the Projectile
// os_fire_ona
// by Don Anderson
// dandersonru@msn.com
//
////////////////////////////////////////////////////////////////////////////////
#include "os_inc"
void main()
{
object oOnager = OBJECT_SELF;
string sOnager = GetTag(oOnager);
object oArea = GetArea(oOnager);
object oPC = GetPCSpeaker();
vector vCurrentPosition = GetPosition(oOnager);
float fCurrentFacing = GetFacing(oOnager);
//Calculate the target location.
float fRange = GetLocalFloat(oOnager, "RANGE");
if (fCurrentFacing > 360.0)
{
fCurrentFacing = 720 - fCurrentFacing;
}
int nRX = Random(2);
int nRY = Random(2);
int nRN = Random(2);
//Positive Error
if(nRN == 0) nRX = nRX;
//Negative Error
if(nRN == 1) nRX = nRX * (-1);
//Positive Error
if(nRN == 0) nRY = nRY;
//Negative Error
if(nRN == 1) nRY = nRY * (-1);
//Total Range Error for Location Target
float fMult = IntToFloat(d3(1));
float fError = SIEGE_ERRANT * fRange * fMult;
vector vDelta;
//On Target
if (fError <= 2.0)
{
vDelta.x = cos(fCurrentFacing) * fRange;
vDelta.y = sin(fCurrentFacing) * fRange;
AssignCommand(oOnager, SpeakString("Projectile away and on target!"));
}
//A little off Target
else
{
vDelta.x = cos(fCurrentFacing) * (fRange + (fError * IntToFloat(nRX)));
vDelta.y = sin(fCurrentFacing) * (fRange + (fError * IntToFloat(nRY)));
AssignCommand(oOnager, SpeakString("Projectile away and a little off target!"));
}
vector vImpact;
vImpact.x = vCurrentPosition.x + vDelta.x;
vImpact.y = vCurrentPosition.y + vDelta.y;
location lLoc = Location(oArea, vImpact, fCurrentFacing);
float fImpactDelay = fRange/16;
//Play the Onager's VFX
effect eImpact;
effect eBump;
int nSpell;
int nAmmo;
float fRadius;
PlaySound("cb_sh_catapult");
if(GetLocalInt(oOnager,"LOADED") == 1)
{
//Caltrop Grenade was Loaded
if(GetLocalInt(oOnager,"AMMOTYPE") == CALTROPS)
{
eImpact = EffectVisualEffect(VFX_DUR_CALTROPS);
nSpell = SPELL_GRENADE_CALTROPS;
CaltropSpread(lLoc,fImpactDelay,eImpact,nSpell);
DeleteLocalInt(oOnager,"AMMOTYPE");
SetLocalInt(oOnager,"LOADED",0);
DeleteLocalInt(oOnager,"AMMOTYPE");
}
//Oil was Loaded
if(GetLocalInt(oOnager,"AMMOTYPE") == OIL)
{
eImpact = EffectVisualEffect(VFX_FNF_GAS_EXPLOSION_GREASE);
eBump = EffectVisualEffect(VFX_FNF_SCREEN_BUMP);
nSpell = SPELL_GREASE;
fRadius = IntToFloat(AOE_PER_GREASE);
nAmmo = OIL;
OilBlast(lLoc,fImpactDelay,eImpact,eBump,nSpell,fRadius,nAmmo);
DeleteLocalInt(oOnager,"AMMOTYPE");
SetLocalInt(oOnager,"LOADED",0);
DeleteLocalInt(oOnager,"AMMOTYPE");
}
}
}