Blockland Forums > Modification Help

Ammoguns: Reloading isnt working?{Help please D:}

Pages: (1/4) > >>

takato14:

Ok, I made a weapon that reloads using the Support_Ammoguns.cs script, and Im having a problem. My gun isnt reloading. It doesnt reload when I press L or if i just keep shooting and I dont know whats going on. I made reload animations for the model but the Weapon Image isnt working right. Here is all the code I have that involves The ammoguns script:


--- Code: ---stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.62;
stateTransitionOnTimeout[0]       = "LoadCheckA";
StateSequence[0] = "use";
StateSound[0] = "WeaponSwitchSound";

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

stateName[2]                     = "Fire";
stateTransitionOnTimeout[2]     = "Delay";
stateTimeoutValue[2]             = 0.00;
stateFire[2]                     = true;
stateAllowImageChange[2]         = false;
stateSequence[2]                 = "Fire";
stateScript[2]                   = "onFire";
stateEjectShell[2]         = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateWaitForTimeout[2] = true;
StateSequence[2] = "fire";
stateSound[2] = gunFireSound;

stateName[3] = "Delay";
stateTransitionOnTimeout[3]     = "FireLoadCheckA";
stateTimeoutValue[3]             = 0.078;
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";

//Torque switches states instantly if there is an ammo/noammo state, regardless of stateWaitForTimeout

stateName[4] = "LoadCheckA";
stateScript[4] = "onLoadCheck";
stateTimeoutValue[4] = 0.01;
stateTransitionOnTimeout[4] = "LoadCheckB";

stateName[5] = "LoadCheckB";
stateTransitionOnAmmo[5] = "Ready";
stateTransitionOnNoAmmo[5] = "ReloadWait";

stateName[6] = "ReloadWait";
stateTimeoutValue[6] = 0.3;
stateTransitionOnTimeout[6] = "Reload";
stateWaitForTimeout[6] = true;

stateName[7] = "Reload";
stateTimeoutValue[7] = 0.3;
stateScript[7] = "onReloadStart";
stateTransitionOnTimeout[7] = "ReloadB";
stateWaitForTimeout[7] = true;
StateSequence[7] = "Reload1";
stateSound[7] = MPTDGReloadSound;

stateName[8] = "ReloadB";
stateTimeoutValue[8] = 1.69;
stateTransitionOnTimeout[8] = "Reloaded";
stateWaitForTimeout[8] = true;
StateSequence[8] = "reload2";
//stateSound[8] = "";

stateName[9] = "Reloaded";
stateTimeoutValue[9] = 0.5;
stateScript[9] = "onReloaded";
stateTransitionOnTimeout[9] = "Ready";

stateName[10] = "Smoke";
stateEmitter[10] = gunSmokeEmitter;
stateEmitterTime[10] = 0.3;
stateEmitterNode[10] = "muzzleNode";
stateTimeoutValue[10] = 0.2;
stateTransitionOnTimeout[10] = "Ready";
stateTransitionOnTriggerDown[10] = "Fire";

stateName[11] = "ReloadSmoke";
stateEmitter[11] = gunSmokeEmitter;
stateEmitterTime[11] = 0.3;
stateEmitterNode[11] = "muzzleNode";
stateTimeoutValue[11] = 0.2;
stateTransitionOnTimeout[11] = "Reload";

stateName[12] = "FireLoadCheckA";
stateScript[12] = "onLoadCheck";
stateTimeoutValue[12] = 0.01;
stateTransitionOnTimeout[12] = "FireLoadCheckB";

stateName[13] = "FireLoadCheckB";
stateTransitionOnAmmo[13] = "Smoke";
stateTransitionOnNoAmmo[13] = "ReloadSmoke";
};

--- End code ---

I also have these functions below the Weapon Image:


--- Code: ---function MPTDGImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, plant);
%projectile = %this.projectile;
%spread = 0.0007;
%shellcount = 1;

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
return %p;
}

function MPTDGImage::onMount(%this, %obj, %slot)
{
%obj.hidenode("RHand");
        %obj.hidenode("LHand");
}


function MPTDGImage::onUnMount(%this, %obj, %slot)
{
%obj.unhidenode("RHand");
        %obj.unhidenode("LHand");
}

function MPTDGImage::onLoadCheck(%this,%obj,%slot)
{
if(%obj.toolAmmo[%obj.currTool] <= 0)
%obj.setImageAmmo(%slot,0);
else
%obj.setImageAmmo(%slot,1);
}

function MPTDGImage::onReloaded(%this,%obj,%slot)
{
%obj.toolAmmo[%obj.currTool] = 40;
%obj.setImageAmmo(%slot,1);
}


--- End code ---
I also have the max ammo and canReload attributes in the item image. What am I doing wrong here?

takato14:

D: Does anyone know what to do? bump x_x

takato14:

T_T come on! Bump, again x_x

takato14:

Why do I have to keep bumping this? Ammoguns is used a LOT. SOMEONE has to know what im doing wrong! D:>

takato14:

. . .  Is it just that hard to figure out, or do you all hate me? Whoever helps me out with this WILL get credit in the release; please help???

Pages: (1/4) > >>

Go to full version