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 → Presenting the Flyable ship cog (sort of)
Presenting the Flyable ship cog (sort of)
2005-08-29, 9:56 PM #1
Ok, I've finally created a (singleplayer only ATM) stable version of my flying ship cog. Does anyone know of a good video program that will let me "film" myself flying around to show you as a teaser? (a balance between quality, framerate, processor power, and file size would be nice, but I could always use a divx encoder for the size)

[edit] OK, here it is http://www.jkhub.net/project/show.php?projid=102§ion=download [/edit]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-08-29, 10:39 PM #2
FRAPS to record, VirtualDub to encode. Google 'em.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-30, 5:26 PM #3
Got them recorded, just gotta wait till I get home to encode them, then I'll need someone to upload them somewhere. If you have a place you can upload them I would be much obliged :) (or at least point me where I can upload them myself)
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-08-30, 6:43 PM #4
I will give you two guesses where to upload them. :p

:)
2005-08-30, 11:45 PM #5
Geocities, Angelfire? :p
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-08-31, 7:04 PM #6
The hub will let me upload videos? cool :cool:
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-08-31, 9:11 PM #7
Ok, when I tried opening the rar I downloaded from the hub (I check my files before showing them off) it claimed to be corrupted, but the files still extracted and played so here it is anyway
http://www.jkhub.net/project/show.php?projid=102§ion=download

If you want to see anything specific in this speak now or forever hold your peace. If your name is Friend14 and you want to finish that lovely x-wing, I would greatly love you (I'll give you the new version of it that works with keyframes)

Comments, critics, it's all welcome here :)


(ps, you also get a sneak peak at my other project going on. DS9)
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-08-31, 9:35 PM #8
I am already expecting one of a few answers, but I will ask anyway.

Why don't you upload your flying ship cog to your Hub project, so other coggers (like myself) can help with it?

By the way, I had no trouble downloading and unzipping the rar file.

:)
2005-09-01, 6:45 AM #9
Actually there's a simple answer to that one, the code looks horrible and I'm in the process of commenting it. Once it's commented, up it goes :)
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-01, 6:55 AM #10
Ok, I changed my mind. Here are the cogs with what I've commented so far
SERVER
Code:
# MOTS Cog Script
#
# shuttle_server.cog
#
# This cog controls all aspects of the Ship cog that require syncing: flying, shooting, creating...
#
# 8/27/05
#
# SG-fan
#
# THIS COG IS NOT SUPPORTED BE LEC
# ===============================================

flags=0x40

symbols

message	startup
message	activated
message	playeraction
message	pulse
message	timer
message	trigger

int		shipcreated=0				local
int		cruiseon=0				local
int		cursor					local	nolink
int		delayer=4				local
int		enginekill=0				local
int		findnewrange=0				local
int		firedelay=0				local
int		hard1availiable=0			local
int		hard2availiable=0			local
int		hard3availiable=0			local
int		hard4availiable=0			local
int		hard1active=0				local
int		hard2active=0				local
int		hard3active=0				local
int		hard4active=0				local
int		keydummy0				local
int		keydummy1				local
int		lasttarget=-1				local
int		maxvelocity=40				local
int		mouselock=0				local
int		mousepilot=1				local
int		on=0					local
int		player					local
int		prevlasttarget=-1			local
int		pricam					local
int		sounddummy				local
int		targethold=-1				local
int		tempscalar				local
int		velocityscalar				local

flex		cruisecharge=3				local
flex		hulllvl=0				local
flex		shieldlvl=0				local
flex		shottimer=.5				local
flex		xsens=75000				local
flex		xvector					local
flex		zsens=2500				local
flex		zvector					local

keyframe	land=xwsfoilscls1.key
keyframe	launch=xwsfoilsopn1.key

sound		camChangeSnd=beep2.wav			local
sound		cruisechargesnd=crowenginewhine02.wav	local
sound		cruisefire=pistout1.wav			local
sound		cruisesnd=ywinglp.wav           	local
sound		regularfiresnd=pistol-1.wav		local
sound		SwitchOffSound=deactivate02.wav		local

template	cursortpl=cursorverysmall3
template	exptpl=+xwing_exp 			local
template	flying=xwing_flying
template	ghosttpl=ghosttmp
template	landed=xwing_landed
template	rangefindertpl=newranger
template	shieldtpl=bubble1
template	shottpl=+stlaser

thing		cam=-1					local
thing		chaseghost=-1				local	nolink
thing		gun0=-1					local
thing		gun1=-1					local
thing		gun2=-1					local
thing		gun3=-1					local
thing		otherplace					nolink
thing		secghost=-1				local	nolink
thing		shields=-1				local
thing		shot=-1					local
thing		shuttle=-1				local
thing		shuttlepart=-1				local
thing		shuttlespot
thing		spawnghost=-1				local	nolink
thing		target=-1				local	nolink

thing		spawner				local

vector		bankright
vector		cursororient				local
vector		enginekillvec				local
vector		firevec					local
vector		flpilot					local
vector		max_foward
vector		rotation2				local
template	tmpghosttpl=tmpghost
end

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

code
startup:
sleep(1);
Print("2");
sleep(1);
Print("1");
sleep(1);

print("testing");
if((IsMulti()==1 && IsServer()==1) || (IsMulti()==0 && IsServer()==0))	// check if (host and multi) || (single player)
   if(shipcreated==0)
	SetTimerEx(1, 5, 0, 0);						// initial creation of ship objects

   Return;

# .....................................................................

activated:
Print("server");
   if(GetThingUserData(otherplace) & 1)
   {
	Print("bitwise '1' found");
	Return;
   }

   if(on) Return;

