PDA

View Full Version : "Laser Aimer" interfering/jamming "Grappling Hook"


Silver_Ibex
10th Nov 2001, 09:20 PM
I have two new classes I added to the “inventory TournamentPickup”, one a laser aimer, the other a yet to be modified grappling hook, the problem is that when the player has both the laser aimer and the hook, the hook jams, it freezes the character in place, so that they are suspended in the air as long as you hold down the “use hook” key

The hook is supposed to pull the character.

Can anyone point out the part that is causing the interference? I’m clueless as to the solution :(

First the Laser Aimer

class PUTLSight expands TournamentPickup;

//Code based on "Laser Sights mutator" by Glen Sharman,
//Modified by Silver_Ibex 2001
//
//with special thanks to Brood_of_Evil for help with the code

var PUTldot LD;


#exec TEXTURE IMPORT FILE=Textures\pdot.pcx NAME=LaserDot
#exec TEXTURE IMPORT FILE=Textures\pdotlocked.pcx NAME=Laserlock

function Activate()
{
GoToState('Activated');
}


state Activated
{
simulated function BeginState()
{
LD = Spawn(Class'PUTLDot', Owner);
bActive = true;
}


simulated function Tick(float DeltaTime)
{
local actor TargetedActor; //**Create an actor object**.

local vector X, Y, Z, StartTrace, EndTrace, HitLocation, HitNormal;


if ( Pawn(Owner).IsInState('FeigningDeath') && bActive )
{
LD.Destroy();
bActive = false;
}

if ( !bActive && !Pawn(Owner).Weapon.bMeleeWeapon && !Pawn(Owner).IsInState('FeigningDeath') )
{
LD = Spawn(Class'PUTLDot', Owner);
bActive = true;
}

GetAxes(Pawn(Owner).ViewRotation, X, Y, Z);
StartTrace = Pawn(Owner).Location + CalcDrawOffset();
EndTrace = StartTrace + vector(Pawn(Owner).ViewRotation) * 90000;
Trace(HitLocation, HitNormal, EndTrace, StartTrace, True);
LD.SetLocation(HitLocation);
LD.Setlocation(EndTrace);
//**The Trace function returns an actor type variable.**
TargetedActor = Trace(HitLocation, HitNormal, EndTrace, StartTrace, True);
LD.SetLocation(HitLocation);

if(TargetedActor.IsA('Pawn')) //**Verify that the actor is a Pawn**
{
//**Yes it's a Pawn**

LD.DrawScale = 0.5; //**you can change the drawscale here**
//**call SetDisplayProperties to change the texture**

LD.SetDisplayProperties(STY_Translucent, Texture'Laserlock', false, false);
}
else //**Else, if there's not an actor at the end of the trace, reset the LDot tp it's default values**
{
LD.DrawScale = LD.Default.DrawScale;
LD.SetDisplayProperties(LD.Default.Style, LD.Default.Texture, false, false);
}
}


simulated function EndState() //destroy laser dot if player dies
{
LD.Destroy();
bActive = false;
}


simulated function Activate()
{
GoToState('DeActivated');
}
}


state DeActivated
{
function BeginState()
{
LD.Destroy();
bActive = false;
}
}


And now the Grappling Hook



class PUTgrapple extends TournamentPickup config;

Var bool bhooked;
Var FocusPoint hook;
var float dist;
var float effect;
var float ropetime;
var float hookspeed;

replication
{
reliable if (Role == ROLE_Authority)
bHooked, dist, Hook;

reliable if (Role < ROLE_Authority)
firehook, releasehook;
}

simulated exec function firehook()
{
local vector L, N;
local actor a;

a = Trace(L, N, 10000.0 * Vector(pawn(owner).ViewRotation) + pawn(owner).Location, pawn(owner).Location, False, );
if ((a != None) && (a == Level))
{
if (L.Z >= Instigator.Location.Z)
{
Hook = Spawn(class'FocusPoint', Instigator, , L + N * 5.0, Rotator(N));
hook.drawscale *=0.5;
pawn(owner).SetPhysics(PHYS_Falling);

bhooked=true;
}
}
}
simulated exec function releasehook()
{

if (Hook != None) Hook.Destroy();
bHooked = False;

pawn(owner).bCanFly = False;
Pawn(owner).SetPhysics(PHYS_Falling);
}
simulated function Tick(float DeltaTime)
{
if (pawn(owner) == None) return;
if (Hook == None) return;
if (!bHooked) return;
if (hook != none)
{
if (VSize(Hook.Location - pawn(owner).Location) >= 2500)
{
Hook.destroy();
bhooked = false;
return;
}
if (VSize(Hook.Location - pawn(owner).Location) <= 25.0)
{
pawn(owner).Velocity = vect(0.0, 0.0, 0.0);
pawn(owner).SetPhysics(PHYS_None);

}
else if (pawn(owner).Physics != PHYS_None)
{
pawn(owner).Velocity = Normal(Hook.Location - pawn(owner).Location) * HookSpeed;
pawn(owner).velocity.z *= 0.6;
effect += DeltaTime;
if (effect >= ropeTime * 0.25)
{
effect -= ropeTime * 0.25;
spawneffect(hook.location,pawn(owner).location);
//pawn(owner).playsound(Sound'opstingray.oprope');

}
}
else
{
if (VSize(Instigator.Velocity) > 0.0) Instigator.Velocity = vect(0.0, 0.0, 0.0);
}
}
}
function Destroyed()
{
if (hook != none)
Hook.Destroy();
}
function SpawnEffect(vector HitLocation, vector SmokeLocation)
{
local PUTrope Smoke,shock;
local Vector DVector;
local int NumPoints;
local rotator SmokeRotation;

DVector = HitLocation - SmokeLocation;
NumPoints = VSize(DVector)/135.0 ;
if ( NumPoints < 1 )
return;
SmokeRotation = rotator(DVector);
SmokeRotation.roll = Rand(65535);

Smoke = Spawn(class'PUTrope',,,SmokeLocation,SmokeRotation);
Smoke.MoveAmount = DVector/NumPoints;
Smoke.NumPuffs = NumPoints -1;
}