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, but this time with other Cogging
Cliff Hanger System - Need help, but this time with other Cogging
2001-07-02, 9:27 AM #1
Ok...here's my current Cliff Hanger COG. It allows you to grapple onto a ledge, and press duck to climb up it. Also, if the player: Changes weapons, dies, or is shot with a concussive blast (ex. Rail Det), you will fall off.

Now I need to make it so when the player shoots, you fall off. Either that, or disable weapon firing while hanging. Either one would work.

Here's what I have now:

# 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
int CurWeap local

message touched
message pulse
message startup

end

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

code

startup:

Player=GetLocalPlayerThing();
Return;

touched:

CurWeap=GetCurWeapon(player);
PulseCheck=0;
If(GetThingHealth(player) == 0) Return; // If the player is dead, don't attach him to the ledge.

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(.001);
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) // If the player dies, detach him from the ledge.
{
StopKey(player, HangTrack, .01);
SetPhysicsFlags(player, 0x1);
ClearActorFlags(0x40000);
PulseCheck=1;
}

If(IsThingCrouching(player)) // If the player presses the climb key (crouch button), then make him climb the ledge.
{
PulseCheck=1;
Print("You are crouching.");
StopKey(player, HangTrack, .001); // Stop hanging KEY.
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.
}

If(IsThingMoving(player)) // If player begins moving, (ex: From shooting a heavy gun or being shot), abort hang.
{
StopKey(player, HangTrack, .001); // Stop hanging KEY.
HangTrack=1;
SetPhysicsFlags(player, 0x1);
ClearActorFlags(player, 0x40000);
PulseCheck=1;
}

If (GetCurWeapon(player) != CurWeap) // If player tries to switch his weapon while hanging, abort the hang and fall.
{
StopKey(player, HangTrack, .001); // Stop hanging KEY.
HangTrack=-1;
SetPhysicsFlags(player, 0x1);
ClearActorFlags(player, 0x40000);
PulseCheck=1;
}

SetFireWait(player, .001); // <--- This doesn't seem to work...only sets fire rate to .001.

Return;

end



Take a look at the end, at SetFireWait...my idea there was to delay the weapon's firing every .001 seconds, the same rate as the pulse's call. Then, when you climb or fall off, it would stop delaying, because of the PulseCheck int. SetFireWait DOES delay the weapon for xx seconds, because I tried it with 5 seconds, and it worked (except on Repeter 1st fire, where it doesnt fire but there is still sound..?).

Okay..could someone help me out here? ANY help at all would be appreciated.

Thanks.

P.S.
If I sound confusing,
just ask me to clear
it up. [http://forums.massassi.net/html/smile.gif]
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-02, 10:57 AM #2
"The doctor is in the house!" [http://forums.massassi.net/html/wink.gif]

I'll take a look at it. Actually, I seem to remember doing this (disabling weapons) with the Droideka shield, so it shouldn't take too long...


Jedi_slayer_1
2001-07-02, 11:06 AM #3
By looking at the cog, I'm guessing the wall is a thing (with wall 3do), right?

There's an easy way to do it, but the player would not be able to fire/change weapons. That OK?


Jedi_slayer_1
2001-07-02, 11:23 AM #4
Here is what you want to do.

As the player attatches himself to the surface, use this:

Code:
// You can't select a gun while you hang!!!
// You would have to let go!!!  [http://forums.massassi.net/html/wink.gif]

   SetInvAvailable(player, 1, -1.0);
   SetInvAvailable(player, 2, -1.0);
   SetInvAvailable(player, 3, -1.0);
   SetInvAvailable(player, 4, -1.0);
   SetInvAvailable(player, 5, -1.0);
   SetInvAvailable(player, 6, -1.0);
   SetInvAvailable(player, 7, -1.0);
   SetInvAvailable(player, 8, -1.0);
   SetInvAvailable(player, 9, -1.0);
   SetInvAvailable(player, 10, -1.0);


// give him weenie-fists with no punch

SetCurWeapon( player, 0 );
jkSetWeaponMesh(player, yourfistmesh);


This will disable all weapons.

Now, when he lets go/falls off, do this:

Code:
// What a coward! He let go!
// Guess I'll give them back...

   SetInvAvailable(player, 1, 1.0);
   SetInvAvailable(player, 2, 1.0);
   SetInvAvailable(player, 3, 1.0);
   SetInvAvailable(player, 4, 1.0);
   SetInvAvailable(player, 5, 1.0);
   SetInvAvailable(player, 6, 1.0);
   SetInvAvailable(player, 7, 1.0);
   SetInvAvailable(player, 8, 1.0);
   SetInvAvailable(player, 9, 1.0);
   SetInvAvailable(player, 10, 1.0);

//Give him REAL fists again...
SetCurWeapon( player, 1 );



Hope that works well for you. If not, mail me again, lol.


Jedi_slayer_1
2001-07-02, 1:48 PM #5
Use this ...

for(i=1; i<10; i=i+1)
{
SetInv(player, i, 0);
}
SelectWeapon(player, 0);
2001-07-02, 2:02 PM #6
Hmm...anything else? I don't want to do that, really...I want the player to retain their weapon, otherwise reselecting it would cripple DM gameplay. Is there a way to detect if the player is firing?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-02, 4:02 PM #7
Hmm... Not sure. I'll think about it and get back to you with what I come up with.

Jedi_slayer_1
2001-07-02, 4:06 PM #8
To see if the player is firing would be somewhat difficult.. would probably require new weapon cogs, though possibly a FirstThingInView() / NextThingInView() could get it... it'd be easier to just disable weapon's firing.

Add this in symbols:

flex dets local
flex seqs local
flex enrgy local
flex power local
flex rails local

Where you want to take away the weapons (in touched, I assume)

dets=GetInv(player, 4);
seqs=GetInv(player, 8);
enrgy=Getinv(player, 11);
power=GetInv(player, 12);
rails=GetInv(player, 15);

SetInv(player, 4, 0);
SetInv(player, 8, 0);
SetInv(player, 11, 0);
SetInv(player, 12, 0);
SetInv(player, 15, 0);

Next, down where you want to give back the weapons, put:

SetInv(player, 4, dets);
SetInv(player, 8, seqs);
SetInv(player, 11, enrgy);
SetInv(player, 12, power);
SetInv(player, 15, rails);

This should prevent the weapons from firing..except fists and saber. If you want to, you could do the same thing as the above except for fists & saber.

Actually, I just thought of something.. though, this would only work for weapons other than the saber and fist... if you get rid of all the SetInv()s, and in the pulse, do a check.. ie:
if(GetInv(player, 4) < dets) //drop player
else if(GetInv(player, 8) < seqs) //drop player
else if(GetInv(player, 11) < enrgy) //drop player
else if(GetInv(player, 12) < power) //drop player
else if(GetInv(player, 15) < rails) //drop player

Also, you could add force mana to this...
2001-07-02, 5:51 PM #9
Hmm...I could just leave it on...you could shoot while holding on with 1 hand. Only thing that get's messed up is the KEYs a bit....hmmm...Anyone else have ideas? For conc and rail det, since those have recoil that moves the player, the rest of the cog will knock you off if you shoot one of them.

I think I'll just leave it...what do you think?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-07-02, 7:04 PM #10
If it works, I suggest you leave it alone (believe me, I KNOW [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/wink.gif]) lol

Anyways, just be sure to save a copy before you go any further.


Jedi_slayer_1
2001-07-03, 12:33 AM #11
Ok I can do this , and yes it will use FirstThingInView for weapons. Firstly I need to get some sleep now, so I will write it for you tommrow morning.

↑ Up to the top!