Author Topic: Alt-Fire  (Read 2075 times)

The script is from the Force-A-Nature and designed for that model. They have different animations.

I know Strato, It's because i've messed everything. :/

The FaN Script is Diferent from Lupara's, like Space Said
Also... What are the animations names? :D

EDIT: if i Make another BAR using the FaN script... The animation of it would work?
« Last Edit: October 28, 2009, 10:23:53 AM by Khain »

Well i've remade Heedcalking's BAR Ammo Script, but it doesn't work correctly.
It's Made to shoot 20 Bullets, but it does shoot 14. :/

Code: [Select]
Loading Add-On: Weapon_BAR (CRC:-1161401726)
Executing Add-Ons/Weapon_BAR/server.cs.
Executing Add-Ons/Weapon_BAR/Weapon_BAR.cs.
ShapeBaseImageData:: Could not resolve state "Ammo14Ready" for image "BARImage"
Executing Add-Ons/Weapon_BAR/Support_RaycastingWeapons.cs.
Activating package: RaycastingFire
 package RaycastingFire is already active
6 datablocks added.

Console won't help. Also, what is raycasting for? BAR does not use raycasting support.

Console won't help. Also, what is raycasting for? BAR does not use raycasting support.
It does!! I did add to it :D

EDIT: I've used Support_RaycastingWeapons
Space Guy's Script
« Last Edit: October 28, 2009, 05:09:17 PM by Khain »

Ammo Code:
Code: [Select]
  // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Reload";
stateSound[0] = weaponSwitchSound;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "Ammo1";
stateAllowImageChange[1]         = true;
stateSequence[1] = "Ready";

//reload passage!

stateName[2]                     = "Reload";
stateAllowImageChange[2]         = true;
stateSequence[2]                = "Reload";
stateScript[2]                  = "Reload";
stateSequence[2] = "Reload";
stateTransitionOnTimeout[2]     = "Reload2";
stateWaitForTimeout[2] = true;
stateTimeoutValue[2] = 0.75;
stateSound[2] = BARReloadSound;

stateName[3]                     = "Reload2";
stateAllowImageChange[3]         = true;
stateSequence[3]                = "Reload2";
stateScript[3]                  = "Reload2";
stateSequence[3] = "Reload2";
stateTransitionOnTimeout[3]     = "Ready";
stateWaitForTimeout[3] = true;
stateTimeoutValue[3] = 0.85;
stateSound[3] = BARReload2Sound;

//ammo passage and firing
//first shot

stateName[4]                    = "Ammo1";
stateTransitionOnTimeout[4]     = "Ammo1Ready";
stateTimeoutValue[4]            = 0.20;
stateFire[4]                    = true;
stateAllowImageChange[4]        = false;
stateSequence[4]                = "nil";
stateScript[4]                  = "onFire";
stateWaitForTimeout[4] = true;
stateEmitter[4] = gunFlashEmitter;
stateEmitterTime[4] = 0.02;
stateEmitterNode[4] = "muzzleNode";
stateSound[4] = BARShotSound;

stateName[5]                     = "Ammo1Ready";
stateTransitionOnTriggerDown[5]  = "Ammo2";
stateAllowImageChange[5]         = true;
stateSequence[5] = "Ready";

//second shot

stateName[6]                    = "Ammo2";
stateTransitionOnTimeout[6]     = "Ammo2Ready";
stateTimeoutValue[6]            = 0.20;
stateFire[6]                    = true;
stateAllowImageChange[6]        = false;
stateSequence[6]                = "nil";
stateScript[6]                  = "onFire";
stateWaitForTimeout[6] = true;
stateEmitter[6] = gunFlashEmitter;
stateEmitterTime[6] = 0.02;
stateEmitterNode[6] = "muzzleNode";
stateSound[6] = BARShotSound;

stateName[7]                     = "Ammo2Ready";
stateTransitionOnTriggerDown[7]  = "Ammo3";
stateAllowImageChange[7]         = true;
stateSequence[7] = "Ready";

//third shot

stateName[8]                    = "Ammo3";
stateTransitionOnTimeout[8]     = "Ammo3Ready";
stateTimeoutValue[8]            = 0.20;
stateFire[8]                    = true;
stateAllowImageChange[8]        = false;
stateSequence[8]                = "Fire";
stateScript[8]                  = "onFire";
stateWaitForTimeout[8] = true;
stateEmitter[8] = gunFlashEmitter;
stateEmitterTime[8] = 0.02;
stateEmitterNode[8] = "muzzleNode";
stateSound[8] = BARShotSound;

stateName[9]                     = "Ammo3Ready";
stateTransitionOnTriggerDown[9]  = "Ammo4";
stateAllowImageChange[9]         = true;
stateSequence[9] = "Ready";

