Author Topic: SEQUENCING HELP (Advanced Scripters See This)  (Read 1400 times)

it seems in my script ive been trying to make 6 shots then reload.. ubt too bad it always shoots and doesnt reload, although i set it to reload on the 6th shot, it wouldnt

check this out: (if you know how to make it better or some other way pls tell i really need it thx)
Quote
   // Initial start up state
   stateName[0]                     = "Activate";
   stateTimeoutValue[0]             = 0.15;
   stateTransitionOnTimeout[0]       = "Ready";
   stateSound[0]               = weaponSwitchSound;

   stateName[1]                     = "Ready";
   stateTransitionOnTriggerDown[1]  = "Fire";
   stateAllowImageChange[1]         = true;
   stateSequence[1]   = "Ready";
   
   stateName[2]                     = "Ready2";
   stateTransitionOnTriggerDown[2]  = "Fire2";
   stateAllowImageChange[2]         = true;
   stateSequence[2]   = "Ready";
   
   stateName[3]                     = "Ready3";
   stateTransitionOnTriggerDown[3]  = "Fire3";
   stateAllowImageChange[3]         = true;
   stateSequence[3]   = "Ready";
   
   stateName[4]                     = "Ready4";
   stateTransitionOnTriggerDown[4]  = "Fire4";
   stateAllowImageChange[4]         = true;
   stateSequence[4]   = "Ready";
   
   stateName[5]                     = "Ready5";
   stateTransitionOnTriggerDown[5]  = "Fire5";
   stateAllowImageChange[5]         = true;
   stateSequence[5]   = "Ready";
   
   stateName[6]                     = "Ready6";
   stateTransitionOnTriggerDown[6]  = "Fire6";
   stateAllowImageChange[6]         = true;
   stateSequence[6]   = "Ready";

   stateName[7]                    = "Fire";
   stateTransitionOnTimeout[7]     = "Smoke";
   stateTimeoutValue[7]            = 0.14;
   stateFire[7]                    = true;
   stateAllowImageChange[7]        = false;
   stateSequence[7]                = "Fire";
   stateScript[7]                  = "onFire";
   stateWaitForTimeout[7]         = true;
   stateEmitter[7]               = XM72FlashEmitter;
   stateEmitterTime[7]            = 0.05;
   stateEmitterNode[7]            = "muzzleNode";
   stateSound[7]               = XM72Shot1Sound;
   stateEjectShell[7]       = true;

   stateName[8] = "Smoke";
   stateEmitter[8]               = XM72SmokeEmitter;
   stateEmitterTime[8]            = 2.75;
   stateEmitterNode[8]            = "muzzleNode";
   stateTimeoutValue[8]            = 0.50;
   stateTransitionOnTimeout[8]     = "Ready2";

   stateName[9]                    = "Fire2";
   stateTransitionOnTimeout[9]     = "Smoke2";
   stateTimeoutValue[9]            = 0.14;
   stateFire[9]                    = true;
   stateAllowImageChange[9]        = false;
   stateSequence[9]                = "Fire";
   stateScript[9]                  = "onFire";
   stateWaitForTimeout[9]         = true;
   stateEmitter[9]               = XM72FlashEmitter;
   stateEmitterTime[9]            = 0.05;
   stateEmitterNode[9]            = "muzzleNode";
   stateSound[9]               = XM72Shot1Sound;
   stateEjectShell[9]       = true;

   stateName[10] = "Smoke2";
   stateEmitter[10]               = XM72SmokeEmitter;
   stateEmitterTime[10]            = 2.75;
   stateEmitterNode[10]            = "muzzleNode";
   stateTimeoutValue[10]            = 0.50;
   stateTransitionOnTimeout[10]     = "Ready3";

   stateName[11]                    = "Fire3";
   stateTransitionOnTimeout[11]     = "Smoke3";
   stateTimeoutValue[11]            = 0.14;
   stateFire[11]                    = true;
   stateAllowImageChange[11]        = false;
   stateSequence[11]                = "Fire";
   stateScript[11]                  = "onFire";
   stateWaitForTimeout[11]         = true;
   stateEmitter[11]               = XM72FlashEmitter;
   stateEmitterTime[11]            = 0.05;
   stateEmitterNode[11]            = "muzzleNode";
   stateSound[11]               = XM72Shot1Sound;
   stateEjectShell[11]       = true;

   stateName[12] = "Smoke3";
   stateEmitter[12]               = XM72SmokeEmitter;
   stateEmitterTime[12]            = 2.75;
   stateEmitterNode[12]            = "muzzleNode";
   stateTimeoutValue[12]            = 0.50;
   stateTransitionOnTimeout[12]     = "Ready4";
   
   stateName[13]                    = "Fire4";
   stateTransitionOnTimeout[13]     = "Smoke4";
   stateTimeoutValue[13]            = 0.14;
   stateFire[13]                    = true;
   stateAllowImageChange[13]        = false;
   stateSequence[13]                = "Fire";
   stateScript[13]                  = "onFire";
   stateWaitForTimeout[13]         = true;
   stateEmitter[13]               = XM72FlashEmitter;
   stateEmitterTime[13]            = 0.05;
   stateEmitterNode[13]            = "muzzleNode";
   stateSound[13]               = XM72Shot1Sound;
   stateEjectShell[13]       = true;

   stateName[14] = "Smoke4";
   stateEmitter[14]               = XM72SmokeEmitter;
   stateEmitterTime[14]            = 2.75;
   stateEmitterNode[14]            = "muzzleNode";
   stateTimeoutValue[14]            = 0.50;
   stateTransitionOnTimeout[14]     = "Ready5";
   
   stateName[15]                    = "Fire5";
   stateTransitionOnTimeout[15]     = "Smoke5";
   stateTimeoutValue[15]            = 0.14;
   stateFire[15]                    = true;
   stateAllowImageChange[15]        = false;
   stateSequence[15]                = "Fire";
   stateScript[15]                  = "onFire";
   stateWaitForTimeout[15]         = true;
   stateEmitter[15]               = XM72FlashEmitter;
   stateEmitterTime[15]            = 0.05;
   stateEmitterNode[15]            = "muzzleNode";
   stateSound[15]               = XM72Shot1Sound;
   stateEjectShell[15]       = true;

   stateName[16] = "Smoke5";
   stateEmitter[16]               = XM72SmokeEmitter;
   stateEmitterTime[16]            = 2.75;
   stateEmitterNode[16]            = "muzzleNode";
   stateTimeoutValue[16]            = 0.50;
   stateTransitionOnTimeout[16]     = "Ready6";
   
   stateName[15]                    = "Fire6";
   stateTransitionOnTimeout[15]     = "Smoke6";
   stateTimeoutValue[15]            = 0.14;
   stateFire[15]                    = true;
   stateAllowImageChange[15]        = false;
   stateSequence[15]                = "Fire";
   stateScript[15]                  = "onFire";
   stateWaitForTimeout[15]         = true;
   stateEmitter[15]               = XM72FlashEmitter;
   stateEmitterTime[15]            = 0.05;
   stateEmitterNode[15]            = "muzzleNode";
   stateSound[15]               = XM72Shot1Sound;
   stateEjectShell[15]       = true;

   stateName[16] = "Smoke6";
   stateEmitter[16]               = XM72SmokeEmitter;
   stateEmitterTime[16]            = 2.75;
   stateEmitterNode[16]            = "muzzleNode";
   stateTimeoutValue[16]            = 0.50;
   stateTransitionOnTimeout[16]     = "Reload";

   stateName[17]         = "Reload";
   stateSequence[17]                = "Reload";
   stateTimeoutValue[17]            = 4.50;
   stateSound[17]               = xm72ReloadSound;
   stateTransitionOnTriggerUp[17]     = "Ready";
   stateSequence[17]   = "Ready";

};

