XIII
Class Med

source: C:\XIII\XIII\Classes\Med.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Powerups
            |
            +--XIII.XIIIItems
               |
               +--XIII.Med
Direct Known Subclasses:FullMedKit, MedKit, MultiplayerAutoFullMedKit, MultiplayerAutoMedKit

class Med
extends XIII.XIIIItems

//----------------------------------------------------------- // //-----------------------------------------------------------
Variables
 sound EffectiveSound
 bool bActivated
 int iHeal

States
Idle, for, InUse, for, Activated

Function Summary
 void GiveTo(Pawn Other)
     
//_____________________________________________________________________________
// Give this inventory item to a pawn.
 bool HandlePickupQuery(Pickup Item)
     
//_____________________________________________________________________________
// ELR OverRide HandlePickupQuery to allow multiple possession of same class
// Only Return True if we are not allowed multiple possession of the same class
 Powerups NextItem(Powerups CurrentChoice, Powerups CurrentItem)
     
//_____________________________________________________________________________
// Find the next Item (using the Inventory group)
 
simulated
UseMe()
     
//_____________________________________________________________________________
// ELR CauseEvent
 
simulated
UseMeQuick(XIIIPlayerController XPC)
     
//_____________________________________________________________________________
// ELR CauseEvent
 
simulated
UsedUp()
     
//_____________________________________________________________________________
// This is called when a usable inventory item has used up it's charge.
 
simulated
UsedUpNoChange()
     
//_____________________________________________________________________________
// This is called when a usable inventory item has used up it's charge.


State Idle Function Summary


State for Function Summary


State InUse Function Summary


State for Function Summary


State Activated Function Summary



Source Code