//fourth shot

stateName[10]                    = "Ammo4";
stateTransitionOnTimeout[10]     = "Ammo4Ready";
stateTimeoutValue[10]            = 0.20;
stateFire[10]                    = true;
stateAllowImageChange[10]        = false;
stateSequence[10]                = "Fire";
stateScript[10]                  = "onFire";
stateWaitForTimeout[10] = true;
stateEmitter[10] = gunFlashEmitter;
stateEmitterTime[10] = 0.02;
stateEmitterNode[10] = "muzzleNode";
stateSound[10] = BARShotSound;

stateName[11]                     = "Ammo4Ready";
stateTransitionOnTriggerDown[11]  = "Ammo5";
stateAllowImageChange[11]         = true;
stateSequence[11] = "Ready";

//fifth shot

stateName[12]                    = "Ammo5";
stateTransitionOnTimeout[12]     = "Ammo5Ready";
stateTimeoutValue[12]            = 0.20;
stateFire[12]                    = true;
stateAllowImageChange[12]        = false;
stateSequence[12]                = "Fire";
stateScript[12]                  = "onFire";
stateWaitForTimeout[12] = true;
stateEmitter[12] = gunFlashEmitter;
stateEmitterTime[12] = 0.02;
stateEmitterNode[12] = "muzzleNode";
stateSound[12] = BARShotSound;

stateName[13]                     = "Ammo5Ready";
stateTransitionOnTriggerDown[13]  = "Ammo6";
stateAllowImageChange[13]         = true;
stateSequence[13] = "Ready";

//sixth shot

stateName[14]                    = "Ammo6";
stateTransitionOnTimeout[14]     = "Ammo6Ready";
stateTimeoutValue[14]            = 0.20;
stateFire[14]                    = true;
stateAllowImageChange[12]        = false;
stateSequence[14]                = "Fire";
stateScript[14]                  = "onFire";
stateWaitForTimeout[14] = true;
stateEmitter[14] = gunFlashEmitter;
stateEmitterTime[14] = 0.02;
stateEmitterNode[14] = "muzzleNode";
stateSound[14] = BARShotSound;

stateName[15]                     = "Ammo6Ready";
stateTransitionOnTriggerDown[15]  = "Ammo7";
stateAllowImageChange[15]         = true;
stateSequence[15] = "Ready";

//seventh shot

stateName[16]                    = "Ammo7";
stateTransitionOnTimeout[16]     = "Ammo7Ready";
stateTimeoutValue[16]            = 0.20;
stateFire[16]                    = true;
stateAllowImageChange[16]        = false;
stateSequence[16]                = "Fire";
stateScript[16]                  = "onFire";
stateWaitForTimeout[16] = true;
stateEmitter[16] = gunFlashEmitter;
stateEmitterTime[16] = 0.02;
stateEmitterNode[16] = "muzzleNode";
stateSound[16] = BARShotSound;

stateName[17]                     = "Ammo7Ready";
stateTransitionOnTriggerDown[17]  = "Ammo8";
stateAllowImageChange[17]         = true;
stateSequence[17] = "Ready";

//eighth shot

stateName[18]                    = "Ammo8";
stateTransitionOnTimeout[18]     = "Ammo8Ready";
stateTimeoutValue[18]            = 0.20;
stateFire[18]                    = true;
stateAllowImageChange[18]        = false;
stateSequence[18]                = "Fire";
stateScript[18]                  = "onFire";
stateWaitForTimeout[18] = true;
stateEmitter[18] = gunFlashEmitter;
stateEmitterTime[18] = 0.02;
stateEmitterNode[18] = "muzzleNode";
stateSound[18] = BARShotSound;

stateName[19]                     = "Ammo8Ready";
stateTransitionOnTriggerDown[19]  = "Ammo9";
stateAllowImageChange[19]         = true;
stateSequence[19] = "Ready";

//nineth shot

stateName[20]                    = "Ammo9";
stateTransitionOnTimeout[20]     = "Ammo9Ready";
stateTimeoutValue[20]            = 0.20;
stateFire[20]                    = true;
stateAllowImageChange[20]        = false;
stateSequence[20]                = "Fire";
stateScript[20]                  = "onFire";
stateWaitForTimeout[20] = true;
stateEmitter[20] = gunFlashEmitter;
stateEmitterTime[20] = 0.02;
stateEmitterNode[20] = "muzzleNode";
stateSound[20] = BARShotSound;

stateName[21]                     = "Ammo9Ready";
stateTransitionOnTriggerDown[21]  = "Ammo10";
stateAllowImageChange[21]         = true;
stateSequence[21] = "Ready";

