Game Development Reference
In-Depth Information
How to do it...
We're only going to add one function to this class.
Just as we did with our healing weapon, we need to override the UTWeapon
class's ProcessInstantHit() function. We're not going to do any sort
of healing again though.
simulated function ProcessInstantHit(byte FiringMode, ImpactInfo
Impact, optional int NumHits)
local TutorialPawn TP;
if (Impact.HitActor != None &&
// Defining the pawn
TP = TutorialPawn(Impact.HitActor);
/** Calls the poison function in the TutorialPawn
class */
// Log for debugging
'Log("***Pawn Health:" @TP.Health);
First we perform a check to see whether our projectile has hit an actor. Immediately
after that, we check to see if that actor is a pawn. We don't want to apply our
poison damage to something non-living like a vehicle or a barrel. Afterwards, we
check to see if the pawn is of our TutorialPawn class. From there, we call the
PoisonPlayer() function from our TutorialPawn class. This is what actually
poisons the pawn. Finally, we add our standard log which tracks our tutorial pawn's
health, to verify that our function is actually having some kind of an effect.
Now it's time to head to our TutorialPawn class. Let's start by adding a variable
to hold the amount of time ticking by, as our pawn is poisoned:
var int PoisonCountdown;
Our PoisonPlayer() function is what is actually being called by our weapon.
This simple function resets our poison counter to 0 , and prevents our damage
from stacking.
Search Nedrilad ::

Custom Search