PDA

View Full Version : Desperately seeking answers


Silver_Ibex
14th Nov 2001, 01:01 PM
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.



//----------------------------------------------------------------//
//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;
}

Hugh Macdonald
14th Nov 2001, 01:10 PM
The line you are looking for is in Tick():

pawn(owner).Velocity = Normal(Hook.Location - pawn(owner).Location) * HookSpeed;

This sets the velocity of the owner to be in the direction pointing from the pawn to the hook (Normal() makes the vector a normal vector (with length 1)), and with magnitude equal to HookSpeed.

The next line:

pawn(owner).velocity.z *= 0.6;

Adds a bit of gravits by decreasing the amount of upwards thrust that is acting on the owner.

The Dopefish
14th Nov 2001, 01:37 PM
Hi. :) I just wanted to pop in and congratulate Silver_Ibex on posting the 800000th post in BuF/PuF history. :)

Silver_Ibex
14th Nov 2001, 05:50 PM
Thanks :)
with that bit of info I got it to work, by putting “HookSpeed=1000” in the “defaultproperties”.

Seeing the variable value was not defined in the code made me realize it had to be defined in the “defaultproperties”.

What gave me the trouble was this property is not a UT standard property so it is not displayed in the “defaultproperties” menu.