also... how can i put up a ammo? its like this

Ready > Check Ammo if Ammo is between 1 and 6 > Fire > Ammo decreases by 1
                                        V
                              Check if ammo is 0 > Set ammo = ammo +6

%player.setImageAmmo(%slot,%on)

In an onFire script. Then, use stateTransitionOn[No]Ammo[%x] to make it go to a "reload" state or the "fire" state depending on whether it does/doesn't have ammo.

%player.setImageAmmo(%slot,%on)

In an onFire script. Then, use stateTransitionOn[No]Ammo[%x] to make it go to a "reload" state or the "fire" state depending on whether it does/doesn't have ammo.

have any example how do i use this and example how it works?

The Gravity Gun and Portal Gun that I made (Not SolarFlare's/Aloshi's ones) have examples of the ammo state being used, but I do not have code that you can copy straight into your file and learn nothing from have it instantly work.

The Gravity Gun and Portal Gun that I made (Not SolarFlare's/Aloshi's ones) have examples of the ammo state being used, but I do not have code that you can copy straight into your file and learn nothing from have it instantly work.

whats the %x for? variable? lulz? i dunno what to put in there...

The number of the state.

stateTransitionOnAmmo3 would be the transition when it gets ammo in state 3.
stateTransitionOnNoAmmo4 would be the transition when you set it to no ammo in state 4.

The number of the state.

stateTransitionOnAmmo3 would be the transition when it gets ammo in state 3.
stateTransitionOnNoAmmo4 would be the transition when you set it to no ammo in state 4.


so i basically did this:

Quote
   stateName[0]                     = "Activate";
   stateTimeoutValue[0]             = 0.15;
   stateTransitionOnTimeout[0]       = "Ready";
   stateSound[0]               = weaponSwitchSound;

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

   stateName[2]                    = "Fire";
   stateTransitionOnTimeout[2]     = "Smoke";
   stateTimeoutValue[2]            = 0.14;
   stateFire[2]                    = true;
   stateAllowImageChange[2]        = false;
   stateSequence[2]                = "Fire";
   stateScript[2]                  = "onFire";
   stateWaitForTimeout[2]         = true;
   stateEmitter[2]               = XM72FlashEmitter;
   stateEmitterTime[2]            = 0.05;
   stateEmitterNode[2]            = "muzzleNode";
   stateSound[2]               = XM72Shot1Sound;
   stateEjectShell[2]       = true;

   stateName[3] = "Smoke";
   stateEmitter[3]               = XM72SmokeEmitter;
   stateEmitterTime[3]            = 2.75;
   stateEmitterNode[3]            = "muzzleNode";
   //stateTimeoutValue[3]            = 3.50;   //this isnt need right? since u dont have transition on timeout
   stateTransitionOnNoAmmo[3]     = "Reload";
   stateTransitionOnAmmo          = "Ready";

   stateName[4]         = "Reload";
   stateSequence[4]                = "Reload";
   stateTransitionOnTriggerUp[4]     = "Ready";
   stateSequence[4]   = "Ready";

};

function XM72Image::onFire(%this,%obj,%slot)
{
  %player.setImageAmmo(%slot,%on)
   if(%obj.getDamagePercent() < 1.0)
      %obj.playThread(2, shiftAway);
   Parent::onFire(%this,%obj,%slot);   
}

i want to have a specific amount of shots, i asked Kaje how and said that i make alots of sequences, but it gets worse... lulz