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 → Cliff Hanger System - Need Help with KEY Cogging
Cliff Hanger System - Need Help with KEY Cogging
2001-06-30, 7:34 PM #1
My Cliff Hanger System is a little editing system for JK levels that allows you to grab ledges and pull yourself up. Originally, it just bounced you up onto the ledge, along with an external KEY. I've since expanded upon it, but I have problems...I want to make it so you can grab the ledge and stay there till you pull yourself up. No problem. Got all that working fine. You just press crouch to jump up (there's no IsThingJumping() cog line in JK, so it needs to be crouch). Now, the problem is the external KEYs. While your frozen, hanging, the COG plays a looping KEY of the player hanging and swaying. But when you pull yourself up, and when it plays the climb up animation, it works, but afterwards the hang animation is still on! As you can see below, I've tried StopThing(player) and StopAnim(Hang_Anim), also I've tried StopKey(), and a butt load of flags and tweaking. Still no luck. The closest I got was replacing the climb anim with the hang anim, which played it once w/o looping. After that one time it stopped and all was normal, but it looked like crap for those 2 seconds of animating.

Here's the COG:


# Jedi Knight COG Script
#
# cliffhanger.cog
#
# Created by Emon. E-Mail: emon@ejm.i-p.com OR emon@coruscant.net - Zone: EJM_Emon
#
# Enables the player to jump and grab onto ledges. Uses thrusts to move the player.
# Additional KEY is not required, all though looks nice. Triggered by surfaces.
#
#
# This COG is not supported by LucasArts Entertainment Co.

flags=0x240

symbols

thing player local

keyframe Climb_Anim=cliffclimb.key
keyframe Hang_Anim=cliffhang.key

surface Ledge

vector upVel local
vector newVel local
vector playerVel local

int PopupSpeed=2
int PulseCheck=0 local

message touched
message pulse

end

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

code

touched:
PulseCheck=0;
If(GetThingHealth(player) == 0) Return;

PlayKey(player, Hang_Anim, 1, 0x0); // Play looping hanging KEY.
Print("You touched the ledge."); // Debug tool. Prints a message letting you know you touched the trigger surface.
SetPulse(.1);
SetThingVel(player, 0.0, 0.0, 0.0); // Stop player movement.
ClearPhysicsFlags(player, 0x1); // Take away gravity.
SetActorFlags(0x40000); // Take away movement.

Return;

pulse:
If (PulseCheck == 1) Return;
If(GetThingHealth(player) == 0)
{
SetPhysicsFlags(player, 0x1);
ClearActorFlags(0x40000);
}

If(IsThingCrouching(player))
{
PulseCheck=1;
Print("You are crouching.");
StopAnim(Hang_Anim);
StopThing(player);

PlayKey(player, Climb_Anim, 1, 0x38); // Play climb up KEY.

SetPhysicsFlags(player, 0x1);
ClearActorFlags(player, 0x40000);
upVel = VectorSet(0.0, 0.0, PopupSpeed);
playerVel = GetThingVel(player);
newVel = VectorAdd(upVel, playerVel);
DetachThing(player);
SetThingVel(player, newVel);
Print("You climbed the ledge."); // Debug tool. Prints a message letting you know your climb was successful.
}
Return;

end



I've tried everything...from flags to PlayMode(), and nothing seems to work. I originally was going to uss alternating PUPs with ParseArg(player, "puppet=ky_hang.pup") but I wanted this to be fully compatible with mods like Spork, where sometimes your using a pup other than KY. This becomes a problem because if your using the lightstaff, and when the Cliff Hanger COG resets the pup, it'll reset the wrong one.

If anyone knows how to fix this in ANY way, of if you have ANY help at all, PLEASE respond!
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-06-30, 7:36 PM #2
Btw, if you are confused at all about what I said, please just ask me to clarify. Again, any help would be appreciated!

P.S.
Does anyone know if
there are really any
other mods besides
Spork that use PUPs
other than Ky.pup?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-01, 6:38 AM #3
Interesting cog, nice idea. The flags for your Hang_Anim playing key, 0x0, do not make the key loop.. however, it is looping. Why? My guess is that the touched: message constantly gets triggered by the floor, and any objects you run into. How to fix this? This gets to be a bit difficult..

First, how do you know what the player is? I see no startup.. add:

message startup

to symbols, and:

startup:
player=jkGetLocalPlayer();
return;

to the code.

Second, you should probably add this line above everything in touched:

if(GetSourceRef() != player)

Third, if this still doesnt work, add a flag check.. ie: if(done) return; THEN you would have to change the command to PlayKey(player, Hang_Anim, 1, 0x1); and use StopKey(Hang_Anim);

Get back to me if this doesn't work.
2001-07-01, 5:20 PM #4
I'm trying that right now.. But 0x0 DOES make it loop... look in Ky.pup. You'll see the stand anim has 0x0 flags. As well, in JKrpg, all the AI have looping anims, exactly how I have mine. And when I take away 0x0, and change it to something like 0x38, it no longer loops. Anyways, I'll try it...hope it works...
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-01, 5:24 PM #5
I also know touched isn't getting called over and over for 2 reasons. 1. The print statment would keep printing the message "You touched the ledge." 2. The KEY loops perfectly, and never gets choppy or seems to restart in the middle.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-01, 5:31 PM #6
Hey Emon:

