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 → Need some help with my COG...shimmying isn't working right (Cliff Hanger)
Need some help with my COG...shimmying isn't working right (Cliff Hanger)
2001-07-15, 2:13 PM #1
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:

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.
2001-07-15, 2:31 PM #2
please, PLEASE, put cog script into code tags
if you don't know how, go here
it makes it a LOT easier to read
and take off the bold tags, it's just courteous to those you want to help you

I haven't looked at your problem yet, but I will soon

------------------
*eats pie*
And meanwhile the bus with legs has destroyed half of disneyland . . . and nobody cares!
2001-07-15, 5:19 PM #3
Okay, okay..sorry... I didn't do that because, IMO, it's HARDER to read. The text is smaller and it's italicized. Also, I've seen people COMPLAIN when it's posted that way.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-15, 7:34 PM #4
I don't find it any easier to read, and if you want to cut & paste it, you must add a vast amount of returns, as copying and pasting puts it all on one line. . . .
2001-07-17, 12:02 PM #5
Comon guys...PLEASE! Anything?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-18, 4:41 AM #6
it looks like u have sleep(.5), i dunno anything bout cogs, but u can try that [http://forums.massassi.net/html/smile.gif]

------------------
Visit My Website! Adam's Pyro Castle
2001-07-18, 4:47 AM #7
OR u have

Code:
If(GetParam(2) == -1)
{	  //Print("Left.");
Call Shimmy_Left;	  }


i think maybe change the -1 to 1 like u have in the "Right" shimmy. oh yeah, forget the (sleep .5 one :P) if this works, plz tell me. cause i will be EXTREMLY happy if it works! [http://forums.massassi.net/html/biggrin.gif] i have no expirence with cogs (except making weapons shoot faster or whatnot) lol [http://forums.massassi.net/html/wink.gif]


------------------
Visit My Website! Adam's Pyro Castle
2001-07-18, 12:29 PM #8
No, that -1 is correct. -1 = left, 1 = right (direction the player moves).
Bassoon, n. A brazen instrument into which a fool blows out his brains.

↑ Up to the top!