//   player = GetSourceRef();
   player = GetParam(0);


   // Do not allow to activate the camera with the scope on...
   if(GetCurWeapon(player) == 13) Return;

   on = 1;

   SendTrigger(-1, 101, otherplace, -1, player, 101);

Printint(shuttle);
Printint(GetThingSignature(shuttle));
Printint(gun3);
Printint(GetThingSignature(gun3));

	xvector=0;		// left/right
	zvector=0;		// up/down

	velocityscalar=0;	// scales the foward velocity for multiple speeds

   SetActorFlags(player, 0x80800002);

   SetTimerEx(0.0000001, 3, 0, 0);				// Teleportation/switch_cam

   SetTimerEx(.1, 12, -1, -1);					// Reactivate shields after .1 seconds

   Return;

# .........................................................................
playeraction:

   if (GetParam(0) == 0.0)             // Jump
   {
	if(GetParam(2)==1)
	{
		if(cruiseon==1)
		{
			KillTimerEx(7);
			StopSound(sounddummy, 1);
			cruiseon=0;
		}
		if(enginekill==0)
		{
			enginekill=1;
			enginekillvec=GetThingVel(shuttle);
		}
		else SetTimerEx(0, 8, 0, 0);		// Engine kill check
	}
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 1.0)             // Crouch
   {
	if(cruiseon==1)
	{
		KillTimerEx(7);
		velocityscalar=maxvelocity;
		StopSound(sounddummy, 1);
		cruiseon=0;
	}
	if(velocityscalar>=maxvelocity)
		velocityscalar=maxvelocity;
	if(velocityscalar>=0.0)
		tempscalar=velocityscalar;
	if(GetParam(2)==2)
	{
		SetTimerEx(0, 8, 0, 0);		// Engine kill check
		velocityscalar=-8;
	}
	else
		velocityscalar=tempscalar;

      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 2.0)             // Activated
   {

      call stop_cam;
	Print("Deactivating Shuttle Properly");
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 3.0)             // Fire
   {
	if(firedelay==0)
	{
		firedelay=1;
		if(cruiseon==0)
		{
			SetTimerEx(shottimer, 9, 0, 0);		// Fire Delay

		   if((hard1availiable == 1) && (hard1active == 1))
		   {
			PlaySoundThing(regularfiresnd, shuttle, 1, 0, 10, 0x80);
			shot=FireProjectile(gun0, shottpl, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);
			SetThingParent(shot, shuttlespot);
			AddThingVel(shot, VectorScale(VectorNorm(GetThingVel(shot)), VectorLen(GetThingVel(shuttle))));
		   }

		   if((hard2availiable == 1) && (hard2active == 1))
		   {
			PlaySoundThing(regularfiresnd, shuttle, 1, 0, 10, 0x80);
			shot=FireProjectile(gun1, shottpl, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);
			SetThingParent(shot, shuttlespot);
			AddThingVel(shot, VectorScale(VectorNorm(GetThingVel(shot)), VectorLen(GetThingVel(shuttle))));
		   }

		   if((hard3availiable == 1) && (hard3active == 1))
		   {
			PlaySoundThing(regularfiresnd, shuttle, 1, 0, 10, 0x80);
			shot=FireProjectile(gun2, shottpl, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);
			SetThingParent(shot, shuttlespot);
			AddThingVel(shot, VectorScale(VectorNorm(GetThingVel(shot)), VectorLen(GetThingVel(shuttle))));
		   }

		   if((hard4availiable == 1) && (hard4active == 1))
		   {
			PlaySoundThing(regularfiresnd, shuttle, 1, 0, 10, 0x80);
			shot=FireProjectile(gun3, shottpl, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);
			SetThingParent(shot, shuttlespot);
			AddThingVel(shot, VectorScale(VectorNorm(GetThingVel(shot)), VectorLen(GetThingVel(shuttle))));
		   }
		}
		else if(cruiseon==1)
		{
			PlaySoundLocal(cruisefire, 1.0, 0.0, 0);
			SetTimerEx(2.0, 9, 0, 0);		// Fire Delay
		}
	}

      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 4.0)             // Strafe
   {
      ReturnEx(0.0);
	  rotation2=GetThingRotVel(shuttle);
	  If(GetParam(2) > 0)
	  {
	  	if(VectorZ(rotation2)==VectorZ(bankright)) Return;
		rotation2=VectorAdd(rotation2, bankright);
		SetThingRotVel(shuttle, rotation2);
	  }
	  else if(GetParam(2) == 0)
	  {
	  	if(VectorZ(rotation2)==VectorZ(bankright))
			rotation2=Vectorsub(rotation2, bankright);
		else if(VectorZ(rotation2)==(-1*VectorZ(bankright)))
			rotation2=Vectoradd(rotation2, bankright);
		SetThingRotVel(shuttle, rotation2);
	  }
	  else if(GetParam(2) < 0)
	  {
		if(VectorZ(rotation2)==(-1*VectorZ(bankright))) Return;
		rotation2=VectorSub(rotation2, bankright);
		SetThingRotVel(shuttle, rotation2);
	  }
   }
   else
   if (GetParam(0) == 5.0)             // Turn
   {
         ReturnEx(0.0);
	  If(GetParam(2) > 0)		// left
	  {
		if(xvector-(GetParam(2)/xsens)>(-.05 * .4))
			xvector=xvector-(GetParam(2)/xsens);
	  }
	  else if(GetParam(2) < 0)		// right
	  {
		if(xvector+((GetParam(2)*-1)/xsens)<(.05 * .4))
			xvector=xvector+((GetParam(2)*-1)/xsens);

	  }

	SendTrigger(-1, 104, otherplace, -1, xvector, -1);		//sync xvector
   }
   else
   if (GetParam(0) == 6.0)			// Fwd / Bkwd Motion
   {
       ReturnEx(0.0);

	  If(GetParam(2) > 0)		// Foward
	  {
		SetTimerEx(0, 8, 0, 0);		// Engine kill check
		if(velocityscalar<maxvelocity)
			velocityscalar=velocityscalar+1;

		if(GetParam(2)==4)
		{
			if(cruiseon==0)
			{
				cruiseon=1;
				Print("Charging Cruise");
				velocityscalar=maxvelocity;

				sounddummy=PlaySoundThing(cruisechargesnd, shuttle, 1, 0, 100, 0x81);
				ChangeSoundPitch(sounddummy, 5, cruisecharge);

				SetTimerEx(1, 7, 0, 0);
				Printint(cruisecharge);
			}
		}
	  }
	  else if(GetParam(2) < 0)		// Backward
	  {
		SetTimerEx(0, 8, 0, 0);		// Engine kill check
		if(velocityscalar>0)
			velocityscalar=velocityscalar-1;
		if(cruiseon==1)
		{
			KillTimerEx(7);
			velocityscalar=maxvelocity;
			StopSound(sounddummy, 1);
			cruiseon=0;
		}
		if(velocityscalar>=maxvelocity)
			velocityscalar=maxvelocity;
	  }
   }
   else
   if (GetParam(0) == 7.0)             // Select Weapon {param(2) 13-22}
   {

	if(GetParam(2)==13)
	{
	   if((hard1availiable==1) && (hard1active==1))
	   {
   		hard1active=0;

		Print("hardpoint 1 deactive");
	   }
	   else if((hard1availiable==1) && !(hard1active==1))
	   {
   		hard1active=1;

		Print("hardpoint 1 active");
	   }
	}
	else if(GetParam(2)==14)
	{
	   if((hard2availiable==1) && (hard2active==1))
	   {
   		hard2active=0;

		Print("hardpoint 2 deactive");
	   }
	   else if((hard2availiable==1) && !(hard2active==1))
	   {
   		hard2active=1;

		Print("hardpoint 2 active");
	   }
	}
	else if(GetParam(2)==15)
	{
	   if((hard3availiable==1) && (hard3active==1))
	   {
   		hard3active=0;

		Print("hardpoint 3 deactive");
	   }
	   else if((hard3availiable==1) && !(hard3active==1))
	   {
   		hard3active=1;

		Print("hardpoint 3 active");
	   }
	}
	else if(GetParam(2)==16)
	{
	   if((hard4availiable==1) && (hard4active==1))
	   {
   		hard4active=0;

		Print("hardpoint 4 deactive");
	   }
	   else if((hard4availiable==1) && !(hard4active==1))
	   {
   		hard4active=1;

		Print("hardpoint 4 active");
	   }
	}
	ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 8.0)             // Pitch up/down
   {
	If(GetParam(2) > 0)		// up
		if(zvector+(GetParam(2)/zsens)<(.038 * .4))
			zvector=zvector+(GetParam(2)/zsens);
	If(GetParam(2) < 0)		// down
		if(zvector-((GetParam(2)*-1)/zsens)>(-.038 * .4))
			zvector=zvector-((GetParam(2)*-1)/zsens);

	SendTrigger(-1, 105, otherplace, -1, zvector, -1);		//sync zvector

      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 12.0)             // Use inv
   {
	if(GetParam(1)==1 && mouselock==0)
	{
		mouselock=1;
		mousepilot=1-mousepilot;
	}

	if(GetParam(1)==0)
		mouselock=0;

	ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 14.0)         // Other Actions
   {
      if (GetParam(2) == 0.0)    // Cycle Camera
      {
	  if(GetPrimaryFocus(0) == secghost || secghost==-1)
            // We're in first person mode (cockpit).
		SetCameraFocus(0, chaseghost);
         else if(GetPrimaryFocus(0) == chaseghost || chaseghost==-1)
            // We're in third person mode.
		SetCameraFocus(0, secghost);

	  else
		print("camera error");
      }
      ReturnEx(0.0);
   }
   else
   {
	PrintFlex(GetParam(0));
      ReturnEx(0.0);
   }


   Return;

