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.
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)
return;
Initialized = True;
// Calculate number of navigation points.
for (NP = Level.NavigationPointList; NP != None; NP = NP.NextNavigationPoint)
{
if (NP.IsA('PathNode'))
NumPoints++;
}
// HUD info copied from base player pawn class so the HUD will show up after the new navigation points code was added
Super.PostBeginPlay();
if (Level.LevelEnterText != "" )
ClientMessage(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') )
HERO.PlayerReplicationInfo.HasFlag.Drop(vect(0,0,0));
//============================================
//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);
HERO.SetLocation(NP.Location);
if ( HERO.IsA('PlayerPawn') )
PlayerPawn(HERO).SetFOVAngle(170);
HERO.AddVelocity(vect(0,0,-25));
///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
}
PointCount++;
}
}
}