Author Topic: function script not working properly  (Read 628 times)

i am having problems with getting two functions to function ;^)
the broken ones are function RaygunImage::onBatteryLoadA(%db,%pl,%slot) and function RaygunImage::onBatteryLoadB(%db,%pl,%slot)
can somebody please help me
Code: [Select]
stateName[0] = "Ready";
stateSequence[0] = "root";
stateTimeoutValue[0] = 0.3;
stateTransitionOnTimeout[0] = "Idle";

stateName[1] = "Idle";
stateTransitionOnNotLoaded[1] = "UnloadA";
stateTransitionOnTriggerDown[1] = "Trigger";

stateName[2] = "Trigger";
stateScript[2] = "onTrigger";
stateTimeoutValue[2] = 0.02;
stateSequence[2] = "trig";
stateTransitionOnTimeout[2] = "FireCheckA";

stateName[3] = "FireCheckA";
stateScript[3] = "onFireCheck";
stateTimeoutValue[3] = 0.01;
stateTransitionOnTimeout[3] = "FireCheckB";

stateName[4] = "FireCheckB";
stateTransitionOnAmmo[4] = "Fire";
stateTransitionOnNoAmmo[4] = "DryFire";

stateName[5] = "Fire";
stateScript[5] = "onFire";
stateEmitterTime[5] = 0.1;
stateEmitter[5] = RaygunFlashEmitter;
stateFire[5] = true;
stateSequence[5] = "fire";
stateEmitterNode[5] = "muzzlePoint";
stateTransitionOnTimeout[5]     = "Release";
stateTimeoutValue[5]            = 0.12;

stateName[6] = "Release";
stateScript[6] = "onRelease";
stateTransitionOnTriggerUp[6] = "Wait";

stateName[7] = "Wait";
stateTimeoutValue[7] = 0.07;
stateTransitionOnTimeout[7] = "Idle";

stateName[8] = "UnloadA";
stateSequence[8] = "unload";
stateTimeoutValue[8] = 0.45;
stateScript[8] = "onUnload";
stateTransitionOnTimeout[8] = "UnloadB";

stateName[9] = "UnloadB";
stateTimeoutValue[9] = 0.6;
stateEjectShell[9] = true;
stateTransitionOnTimeout[9] = "BatteryLoadA";

stateName[10] = "BatteryLoadA";
stateTimeoutValue[10] = 0.61;
stateTransitionOnTimeout[10] = "BatteryLoadB";

stateName[11] = "BatteryLoadB";
stateTimeoutValue[11] = 0.54;
stateTransitionOnTimeout[11] = "ReloadA";

stateName[12] = "ReloadA";
stateSequence[12] = "reload";
stateTimeoutValue[12] = 0.01;
stateScript[12] = "onReloadA";
stateTransitionOnTimeout[12] = "ReloadB";

stateName[13] = "ReloadB";
stateTimeoutValue[13] = 0.9;
stateTransitionOnTimeout[13] = "ReloadC";

stateName[14] = "ReloadC";
stateScript[14] = "onReloadB";
stateTimeoutValue[14] = 0.01;
stateTransitionOnTimeout[14] = "Idle";

stateName[15] = "DryFire";
stateSequence[15] = "dryfire";
stateScript[15] = "onDryFire";
stateTransitionOnTimeout[15]     = "Release";
stateTimeoutValue[15]            = 0.12;
};
function RaygunImage::onFire(%db,%pl,%slot)
{
if(%pl.getDamagePercent() >= 1)
return;
    %pl.playThread(2, shiftRight);
    %pl.playThread(3, shiftLeft);
serverPlay3D(RaygunFire @ getRandom(1,3) @ Sound,%pl.getPosition());

%pl.sAmmo_heat[%db] = mClamp(%pl.sAmmo_heat[%db]+1,0,%db.item.sHeat);
sAmmo_fire(%db,%pl,%slot,0.005+((%pl.sAmmo_heat[%db]/%db.item.sHeat)*0.035),180,1);
cancel(%pl.sAmmoCooldownHeatSched[%db]);
%pl.sAmmoCooldownHeatSched[%db] = %pl.schedule(200,sAmmo_heatCooldown,%db,%slot);

%val = sAmmo_dec(%db,%pl,%slot);
if(!sAmmo_check(%db,%pl,%slot))
serverPlay3D(mac10LastRoundSound,%pl.getPosition());

if(getSimTime()-%pl.lastShellSound > 400 || getRandom(0,1) == 0)
{
%pl.lastShellSound = getSimTime();
schedule(getRandom(200,300),0,serverPlay3D,small_ignorethis @ getRandom(1,5) @ Sound,%pl.getPosition());
}
if(%val == 0)
%pl.setImageAmmo(%slot,0);
}
function RaygunImage::onFireCheck(%db,%pl,%slot)
{
%pl.setImageAmmo(%slot,sAmmo_check(%db,%pl,%slot));
}
function RaygunImage::onBatteryLoadA(%db,%pl,%slot)
{
    %pl.playThread(2, shiftRight);
    %pl.playThread(3, shiftLeft);
schedule(20,0,serverPlay3D,RaygunPutASound,%pl.getPosition());
}

function RaygunImage::onBatteryLoadB(%db,%pl,%slot)
{
    %pl.playThread(2, shiftRight);
    %pl.playThread(3, shiftLeft);
schedule(20,0,serverPlay3D,RaygunPutBSound,%pl.getPosition());
}

function RaygunImage::onUnload(%db,%pl,%slot)
{
sAmmo_display(%pl,0);
%up = %pl.getUpVectorHack();
%forward = %pl.getEyeVectorHack();
%p.explode();
    %pl.playThread(2,plant);
serverPlay3D(RaygunUnloadSound,%pl.getPosition());
}
function RaygunImage::onReloadA(%db,%pl,%slot)
{
%pl.playThread(2, shiftAway);
schedule(20,0,serverPlay3D,RaygunLoadSound,%pl.getPosition());
}
function RaygunImage::onReloadB(%db,%pl,%slot)
{
//%pl.playThread(2,shiftLeft);
%pl.setImageLoaded(%slot,1);
sAmmo_reload(%db,%pl,%slot);
}

you haven't actually set the stateScript value for both of those states, so the onBatteryLoadA/B functions aren't getting called.
look at the fire state to see how its done

you haven't actually set the stateScript value for both of those states, so the onBatteryLoadA/B functions aren't getting called.
look at the fire state to see how its done
oh god damnit