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.
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.
Bassoon, n. A brazen instrument into which a fool blows out his brains.