# .......................................................................

pulse:

if(on)
{
   // check that the player didn't die
   if(GetThingHealth(player) < 1)
   {
      call stop_cam;
	Print("YOU DEAD!!!");
      Return;
   }
   else
   {
   	cam=GetPrimaryFocus(0);

	if(mousepilot==1)
		flpilot=VectorSet(zvector*(3157.5), xvector*(-2400), VectorZ(GetThingRotVel(shuttle)));
	else
		flpilot=VectorSet(0, 0, 0);

	SetThingRotVel(shuttle, flpilot);

	if(enginekill==0)
		SetThingThrust(shuttle, VectorScale(max_foward, velocityscalar));
	else if(enginekill==1)
		SetThingVel(shuttle, enginekillvec);
   }


   if(!(VectorEqual(GetThingPos(shuttle), GetThingPos(shuttlepart)) && VectorEqual(GetThingLVec(shuttle), GetThingLVec(shuttlepart))))
   {
	TeleportThing(shuttlepart, shuttle);
	AttachThingToThingEx(shuttlepart, shuttle, 0xC);
   }	
   if(!(VectorEqual(GetThingPos(shuttle), GetThingPos(shields)) && VectorEqual(GetThingLVec(shuttle), GetThingLVec(shields))))
   {
	TeleportThing(shields, shuttle);
	AttachThingToThingEx(shields, shuttle, 0xC);
   }	
}

   Return;

# ....................................................................

