## XIII
Class DecoWeapon

source: C:\XIII\XIII\Classes\DecoWeapon.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Inventory
             |
             +--Engine.Weapon
                |
                +--XIII.XIIIWeapon
                   |
                   +--XIII.DecoWeapon

Direct Known Subclasses:DecoAshTray, DecoBarSit, DecoBottle, DecoBrik, DecoBroom, DecoChair, DecoCue, DecoDart, DecoGlassShard, DecoPhone, DecoShovelSand, DecoShovelSnow, DecoWBall

class DecoWeapon
extends XIII.XIIIWeapon

    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------

Variables
`class` | `SFXWhenBroken`
`class` | `SFXWhenBrokenNoTgt`
`class` | `SFXWhenBrokenNotPawn`
`bool` | `bFired`
`bool` | `bProjectileThrown`
`float` | `fDelaySFXBroken`
`float` | `fDelayShake`
`sound` | `hDownSound`
`sound` | `hDownUnusedSound`
`int` | `memWeaponGroup`
`bool` | `membWeaponMode`

States
Active, while, DownWeapon

Function Summary
`void` | `AltFinish()`
    //_____________________________________________________________________________
`simulated` | `DetachFromPawn(Pawn P)`
    //_____________________________________________________________________________
`void` | `Finish()`
    //_____________________________________________________________________________
`simulated` | `Fire(float Value)`
    //_____________________________________________________________________________
`string` | `GetAmmoText(out int)`
    //_____________________________________________________________________________
    // ELR Text to be displayed in HUD
`void` | `GiveTo(Pawn Other)`
    //_____________________________________________________________________________
`simulated` | `LocalFire()`
    //_____________________________________________________________________________
`void` | `NewWeaponNotify(Pawn Other)`
    //_____________________________________________________________________________
`Weapon` | `NextWeapon(Weapon CurrentChoice, Weapon CurrentWeapon)`
`Weapon` | `PrevWeapon(Weapon CurrentChoice, Weapon CurrentWeapon)`
    //_____________________________________________________________________________
    // Deco Weapon always are best weapons to change to (not allowed to stay in inv anyway)
`void` | `ProjectileAltFire()`
    //_____________________________________________________________________________

State Active Function Summary
`bool` | `PutDown()`

State while Function Summary

