The ammo reload system
by Michael Branin · in TGB Platformer Kit · 02/19/2012 (7:07 am) · 5 replies
Has anyone played with the ammo system? the reload function seems busted.
Ussing the boombot as an example... in his initiase inventory function we have this defined in the stock PSK
Which as I understand it sets his intial ammo to 10 rockets and 50 of 50 Bullets.
then in the the rocket launchers script we have defined
and in bulletweapons.cs we have
So what I have gathered so far is the player 10 rockets at start out of a max of 20.
the player also have 50 bullets out of a max of 200?
When the player left clicks it fires 1 rocket at a time and the updateWeaponGUI function displays the correc ammo counting down till you reach 0 as it should. When the player Right Clicks he fires machine gummo ammo and the updateWeaponGUI changes the count from 50|50 to 49|50 to 48|50 and so on and so on like you would assume is correct. when the player fires all the machinegun ammo the display reads 0|50 and it can no longer fire.
All this makes sense to me and I feel like this portion is working..
Ussing the boombot as an example... in his initiase inventory function we have this defined in the stock PSK
// Shoot Rockets.
%this.setActiveWeapon( RocketLauncherWeapon );
// Set Ammo Limits.
%this.RocketLauncherAmmo = 10;
%this.MachineGunAmmo = "50 50";
// Update GUI.
%this.updateWeaponGui();Which as I understand it sets his intial ammo to 10 rockets and 50 of 50 Bullets.
then in the the rocket launchers script we have defined
new ScriptObject( RocketLauncherAmmo : ProjectileBaseAmmo )
{
ClipSize = -1;
MaxInventory = 20;
};and in bulletweapons.cs we have
new ScriptObject( MachineGunAmmo : ProjectileBaseAmmo )
{
ClipSize = 50;
MaxInventory = 200;
};So what I have gathered so far is the player 10 rockets at start out of a max of 20.
the player also have 50 bullets out of a max of 200?
When the player left clicks it fires 1 rocket at a time and the updateWeaponGUI function displays the correc ammo counting down till you reach 0 as it should. When the player Right Clicks he fires machine gummo ammo and the updateWeaponGUI changes the count from 50|50 to 49|50 to 48|50 and so on and so on like you would assume is correct. when the player fires all the machinegun ammo the display reads 0|50 and it can no longer fire.
All this makes sense to me and I feel like this portion is working..
#2
02/19/2012 (12:20 pm)
Move to the correct forum. You should get more answers on the T3D forum than on the TGB Platformer Kit one.
#3
02/19/2012 (12:32 pm)
Actually this is the correct forum. this is the ammo reload system inside the T2D platform starter kit. Could you move this thread back to the pT2D platform starterkit forum? I was where i needed to be.
#4
02/19/2012 (2:49 pm)
Sorry for the confusion. When I see the boombot and rocket launcher ammo listed in a post, it smacks of Torque 3D more than the platformer kit forum.
#5
02/19/2012 (2:55 pm)
Completely understandable.
Torque Owner Michael Branin
Default Studio Name
function pskActor::onReload( %this, %trigger ) { if ( !%trigger ) { return; } %weaponName = %this.ActiveWeapon.getName(); %actionCount = %weaponName.ActionCount; for ( %i = 0; %i < %actionCount; %i++ ) { %ammoType = %weaponName.Action[%i].Ammunition.getName(); %clipSize = %ammoType.ClipSize; if ( isObject( %ammoType ) && %clipSize != -1 ) { %ammoList = %this.getFieldValue( %ammoType ); %totalInventory = getWord( %ammoList, 0 ) + getWord( %ammoList, 1 ); %newClip = %clipSize; if ( %newClip > %totalInventory ) { %newClip = %totalInventory; } %newInventory = %totalInventory - %newClip; %this.setFieldValue( %ammoType, %newClip SPC %newInventory ); } } }First off the best I can figure in controller behaviors is the R key is calling the reload function like so
// Reload key if ( %keyDown $= "Reload" ) { // Reload. %this.Owner.onReload( 0, true ); }But .... where is it getting the ammo for reload??
Lets say I fire off 3 rockets and 10 bullets. the display reads 7 and 40|50
then I call $Game::Player.onReload( true );
the onreload steps through and reads that the rocketLauncherAmmo clipsize is -1 so it bypasses the rocketlauncher reload. Then in the machine gunAmmo it changes the ammoGUI HUD to 50|40
Ok .. WTH just happened???