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 → Finished Flying Cog
Finished Flying Cog
2003-07-21, 8:53 AM #1
After much time and thought, I present the working ship cog!
Code:
# MOTS Cog Script
#
# shuttle.cog
#
# SG-fan
#
# THIS COG IS NOT SUPPORTED BE LEC
# =====================================================================

flags=0x40

symbols

thing		console0
thing		shuttle                          nolink
thing		cam                              local
thing		ghost                            nolink

int		player                           local
int		on=0                             local
int		startHealth=0                    local

vector		oldlookvec                       local

sound		SwitchOffSound=deactivate02.wav  local
sound		camChangeSnd=beep2.wav           local

vector		max_foward
vector		max_backward

vector		rotateup
vector		rotateright
vector		bankright
vector		stopped
vector		rotation			local
vector		rotation1			local
vector		rotation2			local

message	activated
message	playeraction
message	pulse
message	timer
message	startup

end

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

code
startup:
   SetTimerEx(1, 321, 0, 0);
   Return;

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

activated:
   player = GetSourceRef();

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

   if(on) Return;

   on = 1;

   SetActorFlags(player, 0x80800000);

   SetTimerEx(0.0000001, 54321, 0, 0);

   Return;

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

playeraction:
   if (GetParam(0) == 0.0)             // Jump
   {
	SetThingRotVel(cam, stopped);
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 1.0)             // Crouch
   {
	SetThingThrust(shuttle, max_backward);
	Print("backward");
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 2.0)             // Activated
   {

      call stop_cam;

      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 3.0)             // Fire
   {
	      SetThingThrust(shuttle, max_foward);
		Print("foward");
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 4.0)             // Strafe
   {
      ReturnEx(0.0);
	  rotation2=GetThingRotVel(cam);
	  If(GetParam(2) > 0)
	  {
	  	if(VectorZ(rotation2)==VectorZ(bankright)) Return;
		Print("bank right");
		rotation2=VectorAdd(rotation2, bankright);
		SetThingRotVel(cam, 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(cam, rotation2);
	  }
	  else if(GetParam(2) < 0)
	  {
		if(VectorZ(rotation2)==(-1*VectorZ(bankright))) Return;
		Print("bank left");
		rotation2=VectorSub(rotation2, bankright);
		SetThingRotVel(cam, rotation2);
	  }
   }
   else
   if (GetParam(0) == 5.0)             // Turn
   {
         ReturnEx(0.0);
	  rotation1=GetThingRotVel(cam);
	  If(GetParam(2) > 0)
	  {
	  	if(VectorY(rotation1)==VectorY(rotateright)) Return;
		Print("left");
		rotation1=VectorAdd(rotation1, rotateright);
		SetThingRotVel(cam, rotation1);
	  }
	  else if(GetParam(2) == 0)
	  {
	  	if(VectorY(rotation1)==VectorY(rotateright))
			rotation1=Vectorsub(rotation1, rotateright);
		else if(VectorY(rotation1)==(-1*VectorY(rotateright)))
			rotation1=Vectoradd(rotation1, rotateright);
		SetThingRotVel(cam, rotation1);
	  }
	  else if(GetParam(2) < 0)
	  {
		if(VectorY(rotation1)==(-1*VectorY(rotateright))) Return;
		Print("right");
		rotation1=VectorSub(rotation1, rotateright);
		SetThingRotVel(cam, rotation1);
	  }

   }
   else
   if (GetParam(0) == 6.0)             // Fwd / Bkwd Motion
   {
       ReturnEx(0.0);
	  rotation=GetThingRotVel(cam);
	  If(GetParam(2) > 0)
	  {
		if(VectorX(rotation)==-1*VectorX(rotateup)) Return;
		Print("down");
		rotation=VectorSub(rotation, rotateup);
		SetThingRotVel(cam, rotation);
	  }
	  else if(GetParam(2) == 0)
	  {
	  	if(VectorX(rotation)==VectorX(rotateup))
			rotation=Vectorsub(rotation, rotateup);
		else if(VectorY(rotation)==(-1*VectorY(rotateup)))
			rotation=Vectoradd(rotation, rotateup);
		SetThingRotVel(cam, rotation);
	  }
	  else if(GetParam(2) < 0)
	  {
	  	if(VectorX(rotation)==VectorX(rotateup)) Return;
		Print("up");
		rotation=VectorAdd(rotation, rotateup);
		SetThingRotVel(cam, rotation);
	  }

   }
   else
   if (GetParam(0) == 14.0)         // Other Actions
   {
      if (GetParam(2) == 0.0)    // Cycle Camera
      {
         if (GetCurrentCamera() == 0)
         {
            // We're in first person mode.
         }
         else
         {
            // We're in third person mode.
         }
      }
      ReturnEx(1.0);
   }
   else
   {
      ReturnEx(0.0);
   }

   Return;

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

pulse:
   SetPulse(0.05);
   // check that the player didn't die
   if(GetThingHealth(player) < 1)
   {
      call stop_cam;
      Return;
   }

   Return;

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

timer:

   if (GetSenderID() == 12345)
   {
	TeleportThing(player, ghost);
	SetTimerEx(.0000001, 123, 0, 0);
   }
   if (GetSenderID() == 123)
   {
	// This is here for nothing really, just to hold a place for .0000001 of a second.
   }
   if (GetSenderID() == 54321)
   {
	TeleportThing(player, ghost);
	SetTimerEx(.0000001, 1234, 0, 0);

   }
   if (GetSenderID() == 1234)
   {
  	StopThing(player);
  	SetActionCog(GetSelfCog(), 0x7FFFFFFF);
	DetachThing(player);
	AttachThingToThingEx(player, shuttle, 0x8);

   	startHealth = GetThingHealth(player);

   	SetPulse(0.5);

   	SetCurrentCamera(0);

   	canpointnow = 1;

   	call switch_cam;
   }
   if (GetSenderID() == 321)
   {
	AttachThingToThingEx(ghost, shuttle, 0x8);
	AttachThingToThingEx(console0, shuttle, 0x8);
   }
   if (GetSenderID() == 101)
   {
	SetThingThrust(shuttle, '0 0 0');
   }
   Return;

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

switch_cam:
   Print(" ");
   Print(" ");
   Print(" ");
   Print(" ");
   Print(" ");

   dummy = PlaySoundLocal(camChangeSnd, 1.0, 0.0, 0);
   cam = shuttle;

	      SetThingThrust(shuttle, max_foward);
		Print("foward");
   SetTimerEx(.1, 101, 0, 0);
   SetTimerEx(minChangeRate, 12, 0, 0);

   Return;

stop_cam:
	StopThing(shuttle);
	DetachThing(player);
   SetTimerEx(0.0000001, 12345, 0, 0);
	StopThing(player);

   SetPulse(0);
   on = 0;
   canpointnow = 0;

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

   ClearActorFlags(player, 0x80800000);

   Print(" ");
   Print(" ");
   Print(" ");
   Print(" ");
   Print(" ");

   Return;

end

The keys for flying are:
-foward/backward keys are pitch down/up
-left/right keys are yaw left/right
-strafe left/right keys are roll left/right
-spacebar activates and deactivates the shuttle
-fire (either) gives foward thrust
-crouch gives backward thrust

The symbols are mainly self-explanitory.
-ghost should be placed behind the console with a view out the front window (required in this version)
-max_foward=(0/+?/0)
-max_backward=(0/-?/0)
-rotateup=(+?/0/0)
-rotateright=(0/+?/0)
-bankright=(0/0/+?)
-stopped=(0/0/0)

Be sure to have the shuttle, console, and ghost in the EXACT same position. Otherwise they will rotate around different areas. Just move the center of the objects (not the ghost) so they are all positioned how you want them.
[edit]I almost forgot, all objects must have the same pitch, yaw, and roll otherwise they don't move together.[/edit]

If you have any questions, or I forgot to mention something, don't hesitate to ask.

You have permission to use this as long as I'm credited in the readme and cog description.

[edit2]I changed the cog to what SM said in his post [http://forums.massassi.net/html/smile.gif] just to keep you from getting confused by my boredness [/edit2]

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

[This message has been edited by SG-fan (edited July 21, 2003).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-07-21, 2:49 PM #2
Yeah. MotS. That other game... [http://forums.massassi.net/html/redface.gif]

I was thinking this was for JK. In JK, I'm fairly positive that the only way to get JK to render a model upside-down is to use the player's torso and set his headpitch min and max to really high numbers. Whether you use rotvels or lookvectors, you can't get JK to render a model upside-down - instead, the models just do a very quick rotation.

But in MotS with this cog, the model actually does render upside-down?

A few things about the cog...

Code:
SetTimerEx(.0000001, 1234, 1234, 1234);


Of course JK can't do anything that quickly, you shouldn't try anything less than 0.001 because JK will not do it. It's also not good programming practice to write floats beginning or ending with a decimal point.

Most people number their timer IDs sequentially, and it's always good to follow conventions like that, but nothing's wrong there. And no need to set the timer's parameters like that.

Code:
SetThingThrust(shuttle, '0/0/0');

When giving a vector explicitly like that, you should use '0 0 0'.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-21, 3:01 PM #3
The model worked fine upside down in mots. I should test different rotations in JK to see if it'll work there. [http://forums.massassi.net/html/smile.gif]

Mots did do the timer correctly even with the very small decimal. I have some bad habits with writing floats pretty [http://forums.massassi.net/html/wink.gif] I'm working on fixing that.
About the funky timer ID's, uh, well, I got a little bored when writing this cog, and, uh, you can see the result [http://forums.massassi.net/html/smile.gif] I also know that I only needed to use the first parameter, but as I said, I was bored. lol

About the vector, I think it worked fine but the thrust it is stopping is so small that I barely notice anyway.

PS. SaberMaster could you make Parsec recongnise mots verbs please [http://forums.massassi.net/html/smile.gif] It would make things so much easier for me to cog, all is use is parsec, datamaster, and a site with mots verbs.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

[This message has been edited by SG-fan (edited July 21, 2003).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-07-22, 3:41 AM #4
Parsec is pretty much finished, it was never meant to be used like it is now, I started out just writing a test program in Basic.

Sometime in the next few months, I'm going to rewrite Parsec for windows, perhaps as part of an IDE.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-22, 2:08 PM #5
WOOHOOO

IDE parsec [http://forums.massassi.net/html/biggrin.gif]...


i wish MOTS wasent so... unused... it rocked with the hole colored lighting thing...

and whatever happened to the days of LEC makeing there own engines for games? coz i wanna see a JK 5 with its own engine, build for the pupose.. :| am i mad?

and if only i could get JK to relice the sorce code to MOTS i could hire a army of programers to give it no detail hom, and shaders... and it would be perfect [http://forums.massassi.net/html/biggrin.gif]

oh and dynamic colored lighting, of corce [http://forums.massassi.net/html/biggrin.gif]


i went off topic.. -gags in pain-

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-07-23, 1:07 PM #6
Does anyone besides SM and PBJ care enough to post here? If no one cares about it then I wont do any more with it.

If you want me to keep working on it, then just say the word [http://forums.massassi.net/html/smile.gif] (ask nicely and I might make a starfighter mod)

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-07-23, 1:39 PM #7
pleeeeeeeeaaaaaaaaaasssssssssseeeeeeeeeee [http://forums.massassi.net/html/tongue.gif]

------------------
Call me Vedder.
Author of: A Pirate's Tale (Mots SP)
APT homepage
----
<phantom> You're always going to be aloser if you attempt to aspire to massassi standards.
<phantom> They're a bunch of socially inadequate <beep> whores who have little or no lives.
APT 1, 2, 3/4, 5/6
TDT
DMDMD

http://veddertheshredder.com
2003-07-24, 2:01 AM #8
akngbjabajbg!!!!!!
PBJ¬!!!!!!

-dies-


yes... work.. work hard and watch the pay off....

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-07-24, 5:52 AM #9
Hey PJB you don't mind me calling you PBJ do you? [http://forums.massassi.net/html/smile.gif]
It's just easier to remember. lol

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-07-24, 6:03 AM #10
:|
i am not made ut of penutbutter, or jelly... and i aint a otter... so it cant applie to me [http://forums.massassi.net/html/biggrin.gif]

P.S. FLYING COG!!!! FINALY!!! PURE OWNAGE!!!!


(but i want one for JK...... work my little slaves work)
------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD

[This message has been edited by [SF]pjb (edited July 24, 2003).]
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?

↑ Up to the top!