//////////////////////////////////////////////////////////////////////////////// // // Siege Arbalest - Fires the Projectile // os_fire_arb // by Don Anderson // dandersonru@msn.com // //////////////////////////////////////////////////////////////////////////////// #include "os_inc" void main() { object oArbalest = OBJECT_SELF; string sArbalest = GetTag(oArbalest); object oArea = GetArea(oArbalest); object oPC = GetPCSpeaker(); vector vCurrentPosition = GetPosition(oArbalest); float fCurrentFacing = GetFacing(oArbalest); //Calculate the target location. float fRange = GetLocalFloat(oArbalest, "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 = 3.0; if(sArbalest == SIEGEARBALEST_LGT) fMult = IntToFloat(d3(1)); if(sArbalest == SIEGEARBALEST_HVY) fMult = IntToFloat(d2(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(oArbalest, 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(oArbalest, 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/25; //Play the Spear's VFX effect eImpact; effect eBump; int nSpell; int nAmmo; float fRadius; //Arbalest Spear was Loaded if(GetLocalInt(oArbalest,"LOADED") == 1) { eImpact = EffectVisualEffect(VFX_COM_CHUNK_STONE_SMALL); eBump = EffectVisualEffect(VFX_FNF_SCREEN_BUMP); nSpell = SPELL_TRAP_ARROW; fRadius = SPEAR_RADIUS; nAmmo = SPEAR; SpearBlast(lLoc,fImpactDelay,eImpact,eBump,nSpell,fRadius,nAmmo); DeleteLocalInt(oArbalest,"AMMOTYPE"); SetLocalInt(oArbalest,"LOADED",0); } }