I've come across the prob before. Occasionally keys just seem to get stuck on [http://forums.massassi.net/html/frown.gif], BUT... Here is a solution:

As the player activates the climb, call the "JKdisablesaber" commands, and set the character's weapon to 1 (fists). With this, you can still use parsearg(pup), and still not mess up another mod. It is also more realistic, as using a weapon while hanging would be frivalous.

I have few altrenate ideas, too. E-mail me if you want them.

Tell me if that helps! [http://forums.massassi.net/html/wink.gif]

Jedi_slayer_1

[This message has been edited by Dynasty (edited July 01, 2001).]
2001-07-01, 5:37 PM #7
Okay...some problems:

First I put if(GetSourceRef() != player) as the 1st lined in Touched. That did nothing new. Then I put the rest of the code in brackets. Then that did nothing AT ALL...the surface wouldn't trigger. I imagine because != means not equal to..

Okay, so then I tried: if(GetSourceRef() == player) with the rest of the code in brackets. Nothing new. Then I tried that same thing, but put PlayKey(player, Hang_Anim, 1, 0x1);. That looped the KEY, but the legs did not animate. Only the upper torso. And I don't understand the flag check thing...please explain a little more.

Thanks.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-01, 5:44 PM #8
Okay...I'll do that, slayer. Thanks for the help.

P.S.
Sorry I insulted
your TC on your
thread...I guess my
skepicivity got ahead
of me. [http://forums.massassi.net/html/smile.gif]
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-01, 5:59 PM #9
Ugh.. sorry about that... I wasn't thinking coherently when I replied..

I messed up most of the time in my last reply :/ *smacks face*

I was looking at your cog, and was wondering..

StopAnim(Hang_Anim);

Hm. Well, it should be StopKey(); instead of StopAnim(); because StopAnim() stops surface animation.

Second, JK has no idea what you want to stop with StopKey(Hang_Anim); You need to tell it what animation to stop.

in symbols, add:

int hangtrack local

change:

PlayKey(player, Hang_Anim, 1, 0x0); // Play looping hanging KEY.

to:

hangtrack=PlayKey(player, Hang_Anim, 1, 0x0); // Play looping hanging KEY.

Next, change:

StopAnim(Hang_Anim);

to:

StopKey(hangtrack);
hangtrack=-1;

Ok, now lets see if this does it [http://forums.massassi.net/html/smile.gif]
2001-07-01, 6:13 PM #10
Nope...no luck, Greven. Here's my current COG:


# Jedi Knight COG Script
#
# cliffhanger.cog
#
# Created by Emon. E-Mail: emon@ejm.i-p.com OR emon@coruscant.net - Zone: EJM_Emon
#
# Enables the player to jump and grab onto ledges. Uses thrusts to move the player.
# Additional KEY is not required, all though looks nice. Triggered by surfaces.
#
#
# This COG is not supported by LucasArts Entertainment Co.

flags=0x240

symbols

thing player local

keyframe Climb_Anim=cliffclimb.key
keyframe Hang_Anim=cliffhang.key

surface Ledge

vector upVel local
vector newVel local
vector playerVel local

int PopupSpeed=2
int PulseCheck=0 local
int HangTrack local

message touched
message pulse
message startup

end

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

code

startup:

Player=jkGetLocalPlayer();
Return;

touched:
if(GetSourceRef() == player)
{
PulseCheck=0;
If(GetThingHealth(player) == 0) Return;

HangTrack = PlayKey(player, Hang_Anim, 1, 0x0); // Play looping hanging KEY.
Print("You touched the ledge."); // Debug tool. Prints a message letting you know you touched the trigger surface.
SetPulse(.1);
SetThingVel(player, 0.0, 0.0, 0.0); // Stop player movement.
ClearPhysicsFlags(player, 0x1); // Take away gravity.
SetActorFlags(0x40000); // Take away movement.
}
Return;

pulse:
If (PulseCheck == 1) Return;
If(GetThingHealth(player) == 0)
{
SetPhysicsFlags(player, 0x1);
ClearActorFlags(0x40000);
}

If(IsThingCrouching(player))
{
PulseCheck=1;
Print("You are crouching.");
StopKey(HangTrack);
HangTrack=-1;
PlayKey(player, Climb_Anim, 1, 0x38); // Play climb up KEY.

SetPhysicsFlags(player, 0x1);
ClearActorFlags(player, 0x40000);
upVel = VectorSet(0.0, 0.0, PopupSpeed);
playerVel = GetThingVel(player);
newVel = VectorAdd(upVel, playerVel);
DetachThing(player);
SetThingVel(player, newVel);
Print("You climbed the ledge."); // Debug tool. Prints a message letting you know your climb was successful.
}
Return;

end



Did I leave something out or mess something up?

Btw, I think StopKey only stops an animation for a specified time period, as in delays it.

This is from the JK Specs:

StopKey () Control

Stops a playing keyframe animation.

Use: StopKey(thing,keyframe,flex delay);

Note the part I italiciezed.



[This message has been edited by Emon (edited July 01, 2001).]
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-01, 6:19 PM #11
err.. oops.
try:

StopKey(player, HangTrack, 0.1);

Sorry, again.
2001-07-01, 7:47 PM #12
No hard feelings [http://forums.massassi.net/html/smile.gif] [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/smile.gif]

Jedi_slayer_1

↑ Up to the top!