Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → My Hook Has Issues
My Hook Has Issues
2002-08-29, 10:19 AM #1
I'm working with a grapple hook in MotS - It seems to work just fine, except when I launch it, it only seems to go so far and land in mid air. Or if your close to a wall, or item then it might touch. Could anyone take a peek at it and see what is wrong please [http://forums.massassi.net/html/smile.gif] Thanks

----------------------------
symbols

keyframe fireAnim=kygrip0.key local

sound grapfireSound=grfire.wav local
sound graphitSound=grhit.wav local
sound grapretractSound=grretract.wav local
thing player local
template grap=+grapplehook local
int hooklanded=0 local
vector dir local
thing graphook local
int hook=0 local
message startup
message activated
message pulse
message newplayer
message stop_hook
end

# ========================================================================================

code
startup:
player = GetLocalPlayerThing();
SetPulse(0);
call stop_hook;

Return;
# .....................................
activated:
player = GetSourceRef();


if(hook)
{
PlaySoundThing(grapretractSound, player, 1.0, -1.0, -1.0, 0x80);
Print("Grapple Retracted");
call stop_hook;
return;
}
else
{

graphook = FireProjectile(player, grap, grapfireSound, 75, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
Print("Grapple Deployed");
hook=1;
SetPulse(0.1);

}

Return;

# .....................................
pulse:

if(hooklanded == 0)
{
if((GetThingAttachFlags(graphook) != 0) || (IsThingMoving(graphook) == 0))
{
hooklanded = 1;
PlaySoundThing(graphitSound, player, 1.0, -1.0, -1.0, 0x80);
Print("Hook Attached");
}
}
else
{
if(GetThingHealth(graphook) == 0)
{

call stop_hook;
return;
}
dir = VectorScale(VectorNorm(VectorSub(GetThingPos(graphook), GetThingPos(player))), 40);
DetachThing(player);
ClearPhysicsFlags(player, 0x1);
ApplyForce(player, dir);
}


Return;
# ........................................................................................

newplayer:
call stop_hook;

Return;
# ........................................................................................

stop_hook:

SetPulse(0);
if(graphook)
{
DestroyThing(graphook);
}
hook = 0;
hooklanded = 0;
SetPhysicsFlags(player, 0x1);


Return;

end
------------------------------------

------------------
Generation Knights - for MotS
( http://viper-studios.clanpages.com/ )
------------------------
2002-08-29, 10:28 AM #2
I thus assume that you did not write that or write it entirely. Look carefully at the fireprojectile. I believe the grappling hook has a timer so that it dies before going too far. Just increase the time to suit your need.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-29, 11:17 AM #3
0.1624

That was the setting. I changed it to a 10.1624 and I get a long shot from it. Thank you that did it [http://forums.massassi.net/html/smile.gif]
2002-08-31, 4:43 AM #4
You might want to use this cog instead:
Code:
# ITEM_HOOK.COG
#
# Inventory cog to control a grappling hook. This cog's bin
# should be flagged 0x10.
#
#==============================================================#
symbols

sound     grapfireSound=grfire.wav         local
sound     grapretractSound=grretract.wav   local
sound	graphitSound=grhit.wav         local

thing     player                           local
thing		graphook			local

template  grap=+grapplehook                local

int       on                               local

vector	pos		local
vector	lpos		local
vector    dir                              local

message   startup
message   activated
message   pulse
message   killed
message   damaged
message   removed

end
#==============================================================#
code
#------------------------------------------------------
startup:
	player = GetLocalPlayerThing();
	graphook=0;
	call stop_hook;

Return;
#------------------------------------------------------
activated:
	if(graphook)
	{
		PlaySoundThing(grapretractSound, player, 1.0, -1, -1, 0x80);
		Print("Grapple Retracted");
		call stop_hook;
	}
	else
	{
		graphook = FireProjectile(player, grap, grapfireSound, 75, '0.0135 0.1624 0.0', '0 0 0', 0, 0, 0, 0);
		CaptureThing(graphook);
		Print("Grapple Deployed");
		SetPulse(0.1);
	}

Return;
#------------------------------------------------------
pulse:
	pos=GetThingPos(graphook);
	if(VectorDist(pos, lpos) < 0.01 && !on)
	{
		on = 1;
		ClearPhysicsFlags(player, 0x1);
		PlaySoundThing(graphitSound, player, 1.0, -1.0, -1.0, 0x80);
	}
	lpos=pos;

	if(!on) Return;

	if(GetThingAttachFlags(player) & 0x1)
	{
		DetachThing(player);
		ApplyForce(player, VectorScale(GetThingUVec(player), 40));
	}

	dir = VectorScale(VectorNorm(VectorSub(GetThingPos(graphook), GetThingPos(player))), 40);
	ApplyForce(player, dir);

Return;
#------------------------------------------------------
killed:
	removed:
	call stop_hook;

Return;
#------------------------------------------------------
stop_hook:
	SetPulse(0);
	if(graphook) DestroyThing(graphook);
	graphook=0;
	on = 0;
	SetPhysicsFlags(player, 0x1);

Return;
#------------------------------------------------------
damaged:
	if(GetParam(1) == 0x40 && on) ReturnEx(0);
	else ReturnEx(GetParam(0));

Return;
#------------------------------------------------------
end


And I rewrote the templates:

Quote:
<font face="Verdana, Arial" size="2">_grapbase none orient=(0/0/0) type=weapon collide=1 move=physics thingflags=0x20000000 physflags=0x200 maxrotvel=90

+grapplehook _grapbase model3d=hook.3do size=0.003 movesize=0.003 soundclass=rail.snd surfdrag=3 airdrag=0 mass=1 vel=(0/2.5/0) angvel=(0/0/90) buoyancy=0.25 typeflags=0x80
</font>


Remember to flag the item's bin with 0x10 so that the cog will receive the damaged message. You can remove kyle.cog from the patch since that's all it was used for. Good luck. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited August 31, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!