// Simple melee weapon base class, by Mr.Self-Destruct class MeleeWeapon extends TournamentWeapon; // Customization variables // Damage dealt var() float Damage; var() float AltDamage; // Range is pretty self explanatory var() float Range; var() float AltRange; // Higher recoil makes the target get knocked back more var() float Recoil; var() float AltRecoil; // Higher speed means slower rate of fire var() float Speed; var() float AltSpeed; function Fire(float Value) { local vector HitLocation, HitNormal, EndTrace, X, Y, Z, Start, momentum; local actor Other; GotoState('NormalFire'); // Retrieve where the player is facing GetAxes(Pawn(owner).ViewRotation, X, Y, Z); // Calculate a line between the player and the weapon's maximum range Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z; AdjustedAim=pawn(owner).AdjustAim(1000000, Start, AimError, False, False); EndTrace = Owner.Location + (Range * vector(AdjustedAim)); // Trace along the line to find a target Other = Pawn(Owner).TraceShot(HitLocation, HitNormal, EndTrace, Start); // If no suitable target, exit firing routine if ( (Other == None) || (Other == Owner) || (Other == self) ) return; // Deal damage to target Other.TakeDamage(Damage, Pawn(Owner), HitLocation, -10000.0 * Y, MyDamageType); // Knock the target back momentum = (Other.Location - Owner.Location) * Recoil/Other.Mass; Other.Velocity += momentum; // Spawn hit decal, but not on players or dead bodies if ( !Other.bIsPawn && !Other.IsA('Carcass') ) spawn(class'SawHit',,,HitLocation+HitNormal, rotator(HitNormal)); } function AltFire(float Value) { local vector HitLocation, HitNormal, EndTrace, X, Y, Z, Start, momentum; local actor Other; GotoState('AltFiring'); // Retrieve where the player is facing GetAxes(Pawn(owner).ViewRotation, X, Y, Z); // Calculate a line between the player and the weapon's maximum range Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z; AdjustedAim=pawn(owner).AdjustAim(1000000, Start, AimError, False, False); EndTrace = Owner.Location + (AltRange * vector(AdjustedAim)); // Trace along the line to find a target Other = Pawn(Owner).TraceShot(HitLocation, HitNormal, EndTrace, Start); // If no suitable target, exit firing routine if ( (Other == None) || (Other == Owner) || (Other == self) ) return; // Deal damage to target Other.TakeDamage(AltDamage, Pawn(Owner), HitLocation, -10000.0 * Y, AltDamageType); // Knock the target back momentum = (Other.Location - Owner.Location) * AltRecoil/Other.Mass; Other.Velocity += momentum; // Spawn hit decal, but not on players or dead bodies if ( !Other.bIsPawn && !Other.IsA('Carcass') ) spawn(class'SawHit',,,HitLocation+HitNormal, rotator(HitNormal)); } state NormalFire { // Prevent the weapon from being fired whilst it's already firing function Fire(float F) { } function AltFire(float F) { } Begin: // Wait a bit to control the rate of fire Sleep(Speed); Finish(); } state AltFiring { // Prevent the weapon from being fired whilst it's already firing function Fire(float F) { } function AltFire(float F) { } Begin: // Wait a bit to control the rate of fire Sleep(AltSpeed); Finish(); } // A simple sword class Sword extends MeleeWeapon; defaultproperties { // Weapon pickup message & weapon name PickupMessage="You got a katana" ItemName="katana" // Range, damage, recoil and speed for primary fire Damage=25.0 Range=60.0 Recoil=300.0 Speed=0.3 // Range, damage, recoil and speed for secondary fire AltDamage=40.0 AltRange=40.0 AltRecoil=550.0 AltSpeed=1 }