Upgradable Arms

Credit to Windex
Authored by Postal

Intermediate

DOWNLOAD ZIP

Howdy, there. If you are new to coding or don't know how to use UEd, ignore this, because this does not go over basics, and presumes that you understand what I am talking about.

Firstly I am going to start off with the Windex shotgun, like in irc log 3 and in my shotgun tutorial, here is its code, please note I made some changes.

//=============================================================================
// WoD Quad-ShotGun.
//=============================================================================
class WoDQSG expands TournamentWeapon;
//
Var Int Loads, Shots, LoadCount;
var vector OrigFireOff;
Var() Int HitDamage;
Var Bool bCase;

Var(SFX) Bool bHudAmmo;
//
function PostBeginPlay()
{
OrigFireOff=FireOffset;
LoadCount=1;
}
//
function PlayPostSelect()
{
// PlayAnim('Loading', 1.3, 0.05);
// Owner.PlaySound(Misc2Sound, SLOT_None,1.3*Pawn(Owner).SoundDampening);
GoToState('Reload');
}
//
simulated function PostRender( canvas Canvas )
{
Local Int Clip;

If (bHudAmmo)
{
If (AmmoType.AmmoAmount <= ReloadCount) Clip = AmmoType.AmmoAmount;
Else Clip = LoadCount;
Canvas.Style = ERenderStyle.STY_Normal;
Canvas.SetPos(0.5 * Canvas.ClipX, 0.8 * Canvas.ClipY);
Canvas.Font = Canvas.SmallFont;
if(LoadCount <= 1)
{
Canvas.DrawColor.R = 255;
Canvas.DrawColor.G = 0;
Canvas.DrawColor.B = 0; 
}
else
{
Canvas.DrawColor.R = 0;
Canvas.DrawColor.G = 255;
Canvas.DrawColor.B = 0;
}
Canvas.DrawText("Shells: "$LoadCount);
}
}
//
function Fire( float Value )
{
// if (AmmoType.UseAmmo(1))
if (AmmoType.UseAmmo(LoadCount))
{
GoToState('NormalFire');
}
}

function AltFire( float Value )
{
// if (AmmoType.UseAmmo(1))
if (AmmoType.AmmoAmount>0)
{
if (LoadCount < 4)
{
LoadCount++;
GoToState('Reload');
}
Else If (AmmoType.UseAmmo(LoadCount))
{
GoToState('NormalFire');
}
}
// Else GoToState('NormalFire');
}
//
state NormalFire
{
ignores Fire, AltFire;
Begin:
CheckVisibility();
bPointing=True;
if ( PlayerPawn(Owner) != None )
{
PlayerPawn(Owner).ClientInstantFlash( -0.4, vect(650, 450, 190));
PlayerPawn(Owner).ShakeView(ShakeTime, ShakeMag, ShakeVert);
}
// Owner.MakeNoise(2.0 * Pawn(Owner).SoundDampening);

for(loads=0;loads<LoadCount;Loads++)
{
bCase=True;
SetShotPattern(LoadCount, loads);
for(shots=0;shots<10;shots++)
{
TraceFire(1.7);
}
}

PlayAnim( 'Fire', 0.9, 0.05);
Owner.PlaySound(Sound'UnrealShare.flak.shot1',
SLOT_None,Pawn(Owner).SoundDampening*4.0);

LoadCount=1;
GoToState('ReLoad');