Timer:
   if (GetSenderID() == 1)		// exit ship teleporter
   {
	TeleportThing(player, spawnghost);
	StopThing(player);
	SetTimerEx(.0000001, 2, 0, 0);
	return;
   }
   else if (GetSenderID() == 2)
   {
	// This is here for nothing really, just to hold a place for .0000001 of a second.
	return;
   }
   else if (GetSenderID() == 3)	// activation teleportation
   {
	TeleportThing(player, otherplace);
	SetTimerEx(.0000001, 4, 0, 0);
	return;
   }
   else if (GetSenderID() == 4)	// activation code
   {
  	StopThing(player);
  	SetActionCog(GetSelfCog(), 0x7FFFFFFF);

   	SetPulse(0.03);

   	SetCurrentCamera(0);

   	call switch_cam;
	return;
   }
   else if (GetSenderID() == 5)	// initial creation of ship objects
   {
	shipcreated=1;
	shuttle=FireProjectile(shuttlespot, flying, -1, -1, VectorSet(0, 0, 0), '0 0 0', 0, 0, 0, 0);
Printint(shuttle);
Printint(GetThingSignature(shuttle));
	shuttlepart=FireProjectile(shuttlespot, landed, -1, -1, VectorSet(0, 0, 0), '0 0 0', 0, 0, 0, 0);
	shields=FireProjectile(shuttlespot, shieldtpl, -1, -1, VectorSet(0, 0, 0), '0 0 0', 0, 0, 0, 0);
	secghost=FireProjectile(shuttlespot, ghosttpl, -1, -1, VectorSet(0, 0, 0), '0 0 0', 0, 0, 0, 0);
	chaseghost=FireProjectile(shuttlespot, ghosttpl, -1, -1, VectorSet(0, -0.8, 0.1), '0 0 0', 0, 0, 0, 0);
	spawnghost=FireProjectile(shuttlespot, ghosttpl, -1, -1, VectorSet(0, 0.2, 0.1), '0 0 0', 0, 0, 0, 0);
	gun0=FireProjectile(shuttlespot, ghosttpl, -1, -1, VectorSet(0.4, 0.28, -0.16), '0 0 0', 0, 0, 0, 0);
	gun1=FireProjectile(shuttlespot, ghosttpl, -1, -1, VectorSet(0.4, 0.28, 0.04), '0 0 0', 0, 0, 0, 0);
	gun2=FireProjectile(shuttlespot, ghosttpl, -1, -1, VectorSet(-0.4, 0.28, 0.04), '0 0 0', 0, 0, 0, 0);
	gun3=FireProjectile(shuttlespot, ghosttpl, -1, -1, VectorSet(-0.4, 0.28, -0.16), '0 0 0', 0, 0, 0, 0);


capturething(shuttle);
capturething(shuttlepart);
capturething(shields);

Printint(gun3);
Printint(GetThingSignature(gun3));


if(gun3==-1 || GetThingSignature(gun3)==-1)
{
 Print("GUN3 ERROR");
 SetCogFlags(GetSelfCog(), 0x2);
return;
}
if(gun2==-1 || GetThingSignature(gun2)==-1)
{
 Print("GUN2 ERROR");
 SetCogFlags(GetSelfCog(), 0x2);
return;
}
if(gun1==-1 || GetThingSignature(gun1)==-1)
{
 Print("GUN1 ERROR");
 SetCogFlags(GetSelfCog(), 0x2);
return;
}
if(gun0==-1 || GetThingSignature(gun0)==-1)
{
 Print("GUN0 ERROR");
 SetCogFlags(GetSelfCog(), 0x2);
return;
}
if(spawnghost==-1 || GetThingSignature(spawnghost)==-1)
{
 Print("SPAWNGHOST ERROR");
 SetCogFlags(GetSelfCog(), 0x2);
return;
}
if(chaseghost==-1 || GetThingSignature(chaseghost)==-1)
{
 Print("CHASEGHOST ERROR");
 SetCogFlags(GetSelfCog(), 0x2);
return;
}
if(secghost==-1 || GetThingSignature(secghost)==-1)
{
 Print("SECGHOST ERROR");
 SetCogFlags(GetSelfCog(), 0x2);
return;
}
if(shields==-1 || GetThingSignature(shields)==-1)
{
 Print("SHIELDS ERROR");
 SetCogFlags(GetSelfCog(), 0x2);
return;
}
if(shuttlepart==-1 || GetThingSignature(shuttlepart)==-1)
{
 Print("SHUTTLEPART ERROR");
 SetCogFlags(GetSelfCog(), 0x2);
return;
}
if(shuttle==-1 || GetThingSignature(shuttle)==-1)
{
 Print("SHUTTLE ERROR");
 SetCogFlags(GetSelfCog(), 0x2);
return;
}
///%%%%%%%%%%%%%%%%%%%%####################$$$$$$$$$$$$$$$$$$###############((((((((())()()))))))))))))))))))))((((((((((((())))))))#######3))))))))((((((())))/////////////////////////////////

	AttachThingToThingEx(secghost, shuttle, 0xc);
	AttachThingToThingEx(chaseghost, shuttle, 0xc);
	AttachThingToThingEx(spawnghost, shuttle, 0xc);
	AttachThingToThingEx(shuttlepart, shuttle, 0xc);
	AttachThingToThingEx(gun0, shuttle, 0xc);
	AttachThingToThingEx(gun1, shuttle, 0xc);
	AttachThingToThingEx(gun2, shuttle, 0xc);
	AttachThingToThingEx(gun3, shuttle, 0xc);
	AttachThingToThingEx(shields, shuttle, 0xc);

	hard1availiable=1;	// Hardpoints 1-4 availiable
	hard2availiable=1;
	hard3availiable=1;
	hard4availiable=1;
   	hard1active=1;		// Hardpoints 1-4 active
   	hard2active=1;
   	hard3active=1;
   	hard4active=1;

	hulllvl=100;
	SendTrigger(-1, 102, otherplace, -1, 100, -1);		//hull to 100

	SendTrigger(-1, 106, otherplace, shuttle, shuttlepart, shields);
	SendTrigger(-1, 107, otherplace, gun0, gun1, gun2);
	SendTrigger(-1, 108, otherplace, gun3, -1, -1);


	SetTimerEx(0, 14, 0, 0);
	return;
   }
   else if (GetSenderID() == 6)	// full stop
   {
	SetThingThrust(shuttle, '0 0 0');
	Print("full Stop");
	return;
   }
   else if (GetSenderID() == 7)	// charge cruise
   {
	if(GetParam(0)>=cruisecharge-1)
	{
		velocityscalar=100;
		Print("Cruising");
		StopSound(sounddummy, .5);
		sounddummy=PlaySoundThing(cruisesnd, shuttle, 1, 0, 100, 0x81);
	}
	else
	{
		Printint(cruisecharge-(GetParam(0)+1));
		SetTimerEx(1, 7, GetParam(0)+1, 0);
	}
	return;
   }
   else if (GetSenderID() == 8)	// stop engine kill
   {
	if(enginekill==1)
	{
		enginekill=0;
		if(velocityscalar>=maxvelocity)
			velocityscalar=maxvelocity;
	}
	return;
   }
   else if (GetSenderID() == 9)	// enable firing
   {
	firedelay=0;
	return;
   }
   else if (GetSenderID() == 10)	// sync data with new player
   {

	if(IsMulti()==1 && IsServer()==1)	// check if (host and multi)
	{
	   if(GetParam(0)!=GetPlayerThing(0))
	   {
		SendTrigger(GetParam(0), 900, shuttle, shuttlepart, secghost, otherplace);
		SendTrigger(GetParam(0), 901, spawnghost, gun0, gun1, otherplace);
		SendTrigger(GetParam(0), 902, gun2, gun3, chaseghost, otherplace);
		SendTrigger(GetParam(0), 904, shields, -1, -1, otherplace);


		SendTrigger(GetParam(0), 999, otherplace, -1, GetThingUserData(otherplace), -1);


		SyncThingAttachment(secghost);
		SyncThingAttachment(chaseghost);
		SyncThingAttachment(spawnghost);
		SyncThingAttachment(shuttlepart);
		SyncThingAttachment(gun0);
		SyncThingAttachment(gun1);
		SyncThingAttachment(gun2);
		SyncThingAttachment(gun3);
	   }
	}
	return;
   }

   else if (GetSenderID() == 12)	// reactivate shields
   {
	shieldlvl=100;
	SendTrigger(-1, 103, otherplace, -1, 100, -1);		//shield to 100

	SetCollideType(shields, 3);
	KillTimerEx(15);
	ClearThingFlags(shields, 0x10);
	SetTimerEx(.1, 15, 0, 0);
	return;
   }
   else if (GetSenderID() == 13)	// Ship Destroyed
   {
	if(GetParam(0)==shuttle || GetParam(0)==shuttlepart)
	{

	   StopKey(shuttle, keydummy0, 0);
	   StopKey(shuttlepart, keydummy1, 0);

	   if(on==1)
	   {
		SetPulse(0);

		StopThing(shuttle);

		// Turn off control capture
		SetActionCog(-1, 0);

		SetTimerEx(0.0000001, 1, 0, 0);
		StopThing(player);

		SetCameraFocus(0, pricam);

		ClearActorFlags(player, 0x80800000);

		Print("EMERGENCY MALFUNCTION.  EJECTING PILOT!!!");
		SendTrigger(-1, 112, otherplace, -1, 0, 112);

		on = 0;
	   }

	   FireProjectile(shuttle, exptpl, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);


// [NEW]

	TeleportThing(shuttle, shuttlespot);
	TeleportThing(shuttlepart, shuttle);
	TeleportThing(shields, shuttle);
	TeleportThing(secghost, shuttle);

	spawner=FireProjectile(shuttle, tmpghosttpl, -1, -1, VectorSet(0, -0.8, 0.1), '0 0 0', 0, 0, 0, 0);
	TeleportThing(chaseghost, spawner);
	DestroyThing(spawner);

	spawner=FireProjectile(shuttle, tmpghosttpl, -1, -1, VectorSet(0, 0.2, 0.1), '0 0 0', 0, 0, 0, 0);
	TeleportThing(spawnghost, spawner);
	DestroyThing(spawner);

	spawner=FireProjectile(shuttle, tmpghosttpl, -1, -1, VectorSet(0.4, 0.28, -0.16), '0 0 0', 0, 0, 0, 0);
	TeleportThing(gun0, spawner);
	DestroyThing(spawner);

	spawner=FireProjectile(shuttle, tmpghosttpl, -1, -1, VectorSet(0.4, 0.28, 0.04), '0 0 0', 0, 0, 0, 0);
	TeleportThing(gun1, spawner);
	DestroyThing(spawner);

	spawner=FireProjectile(shuttle, tmpghosttpl, -1, -1, VectorSet(-0.4, 0.28, 0.04), '0 0 0', 0, 0, 0, 0);
	TeleportThing(gun2, spawner);
	DestroyThing(spawner);

	spawner=FireProjectile(shuttle, tmpghosttpl, -1, -1, VectorSet(-0.4, 0.28, -0.16), '0 0 0', 0, 0, 0, 0);
	TeleportThing(gun3, spawner);
	DestroyThing(spawner);

	AttachThingToThingEx(secghost, shuttle, 0xc);
	AttachThingToThingEx(chaseghost, shuttle, 0xc);
	AttachThingToThingEx(spawnghost, shuttle, 0xc);
	AttachThingToThingEx(shuttlepart, shuttle, 0xc);
	AttachThingToThingEx(gun0, shuttle, 0xc);
	AttachThingToThingEx(gun1, shuttle, 0xc);
	AttachThingToThingEx(gun2, shuttle, 0xc);
	AttachThingToThingEx(gun3, shuttle, 0xc);
	AttachThingToThingEx(shields, shuttle, 0xc);

	hulllvl=100;
	SendTrigger(-1, 102, otherplace, -1, 100, -1);		//hull to 100

	SetTimerEx(0, 14, 0, 0);
// [/NEW]
//	   SendTrigger(-2, 905, 0, 0, 0, otherplace);
	}
	return;
   }
   else if (GetSenderID() == 14)	// Shields deactivating
   {
	shieldlvl=100;			// Deactivate shields
	SendTrigger(-1, 103, otherplace, -1, 100, -1);		//shield to 100

	SetCollideType(shields, 0);
	KillTimerEx(15);
	if(GetThingFlags(shields) & 0x10)
		ClearThingFlags(shields, 0x10);
	SetTimerEx(.1, 15, 0, 0);
	shieldlvl=0;
	SendTrigger(-1, 103, otherplace, -1, 0, -1);		//shield to 0

	return;
   }
   else if (GetSenderID() == 15)	// Shields deactivated
   {
	SetThingFlags(shields, 0x10);
	return;
   }