00001	//-----------------------------------------------------------
00002	//
00003	//-----------------------------------------------------------
00004	class Med extends XIIIItems
00005	  abstract;
00006	
00007	var int iHeal;
00008	var sound EffectiveSound;
00009	var bool bActivated;
00010	
00011	//_____________________________________________________________________________
00012	// Find the next Item (using the Inventory group)
00013	simulated function PowerUps NextItem(PowerUps CurrentChoice, PowerUps CurrentItem)
00014	{
00015	    local bool bAllow2H;
00016	
00017	    if ( (XIIIPawn(Owner).LHand != none) && XIIIPawn(Owner).LHand.bActive )
00018	      bAllow2H = false;
00019	    else
00020	      bAllow2H = true;
00021	
00022	    if ( bDisplayableInv && bActivatable && ((IHand != IH_2H) || bAllow2H) )
00023	    {
00024	      if ( (CurrentChoice == None) )
00025	      {
00026	        if ( CurrentItem != self )
00027	          CurrentChoice = self;
00028	      }
00029	      // MedKit specific, if no current item given then give priority to MedKits
00030	      if ( CurrentItem == none )
00031	      {
00032	        CurrentItem = self; // Test ?
00033	        CurrentChoice = self;
00034	      }
00035	      else if ( (CurrentChoice != none) && (InventoryGroup == CurrentChoice.InventoryGroup) )
00036	      {
00037	        if ( InventoryGroup == CurrentItem.InventoryGroup )
00038	        {
00039	          if ( (GroupOffset > CurrentItem.GroupOffset)
00040	            && (GroupOffset < CurrentChoice.GroupOffset) )
00041	            CurrentChoice = self;
00042	        }
00043	        else if ( GroupOffset < CurrentChoice.GroupOffset )
00044	          CurrentChoice = self;
00045	      }
00046	      else if ( (CurrentChoice != none) && (InventoryGroup < CurrentChoice.InventoryGroup) )
00047	      {
00048	        if ( (InventoryGroup > CurrentItem.InventoryGroup)
00049	          || (CurrentChoice.InventoryGroup < CurrentItem.InventoryGroup) )
00050	        CurrentChoice = self;
00051	      }
00052	      else if ( (CurrentChoice != none) && (CurrentItem != none) && ((CurrentChoice.InventoryGroup < CurrentItem.InventoryGroup)
00053	        && (InventoryGroup > CurrentItem.InventoryGroup)) )
00054	        CurrentChoice = self;
00055	    }
00056	    if ( Inventory == None )
00057	      return CurrentChoice;
00058	    else
00059	      return Inventory.NextItem(CurrentChoice,CurrentItem);
00060	}
00061	
00062	//_____________________________________________________________________________
00063	// ELR OverRide HandlePickupQuery to allow multiple possession of same class
00064	// Only Return True if we are not allowed multiple possession of the same class
00065	function bool HandlePickupQuery( Pickup Item )
00066	{
00067	    DebugLog(Self@"HandlePickupQuery for"@Item);
00068	    // Stack Items, 1 charge
00069	    if (Item.InventoryType == class)
00070	    {
00071	      if ( Item.Inventory != None )
00072	        Charge += Item.Inventory.Charge;
00073	      else
00074	        Charge += Item.InventoryType.Default.Charge;
00075	      Item.AnnouncePickup(Pawn(Owner));
00076	      return true;
00077	    }
00078	    if ( Inventory == None )
00079	      return false;
00080	
00081	    return Inventory.HandlePickupQuery(Item);
00082	}
00083	
00084	//_____________________________________________________________________________
00085	// Give this inventory item to a pawn.
00086	function GiveTo( pawn Other )
00087	{
00088	    Local Inventory Dual;
00089	//    Log("GIVETO (inventory)"@self@"to"@Other);
00090	    Dual = Other.FindInventoryType(class);
00091	    if ( Dual == none )
00092	    {
00093	      Instigator = Other;
00094	      Other.AddInventory( Self );
00095	      GotoState('');
00096	    }
00097	    else
00098	    {
00099	      Dual.Charge += Charge;
00100	      Destroy();
00101	    }
00102	}
00103	
00104	//_____________________________________________________________________________
00105	// ELR CauseEvent
00106	simulated function UseMeQuick(XIIIPlayercontroller XPC)
00107	{
00108	    local int i;
00109	    local XIIIPawn P;
00110	    local bool bUsedUp;
00111	
00112	    DebugLog("@@@ UseMe for "$self);
00113	
00114	    P = XIIIPawn(Owner);
00115	    if (P != none )
00116	    {
00117	      if ( P.IsWounded() && (iHeal > 0) )
00118	      {
00119	        if ( Instigator.FindInventoryKind('FirstAidSkill') != none )
00120	          P.Heal(P.Default.Health*iHeal/50);
00121	        else
00122	          P.Heal(P.Default.Health*iHeal/100);
00123	        bUsedUp = true;
00124	      }
00125	      if ( bUsedUp )
00126	      {
00127	        Charge --;
00128	        XPC.ClientFilter(
00129	          class'Canvas'.Static.MakeColor(0,148,148,255),
00130	          class'Canvas'.Static.MakeColor(128,128,128,255),
00131	          1.0/0.25
00132	        );
00133	        XPC.ClientTargetHighLight( 0, 0, 0.25);
00134	      }
00135	    }
00136	    if ( bUsedUp )
00137	      Instigator.PlayRolloffSound(EffectiveSound, self, 0);
00138	}
00139	
00140	//_____________________________________________________________________________
00141	// ELR CauseEvent
00142	simulated function UseMe()
00143	{
00144	    local int i;
00145	    local XIIIPawn P;
00146	    local bool bUsedUp;
00147	
00148	    DebugLog("@@@ UseMe for "$self);
00149	
00150	    P = XIIIPawn(Owner);
00151	    if (P != none )
00152	    {
00153	      if ( P.IsWounded() && (iHeal > 0) )
00154	      {
00155	        if ( Instigator.FindInventoryKind('FirstAidSkill') != none )
00156	          P.Heal(P.Default.Health*iHeal/50);
00157	        else
00158	          P.Heal(P.Default.Health*iHeal/100);
00159	        bUsedUp = true;
00160	      }
00161	      if ( bUsedUp )
00162	        Charge --;
00163	    }
00164	//    if ( bUsedUp )
00165	//      Owner.PlayRolloffSound(EffectiveSound, self);
00166	}
00167	
00168	//_____________________________________________________________________________
00169	// This is called when a usable inventory item has used up it's charge.
00170	simulated function UsedUpNoChange()
00171	{
00172	    DebugLog("@@@ UsedUpNoChange for "$self);
00173	    if ( Pawn(Owner) != None )
00174	    {
00175	      bActivatable = false;
00176	//      XIIIPlayercontroller(XIIIPawn(Owner).controller).cNextItem();
00177	//      Log("  @ UsedUp Next Item="$XIIIPawn(Owner).PendingItem);
00178	//      if ( (XIIIPawn(Owner).PendingItem == None) || (XIIIPawn(Owner).PendingItem == self) )
00179	//        XIIIPlayercontroller(XIIIPawn(Owner).controller).NextWeapon();
00180	
00181	//      XIIIPawn(Owner).ChangedWeapon();
00182	      if (Level.Game.StatLog != None)
00183	        Level.Game.StatLog.LogItemDeactivate(Self, XIIIPawn(Owner));
00184	//      Instigator.ReceiveLocalizedMessage( MessageClass, 0, None, None, Self.Class );
00185	    }
00186	//    Owner.PlayRolloffSound(DeactivateSound, self);
00187	
00188	    if ( XIIIPawn(Owner).PendingItem == self )
00189	      XIIIPawn(Owner).PendingItem = none;
00190	    Destroy();
00191	}
00192	
00193	//_____________________________________________________________________________
00194	// This is called when a usable inventory item has used up it's charge.
00195	simulated function UsedUp()
00196	{
00197	    DebugLog("@@@ UsedUp for "$self);
00198	    if ( Pawn(Owner) != None )
00199	    {
00200	      bActivatable = false;
00201	//      XIIIPlayercontroller(XIIIPawn(Owner).controller).cNextItem();
00202	//      Log("  @ UsedUp Next Item="$XIIIPawn(Owner).PendingItem);
00203	//      if ( (XIIIPawn(Owner).PendingItem == None) || (XIIIPawn(Owner).PendingItem == self) )
00204	      if ( XIIIPawn(Owner).SelectedItem == self )
00205	        XIIIPawn(Owner).SelectedItem = none;
00206	      if ( XIIIPawn(Owner).PendingItem == self )
00207	        XIIIPawn(Owner).PendingItem = none;
00208	      if ( !XIIIPlayercontroller(XIIIPawn(Owner).controller).bWaitForWeaponMode )
00209	        XIIIPlayercontroller(XIIIPawn(Owner).controller).NextWeapon();
00210	
00211	      XIIIPawn(Owner).ChangedWeapon();
00212	      if (Level.Game.StatLog != None)
00213	        Level.Game.StatLog.LogItemDeactivate(Self, XIIIPawn(Owner));
00214	//      Instigator.ReceiveLocalizedMessage( MessageClass, 0, None, None, Self.Class );
00215	    }
00216	//    Owner.PlayRolloffSound(DeactivateSound, self);
00217	    Destroy();
00218	}
00219	
00220	//_____________________________________________________________________________
00221	state Activated
00222	{
00223	    simulated function BeginState()
00224	    {
00225	      DebugLog(Level.TimeSeconds@"@@@ Activated BeginState for "$self);
00226	      Instigator = Pawn(Owner);
00227	      PlaySelect();
00228	      bRendered = true;
00229	//      bHidden = false;
00230	//      RefreshDisplaying();
00231	      bActivated = false;
00232	      bChangeItem = false;
00233	    }
00234	
00235	    simulated function AnimEnd(int Channel)
00236	    {
00237	      DebugLog("  > Activated AnimEnd bChangeItem="$bChangeItem);
00238	      if ( bChangeItem )
00239	      {
00240	        GotoState('DownItem');
00241	        return;
00242	      }
00243	      if ( bActivated && XIIIPawn(Owner).IsWounded() )
00244	      {
00245	        GotoState('InUse');
00246	        return;
00247	      }
00248	      GotoState('Idle');
00249	    }
00250	
00251	    simulated function Activate() { DebugLog("@@@ Activated while going out"); bActivated = true; }
00252	}
00253	
00254	//_____________________________________________________________________________
00255	// For medkits, the UseMe is called at the beginning & not at the end of anim.
00256	State InUse
00257	{
00258	    simulated function BeginState()
00259	    {
00260	      DebugLog("@@@ InUse BeginState for "$self);
00261	      PlayUsing();
00262	      UseMe();
00263	    }
00264	
00265	    simulated function Activate() {}
00266	
00267	    simulated function AnimEnd(int Channel)
00268	    {
00269	      if (Charge <=0)
00270	      {
00271	        UsedUp();
00272	        return;
00273	      }
00274	      if ( bChangeItem )
00275	      {
00276	        GotoState('DownItem');
00277	        return;
00278	      }
00279	      GotoState('Idle');
00280	    }
00281	}
00282	
00283	//_____________________________________________________________________________
00284	state Idle
00285	{
00286	    simulated function Activate()
00287	    {
00288	      if ( XIIIPawn(Owner).bHaveOnlyOneHandFree && (IHand == IH_2H) )
00289	      {
00290	        PlayerController(Pawn(owner).controller).MyHud.LocalizedMessage(class'XIIISoloMessage', 8);
00291	      }
00292	      else if ( XIIIPawn(owner).IsWounded() )
00293	        GotoState('InUse');
00294	    }
00295	}
00296	
00297	//_____________________________________________________________________________
00298	simulated function PlayIdle()
00299	{
00300	    DebugLog("@@@"@self@"PlayIdle");
00301	    PlayAnim('Wait', 1.0);
00302	}
00303	
00304	//_____________________________________________________________________________
00305	simulated function PlayUsing()
00306	{
00307	    DebugLog("@@@"@self@"PlayUsing");
00308	    PlayAnim('Fire', 2.0);
00309	//    Instigator.PlayRolloffSound(ActivateSound, self);
00310	}
00311	
00312	//_____________________________________________________________________________
00313	simulated function FPSItemNote1()
00314	{
00315	    Instigator.PlayRolloffSound(EffectiveSound, self, 0);
00316	}
00317	
00318	//_____________________________________________________________________________
00319	simulated function FPSItemNote2()
00320	{
00321	    Instigator.PlayRolloffSound(EffectiveSound, self, 1);
00322	}
00323	
00324	
00325	
00326	defaultproperties
00327	{
00328	     IHand=IH_2H
00329	     bNumberedItem=True
00330	     bAutoActivate=True
00331	     bActivatable=True
00332	     ExpireMessage="Medicine was used."
00333	     bDisplayableInv=True
00334	     Charge=1
00335	     PlayerViewOffset=(X=12.000000,Y=6.000000,Z=-5.000000)
00336	     ItemName="Medecine"
00337	}

End Source Code