Wednesday, 23 November 2011

Regeneration Coding

class CustomPawn extends UTPawn;
//check if player is in volume
var bool bIsInVolume;
//Regen variables
var float ElapsedRegenTime;
var float RegenAmount;
var float RegenTime;
simulated event PostBeginPlay()
{
 super.PostBeginPlay();

 //print to chow code is working
 `Log("USING CUSTOM PAWN CALLED CustomPawn.");
}
public funtion CheckInCover (Pawn Other)
{
 if(Pawn.PhysicsVolume.bIsInVolume == true)
 {
  Timer();
 }
}
function Timer(float DeltaTime)
{
   //calculate elapsed time
   ElapsedRegenTime += DeltaTime;
  
   //has enough time elapsed?
 if(ElapsedRegenTime >= RegenTime)
 {
  //heal the Pawn and reset elapsed time
  HealDamage(RegenAmount, Controller, class'DamageType');
  ElapsedRegenTime = 0.0f;
 }
}

}

class RegenVolume extends PhysicsVolume
placeable;
//the event that checks if the player is touching the cover volume
event PawnEnteredVolume (Pawn Other)
{
 //check if customPawn has entered the volume
 if (CustomPawn(other) != none)
 {
  //sets bIsInVolume to true
  CustomPawn(other).bIsInVolume = true;
 }
}
//the event to check whether the player has left the volume
event untouch(Actor Other)
{
 //check if customPawn has left the volume
 if(CustomPawn(other) != none)
 {
  //sets bIsInVolume to false
  CustomPawn(other).bIsInVolume = false;
 }
}
defaultproperties
{
}

No comments:

Post a Comment