Author Topic: Ammoguns: Reloading isnt working?{Help please D:}  (Read 3158 times)

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: [Select]
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";
};

I also have these functions below the Weapon Image:

Code: [Select]
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);
}

I also have the max ammo and canReload attributes in the item image. What am I doing wrong here?
« Last Edit: July 13, 2010, 01:11:03 PM by takato14 »

D: Does anyone know what to do? bump x_x

T_T come on! Bump, again x_x

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

. . .  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???

Did you try looking at another weapon's script that has reloading?

Did you try looking at another weapon's script that has reloading?
Yes... Several different ones. x_x Mine has little to no difference from one that works only different datablock references and names.
« Last Edit: July 16, 2010, 01:14:05 PM by takato14 »

Im still in need of help D:

I know how you feel. I can't figure the damn thing out either!

You made me think you knew what was wrong... :C


Can someone at LEAST tell me who made the ammoguns script so I can ask them? (the one that reloads when you press l)

The revolver uses reloading, you can manually reload with right click.

The revolver uses reloading, you can manually reload with right click.
Not what Im talking about.... the support_ammoguns script. I cant get it to work. Does anyone know how to make it work?

You have no ::Onspawn or whatever it is, let me look real quick.

Edit:You don't have this part in the ::OnMount script. This is the part that gives it the ammo in the first place.
Code: [Select]
function WeaponImage::onMount(%this,%obj,%slot)
{
Parent::onMount(%this,%obj,%slot);
if(%this.item.maxAmmo >= 0 && (%obj.currTool == -1 || %obj.toolAmmo[%obj.currTool] $= ""))
{
%obj.toolAmmo[%obj.currTool] = %this.item.maxAmmo;
}
}
« Last Edit: August 03, 2010, 02:03:35 PM by Munkey »