//Tenth shot

stateName[22]                    = "Ammo10";
stateTransitionOnTimeout[22]     = "Ammo10Ready";
stateTimeoutValue[22]            = 0.20;
stateFire[22]                    = true;
stateAllowImageChange[22]        = false;
stateSequence[22]                = "Fire";
stateScript[22]                  = "onFire";
stateWaitForTimeout[22] = true;
stateEmitter[22] = gunFlashEmitter;
stateEmitterTime[22] = 0.02;
stateEmitterNode[22] = "muzzleNode";
stateSound[22] = BARShotSound;

stateName[23]                     = "Ammo10Ready";
stateTransitionOnTriggerDown[23]  = "Ammo11";
stateAllowImageChange[23]         = true;
stateSequence[23] = "Ready";

//Eleventh shot

stateName[24]                    = "Ammo11";
stateTransitionOnTimeout[24]     = "Ammo11Ready";
stateTimeoutValue[24]            = 0.20;
stateFire[24]                    = true;
stateAllowImageChange[24]        = false;
stateSequence[24]                = "Fire";
stateScript[24]                  = "onFire";
stateWaitForTimeout[24] = true;
stateEmitter[24] = gunFlashEmitter;
stateEmitterTime[24] = 0.02;
stateEmitterNode[24] = "muzzleNode";
stateSound[24] = BARShotSound;

stateName[25]                     = "Ammo11Ready";
stateTransitionOnTriggerDown[25]  = "Ammo12";
stateAllowImageChange[25]         = true;
stateSequence[25] = "Ready";

//Twleveth shot

stateName[26]                    = "Ammo12";
stateTransitionOnTimeout[26]     = "Ammo12Ready";
stateTimeoutValue[26]            = 0.20;
stateFire[26]                    = true;
stateAllowImageChange[26]        = false;
stateSequence[26]                = "Fire";
stateScript[26]                  = "onFire";
stateWaitForTimeout[26] = true;
stateEmitter[26] = gunFlashEmitter;
stateEmitterTime[26] = 0.02;
stateEmitterNode[26] = "muzzleNode";
stateSound[26] = BARShotSound;

stateName[27]                     = "Ammo12Ready";
stateTransitionOnTriggerDown[27]  = "Ammo13";
stateAllowImageChange[27]         = true;
stateSequence[27] = "Ready";

//Thirteenth shot

stateName[28]                    = "Ammo13";
stateTransitionOnTimeout[28]     = "Ammo13Ready";
stateTimeoutValue[28]            = 0.20;
stateFire[28]                    = true;
stateAllowImageChange[28]        = false;
stateSequence[28]                = "Fire";
stateScript[28]                  = "onFire";
stateWaitForTimeout[28] = true;
stateEmitter[28] = gunFlashEmitter;
stateEmitterTime[28] = 0.02;
stateEmitterNode[28] = "muzzleNode";
stateSound[28] = BARShotSound;

stateName[29]                     = "Ammo13Ready";
stateTransitionOnTriggerDown[29]  = "Ammo14";
stateAllowImageChange[29]         = true;
stateSequence[29] = "Ready";

//Fourteenth shot

stateName[30]                    = "Ammo14";
stateTransitionOnTimeout[30]     = "Ammo14Ready";
stateTimeoutValue[30]            = 0.20;
stateFire[30]                    = true;
stateAllowImageChange[30]        = false;
stateSequence[30]                = "Fire";
stateScript[30]                  = "onFire";
stateWaitForTimeout[30] = true;
stateEmitter[30] = gunFlashEmitter;
stateEmitterTime[30] = 0.02;
stateEmitterNode[30] = "muzzleNode";
stateSound[30] = BARShotSound;

stateName[31]                     = "Ammo14Ready";
stateTransitionOnTriggerDown[31]  = "Ammo15";
stateAllowImageChange[31]         = true;
stateSequence[31] = "Ready";

//Fifteenth shot

stateName[32]                    = "Ammo15";
stateTransitionOnTimeout[32]     = "Ammo15Ready";
stateTimeoutValue[32]            = 0.20;
stateFire[32]                    = true;
stateAllowImageChange[32]        = false;
stateSequence[32]                = "Fire";
stateScript[32]                  = "onFire";
stateWaitForTimeout[32] = true;
stateEmitter[32] = gunFlashEmitter;
stateEmitterTime[32] = 0.02;
stateEmitterNode[32] = "muzzleNode";
stateSound[32] = BARShotSound;

stateName[33]                     = "Ammo15Ready";
stateTransitionOnTriggerDown[33]  = "Ammo16";
stateAllowImageChange[33]         = true;
stateSequence[33] = "Ready";

