RuneI
Class Food

source: c:\runehov\RuneI\Classes\food.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Pickup
            |
            +--RuneI.Food
Direct Known Subclasses:HealthFruit1, HealthFruit2, LegOMeat1, LegOMeat2, LegOMeat3, Lizard, Stein

class Food
extends Engine.Pickup

//============================================================================= // Food. //=============================================================================
Variables
 class JunkActor
 int Nutrition


Function Summary
 int GetUsePriority()
     
//============================================================================
//
// GetUsePriority
//
// Returns the priority of the weapon, lower is better
//============================================================================
 void InventorySpecial1()
 void InventorySpecial2()
     
/*
 void PickupFunction(Pawn Other)



Source Code


00001	//=============================================================================
00002	// Food.
00003	//=============================================================================
00004	class Food extends Pickup
00005		abstract;
00006	
00007	
00008	var() int Nutrition;
00009	var() class<actor> JunkActor;
00010	
00011	var(Sounds) sound UseSound; // The sound that is played when the item is immediately picked up
00012	
00013	//============================================================================
00014	//
00015	// GetUsePriority
00016	//
00017	// Returns the priority of the weapon, lower is better
00018	//============================================================================
00019	
00020	function int GetUsePriority()
00021	{
00022		return(3);
00023	}
00024	
00025	function PickupFunction(Pawn Other)
00026	{
00027		local int i;
00028		local int adjNutrition;
00029	
00030		adjNutrition = Nutrition;
00031	
00032		switch(Level.Game.Difficulty)
00033		{
00034		case 0: // Easy mode, more health
00035			adjNutrition *= 1.5;
00036			break;
00037		case 2: // Hard mode, less health
00038			adjNutrition *= 0.75;
00039			break;
00040		}
00041	
00042		Other.Health += adjNutrition;
00043		if (Other.Health > Other.MaxHealth)
00044			Other.Health = Other.MaxHealth;
00045	
00046		// Cure eater of any ailments
00047		if(Other.Fatness != 128)
00048			Other.DesiredFatness = 128;
00049		if(Other.ScaleGlow != 1.0)
00050			Other.ScaleGlow = 1.0;
00051		if(Other.BodyPartMissing(BODYPART_LARM1))
00052			Other.RestoreBodyPart(BODYPART_LARM1);
00053		if(Other.BodyPartMissing(BODYPART_RARM1))
00054			Other.RestoreBodyPart(BODYPART_RARM1);
00055	
00056		// Restore health of bodyparts (must be after restoring limbs)
00057		for (i=0; i<NUM_BODYPARTS; i++)
00058			Other.BodyPartHealth[i] = Other.Default.BodyPartHealth[i];
00059	
00060		// Fire the event on the food item
00061		if(Other.bIsPawn)
00062			FireEvent(Event);
00063	
00064		Destroy();
00065	}
00066	
00067	function InventorySpecial1()
00068	{ // Special1 - Eat/drink the food/mead
00069		local Pawn P;
00070		local int joint;
00071		local actor junk;
00072	
00073		if(Owner == None)
00074			return;
00075	
00076		P = Pawn(Owner);
00077	
00078		joint = P.JointNamed(P.WeaponJoint);
00079		if(joint != 0)
00080		{
00081			P.DetachActorFromJoint(joint);
00082	
00083			if(JunkActor != None)
00084			{
00085				junk = Spawn(JunkActor, P,, Location);
00086				if(junk != None)
00087					P.AttachActorToJoint(junk, joint);
00088			}
00089		}
00090	
00091		SetOwner(P); // Has to reset owner, as it is set to None by DetachActorFromJoint
00092	
00093		if ( PickupMessageClass == None )
00094			P.ClientMessage(PickupMessage, 'Pickup');
00095		else
00096			P.ReceiveLocalizedMessage( PickupMessageClass, 0, None, None, Self.Class );
00097		PlaySound(PickupSound,,2.0);	
00098		PickupFunction(P);
00099	}
00100	
00101	/*
00102	function InventorySpecial2()
00103	{ // Drop the refuse (bone or empty stein)
00104		local Pawn P;
00105		local actor junk;
00106	
00107		if(Owner == None)
00108			return;
00109			
00110		P = Pawn(Owner);
00111		junk = P.DetachActorFromJoint(P.JointNamed(P.WeaponJoint));
00112	
00113		if(junk != None)
00114		{	
00115			junk.Velocity = DropVelocity(P);
00116			junk.SetPhysics(PHYS_Falling);
00117			junk.bCollideWorld = true;
00118		}
00119	
00120		if (!bDeleteMe)
00121			Destroy();
00122	}
00123	*/
00124	
00125	defaultproperties
00126	{
00127	     Nutrition=5
00128	     RespawnTime=30.000000
00129	     RespawnSound=Sound'OtherSnd.Respawns.respawn01'
00130	     PickupMessageClass=Class'RuneI.PickupMessage'
00131	}

End Source Code