Okay, now with this COG you can grapple onto a ledge, pullyourself up, drop down, or shimmy left and right. Only problem is, you can only shimmy once, like .5 seconds after you touch the ledge. Take a look at the COG:
If I change the touched message to activated, it works fine. *Confused*. Also, the looping, hangking KEY occasionally sticks, and doesn't stop, even without proper (or what I THINK is proper..) code.
Any help would be great. Thanks.
[This message has been edited by Aglar (edited July 15, 2001).]
Code:
# Jedi Knight COG Script
#
# CliffHanger_MotS.COG
#
# Created by Emon. E-Mail: emon@coruscant.net - Zone: EJM_Emon - ICQ: 35960628
# Feel free to use this COG as long as credit is given in the readme file.
#
# Allows players to grapple onto ledges, shimmy left or right, fall, or pull themselves
# up.
#
#
# This COG is not supported by LucasArts Entertainment Co.
flags=0x240
symbols
thing Player local
thing LeftStop
thing RightStop
keyframe HangAnim=cliffhang.key
keyframe ClimbAnim=cliffclimb.key
sound GrabSound=kylerun01.wav
sound ShuffleSound=shuffle.wav
surface Ledge1
int HangTrack local
int Shimmy=0 local
int Climbing=0 local
int ShimmyCheck=0 local
int NoHang=1 local
flex VecX local
flex VecY local
flex VecZ=0 local
vector upVel local
vector playerVel local
vector newVel local
vector sideVel local
vector newSideVel local
message startup
message touched
message playeraction
message pulse
message damaged
message timer
end
# ========================================================================================
code
startup:
Player = GetLocalPlayerThing();
SetCollideType(LeftStop, 0x0);
SetCollideType(RightStop, 0x0);
Return;
touched:
If(GetSenderRef() != Ledge1) Return;
SetCollideType(LeftStop, 0x3);
SetCollideType(RightStop, 0x3);
If(GetThingAttachFlags(Player) == 1) Return;
PlaySoundLocal(GrabSound, 1, 0, 0);
SetPulse(.001);
StopThing(Player);
SetActorFlags(Player, 0x40000);
ClearPhysicsFlags(Player, 0x1);
HangTrack = PlayKey(Player, HangAnim, 1, 0x0);
SetActionCog(GetSelfCog(), 0x7fffffff);
Return;
playeraction:
If(GetParam(0) == 3 || GetParam(0) == 7 || GetParam(0) == 8)
ReturnEx(0);
else
If(GetParam(0) == 11)
{
If(GetParam(2) == -1)
{
//Print("Left.");
Call Shimmy_Left;
}
If(GetParam(2) == 1)
{
//Print("Right.");
Call Shimmy_Right;
}
}
else
If(GetParam(0) == 13)
{
ReturnEx(0);
StopKey(Player, HangTrack, NoHang);
HangTrack=-1;
SetActionCog(-1, 0);
SetPhysicsFlags(Player, 0x1);
ClearActorFlags(Player, 0x40000);
SetPulse(0);
SetCollideType(LeftStop, 0x0);
SetCollideType(RightStop, 0x0);
}
else
If(GetParam(0) == 2)
{
ReturnEx(0);
If(Shimmy == 1) Return;
Climbing = 1;
StopKey(Player, HangTrack, NoHang);
HangTrack=-1;
SetActionCog(-1, 0);
PlayKey(Player, ClimbAnim, 1, 0x38);
Sleep(.5);
PlaySoundLocal(ShuffleSound, 1, 0, 0);
SetPhysicsFlags(Player, 0x1);
ClearActorFlags(Player, 0x40000);
upVel = VectorSet(0.0, 0.0, 1.5);
playerVel = GetThingVel(player);
newVel = VectorAdd(upVel, playerVel);
SetThingVel(player, newVel);
SetPulse(0);
Climbing = 0;
SetCollideType(LeftStop, 0x0);
SetCollideType(RightStop, 0x0);
}
else
ReturnEx(1);
Return;
pulse:
If(GetAttachFlags(Player) == 1)
{
Hanging=0;
StopKey(Player, HangTrack, NoHang);
HangTrack=-1;
SetActionCog(-1, 0);
SetPhysicsFlags(Player, 0x1);
ClearActorFlags(Player, 0x40000);
SetPulse(0);
SetCollideType(LeftStop, 0x0);
SetCollideType(RightStop, 0x0);
}
Return;
damaged:
If(GetSenderRef() != Player) Return;
StopKey(Player, HangTrack, NoHang);
HangTrack=-1;
SetActionCog(-1, 0);
SetPhysicsFlags(Player, 0x1);
ClearActorFlags(Player, 0x40000);
SetPulse(0);
SetCollideType(LeftStop, 0x0);
SetCollideType(RightStop, 0x0);
Return;
Shimmy_Left:
If(Climbing == 1 || ShimmyCheck == 1) Return;
Shimmy = 1;
ShimmyCheck = 1;
sideVel = VectorScale((VectorNorm(VectorSub(GetThingPos(RightStop), GetThingPos(Player)))), 1.2);
VecX = VectorX(sideVel);
VecY = VectorY(sideVel);
newSideVel = VectorSet(VecX, VecY, VecZ);
SetThingVel(Player, newSideVel);
Sleep(.1);
StopThing(Player);
SetTimer(.8);
Shimmy = 0;
Return;
Shimmy_Right:
If(Climbing == 1 || ShimmyCheck == 1) Return;
Shimmy = 1;
ShimmyCheck = 1;
sideVel = VectorScale((VectorNorm(VectorSub(GetThingPos(LeftStop), GetThingPos(Player)))), 1.2);
VecX = VectorX(sideVel);
VecY = VectorY(sideVel);
newSideVel = VectorSet(VecX, VecY, VecZ);
SetThingVel(Player, newSideVel);
Sleep(.1);
StopThing(Player);
SetTimer(.8);
Shimmy = 0;
Return;
timer:
ShimmyCheck = 0;
Return;
end
If I change the touched message to activated, it works fine. *Confused*. Also, the looping, hangking KEY occasionally sticks, and doesn't stop, even without proper (or what I THINK is proper..) code.
Any help would be great. Thanks.
[This message has been edited by Aglar (edited July 15, 2001).]
Bassoon, n. A brazen instrument into which a fool blows out his brains.
![http://forums.massassi.net/html/smile.gif [http://forums.massassi.net/html/smile.gif]](http://forums.massassi.net/html/smile.gif)
i have no expirence with cogs (except making weapons shoot faster or whatnot) lol ![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)