State DownWeapon Function Summary

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class DecoWeapon extends XIIIWeapon;
    00005
    00006	var int memWeaponGroup;
    00007
    00008	var bool membWeaponMode;
    00009	var bool bFired;
    00010	var bool bProjectileThrown;
    00011
    00012	var class<emitter> SFXWhenBroken;
    00013	var class<emitter> SFXWhenBrokenNotPawn;
    00014	var class<emitter> SFXWhenBrokenNoTgt;
    00015	var float fDelaySFXBroken;
    00016	var float fDelayShake;
    00017
    00018	var sound hDownSound;
    00019	var sound hDownUnusedSound;
    00020
    00021	//_____________________________________________________________________________
    00022	function NewWeaponNotify(Pawn Other);
    00023
    00024	//_____________________________________________________________________________
    00025	simulated function Fire( float Value )
    00026	{
    00027	    bFired = true;
    00028	    Super.Fire(Value);
    00029	}
    00030
    00031	//_____________________________________________________________________________
    00032	simulated function DetachFromPawn(Pawn P)
    00033	{
    00034	    if ( ThirdPersonActor != None )
    00035	    {
    00036	      ThirdPersonActor.Destroy();
    00037	      ThirdPersonActor = None;
    00038	    }
    00039	//  	SetDrawType(DT_None); // can't be used else anims won't play and base soldiers won't work
    00040	//    bHidden = true; // ELR can't set bhidden here because when downing it will hide the down anim
    00041	}
    00042
    00043	//_____________________________________________________________________________
    00044	// Deco Weapon always are best weapons to change to (not allowed to stay in inv anyway)
    00045	simulated function Weapon PrevWeapon(Weapon CurrentChoice, Weapon CurrentWeapon)
    00046	{
    00047	    return self;
    00048	}
    00049	simulated function Weapon NextWeapon(Weapon CurrentChoice, Weapon CurrentWeapon)
    00050	{
    00051	    return self;
    00052	}
    00053
    00054	//_____________________________________________________________________________
    00055	function GiveTo(Pawn Other)
    00056	{
    00057	    // We must get this weapon in hand when we grab it.
    00058	    // but memorize the player state.
    00059	    if ( XIIIPlayerController(Other.controller).bWeaponMode && (Other.weapon != none) && (DecoWeapon(Other.weapon) == none) )
    00060	    {
    00061	      DebugLog(self@"Decoweapon Giveto, Memorize WEAPON");
    00062	      MemWeaponGroup = Other.weapon.InventoryGroup;
    00063	      MembWeaponMode =  XIIIPlayerController(Other.controller).bWaitForWeaponMode;
    00064	    }
    00065	    else if ( XIIIPlayerController(Other.controller).bWeaponMode && (Other.Weapon == none) )
    00066	    {
    00067	      DebugLog(self@"Decoweapon Giveto, Memorize NO WEAPON");
    00068	      MemWeaponGroup = 0;
    00069	      MembWeaponMode =  XIIIPlayerController(Other.controller).bWaitForWeaponMode;
    00070	    }
    00071	    else if ( !XIIIPlayerController(Other.controller).bWeaponMode )
    00072	    {
    00073	      DebugLog(self@"Decoweapon Giveto, Memorize ITEM");
    00074	      MemWeaponGroup = 0;
    00075	      MembWeaponMode =  false;
    00076	    }
    00077	    else
    00078	    { // not possible anymore but just in case come back
    00079	      DebugLog(self@"Decoweapon Giveto, Memorize Weapon WAS DECO");
    00080	      MemWeaponGroup = DecoWeapon(Other.weapon).MemWeaponGroup;
    00081	      MembWeaponMode = DecoWeapon(Other.weapon).MembWeaponMode;
    00082	    }
    00083	    if ( membWeaponMode )
    00084	    { // Player In weapon mode state, just switch weapon
    00085	      Super.GiveTo(Other);
    00086	      DebugLog(self@"Decoweapon Giveto, WEAP in hand");
    00087	      XIIIPlayerController(Other.controller).SwitchWeapon(InventoryGroup);
    00088	    }
    00089	    else
    00090	    {
    00091	      // Player in Items mode, need to put down
    00092	      DebugLog(self@"Decoweapon Giveto, ITEM in hand putting down"@Other.SelectedItem);
    00093	      Other.PendingWeapon = self;
    00094	      Other.Weapon = self;
    00095	      Super.GiveTo(Other);
    00096	      XIIIItems(Other.SelectedItem).PutDown();
    00097	      XIIIPlayerController(Other.controller).bWaitForWeaponMode = true;
    00098	//      XIIIPlayerController(Instigator.controller).SwitchWeaponMode();
    00099	//      XIIIPlayerController(Instigator.controller).Pawn.PendingWeapon = self;
    00100	//      XIIIPlayerController(Instigator.controller).NextWeapon();
    00101	//      XIIIPlayerController(Instigator.controller).SwitchWeapon(InventoryGroup);
    00102	    }
    00103	}
    00104
    00105	//_____________________________________________________________________________
    00106	// ELR Text to be displayed in HUD
    00107	simulated function string GetAmmoText(out int bDrawbulletIcon)
    00108	{
    00109	    local string AmmoText;
    00110
    00111	    AmmoText = ItemName;
    00112	    bDrawbulletIcon = 0;
    00113	    return AmmoText;
    00114	}
    00115
    00116	//_____________________________________________________________________________
    00117	function ProjectileAltFire()
    00118	{
    00119	    bProjectileThrown = true;
    00120	    Super.ProjectileAltFire();
    00121	}
    00122
    00123	//_____________________________________________________________________________
    00124	simulated function LocalFire()
    00125	{
    00126	    local PlayerController P;
    00127
    00128	    if ( DBWeap ) Log("  Localfire call for"@self@"w/ ReLoadCount="$ReLoadCount@" AmmoAmount="$AmmoType.AmmoAmount@" HasAmmo="$HasAmmo());
    00129
    00130	    if ( HasAmmo() )
    00131	    {
    00132	      if ( (Instigator != None) && Instigator.IsLocallyControlled() )
    00133	      {
    00134	        P = PlayerController(Instigator.Controller);
    00135	        if (P!=None)
    00136	          SetTimer2(fDelayShake, false);
    00137	//          P.ShakeView(ShakeTime, ShakeMag, ShakeVert, 120000, ShakeSpeed, ShakeCycles);
    00138	      }
    00139	    }
    00140	    PlayFiring();
    00141	}
    00142
    00143	//_____________________________________________________________________________
    00144	simulated event Timer2()
    00145	{
    00146	    local PlayerController P;
    00147
    00148	    P = PlayerController(Instigator.Controller);
    00149	    P.ShakeView(ShakeTime, ShakeMag, ShakeVert, 120000, ShakeSpeed, ShakeCycles);
    00150	}
    00151
    00152	//_____________________________________________________________________________
    00153	function Finish()
    00154	{
    00155	    if ( DBWeap ) Log("Decoweapon Finish in state"@GetStateName());
    00156
    00157	    if ( GetStateName() == 'Active' )
    00158	    {
    00159	      GotoState('Idle');
    00160	      return;
    00161	    }
    00162	    // Owner must restore states, this one is OoO
    00163	//    if ( bChangeWeapon )
    00164	      GotoState('DownWeapon');
    00165	}
    00166
    00167	//_____________________________________________________________________________
    00168	function AltFinish()
    00169	{
    00170	    Finish();
    00171	}
    00172
    00173	//_____________________________________________________________________________
    00174	State DownWeapon
    00175	{
    00176	    simulated function AnimEnd(int Channel)
    00177	    {
    00178	      if ( DBWeap ) Log("DOWNWEAPON AnimEnd for"@self);
    00179
    00180	      Instigator.PendingWeapon = none;
    00181	      Instigator.Weapon = none;
    00182	      PlayerController(Instigator.Controller).SwitchWeapon(MemWeaponGroup);
    00183	      if ( !XIIIPlayerController(Instigator.Controller).bWaitForWeaponMode )
    00184	         XIIIPlayerController(Instigator.controller).HideWeapon();
    00185	      if ( DBWeap ) Log("           Restoring Previous weapon "$Instigator.PendingWeapon);
    00186
    00187	      bChangeWeapon = false;
    00188	      Pawn(Owner).ChangedWeapon();
    00189	      AmmoType.Destroy();
    00190	      bRendered = false;
    00191	      bHidden = true;
    00192	      RefreshDisplaying();
    00193	      Destroy();
    00194	    }
    00195	    simulated function BeginState()
    00196	    {
    00197	//      Log("DOWNWEAPON BeginState for"@self);
    00198	      Super.BeginState();
    00199	      DetachFromPawn(Instigator);
    00200	      if ( (fDelaySFXBroken > 0.0) && !bProjectileThrown && DecoAmmo(AmmoType).bUnused )
    00201	        SetTimer2(fDelaySFXBroken, false);
    00202	      else if ( !bProjectileThrown && (DecoAmmo(AmmoType).bUnused) )
    00203	        Spawn(SFXWhenBrokenNoTgt,self,,Location+vector(owner.rotation)*120.0, owner.rotation);
    00204	    }
    00205	    simulated event Timer2()
    00206	    {
    00207	      Spawn(SFXWhenBrokenNoTgt,self,,Location+vector(owner.rotation)*120.0, owner.rotation);
    00208	    }
    00209	}
    00210
    00211	//_____________________________________________________________________________
    00212	/* Bring newly active weapon up.
    00213	The weapon will remain in this state while its selection animation is being played (as well as any postselect animation).
    00214	While in this state, the weapon cannot be fired.
    00215	*/
    00216	state Active
    00217	{
    00218	    simulated function bool PutDown()
    00219	    { // for deco weapons don't allow putdown till the end of the state (else will keep some inventory & will not be able to grab same later
    00220	      bChangeWeapon = true;
    00221	      return True;
    00222	    }
    00223	}
    00224
    00225	//_____________________________________________________________________________
    00226	simulated function TweenDown()
    00227	{
    00228	    PlayAnim('Down', 1.0);
    00229	    Instigator.PlayRolloffSound(hDownSound, self, 0, int(Pawn(Owner).IsPlayerPawn()), 0 );
    00230	    if (!bProjectileThrown && DecoAmmo(AmmoType).bUnused)
    00231	      Instigator.PlayRolloffSound(hDownUnusedSound, self, 0, int(Pawn(Owner).IsPlayerPawn()), 0 );
    00232	}
    00233
    00234	//_____________________________________________________________________________
    00235	simulated event FPSDownNote1()
    00236	{
    00237
if (!bProjectileThrown && DecoAmmo(AmmoType).bUnused) 00238 Instigator.PlayRolloffSound(hDownSound, self, 0, int(Pawn(Owner).IsPlayerPawn()), 1 ); 00239 if (!bProjectileThrown && DecoAmmo(AmmoType).bUnused) 00240 Instigator.PlayRolloffSound(hDownUnusedSound, self, 0, int(Pawn(Owner).IsPlayerPawn()), 1 ); 00241 } 00242 00243 00244 defaultproperties 00245 { 00246 fDelaySFXBroken=0.300000 00247 fDelayShake=0.600000 00248 bMeleeWeapon=True 00249 WHand=WHA_Deco 00250 AmmoName=Class'XIII.DecoAmmo' 00251 PickupAmmoCount=1 00252 FireOffset=(Y=5.000000,Z=-2.000000) 00253 ShotTime=0.700000 00254 FiringMode="FM_Stun" 00255 FireNoise=0.400000 00256 EmptyFiringAnim="Fire" 00257 ShakeMag=1600.000000 00258 shaketime=6.000000 00259 ShakeVert=(Z=30.000000) 00260 ShakeSpeed=(X=500.000000,Y=500.000000,Z=500.000000) 00261 ShakeCycles=4.000000 00262 AIRating=-5.000000 00263 TraceDist=30.000000 00264 InventoryGroup=20 00265 PlayerViewOffset=(X=5.000000,Y=4.500000,Z=-4.500000) 00266 ItemName="DECORATION" 00267 bTravel=False 00268 DrawScale=0.300000 00269 }

End Source Code