return;

# ....................................................................

trigger:

   if(GetSourceRef()==900)	// Sync group 1 objects
   {
	print("syncing group 1");
	if(GetParam(3)!=otherplace) Return;
	shuttle=GetParam(0);
	shuttlepart=GetParam(1);
	secghost=GetParam(2);
	return;
   }
   else if(GetSourceRef()==901)	// Sync group 2 objects
   {
	print("syncing group 2");
	if(GetParam(3)!=otherplace) Return;
	spawnghost=GetParam(0);
	gun0=GetParam(1);
	gun1=GetParam(2);
	return;
   }
   else if(GetSourceRef()==902)	// Sync group 3 objects
   {
	print("syncing group 3");
	if(GetParam(3)!=otherplace) Return;
	gun2=GetParam(0);
	gun3=GetParam(1);
	chaseghost=GetParam(2);
	return;
   }
   else if(GetSourceRef()==903)	// Sync the stuff after a second or two
   {
	SetTimerEx(1, 10, GetParam(0), 0);
	return;
   }
   else if(GetSourceRef()==904)	// Sync group 4 objects
   {
	print("syncing group 4");
	if(GetParam(3)!=otherplace) Return;
	shields=GetParam(0);
	return;
   }
   else if(GetSourceRef()==905)	// Redirect
   {
	if(GetParam(3)!=otherplace) Return;
	SetTimerEx(GetParam(2), GetParam(0), GetParam(1), -1);
	printint(GetParam(2));
	printint(GetParam(0));
	printint(GetParam(1));
	return;
   }


