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 → Flying cog
Flying cog
2003-01-20, 6:21 AM #1
Hey I have made a flying cog that doesn't work that well, and it wont sync over multiplayer. Does anyone have any little tips or suggestions for it.

Oh and I will post the cog if someone wants it and can tell me what to do to format it right.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-01-20, 6:27 AM #2
ehh, edit cog in Notepad and copy/paste it..
2003-01-20, 6:31 AM #3
No thats not what I ment. [http://forums.massassi.net/html/rolleyes.gif] I ment the code tag things, I guess I should have said that...
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-01-20, 6:54 AM #4
Nevermind about the code block question I figured it out. Here is the cog.

Code:
# SG-fan
#
# This is a flying ship cog which allows 
# the player to pilot a ship in all 
# directions. Foward/backward keys are for 
# up/down. Left/right keys are for 
# left/right.
#
# Bugs: Does not support upside down flying.
#       Cannot hold passengers.
#
# THIS COG IS NOT SUPPORTED BY LEC.

flags=0x40

symbols

thing		console0

thing		shuttle                          nolink

thing		cam                              local

int		messagebase=-1

int		player                           local
int		on=0                             local
flex		temp                             local
int		canpointnow=0                    local

int		startHealth=0                    local
int		mode                             local
vector		startPosition                    local
vector		oldlookvec                       local
vector		vec0                             local
vector		vec1                             local

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

vector		max_foward
vector		max_backward

thing		ghost                            nolink

message	activated
message	playeraction
message	pulse
message	timer
message	startup

end

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

code
startup:
   SetTimerEx(1, 321, 321, 321);
   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, 54321, 54321);

   Return;

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

playeraction:
   if (GetParam(0) == 0.0)             // Jump
   {
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 1.0)             // Crouch
   {
	SetThingThrust(shuttle, max_backward);
	Print("RETREAT");
      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 march");
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 4.0)             // Strafe
   {
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 5.0)             // Turn
   {
      if(canpointnow)
      {
         canpointnow = 0;
         vec0 = GetThingLVecPYR(cam);
         temp = VectorY(vec0) + (GetParam(2) / 100);
         if(temp > 360) temp = temp - 360;
         if(temp < 0) temp = temp + 360;
         vec0 = VectorSet(VectorX(vec0), temp, VectorZ(vec0));
         SetThingLookPYR(cam, vec0);
         SetThingLookPYR(player, vec0);
         SetThingLookPYR(console0, vec0);
         canpointnow = 1;
         ReturnEx(0.0);
      }
   }
   else
   if (GetParam(0) == 6.0)             // Fwd / Bkwd Motion
   {
      if(canpointnow)
      {
         canpointnow = 0;
         vec0 = GetThingLVecPYR(cam);
         temp = VectorX(vec0) + (GetParam(2) * -1);
         if(temp > 80) temp = 80;
         if(temp < -80) temp = -80;
         vec0 = VectorSet(temp, VectorY(vec0), VectorZ(vec0));
         SetThingLookPYR(cam, vec0);
         SetThingLookPYR(player, vec0);
         SetThingLookPYR(console0, vec0);
         canpointnow = 1;
         ReturnEx(0.0);
      }
   }
   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.5);
   // check that the player didn't die
   if(GetThingHealth(player) < 1)
   {
      call stop_cam;
      Return;
   }

   Return;

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

timer:
   if (GetSenderID() == 12)
   {
	allowChangeCam = 1;
   }
   if (GetSenderID() == 12345)
   {
	TeleportThing(player, ghost);
	SetTimerEx(.0000001, 123, 123, 123);
   }
   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, 1234, 1234);

   }
   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);
   }
   Return;

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

switch_cam:
   Print(" ");
   Print(" ");
   Print(" ");
   Print(" ");
   Print(" ");
   if(messagebase > -1) jkPrintUNIString(player, (messagebase + activeCam));
   if(messagebase < 0)
   {
      jkStringClear();
      jkStringConcatAsciiString("Camera ");
      jkStringConcatInt(activeCam);
      jkStringOutput(-1, -1);
   }

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

   cam = shuttle;
   SetCameraZoom(0, 1, 150.0);
   zoom = 1.0;
   oldlookvec = GetThingLVecPYR(cam);
   allowChangeCam = 0;
   SetTimerEx(minChangeRate, 12, 12, 12);
   Return;

stop_cam:
	StopThing(shuttle);
	DetachThing(player);
   SetTimerEx(0.0000001, 12345, 12345, 12345);
	StopThing(player);
   SetCameraFocus(0, player);
   SetCameraZoom(0, 1, 150.0);
   SetCurrentCamera(old_camera);

   SetPulse(0);
   on = 0;
   canpointnow = 0;
   canzoomnow = 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 


Tell me if you see any errors, Oh and I think I just fixed the sync thing but I can't check it right now.
The cog is designed to work like this:
,,,,,/--------|
,,,,/,,*,,,,,,,,| * is a ghost
,,,/,,,_,,,,,,,,| _
,,/__||_____| || is the console
the commas are only there for spacing.
the rest of it is an empty ship.

[edit/]stupid spacing[/edit]

[http://www.massassi.net/ec/images/9418.jpg]

[edit/]Here's a pic I quickly made in paint[/edit]


[This message has been edited by SG-fan (edited January 20, 2003).]

[This message has been edited by SG-fan (edited February 10, 2003).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-01-22, 2:48 AM #5
anyone???
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-01-25, 4:47 PM #6
Bumpidy, bump, bump bump.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-01-26, 6:30 AM #7
This is MotS, then?
2003-01-26, 8:16 AM #8
yes it is for mots, I would have rather put it in JK, but due to the wonderful playeraction it was easier to put in mots.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-01-26, 10:28 AM #9
so you're just trying to make it so it seems like the player is in a zero g situation?
2003-01-26, 10:34 AM #10
No, what it does is it attaches the player to a shuttle 3do and lets him fly the ship around.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-01-27, 3:58 AM #11
Oh, dang.
2003-01-28, 5:30 PM #12
You might try attaching the shuttle to the player instead, then the player flies himself around.

------------------
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
2003-01-29, 1:23 PM #13
hi i am a bit of a newbie, i dont quite know what to do with this cog. how do i use it in my level

------------------
I am pjb.
[fttp://www.members.aol.com/pokejoyboy/sig.gif]
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-02-07, 3:03 AM #14
please explain it to me. PLEASE!
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-02-07, 8:49 AM #15
I hope your ship is more than just a cube with a sloped front.
2003-02-07, 7:09 PM #16
Wow I thought this thread had died. Oh well. What you do to use it is insert a shuttle, a console, and a ghost and set them to how they are in the picture. (the shuttle will be different of course) Then set the console variable as the console, the shuttle as the shuttle, messagebase as -1, max_foward as around (0/7/0), max_backward as around (0/-7/0).

Then test the level and activate the console.

Oh and the foward/backward keys make you look up and down, while the crouch/fire keys control foward and backward motion. Oh and ignore the "retreat" and "foward march" quotes. They were being used in the early developement as checks and I never took them out.

Finally, to leave the shuttle just press the activate key.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-02-12, 10:13 AM #17
cool thanxs.
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-02-12, 11:17 AM #18
no problem [http://forums.massassi.net/html/smile.gif] Just make sure to give me some credit. [http://forums.massassi.net/html/wink.gif]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

↑ Up to the top!