//============================================================================= // AlienWeapon. //============================================================================= class AlienWeapon expands Weapon abstract; #exec AUDIO IMPORT FILE="Sounds\lhit.wav" NAME="lhit" GROUP="Sounds" #exec AUDIO IMPORT FILE="Sounds\lstart.wav" NAME="lstart" GROUP="Sounds" #exec AUDIO IMPORT FILE="Sounds\rexp3.wav" NAME="rexp3" GROUP="Sounds" #exec AUDIO IMPORT FILE="Sounds\attack2.wav" NAME="attack2" GROUP="Sounds" #exec AUDIO IMPORT FILE="Sounds\enfstop.wav" NAME="enfstop" GROUP="Sounds" function Tick( float DeltaTime ) { Super.Tick( DeltaTime ); if( Owner == None ) return; if( Location != Owner.Location ); SetLocation(Owner.Location); if( Base != Owner ) SetBase(Owner); } // set which hand is holding weapon function setHand(float Hand); function Projectile ProjectileFire(class ProjClass, float ProjSpeed, bool bWarn) { local Vector Start, X,Y,Z; local Pawn PawnOwner; PawnOwner = Pawn(Owner); Owner.MakeNoise(PawnOwner.SoundDampening); GetAxes(PawnOwner.ViewRotation,X,Y,Z); Start = Owner.Location + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z; AdjustedAim = PawnOwner.AdjustAim(ProjSpeed, Start, AimError, True, bWarn); return Spawn(ProjClass,,, Start,AdjustedAim); } // Either give this inventory to player Other, or spawn a copy // and give it to the player Other, setting up original to be respawned. // Also add Ammo to Other's inventory if it doesn't already exist // function inventory SpawnCopy( pawn Other ) { local inventory Copy; local Weapon newWeapon; if ( (!Other.IsA('FvFAlien')) || (FvFAlien(Other) == None) ) { Destroy(); return None; } Copy = self; Copy.RespawnTime = 0.0; Copy.bHeldItem = true; Copy.GiveTo( Other ); Copy.SetOwner( Other ); Copy.SetLocation( Other.Location ); Copy.SetBase( Other ); newWeapon = Weapon(Copy); newWeapon.Instigator = Other; newWeapon.GiveAmmo(Other); newWeapon.SetSwitchPriority(Other); if ( !Other.bNeverSwitchOnPickup ) newWeapon.WeaponSet(Other); newWeapon.AmbientGlow = 0; return newWeapon; } function GiveAmmo( Pawn Other ) { if ( AmmoName == None ) return; AmmoType = Ammo(Other.FindInventoryType(AmmoName)); if ( AmmoType != None ) AmmoType.AddAmmo(PickUpAmmoCount); else { AmmoType = Spawn(AmmoName); // Create ammo type required Other.AddInventory(AmmoType); // and add to player's inventory AmmoType.SetOwner(Owner); AmmoType.Instigator = Pawn(Owner); AmmoType.BecomeItem(); AmmoType.AmmoAmount = PickUpAmmoCount; AmmoType.GotoState('Idle2'); } } // Toss this weapon out function DropFrom(vector StartLocation) { if ( Pawn(Owner) == None ) Destroy(); else if( (Pawn(Owner) != None) && Pawn(Owner).GetStateName() == 'Dying') Destroy(); } // // Change weapon to that specificed by F matching inventory weapon's Inventory Group. function Weapon WeaponChange( byte F ) { local Weapon newWeapon; if ( InventoryGroup == F ) { if ( Pawn(Owner).Health < 2 ) { if ( Inventory == None ) newWeapon = None; else newWeapon = Inventory.WeaponChange(F); if ( newWeapon == None ) Pawn(Owner).ClientMessage( "Not enough life." ); return newWeapon; } else return self; } else if ( Inventory == None ) return None; else return Inventory.WeaponChange(F); } // Finish a firing sequence function Finish() { local Pawn PawnOwner; if ( bChangeWeapon ) { GotoState('DownWeapon'); return; } PawnOwner = Pawn(Owner); if ( PlayerPawn(Owner) == None ) { if ( PawnOwner.Health < 2 ) { PawnOwner.StopFiring(); PawnOwner.SwitchToBestWeapon(); if ( bChangeWeapon ) GotoState('DownWeapon'); } else if ( (PawnOwner.bFire != 0) && (FRand() < RefireRate) ) Global.Fire(0); else if ( (PawnOwner.bAltFire != 0) && (FRand() < AltRefireRate) ) Global.AltFire(0); else { PawnOwner.StopFiring(); GotoState('Idle'); } return; } if ( (PawnOwner.Health < 2) || (PawnOwner.Weapon != self) ) GotoState('Idle'); else if ( PawnOwner.bFire!=0 ) Global.Fire(0); else if ( PawnOwner.bAltFire!=0 ) Global.AltFire(0); else GotoState('Idle'); } //============================================================================= // Weapon rendering // Draw first person view of inventory simulated event RenderOverlays( canvas Canvas ) { local rotator NewRot; local bool bPlayerOwner; local int Hand; local PlayerPawn PlayerOwner; if ( bHideWeapon || (Owner == None) ) return; PlayerOwner = PlayerPawn(Owner); if ( PlayerOwner != None ) { bPlayerOwner = true; Hand = PlayerOwner.Handedness; } if ( (Level.NetMode == NM_Client) && bPlayerOwner && (Hand == 2) ) { bHideWeapon = true; return; } if ( !bPlayerOwner || (PlayerOwner.Player == None) ) Pawn(Owner).WalkBob = vect(0,0,0); if ( (bMuzzleFlash > 0) && bDrawMuzzleFlash && Level.bHighDetailMode && (MFTexture != None) ) { MuzzleScale = Default.MuzzleScale * Canvas.ClipX/640.0; if ( !bSetFlashTime ) { bSetFlashTime = true; FlashTime = Level.TimeSeconds + FlashLength; } else if ( FlashTime < Level.TimeSeconds ) bMuzzleFlash = 0; if ( bMuzzleFlash > 0 ) { if ( Hand == 0 ) Canvas.SetPos(Canvas.ClipX/2 - MuzzleScale * FlashS + Canvas.ClipX * (-0.2 * Default.FireOffset.Y * FlashO), Canvas.ClipY/2 - MuzzleScale * FlashS + Canvas.ClipY * (FlashY + FlashC)); else Canvas.SetPos(Canvas.ClipX/2 - MuzzleScale * FlashS + Canvas.ClipX * (Hand * Default.FireOffset.Y * FlashO), Canvas.ClipY/2 - MuzzleScale * FlashS + Canvas.ClipY * FlashY); Canvas.Style = 3; Canvas.DrawIcon(MFTexture, MuzzleScale); Canvas.Style = 1; } } else bSetFlashTime = false; if ( Location != Owner.Location ) SetLocation(Owner.Location); } function bool HandlePickupQuery( inventory Item ) { local int OldAmmo; local Pawn P; if ( Item.IsA('Weapon') && !Item.IsA('AlienWeapon') ) return true; else if ( (Item.IsA('Health')) || (Health(Item) != None) ) return true; else if ( Inventory == None ) return false; return Inventory.HandlePickupQuery(Item); } //============================================================================= // Pickup state: this inventory item is sitting on the ground. auto state Pickup { function BeginState() { if( (FvFAlien(Owner) == None) && !bDeleteMe ) Destroy(); } Begin: if( (FvFAlien(Owner) == None) && !bDeleteMe ) Destroy(); Dropped: if( (FvFAlien(Owner) == None) && !bDeleteMe ) Destroy(); } /////////////////////////////////////////////////////// state NormalFire { function Tick ( float DeltaTime ) { Global.Tick( DeltaTime ); } function Fire(float F) { } function AltFire(float F) { } Begin: Sleep(RefireRate); Finish(); } //////////////////////////////////////////////////////// state AltFiring { function Tick ( float DeltaTime ) { Global.Tick( DeltaTime ); } function Fire(float F) { } function AltFire(float F) { } Begin: Sleep(AltRefireRate); Finish(); } //********************************************************************************** // Weapon is up, but not firing state Idle { function Tick ( float DeltaTime ) { Global.Tick( DeltaTime ); } function AnimEnd(); function bool PutDown() { GotoState('DownWeapon'); return True; } Begin: bPointing=False; if ( (Pawn(Owner) != None) && (Pawn(Owner).Health < 2) ) Pawn(Owner).SwitchToBestWeapon(); //Goto Weapon that has Ammo if ( Pawn(Owner).bFire!=0 ) Fire(0.0); if ( Pawn(Owner).bAltFire!=0 ) AltFire(0.0); Disable('AnimEnd'); } // // Bring newly active weapon up // Bring newly active weapon up state Active { function Tick ( float DeltaTime ) { Global.Tick( DeltaTime ); } function Fire(float F) { } function AltFire(float F) { } function bool PutDown() { if ( bWeaponUp || (AnimFrame < 0.75) ) GotoState('DownWeapon'); else bChangeWeapon = true; return True; } function BeginState() { bChangeWeapon = false; } Begin: if ( bChangeWeapon ) GotoState('DownWeapon'); bWeaponUp = True; Finish(); } // // Putting down weapon in favor of a new one. // State DownWeapon { ignores Fire, AltFire; function Tick ( float DeltaTime ) { Global.Tick( DeltaTime ); } function bool PutDown() { return true; //just keep putting it down } function BeginState() { bChangeWeapon = false; bMuzzleFlash = 0; } Begin: Pawn(Owner).ChangedWeapon(); } function BringUp() { if ( Owner.IsA('PlayerPawn') ) PlayerPawn(Owner).EndZoom(); bWeaponUp = false; GotoState('Active'); } function RaiseUp(Weapon OldWeapon) { BringUp(); } function bool PutDown() { bChangeWeapon = true; return true; } function TweenDown(); function TweenSelect(); function PlaySelect(); function PlayPostSelect(); function PlayIdleAnim(); defaultproperties { AmmoName=Class'KPW.AlienAmmo' PickupAmmoCount=250 bCanThrow=False FireOffset=(X=42.000000,Y=-12.000000,Z=5.000000) shakemag=0.000000 shaketime=0.000000 shakevert=0.000000 AutoSwitchPriority=0 InventoryGroup=255 bAmbientGlow=False RespawnTime=0.000000 PlayerViewOffset=(X=0.000000,Z=0.000000) PlayerViewScale=0.000000 PickupViewScale=0.000000 ThirdPersonScale=0.000000 bTravel=False Physics=PHYS_Trailer DrawType=DT_None Style=STY_None Texture=None DrawScale=0.000000 ScaleGlow=0.000000 AmbientGlow=0 bUnlit=True CollisionRadius=0.000000 CollisionHeight=0.000000 bCollideActors=False bFixedRotationDir=False Mass=0.000000 RotationRate=(Yaw=0) DesiredRotation=(Yaw=0) }