XIII
Class XIIIAmmoPick

source: C:\XIII\XIII\Classes\XIIIAmmoPick.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pickup
         |
         +--Engine.Ammo
            |
            +--XIII.XIIIAmmoPick
Direct Known Subclasses:BazookAmmoClip, BoltAmmoBox, HarponAmmoClip, M16AmmoClip, M16GrenadPick, M60AmmoClip, MiniUziAmmoClip, PumpAmmoClip, bmg50AmmoClip, c44AmmoClip, c556AmmoClip, c9mmAmmoClip

class XIIIAmmoPick
extends Engine.Ammo

//----------------------------------------------------------- // //-----------------------------------------------------------
States
Pickup
State Pickup Function Summary
 bool ValidTouch(Actor Other)
     
    /* ValidTouch()
    Validate touch (if valid return true to let other pick me up and trigger event).
    */



Source Code


00001	//-----------------------------------------------------------
00002	//
00003	//-----------------------------------------------------------
00004	class XIIIAmmoPick extends Ammo;
00005	
00006	//_____________________________________________________________________________
00007	event ParseDynamicLoading(LevelInfo MyLI)
00008	{
00009	    Log("ParseDynamicLoading Actor="$self);
00010	    if ( class<Ammunition>(default.InventoryType).default.ProjectileClass != none )
00011	      MyLI.ForcedStaticMeshes[MyLI.ForcedStaticMeshes.Length] =
00012	        StaticMesh(DynamicLoadObject(class<XIIIProjectile>(class<Ammunition>(default.InventoryType).default.ProjectileClass).default.StaticMeshName, class'StaticMesh'));
00013	}
00014	
00015	//_____________________________________________________________________________
00016	event float BotDesireability(Pawn Bot)
00017	{
00018	    local Ammunition AlreadyHas;
00019	
00020	    AlreadyHas = Ammunition(Bot.FindInventoryType(InventoryType));
00021	    if ( AlreadyHas == None )
00022	      //return (0.35 * MaxDesireability);
00023	      return -1;
00024	    if ( AlreadyHas.AmmoAmount == 0 )
00025	      return MaxDesireability;
00026	    if (AlreadyHas.AmmoAmount >= AlreadyHas.MaxAmmo)
00027	      return -1;
00028	
00029	    return ( MaxDesireability * FMin(1, 0.15 * AmmoAmount/AlreadyHas.AmmoAmount) );
00030	}
00031	
00032	//_____________________________________________________________________________
00033	// Pickup state: this inventory item is sitting on the ground.
00034	auto state Pickup
00035	{
00036	    /* ValidTouch()
00037	    Validate touch (if valid return true to let other pick me up and trigger event).
00038	    */
00039	    function bool ValidTouch( actor Other )
00040	    {
00041	      local Ammunition AlreadyHas;
00042	
00043	      // make sure its a live player
00044	      if ( (Pawn(Other) == None) || !Pawn(Other).bCanPickupInventory || (Pawn(Other).Health <= 0) )
00045	        return false;
00046	
00047	      // make sure not touching through wall
00048	      // ELR take EyeHeight into account
00049	      if ( !FastTrace(Other.Location+Pawn(Other).EyeHeight*vect(0,0,1), Location) )
00050	        return false;
00051	
00052	      // make sure game will let player pick me up
00053	      if( Level.Game.PickupQuery(Pawn(Other), self) )
00054	      {
00055	        AlreadyHas = Ammunition(Pawn(Other).FindInventoryType(InventoryType));
00056	        if ( (AlreadyHas == none) || (AlreadyHas.AmmoAmount < AlreadyHas.MaxAmmo) )
00057	        {
00058	          TriggerEvent(Event, self, Pawn(Other));
00059	          return true;
00060	        }
00061	        else if ( AlreadyHas.AmmoAmount == AlreadyHas.MaxAmmo )
00062	          PlayerController(Pawn(Other).Controller).MyHud.LocalizedMessage(class'XIIIDialogMessage', 4);
00063	      }
00064	      return false;
00065	    }
00066	}
00067	
00068	
00069	defaultproperties
00070	{
00071	     RespawnTime=5.000000
00072	     hRespawnSound=Sound'XIIIsound.Multi__SFXMulti.SFXMulti__hRespawnGun'
00073	     DrawType=DT_StaticMesh
00074	     MessageClass=Class'XIII.XIIIPickupMessage'
00075	}

End Source Code