I'm making a script for realistic (reloadable) weapons in UDK.
I'm basing it off of this tutorial, but am using my own variables and such, and I'm using states so that you won't be able to do things like shoot, or switch weapons while reloading.
http://forums.epicgames.com/showthread.php?t=704840&page=2
Here's the tutorial
Here's my code.
(ignore the weird broadcasts and comments i add onto the code)
Please someone help to explain why I can't seem to call a function in the middle of a state.
I get the ERROR, 'Function' is not allowed here, error, and can't find a way to stop it from happening.
I'm goign to keep fiddling around with it until I can, but please someone help!!
I'm basing it off of this tutorial, but am using my own variables and such, and I'm using states so that you won't be able to do things like shoot, or switch weapons while reloading.
http://forums.epicgames.com/showthread.php?t=704840&page=2
Here's the tutorial
Here's my code.
Code:
/** Created by Sascha Burckhardt for ECHO **/
class EOWeapon extends UTWeapon;
// Size of the magazine
var int MagazineSize;
// How much ammo we have spare
var int SpareAmmo;
// Name of the reload animation
var name ReloadAnimation;
// The time it takes to reload.
var float ReloadTime;
// Are we reloading?
var bool bIsReloading;
exec function DisplaySpareAmmo()
{
WorldInfo.Game.BroadcastHandler.Broadcast(self, "Weapon Has:"$SpareAmmo);
}
// If we are out of ammo, we must reload. //
simulated function AmmoCheck()
{
Start:
if(AmmoCount == 0)
{
GoToState( 'ReloadState' );
}
else
{
GoTo Start;
}
}
// If we press the reload button, we must reload //
simulated exec function ReloadWeapon()
{
GoToState( 'ReloadStart' );
}
// Begin Reloading
simulated state ReloadStart
{
Begin:
loginternal( "THIS IS THE RELOADING STATE LOLOLOLOLO" );
WorldInfo.Game.BroadcastHandler.Broadcast(self, "Buildin' A Sentry");
simulated function BeginReload()
{
if (bIsReloading || AmmoCount <= 0)
{
return;
}
bIsReloading = True;
setTimer(ReloadTime, false, 'Reloading');
}
/** DERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRP **/
simulated function ReloadAmmo()
{
bIsReloading = True;
if (SpareAmmo >= Default.AmmoCount)
{
// Set the AmmoCount to default
AmmoCount = Default.AmmoCount;
// Subtract SpareAmmo from AmmoCount
SpareAmmo -= AmmoCount;
}
else
{
// Set AmmoCount to how much we have left
AmmoCount = SpareAmmo;
// Set SpareAmmo to zero
SpareAmmo = 0;
// Set to active state.
}
GoToState ( 'Active' );
WorldInfo.Game.BroadcastHandler.Broadcast(self, "ALARM: FRIENDLY TARGET. CEASE FIRE. ");
bIsReloading = False;
}
}
(ignore the weird broadcasts and comments i add onto the code)
Please someone help to explain why I can't seem to call a function in the middle of a state.
I get the ERROR, 'Function' is not allowed here, error, and can't find a way to stop it from happening.
I'm goign to keep fiddling around with it until I can, but please someone help!!