Return;

# .....................................................................

switch_cam:

	pricam=GetPrimaryFocus(0);

   	PlaySoundLocal(camChangeSnd, 1.0, 0.0, 0);

	SetCameraFocus(0, chaseghost);

	StopKey(shuttle, keydummy0, 0);
	StopKey(shuttlepart, keydummy1, 0);

	keydummy0=PlayKey(shuttle, launch, 2, 0x4);
	keydummy1=PlayKey(shuttlepart, launch, 2, 0x4);

	      SetThingThrust(shuttle, max_foward);

   SetTimerEx(.1, 6, 0, 0);


   Return;

# .......................................................................

stop_cam:

   SetPulse(0);

	SetThingRotVel(shuttle, '0 0 0');
	SetThingThrust(shuttle, '0 0 0');

	StopThing(shuttle);

   SetTimerEx(0.0000001, 1, 0, 0);

	StopThing(player);



   if(GetThingUserData(otherplace) & 1)
   {
	   SendTrigger(-1, 112, otherplace, -1, 0, 112);
   }


	SetTimerEx(0, 14, 0, 0);

   on = 0;

	StopKey(shuttle, keydummy0, 0);
	StopKey(shuttlepart, keydummy1, 0);

	keydummy0=PlayKey(shuttle, land, 2, 0x2);
	keydummy1=PlayKey(shuttlepart, land, 2, 0x2);

	SetCameraFocus(0, pricam);

   PlaySoundLocal(SwitchOffSound, 1.0, 0.0, 0);
   // Turn off control capture.
   SetActionCog(-1, 0);

   ClearActorFlags(player, 0x80800000);

	TeleportThing(shuttlepart, shuttle);
	AttachThingToThingEx(shuttlepart, shuttle, 0xC);

   Return;


end

CLIENT
Code:
# MOTS Cog Script
#
# shuttle_client.cog
#
# This cog controls all aspects of the Ship cog that DO NOT require syncing: aiming, vectoring, shielding...
#
# 8/27/05
#
# SG-fan
#
# THIS COG IS NOT SUPPORTED BE LEC
# ===============================================

flags=0x240

symbols

message	activate
message	pulse
message	timer
message	newplayer
message	trigger
message	damaged

int		cursor					local	nolink
int		findnewrange=0				local
int		lasttarget=-1				local
int		on=0					local
int		player					local
int		prevlasttarget=-1			local
int		targethold=-1				local

flex		hulllvl=0				local
flex		shieldlvl=0				local
flex		xvector					local
flex		zvector					local

