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 → Some Problems with GetThingPos();
Some Problems with GetThingPos();
2001-07-27, 6:12 PM #1
Having a bit of trouble with my Cliff Hanger COG and GetThingPos(); When you touch the surface, it stores your position on the Z axis, or verticle axis. Then, the pulse should kick you off anytime that your position on the Z axis changes (climbing excluded). I've removed everything else in the pulse check except the debug print, which works. It prints the vector correctly, so I know GetThingPos is working, but for some reason, it doesn't drop me from the ledge! Here's 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. 
#
# Buttons:
# Shimmy Left = Cycle Force left
# Shimmy Right = Cycle Force right
# Drop = Use Force
# Climb Up = Activate / Use
#
# This COG is not supported by LucasArts Entertainment Co.

flags=0x240

symbols

thing        Player                             local                         
thing        LeftStop                                                         
thing        RightStop                                                        

keyframe     HangAnim=cliffhang.key             local                         
keyframe     ClimbAnim=cliffclimb.key           local                         
keyframe     ShimmyRight=shimmyright.key        local                         
keyframe     ShimmyLeft=shimmyleft.key          local                         

sound        GrabSound=kylerun01.wav                                          
sound        ShuffleSound=shuffle.wav                                         

surface      Ledge1                             linkid=1                      

int          HangTrack                          local                         
int          Shimmy=0                           local                         
int          Climbing=0                         local                         
int          ShimmyCheck=0                      local                         
int          NoHang=.1                          local                         
int          Hanging=0                          local                         
int          OldHealth                          local                         
int          OldShield                          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                         
vector       OldLook                            local                         
vector       OldPosition                        local                         

message      startup                                                          
message      touched                                                          
message      playeraction                                                     
message      pulse                                                            
message      timer                                                            

end                                                                           

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

code

startup:

	Player = GetLocalPlayerThing();
	SetCollideType(LeftStop, 0x0);
	SetCollideType(RightStop, 0x0);
	Return;

touched:

	If(GetSenderID() == 1)
	{
	If(GetThingAttachFlags(Player) == 1) Return;
	If(GetThingHealth(Player) == 0) Return;
	If(Hanging == 1) Return;
	OldLook = VectorScale(GetSurfaceNormal(Ledge1), -1);
	OldHealth = GetThingHealth(Player);
	OldShield = GetInv(Player, 60);
	OldPosition = VectorSet(0, 0, (VectorZ(GetThingPos(Player))));
	PrintVector(OldPosition);
	Hanging = 1;
	SetCollideType(LeftStop, 0x3);
	SetCollideType(RightStop, 0x3);
	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)
	  {
	  ReturnEx(0);
	  Call Shimmy_Left;
	  }
	
	  If(GetParam(2) == 1)
	  {
	  ReturnEx(0);
	  Call Shimmy_Right;
	  }
	}

	else
	If(GetParam(0) == 13)
	{
	ReturnEx(0);
	Call Detach_Player;
	}

	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);
	Hanging = 0;
	}

	else
	 ReturnEx(1);		
	
	Return;

pulse:

	SetThingLook(Player, OldLook);
	
//	If(GetInv(Player, 60) < OldShield || GetThingHealth(Player) < OldHealth)
//	 Call Detach_Player;	

//	If(GetAttachFlags(Player) == 1)
//	 Call Detach_Player;
		
//	If((IsInvActivated(Player, 21)))
//	 Call Detach_Player;

	PrintVector(VectorSet(0, 0, (VectorZ(GetThingPos(Player)))));
	
	If(VectorSet(0, 0, (VectorZ(GetThingPos(Player)))) != OldPosition)
	 Call Detach_Player;

	Return;

Shimmy_Left:
	
	If(Climbing == 1 || ShimmyCheck == 1) Return;
	Shimmy = 1;
	ShimmyCheck = 1;
	sideVel = VectorScale((VectorNorm(VectorSub(GetThingPos(RightStop), GetThingPos(Player)))), 1.05);
	VecX = VectorX(sideVel);
	VecY = VectorY(sideVel);
	newSideVel = VectorSet(VecX, VecY, VecZ);
	StopKey(Player, HangTrack, NoHang);
	HangTrack=-1;
	PlayKey(Player, ShimmyLeft, 1, 0x38);
	PlaySoundLocal(ShuffleSound, 1, 0, 0);
	Sleep(.15);
	HangTrack = PlayKey(Player, HangAnim, 1, 0x0);
	SetThingVel(Player, newSideVel);
	Sleep(.1);
	StopThing(Player);
	SetTimer(.3);
	Shimmy = 0;
	Return;
	
	
Shimmy_Right:

	If(Climbing == 1 || ShimmyCheck == 1) Return;
	Shimmy = 1;
	ShimmyCheck = 1;
	sideVel = VectorScale((VectorNorm(VectorSub(GetThingPos(LeftStop), GetThingPos(Player)))), 1.05);
	VecX = VectorX(sideVel);
	VecY = VectorY(sideVel);
	newSideVel = VectorSet(VecX, VecY, VecZ);
	StopKey(Player, HangTrack, NoHang);
	HangTrack=-1;
	PlayKey(Player, ShimmyRight, 1, 0x38);
	PlaySoundLocal(ShuffleSound, 1, 0, 0);
	Sleep(.15);
	HangTrack = PlayKey(Player, HangAnim, 1, 0x0);
	SetThingVel(Player, newSideVel);
	Sleep(.1);
	StopThing(Player);
	SetTimer(.3);
	Shimmy = 0;
	Return;

timer:
	
	ShimmyCheck = 0;
	Return;

Detach_Player:

	StopKey(Player, HangTrack, NoHang);
	HangTrack=-1;
	SetActionCog(-1, 0);
	SetPhysicsFlags(Player, 0x1);
	ClearActorFlags(Player, 0x40000);
	SetPulse(0);
	SetCollideType(LeftStop, 0x0);
	SetCollideType(RightStop, 0x0);
	Hanging = 0;
	Return;

end
Bassoon, n. A brazen instrument into which a fool blows out his brains.

↑ Up to the top!