//Sixteenth shot

stateName[34]                    = "Ammo16";
stateTransitionOnTimeout[34]     = "Ammo16Ready";
stateTimeoutValue[34]            = 0.20;
stateFire[34]                    = true;
stateAllowImageChange[34]        = false;
stateSequence[34]                = "Fire";
stateScript[34]                  = "onFire";
stateWaitForTimeout[34] = true;
stateEmitter[34] = gunFlashEmitter;
stateEmitterTime[34] = 0.02;
stateEmitterNode[34] = "muzzleNode";
stateSound[34] = BARShotSound;

stateName[35]                     = "Ammo16Ready";
stateTransitionOnTriggerDown[35]  = "Ammo17";
stateAllowImageChange[35]         = true;
stateSequence[35] = "Ready";

//Seventeenth shot

stateName[36]                    = "Ammo17";
stateTransitionOnTimeout[36]     = "Ammo17Ready";
stateTimeoutValue[36]            = 0.20;
stateFire[36]                    = true;
stateAllowImageChange[36]        = false;
stateSequence[36]                = "Fire";
stateScript[36]                  = "onFire";
stateWaitForTimeout[36] = true;
stateEmitter[36] = gunFlashEmitter;
stateEmitterTime[36] = 0.02;
stateEmitterNode[36] = "muzzleNode";
stateSound[36] = BARShotSound;

stateName[37]                     = "Ammo17Ready";
stateTransitionOnTriggerDown[37]  = "Ammo18";
stateAllowImageChange[37]         = true;
stateSequence[37] = "Ready";

//Eighteenth shot

stateName[38]                    = "Ammo18";
stateTransitionOnTimeout[38]     = "Ammo18Ready";
stateTimeoutValue[38]            = 0.20;
stateFire[38]                    = true;
stateAllowImageChange[38]        = false;
stateSequence[38]                = "Fire";
stateScript[38]                  = "onFire";
stateWaitForTimeout[38] = true;
stateEmitter[38] = gunFlashEmitter;
stateEmitterTime[38] = 0.02;
stateEmitterNode[38] = "muzzleNode";
stateSound[38] = BARShotSound;

stateName[39]                     = "Ammo18Ready";
stateTransitionOnTriggerDown[39]  = "Ammo19";
stateAllowImageChange[39]         = true;
stateSequence[39] = "Ready";

//Nineteenth shot

stateName[40]                    = "Ammo19";
stateTransitionOnTimeout[40]     = "Ammo19Ready";
stateTimeoutValue[40]            = 0.20;
stateFire[40]                    = true;
stateAllowImageChange[40]        = false;
stateSequence[40]                = "Fire";
stateScript[40]                  = "onFire";
stateWaitForTimeout[40] = true;
stateEmitter[40] = gunFlashEmitter;
stateEmitterTime[40] = 0.02;
stateEmitterNode[40] = "muzzleNode";
stateSound[40] = BARShotSound;

stateName[41]                     = "Ammo19Ready";
stateTransitionOnTriggerDown[41]  = "AmmoR";
stateAllowImageChange[41]         = true;
stateSequence[41] = "Ready";

//Twenty shot and loop back to reload

stateName[42]                    = "AmmoR";
stateTransitionOnTimeout[42]     = "Reload";
stateTimeoutValue[42]            = 0.14;
stateFire[42]                    = true;
stateAllowImageChange[42]        = false;
stateSequence[42]                = "Fire";
stateScript[42]                  = "onFire";
stateWaitForTimeout[42] = true;
stateEmitter[42] = gunFlashEmitter;
stateEmitterTime[42] = 0.02;
stateEmitterNode[42] = "muzzleNode";
stateSound[42] = BARShotSound;
};

function BARImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, plant);
Parent::onFire(%this,%obj,%slot);
}


You can only have up to 30 image states. Doing it like that is a really bad way of organising it. That's why I made the Force-A-Nature script since it avoids that and the need to reload every time you get the gun out.

You can only have up to 30 image states. Doing it like that is a really bad way of organising it. That's why I made the Force-A-Nature script since it avoids that and the need to reload every time you get the gun out.
Space, i know you did teach me the script about the ammo... But how do i set ammount of ammo? Like FaN has 2 Bullets how could i change it to have 20?

The item's maxAmmo parameter is the number of shots you get in it by default.
The item's canReload parameter, if enabled, sets the image ammo to 'off' when you press the Light key in a state named "Ready". You can use this to reload the weapon at any time.

Finally, Figured out that Ammo Script!
Thanks, Space Guy! :P

I did remove the ammo script. Adding Space's Ammo Script. A bit hard but i'm doing it :D