Can someone please explain and point out the part where this grappling hook code tells the owner to be pulled in the direction of the hook???
I have even resorted to cut and pasting the code and still can't get a grappling hook that will pull the owner.
I have even resorted to cut and pasting the code and still can't get a grappling hook that will pull the owner.
//----------------------------------------------------------------//
//Opstingray grapple -- q2 lithium style -- //
// //
//----------------------------------------------------------------//
class opgrapple extends TournamentPickup config;
Var bool bhooked;
Var lsight 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'lsight', 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 oprope 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'oprope',,,SmokeLocation,SmokeRotation);
Smoke.MoveAmount = DVector/NumPoints;
Smoke.NumPuffs = NumPoints -1;
}