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 → Two Cogs Left: Catapult/Rope Climb
Two Cogs Left: Catapult/Rope Climb
2006-08-16, 8:48 AM #1
Getting these two cogs to work correctly in multiplayer is the only thing holding me back from completing my Great Wall of China CTF level. I will only post the catapult one for now because I have a few Ideas on how to get my rope climbing cog to work better. If I continue to have trouble with it then I'll post it as well.

Here is the catapult cog Zagibu wrote for me. It may have some modifications I've made but I think it is probably the original. The problems it has are 1: for some reason after two or three times of a player being launched by the catapult, the catapult moves forward, leaving the fire ghost behind it. 2: When the catapult does move forward on a host computer (even though it shouldn't) it doesn't move on the client computer. I corrected the movement problem using a 3do flicker cog but then the catapult wouldn't fire. I hope this info is helpful in debugging this cog. Attached is a test level with a gob and a jed project folder along with the cog below.

Code:
symbols

keyframe      	animation

sound		fire_sound

vector		force

thing		catapult
thing		fire_ghost
thing		player			local

flex		max_dist=0.1
flex		dist_temp		local
flex		fire_sound_dist=2

int		firing			local

message		startup
message		entered
message		trigger

end

code

startup:
	// Initialize control variables
	firing = 0;
	Return;

entered:
	// Return if another firing process is in the works
	if(firing)
		Return;

	// Determine distance from toucher to fire_ghost
	dist_temp = VectorDist(GetThingPos(GetSourceRef()), GetThingPos(fire_ghost));
	// Only process positive distances
	if(dist_temp < 0)
		dist_temp = dist_temp * -1;
	// Check if toucher is within range of fire_ghost
	if(dist_temp - max_dist < 0)
		SendTrigger(-1, 133799, GetPlayerNum(GetSourceRef()), -1, -1, -1);

	Return;

trigger:
	if(GetSourceRef() == 133799)
	{
		player = GetPlayerThing(GetParam(0));

		// Activate the catapult
		firing = 1;

		// Detach the player from the catapult
		DetachThing(player);

		// Shoot the player
		ApplyForce(player, force);

		// Display the fire animation
		PlayKey(catapult, animation, 0, 0x2);

		// Play the fire sound
		PlaySoundThing(fire_sound, catapult, 1.6, 0, fire_sound_dist * 10.5, 0x80);

		// Wait until animation has stopped
		Sleep(GetKeyLen(animation));

		// Deactivate catapult
		firing = 0;
	}

	Return;

end
Attachment: 13535/Cattest.zip (87,875 bytes)
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-08-16, 11:25 AM #2
I downloaded the test zip and tested it.

I don't know what caused the "moving" bug, but I placed "move=none" in the catapult's template, and it stopped the bug. So, there is no need to use a flicker cog for the catapult.

Also, I found that the trigger in the cog was being called twice, due to the trigger being sent to all players in the game. This caused the force used to propel the player to be applied for each player in the game. I cleaned up the cog code, tested it on a LAN with two players in the game, and uploaded it to my Tidbits project.

Enjoy!
:)
2006-08-16, 3:23 PM #3
Thanks!

I've been trying to get that cog debugged for a year now. Both Zagibu and I have made several attempts to fix it but never were able to get it right. Thanks a lot Zeq! :)

I'm still working on the rope climbing cog but if I can't get it to work then i'll post back here. My knowledge of cog is still a bit elementary but it's getting to be better.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-08-16, 4:29 PM #4
I've fiddled with this cog for a week or two now. I have it working in conjunction with the triggerzone cog. It works perfectly in SP and on a host computer in MP but it isn't syched. Once again I have a jed project folder and a gob attached for easy testing. It would be good to have any tips on how to get things synched correctly.

Code:
# RopeClimb.cog
#
#
# Jedi Knight Cog Script
#
# This cog controls a 3do climbing rope
# Walk up to the rope and jump then use walk to climb up the rope
#
# Jedi I 2006
# concept from Tom Smallwood's ladder.cog
#
#-------------------------------------------------------------------------------------------------------------------------------

symbols

message	touched
message	pulse

thing		rope		

int		climbing	local
int		player	local

end

#-------------------------------------------------------------------------------------------------------------------------------

code

touched:  // start climbing the rope

	player=getsourceref();

	if(climbing==1)	return;

	if(getsenderref()!=rope)	return;

	if(getsenderref()==rope)	// if player touches the rope then let them climb up

		{
	
		detachthing(player);	// detach player from floor

		ClearPhysicsFlags(player, 0x1);	// change player's physics properties to allow them to walk up the rope

		SetPhysicsFlags(player, 0x2802);

		attachthingtothing(player,rope);	// attach player to rope 

		climbing=1;	// player is climbing the rope

		setpulse(0.5);

		}

	return;

#-------------------------------------------------------------------------------------------------------------------------------


pulse:	//prevent the player from floating up


	stopthing(player);

	if(getthingattachflags(player)== 0x0) // check if player is still attached to rope

		{

		ClearPhysicsFlags(player, 0x2800);
		
		SetPhysicsFlags(player, 0x1);
		
		detachthing(player);
		
		climbing=0;

		setpulse(0);

		}
	
return;

end
Attachment: 13541/Rope Test.zip (21,687 bytes)
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-08-16, 11:36 PM #5
What do you wanna sync here? Player movement is always synched. Actually, I think it'd be a better idea to flag it 0x240.
Also, it's pretty strange to say that you have been trying to fix the catapult cog for a year, as the last thing I heard from you was that it worked. I also fixed the doubly-applied force in the latest version I gave you. And if you noticed: Zeq didn't fix the cog, he fixed your template.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-08-17, 9:22 AM #6
In addtion to using flags=0x240, I recommend changing this line:

if(climbing==1) return;

to:

if (player != GetLocalPlayerThing() || climbing == 1)


That change will prevent every player from running the code (only one player needs to), which would likely cause trouble when multiple players are climbing at same time.

:)
2006-08-17, 9:26 AM #7
Sorry about that Zagibu. I don't know enough about cog to really know exactly how the problem was solved. You've helped me with my cogs more than any other editor so thanks a lot! I didn't mean to discredit you. Zeq finnally got the catapult working (something I never was able to do). Last time I heard from you, you said the cog was working. Appearantly it was but I just wasn't smart enough to figure out how to make it work. I am learning a lot about the inner workings of JK but I'm no expert so far.

For some reason when I test the rope climbing cog, it only works on the host computer. The triggerzone cog works on the host and client computers though. On the client computer there is no trace of the rope climbing cog actually doing anything. This may have to do with the way I called up the player.

In other words, I don't know what exactly needs to by synched. I just know that the cog doesn't work on a client computer which must mean something isn't syched. I think it is actually calling the player that is the problem here though.

That could be my very problem Zeq. I'll try that.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-08-23, 9:29 AM #8
Yes!

It's finnaly works. :) It took me a week or two to realize that you guys were talking about the cogscript flags and not the physics flags. Those two changes made it work the way I wanted. Also, I made it so it isn't linked to the triggerzone cog. I only use the triggerzone cog to create zero gravity so it is easier to stay on the rope. Thanks a lot guys. Now all I have to do is nit pick at the visual bugs I have and install CTF to my level and it will be ready for beta testing.

Thanks for putting up with me. I think you will like this level once I complete it.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?

↑ Up to the top!