template	cursortpl=cursorverysmall3
template	rangefindertpl=newranger

thing		cam=-1					local
thing		gun0=-1					local
thing		gun1=-1					local
thing		gun2=-1					local
thing		gun3=-1					local
thing		otherplace					nolink
thing		shields=-1				local
thing		shuttle=-1				local
thing		shuttlepart=-1				local
thing		shuttlespot
thing		target=-1				local	nolink

vector		cursororient				local
vector		firevec					local
template	tmpghosttpl=tmpghost



int	Pram0		local
int	Pram1		local

cog	server
end

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

code
activate:
Print("client");
   SendMessageEx(server, activated, GetSourceRef(), GetSenderRef(), GetSourceType(), GetSenderType());
return;

pulse:

if(on)
{
   // check that the player didn't die
   if(GetThingHealth(player) < 1)
   {
      call stop_cam;
	Print("YOU DEAD!!!");
      Return;
   }
   else
   {
   	cam=GetPrimaryFocus(0);
	if((cursor>=0)&&(GetThingType(cursor)!=10))
		DestroyThing(cursor);
	cursor=FireProjectile(cam, cursortpl, -1, -1, VectorSet(xvector, 0.05 * .4, zvector), '0 0 0', 0, 0, 0, 0);

	SetThingParent(cursor, shuttlespot);

	AttachThingToThingEx(cursor, cam, 0xc);

	cursororient=VectorSub(GetThingPos(cursor), GetThingPos(cam));
	SetThingLook(cursor, cursororient);

	if((target>=0)&&(GetThingType(target)!=10))
	{
		prevlasttarget=lasttarget;
		lasttarget=target;
		DestroyThing(target);
		target=-1;
	}
	target=FireProjectile(cursor, rangefindertpl, -1, -1, VectorSet(0, 50, 0), '0 0 0', 0, 0, 0, 0);

	findnewrange=0;

	while(VectorDist(GetThingPos(target), GetThingPos(shuttle)) <= GetThingCollideSize(shuttlepart) * 1.5)
	{
		findnewrange=1;
		if((target>=0)&&(GetThingType(target)!=10))
		{
			SetThingLook(target, cursororient);
			prevlasttarget=lasttarget;
			lasttarget=target;
			targethold=FireProjectile(target, tmpghosttpl, -1, -1, VectorSet(0, 0.05, 0), '0 0 0', 0, 0, 0, 0);
			DestroyThing(target);
			target=targethold;
		}
	}
	if(findnewrange==1)
	{
		if((target>=0)&&(GetThingType(target)!=10))
		{
			SetThingLook(target, cursororient);
			prevlasttarget=lasttarget;
			lasttarget=target;
			targethold=FireProjectile(target, rangefindertpl, -1, -1, VectorSet(0, 50, 0), '0 0 0', 0, 0, 0, 0);
			DestroyThing(target);
			target=targethold;
		}
	}

	firevec=VectorSub(GetThingPos(target), GetThingPos(gun0));
	SetThingLook(gun0, firevec);

	firevec=VectorSub(GetThingPos(target), GetThingPos(gun1));
	SetThingLook(gun1, firevec);

	firevec=VectorSub(GetThingPos(target), GetThingPos(gun2));
	SetThingLook(gun2, firevec);

	firevec=VectorSub(GetThingPos(target), GetThingPos(gun3));
	SetThingLook(gun3, firevec);

   }	
}

   Return;

# ....................................................................

Timer:
   if (GetSenderID() == 2)
   {
	// This is here for nothing really, just to hold a place for .0000001 of a second.
	return;
   }
   else if (GetSenderID() == 6)	// full stop
   {
	SetThingThrust(shuttle, '0 0 0');
Print("full Stop");
	return;
   }

   else if (GetSenderID() == 13)	// Ship Destroyed
   {
	if(GetParam(0)==shuttle || GetParam(0)==shuttlepart)
	{

	   if(on==1)
	   {
		SetPulse(0);

		if((cursor>=0)&&(GetThingType(cursor)!=10)) DestroyThing(cursor);

		on = 0;
	   }

	}
	return;
   }

return;

# ....................................................................

newplayer:
   SendTrigger(GetPlayerThing(0), 903, GetSenderRef(), 0, 0, 0);

   Return;

# ....................................................................

trigger:
 Pram0=GetParam(0);
 Pram1=GetParam(1);

 if(Pram0==otherplace)
 {
   if(GetSourceRef()==101)	// activating shuttle
   {
	print("SETTING SHUTTLE ON. . .");
	SetThingUserData(Pram0, GetThingUserData(Pram0)+1);

	xvector=0;		// left/right
	zvector=0;		// up/down

	player=GetParam(2);

	on=1;

   	SetPulse(0.03);
   }
   else if(GetSourceRef()==112)	// deactivating shuttle
   {
	print("...SHUTTLE OFF...");
	SetThingUserData(Pram0, GetThingUserData(Pram0)-1);
		SetPulse(0);

		if((cursor>=0)&&(GetThingType(cursor)!=10)) DestroyThing(cursor);

		on = 0;
   }
   else if(GetSourceRef()==999)	// Sync data
   {
	if(Pram0!=-1)
		SetThingUserData(Pram0, GetParam(2));
	if(Pram1!=-1)
		SetThingUserData(Pram1, GetParam(3));
   }
   else if(GetSourceRef()==102)	// activating shuttle
   {
	hulllvl=GetParam(2);
   }
   else if(GetSourceRef()==103)	// activating shuttle
   {
	shieldlvl=GetParam(2);
   }
   else if(GetSourceRef()==104)	// activating shuttle
   {
	xvector=GetParam(2);
   }
   else if(GetSourceRef()==105)	// activating shuttle
   {
	zvector=GetParam(2);
   }
   else if(GetSourceRef()==106)	// Sync group 1 objects
   {
	print("syncing1");
	shuttle=GetParam(1);
	shuttlepart=GetParam(2);
	shields=GetParam(3);
	CaptureThing(shuttle);
	CaptureThing(shuttlepart);
	CaptureThing(shields);
   }
   else if(GetSourceRef()==107)	// Sync group 2 objects
   {
	print("syncing2");
	gun0=GetParam(1);
	gun1=GetParam(2);
	gun2=GetParam(3);
   }
   else if(GetSourceRef()==108)	// Sync group 3 objects
   {
	print("syncing3");
	gun3=GetParam(1);
   }


 }
   Return;

