View Full Version : Special FX and a subtraction from health

10th Nov 2001, 12:19 AM
What I am trying to do is give my new player pawn class the ability to teleport to a random path node when a button is pressed.

So I placed some code based on code taken from the Relic class and the translocator, into the player pawn class, and it works :)

Now I want to modify it, so that it subtracts a fixed number from the players’ health every time they teleport.
I also need the translocator special effects to spawn like they do when you use the translocator.

Special FX and a subtraction from health are what I need help with

Below is the code I dumped into the new player class.

var int NumPoints;
var bool Initialized;
var int NavPoint;

event PostBeginPlay()
local NavigationPoint NP;

if (Initialized)
Initialized = True;

// Calculate number of navigation points.
for (NP = Level.NavigationPointList; NP != None; NP = NP.NextNavigationPoint)
if (NP.IsA('PathNode'))

// HUD info copied from base player pawn class so the HUD will show up after the new navigation points code was added

if (Level.LevelEnterText != "" )
if ( Level.NetMode != NM_Client )
HUDType = Level.Game.HUDType;
ScoringType = Level.Game.ScoreboardType;
MyAutoAim = FMax(MyAutoAim, Level.Game.AutoAim);
bIsPlayer = true;
DodgeClickTime = FMin(0.3, DodgeClickTime);
DesiredFOV = DefaultFOV;
EyeHeight = BaseEyeHeight;
if ( Level.Game.IsA('SinglePlayer') && (Level.NetMode == NM_Standalone) )
FlashScale = vect(0,0,0);

//FX spawner taken from the translocator weapon code

function SpawnEffect(vector Start, vector Dest)
local actor e;

e = Spawn(class'TranslocOutEffect',,,start, Owner.Rotation);
e.Mesh = Owner.Mesh;
e.Animframe = Owner.Animframe;
e.Animsequence = Owner.Animsequence;
e.Velocity = 900 * Normal(Dest - Start);

//the command the key is bound to

exec function PUTTeleport()
local int PointNumber, PointCount;
local Pawn HERO;
local NavigationPoint NP;
local vector Dest, Start;

NavPoint = Rand(NumPoints);

HERO = self;
Start = self.Location;

PointNumber = Rand(self.NumPoints);

for (NP = Level.NavigationPointList; NP != None; NP = NP.NextNavigationPoint)
if (NP.IsA('PathNode'))
if (PointCount == PointNumber)
if ( (HERO.PlayerReplicationInfo.HasFlag != None)
&& HERO.PlayerReplicationInfo.HasFlag.IsA('CTFFlag') )

//this is the part that’s giving me trouble, how do I get the FX to spawn

Dest = (NP.Location); //have to tell it the path node number somehow, not sure if this is right

//the relics spawn FX code, I commented it out as it was not working and moved onto trying out the translocator FX

//Spawn(class'ItemSpawnEffect', HERO,, HERO.Location, HERO.Rotation);

//the translocator FX

SpawnEffect(Start, Dest);

if ( HERO.IsA('PlayerPawn') )

///And finally I need a line of code that subtracts from the health
//I think it is something like “HERO.Health -25;” though that doesn’t work


10th Nov 2001, 01:24 AM
Easy hehe, for the teleport effect, just write:


if you need to modify the UTTeleportEffect (like to modify the DrawScale) simply make an object of the class, like this:

local (or var) UTTeleportEffect x;

x = Spawn(class'UTTeleportEffect',,,Hero.Location);
x.DrawScale = <some number>;
x.LightBrightness = <some number>;

etc, etc.

write one both before and after it has teleported.

As for the damage, you can do it two ways:

1.Substract health from the "Hero" modifying the HERO.Health variable like:

//....after teleport
HERO.Health -= <damage>;

if(HERO.Health < 0 )
HERO.Died(self, <some damage type>, HERO.Location)

of you can call the actor function take damage:

//...after teleport
HERO.TakeDamage( <damage> , self, HERO.Location, HERO.Location, damage type);

the later one look more realistic in the sense that the Pawn will play the hurt animation when the damage is taken. The first one is just a substraction of health, plus checking if health is lower than 0, because just setting the HERO.Health variable to 0 won't kill the pawn per se.

The damage type is important if you want to control how the player dies, for instance, if your damage type is 'Decapitated', when the player dies it head will explode lol, or 'gibbed' well I bet you know what that means hehe.
Well hope that helps!

10th Nov 2001, 06:32 PM
Thanks for the help:cool:

I had to tweak the code some to get it to detect death at and below 0 instead of at -1.

Also the damage code wouldn’t work till I phrased it like below, I based it on the “trigger death” class code, and made a new damage class :)

HERO.Health -= 25;

if(HERO.Health < 1 )

HERO.Died(none, 'Drained',HERO.Location);