# .....................................................................

stop_cam:

   SetPulse(0);

	if((cursor>=0)&&(GetThingType(cursor)!=10)) DestroyThing(cursor);


   on = 0;

   Return;

# ..................................................................

damaged:								// SenderRef == object/surface damaged
									// SourceRef == damage source (projectile)
									// Param(0) == Damage amount
									// Param(1) == Damage flag
if((IsMulti()==1 && IsServer()==1) || (IsMulti()==0 && IsServer()==0))	// check if (host and multi) || (single player)
{
 if(GetSenderRef()==shuttle || GetSenderRef()==shuttlepart)		// Hit hull
 {
  if(shieldlvl<=0)
  {
    if(GetParam(1)==2)							// Energy damage (Regular weapon)
    {
	if(hulllvl-GetParam(0) > 0)			// hull still greater than 0 (not destroyed)
	{
	   hulllvl=hulllvl-GetParam(0);
	   JkStringClear();
	   JkStringConcatAsciiString("hull: ");
	   JkStringConcatFlex(hulllvl);
	   JkStringOutput(-3, -1);
	}
	else
	{
	   SetTimerEx(0, 13, GetSenderRef(), 0);					// ***BLOW UP SHIP***
	   SendTrigger(-1, 905, 13, GetSenderRef(), 0, otherplace);
	}
    }
    else if(GetParam(1)==8)						// Force damage (Shieldbuster weapon)
    {
	if(hulllvl-(1/3 * GetParam(0)) > 0)		// hull still greater than 0 (not destroyed)
	{
	   hulllvl=hulllvl-(1/3 * GetParam(0));
	   JkStringClear();
	   JkStringConcatAsciiString("hull: ");
	   JkStringConcatFlex(hulllvl);
	   JkStringOutput(-3, -1);
	}
	else
	{
	   SetTimerEx(0, 13, GetSenderRef(), 0);					// ***BLOW UP SHIP***
	   SendTrigger(-1, 905, 13, GetSenderRef(), 0, otherplace);
	}
   }
  }
 }
 else if(GetSenderRef()==shields)							// Hit shield    ***SHIELDS IMPLEMENTED***
 {
   if(GetParam(1)==2)							// Energy damage (Regular weapon)
   {
	if(shieldlvl-(1/4 * GetParam(0)) > 0)		// shields still greater than 0 (not disabled)
	{
	   shieldlvl=shieldlvl-(1/4 * GetParam(0));
	   JkStringClear();
	   JkStringConcatAsciiString("shields: ");
	   JkStringConcatFlex(shieldlvl);
	   JkStringOutput(-3, -1);
	}
	else if(shieldlvl-(1/4 * GetParam(0)) <= 0)	// Shields disabled
	{
	   SendTrigger(-1, 905, 14, -1, 0, otherplace);					// Deactivate shields
	   SendTrigger(-1, 905, 12, -1, 10, otherplace);				// Reactivate shields after 10 seconds
	}
   }
   else if(GetParam(1)==8)						// Force damage (Shieldbuster weapon)
   {
	if(shieldlvl-GetParam(0)*1.5 > 0)		// shields still greater than 0 (not disabled)
	{
	   shieldlvl=shieldlvl-(GetParam(0)*1.5);
	   JkStringClear();
	   JkStringConcatAsciiString("shields: ");
	   JkStringConcatFlex(shieldlvl);
	   JkStringOutput(-3, -1);
	}
	else if(shieldlvl-GetParam(0)*1.5 <= 0)	// Shields disabled
	{
	   SendTrigger(-1, 905, 14, -1, 0, otherplace);					// Deactivate shields
	   SendTrigger(-1, 905, 12, -1, 10, otherplace);				// Reactivate shields after 10 seconds
	}
   }
 }
}

   Return;
end


Please do NOT steal the code (without giving me some credit ;))
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-01, 8:14 AM #11
Thank you for posting the cogs.

Of course we JK editors won't steal them. All due credit will be yours.

(Check your Project's forum for comments from other editors.)

:)
2005-09-01, 8:51 PM #12
Ya I trust you guys, I was just being funny :)
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-02, 6:25 AM #13
sweet!~!! :D :D :D :cool: :p

SGfan make it for JK!!!!!!!!!!!. I can give you my death glider and the sounds I made.

U could use it for your prometheus project, and I could use it for my levels.

Oh man that would be sweet



as for the cog/ or the way the plane works, there should be a minimum speed, and if it hits the ground you have to crash.

I can also give you the staff cannon templates and sounds and effects

:D
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2005-09-04, 2:52 PM #14
Did I miss the memo of all the editors leaving? Maybe I should post on the showcase instead...
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-04, 6:18 PM #15
Ruthven, I'm not going to put in the minimum speed thing since this is mainly for space battles (and if you are over land, you can just say its the antigravity repulsor thingers)
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-05, 6:38 PM #16
SG-Fan you are a master guru cogger!

↑ Up to the top!