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 → A very complex cog (my latest pet project) that needs very complex help
12
A very complex cog (my latest pet project) that needs very complex help
2002-07-20, 11:09 AM #1
Ahem: (partially based off of Force Farsight, and partially off of my own deluded mind) This is a 'MotS RTS' cog.

Code:
# Rites of Xanthus TC Cog Script
# Mysteries of the Sith
#
# ARMY0.COG
# 7.20.02
# -by Lord_Grismath (GrismathDynasty@hotmail.com)
#
#  The first test of my RTS system for MotS.

symbols

thing       player                           local
thing       telething

int         done=0                           local
int         active=0                         local
int         old_camera                       local
int         camera=-1                        local

flex        tempFlex                         local

vector      tempvec                          local
vector      tempvec2                         local
vector      motionVector                     local

flex        startHealth=0                    local
vector      startPosition                    local

sound       seeingSound=ForceSee01.WAV       local
sound       seeingSound2=FarSight1.wav       local
template    camera_tpl=+FarSight             local

int         farsightEffectHandle=-1          local

int         channel=-1                       local
int         bouncing=0                       local

int         multiCap=0                       local
int         oldFlags                         local

thing		com0
thing		com1
thing		com2
thing		com3

thing		tempghost	local
template	gtemp=ghost

int		X=0		local

model		tmodel		local
flex		thealth=0	local
int		bah=0		local	//if you're possessing someone
int		comnum		local	//no. of the commander

message     startup
message     shutdown
message     activated
message     timer
message     pulse
message     killed
message     selected
message     playeraction
message     user0
message     touched

end

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

code

startup:
player=GetLocalPlayerThing();
Teleportthing(player, telething);
print("started");
//call activated;
//return;

//activated:
//No underwater usage
// if(GetSectorFlags(GetThingSector(player)) & 2) Return;

 PlaySoundThing(seeingSound, player, 1.0, -1, -1, 0x80);

 motionVector = '0 0 0';
 camera = FireProjectile(player, camera_tpl, -1, 24, '0 0.06 0.02', GetThingLVec(player), 1.0, 0, 0, 0)
 old_camera = GetCurrentCamera();
 SetCurrentCamera(0);
 SetCameraFocus(0, camera);
 //farsightEffectHandle = newColorEffect(0, 0, 0,  0, 0, 0,  64, 64, 0,  1.0); Do I want colours?

 StopThing(player);
 SetActionCog(GetSelfCog(), 0x7FFFFFFF);

 active = 1;
 SetInvActivated(player, 35, 1);

 startHealth = GetThingHealth(player);
 startPosition = GetThingPos(player);

SetPulse(0.5);
SetBinWait(player, 35, 1.0);

bouncing = 1;
SetTimerEx(1, 3, 0, 0);
   Return;

playeraction:

   if(GetSectorFlags(GetThingSector(player)) & 2)
   {
      call stop_power;
      ReturnEx(0.0);
      Return;
   }

   if(!active)
   {
      ReturnEx(0.0);
      Return;
   }


   if (GetParam(0) == 0.0)             // Jump
   {
      tempFlex = 0.0;

         // Only allow motion at one speed.
      if (GetParam(2) != 0.0)
         tempFlex = 2.8;

      motionVector = VectorSet(VectorX(motionVector), tempFlex, VectorZ(motionVector));
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 1.0)             // Crouch
   {
      tempFlex = 0.0;

         // Only allow motion at one speed.
      if (GetParam(2) != 0.0)
         tempFlex = 2.8;

      motionVector = VectorSet(VectorX(motionVector), -tempFlex, VectorZ(motionVector));
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 2.0)             // Activated
   {
//    print("Activation!");
      call stop_power;
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 3.0)             // Fire
   {
         ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 4.0)             // Strafe
   {
      motionVector = VectorSet(GetParam(2), VectorY(motionVector), VectorZ(motionVector));

      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 5.0)             // Turn
   {
      tempvec = GetThingRotVel(camera);
      tempvec = VectorSet(VectorX(tempvec), GetParam(2), VectorZ(tempvec));
      SetThingRotVel(camera, tempvec);

      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 6.0)             // Fwd / Bkwd Motion
   {
      motionVector = VectorSet(VectorX(motionVector), VectorY(motionVector), GetParam(2));

      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 8.0)             // Pitch
   {
      tempvec = GetThingLVecPYR(camera);

      tempFlex = VectorX(tempvec)+(GetParam(1) / 100.0);

      // Limit the pitch vector (flipping over doesn't work right...)
      if (tempFlex < -80.0)
         tempFlex = -80.0;
      else
      if (tempFlex > 80.0)
         tempflex = 80.0;

      tempvec = VectorSet(tempFlex, VectorY(tempvec), VectorZ(tempvec));
      SetThingLookPYR(camera, tempvec);

      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 10.0)         // Select Inventory Item
   {
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 11.0)         // Select Skill
   {
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 12.0)         // Use Inventory Item
   {
   }
   else
   if (GetParam(0) == 13.0)         // Use Skill
   {

      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 14.0)         // Other Actions
   {
      if (GetParam(2) == 0.0)    // Cycle Camera
      {
 	print("3rd person only...wraa");
         }
      }

      ReturnEx(1.0);
   }
   else
   {
      ReturnEx(0.0);
   }

   // Add up the various velocities.
   tempvec  = GetThingLVec(camera);
   tempvec  = VectorScale(tempvec, VectorZ(motionVector) / 3.0);
   tempvec2 = GetThingUVec(camera);
   tempvec2 = VectorScale(tempvec2, VectorY(motionVector) / 3.0);
   tempvec  = VectorAdd(tempvec, tempvec2);
   tempvec2 = GetThingRVec(camera);
   tempvec2 = VectorScale(tempvec2, VectorX(motionVector) / 3.0);
   tempvec  = VectorAdd(tempvec, tempvec2);

   SetThingVel(camera, tempvec);


   Return;

timer:

   if (GetSenderId() == 1)
   {
      // Turn off control capture.
      SetActionCog(-1, 0);
      SetInvActivated(player, 35, 0);
   }
   else
   if(GetSenderId() == 2)                    // Deactivate power.
   {
      call stop_power;
   }
   else
   if (GetSenderId() == 3)
   {
      bouncing = 0;
   }
   else
   if (GetSenderId() == 4)
   {
      multiCap = 0;
   }
   else
   if (GetSenderId() == 5)
   {
      SetPhysicsFlags(camera, 0x4000000);
   }

   Return;

pulse:
   // if the player dies, return to the camera
   if(GetThingHealth(player) < 1)
   {
      setThingHealth(player, 100);
      teleportThing(player, telething);
      call activated;
	bah=0;
      Return;

   }

   // and that he didn't take health damage PFFFFT WEAKLING! LET HIM BLEED.
   if(GetThingHealth(player) < startHealth)
   {
      //call stop_power;
      Return;
   }

   // If he changed position (blown by explosion, pushed, ...) stop the power BOOM!
   if(!VectorEqual(startPosition, GetThingPos(player)))
   {
      //call stop_power;
      Return;
   }
   Return;

selected:
	Sleep(0.25); //err..
   Return;

killed:
   if(GetSenderRef() != player) Return;  // all others are expendable!

stop_power:
   if(active)
   {
      SetCameraFocus(0, player);
      SetCurrentCamera(old_camera);
      DestroyThing(camera);

if(bah==1) {
tempghost=CreateThing(gtemp, player);
tmodel=GetThingModel(player);
thealth=GetThingHealth(player0);
com0[comnum]=CreateThing(tmodel, tempghost);
SetThingHealth(com0[comnum], thealth);
TeleportThing(player, Telething);
}

   }

   SetPulse(0);

   if(channel != -1)
   {
      StopSound(channel, 0.1);
      channel = -1;
   }

   KillTimerEx(2);

   active = 0;
   bouncing = 0;
   multiCap = 0;

   SetTimerEx(0.5, 1, 0, 0);

   Return;

touched:
for(X=0; X<4; X=X+1) {
if(GetSenderRef()==com0[X]) {
if(GetThingHealth(com0[X])>0) {
tempghost=CreateThing(gtemp, com0[X]);
tmodel=GetThingModel(com0[X]);
thealth=GetThingHealth(com0[X]);
SetThingModel(player, tmodel);
SetThingHealth(player, com0[X]);
TeleportThing(player, tempghost);
DestroyThing(tempghost);
bah=1;
comnum=X;
call stop_power;
}}}

return;

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

end


It doesn't even start, and yes, I did throw it in the level.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-20, 12:00 PM #2
Few things to clean out and a few things to try. To change/remove.
  1. Get rid of all unused symbols ex. message activated.
  2. Get rid of those comments in the middle of the startip message
  3. FireProjectile() change 24 to -1 unless you want the player to do the force power move thingy...
  4. Remove/change the bin stuff, unless you want to mess with the force farsight bin...
  5. If your not going to put anything in the Use Inventory part of PlayerAction: remove it!
  6. After Print("3rd person only...wraa"); remove the }, one too many/too little, or change it to ReturnEx(0.0); if needed...
  7. Remove anything else you don't need and I don't want to say[/list=a] To add.
    1. Add this right after startup:, Sleep(.25); hey it helped my people.cog...[/list=a] Now try it, it should work better. [http://forums.massassi.net/html/wink.gif]

      ------------------
      The Sniper Missions. Current project, The Sniper Missions

      The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-20, 2:31 PM #3
Just above the symbols put
"flags=0x240"

Then it will run.
Team Battle.
2002-07-20, 3:54 PM #4
Well, I've begun fixing the cog, and it still refuses to work. Ahem: the new symbol/start section:

Code:
# Rites of Xanthus TC Cog Script
# Mysteries of the Sith
#
# ARMY0.COG
# 7.20.02
# -by Lord_Grismath (GrismathDynasty@hotmail.com)
#
#  The first test of my RTS system for MotS.

flags=0x240

symbols

thing       player                           local
thing       telething

int         done=0                           local
int         active=0                         local
int         old_camera                       local
int         camera=-1                        local

flex        tempFlex                         local

vector      tempvec                          local
vector      tempvec2                         local
vector      motionVector                     local

flex        startHealth=0                    local
vector      startPosition                    local

sound       seeingSound=ForceSee01.WAV       local
sound       seeingSound2=FarSight1.wav       local
template    camera_tpl=+FarSight             local

int         farsightEffectHandle=-1          local

int         channel=-1                       local
int         bouncing=0                       local

int         multiCap=0                       local
int         oldFlags                         local

thing		com0
thing		com1
thing		com2
thing		com3

thing		tempghost	local
template	gtemp=ghost

int		X=0		local

model		tmodel		local
flex		thealth=0	local
int		bah=0		local	//if you're possessing someone
int		comnum		local	//no. of the commander

message     startup
message     shutdown
message     activated
message     timer
message     pulse
message     killed
message     selected
message     playeraction
message     user0
message     touched

end

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

code

startup:
Sleep(0.25);
player=GetLocalPlayerThing();
Teleportthing(player, telething);
print("started");


I'll probably end up redoing it from scratch. :P
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-20, 4:48 PM #5
On your original cog I noticed you wrote this:

camera = FireProjectile(player, camera_tpl, -1, 24, '0 0.06 0.02', GetThingLVec(player), 1.0, 0, 0, 0)

It should be

camera = FireProjectile(player, camera_tpl, -1, 24, '0 0.06 0.02', GetThingLVec(player), 1.0, 0, 0, 0);

Dunno, good luck!
Team Battle.
2002-07-21, 12:53 AM #6
... uhhh... those are the exact same commands.

Do you mean 'camera = FireProjectile(player, camera_tpl, -1, 24, '0 0.06 0.02', GetThingLVec(player), 1.0, 0, 0, 0);' ?

And I'm definately re-writing this later today. :P
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-21, 4:58 AM #7
No, you forgot the semicolon ( ; ). I didn't bother to see the whole thing, you can remove the flags=0x240, this is not a C/S cog.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-21, 5:42 AM #8
I just looked through the cog, and I notice a lot of things wrong with it. It doesn't even look like you checked it for errors because they're so blatant.

The way to write cogs is to start with something simple and make sure it works before you add more to it. Don't write a 300-line cog and then post it on the forum when it doesn't work right away. You're dealing with basic syntax errors, not anything too complicated.

Review your code carefully, check it with CogWriter, and then post it again if it still won't work. Good luck. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-21, 12:59 PM #9
Code:
# -by Lord_Grismath (GrismathDynasty@hotmail.com)

flags=0x240;

symbols

message	startup
message	pulse
message	killed
message	touched
message	playeraction

thing		com0
thing		com1
thing		com2
thing		com3
thing		telething			local
thing		tghost				local

vector		tempvec			local
vector		tempvec2			local
vector		motionVector			local

model		tmodel				local

template	ghtemp=ghost			local
template	camera_tpl=+FarSight		local

int		player				local
int		X=0				local
int		poss=0				local
int		comnum=-1			local
int		camera=-1			local
int		act0				local
int		act1				local
int		act2				local
int		act3				local

flex		thealth=0			local

end

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

code

startup:
Sleep(0.25);
Print("Generalship Cog Implemented");
call goto_camera;
return;

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

pulse:
if(GetThingHealth(player) < 1) {
 SetThingHealth(player, 100);
 call stop_camera;
 poss=0;
 return;
}
return;

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

goto_camera:

Print("Camera Activating...");

 motionVector = '0 0 0';
 camera = FireProjectile(player, camera_tpl, -1, -1, '0 0.06 0.02', GetThingLVec(player), 1.0, 0, 0, 0)
 SetCurrentCamera(0);
 SetCameraFocus(0, camera);
TeleportThing(player, telething);
StopThing(player);
 SetActionCog(GetSelfCog(), 0x7FFFFFFF);
 poss = 0;

Print("Camera Activated");

return;

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

killed:
   if(GetSenderRef() != player) Return;

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

stop_camera:
if(poss==1) {
 tghost=CreateThing(ghtemp, player);
 tmodel=GetThingModel(player);
 thealth=GetThingHealth(player);
 TeleportThing(player, telething);
 com0[comnum]=CreateThing(tmodel, tghost);
 SetThingHealth(com0[comnum], thealth);
 SetPulse(0);
}
return;

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

touched:

for(X=0; X<4; X=X+1) {
if(GetSenderRef()==com0[X]) {
if(GetThingHealth(com0[X])>0) {
 tghost=CreateThing(gtemp, com0[X]);
 tmodel=GetThingModel(com0[X]);
 thealth=GetThingHealth(com0[X]);
 SetThingModel(player, tmodel);
 SetThingHealth(player, thealth);
 TeleportThing(player, tghost);
 DestroyThing(tempghost);
 poss = 1;
 comnum = X;
 SetPulse(0.5);
}}}
return;

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

end


Totally re-written from scratch. And not to tset it. I just hope it works... (it probably won't [http://forums.massassi.net/html/tongue.gif])
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-21, 3:41 PM #10
Ahem. We'll start big and go to small mistakes. (HUGE ONE!) You need a PlayerAction. It won't work unless you have a PlayerAction. (BIG One) Semi-colon after the FireProjectile. FireProjectile(blah blah blah)[;] <<< there, in the []. No [] though. (Medium One) Remove the flags=0x240 line above the symbols, this is not a Client/Server Cog (C/S)!(small one) There seems to be no point in having the Killed message, unless you're going to do something with in after 'modifing' the cog, remove it! Other then that, everything else seems to be fine, except one thing. I'm not sure if it should be GetSenderRef() or GetSourceRef() in the touched message. *Moves the mike infront of SaberMaster* Any thoughts on this?

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-21, 4:40 PM #11
hmm, could've sworn my cogs dont run unless they have that flag if they are level cogs and not defined in items.dat [http://forums.massassi.net/html/confused.gif]
Team Battle.
2002-07-21, 4:44 PM #12
And besides I doubt you need the 0x240 flag in a client server cog, because it just has triggers in it. I am not using it for the Team Battle coding (Yes, I try to code for TB, dont ask [http://forums.massassi.net/html/rolleyes.gif] ) for triggers and c/s cogs. Seems to work fine [http://forums.massassi.net/html/confused.gif]
Team Battle.
2002-07-21, 5:37 PM #13
I don't like excess stuff like that. But you do use that flag for C/S cogs (client side).

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-21, 6:13 PM #14
*grabs mike*


If you use the flag statement, REMOVE THE SEMICOLON.

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-07-22, 12:26 AM #15
Aaaaah conflicting orders!

Quote:
<font face="Verdana, Arial" size="2">No, you forgot the semicolon ( ; )...</font>


Oh wait, that was for FireProjectile, wasn't it?

[http://forums.massassi.net/html/tongue.gif] Time to go a'fixing, I suppose.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-22, 11:37 AM #16
And while your at it:
  • gtemp & tempghost were undefined.
  • telething & gtemp & tempghost were never given values.
  • tempvec & tempvec2 were not used.
  • motionVector was assigned, but never used.
  • player was never assigned and is defined as an int.
  • act0 array was not used.
  • message playeraction was never used.
  • the created com objects are never captured.


That's not listing the syntax errors. Use a syntax checker. It would help if you explained what exactly you're trying to do. As it is, the list above shows only logical inconsistencies.

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-22, 2:50 PM #17
Player can be defined as an Int, it doesnt matter. Ive done it before, and since he is never created/destroyed, and is quite often object 0, it really doesnt matter at all.


Unless you know something I dont... [http://forums.massassi.net/html/wink.gif]

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-07-23, 12:36 AM #18
Some improvement, I hope?

Code:
# -by Lord_Grismath (GrismathDynasty@hotmail.com)

flags=0x240

symbols

message	startup
message	pulse
message	killed
message	touched
message	playeraction

thing		com0
thing		com1
thing		com2
thing		com3
thing		telething			local
thing		tghost				local

vector		tempvec			local
vector		tempvec2			local
vector		motionVector			local

model		tmodel				local

template	ghtemp=ghost			local
template	camera_tpl=+FarSight		local

int		player				local
int		X=0				local
int		poss=0				local
int		comnum=-1			local
int		camera=-1			local
int		act0				local
int		act1				local
int		act2				local
int		act3				local

flex		thealth=0			local

end

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

code

startup:
Sleep(0.25);
player=GetLocalPlayerThing();
Print("Generalship Cog Implemented");
call goto_camera;
return;

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

pulse:
if(GetThingHealth(player) < 1) {
 SetThingHealth(player, 100);
 call stop_camera;
 poss=0;
 return;
}
return;

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

playeraction:
if(poss) {
 ReturnEx(0.0);
 Return;
}
if (GetParam(0) == 0.0) {
//Jumping
 tempFlex = 0.0;
// Only allow motion at one speed. i.e. disable running
 if (GetParam(2) != 0.0)
 tempFlex = 2.8;
 motionVector = VectorSet(VectorX(motionVector), tempFlex, VectorZ(motionVector));
 ReturnEx(0.0);
} else
 if (GetParam(0) == 1.0) {
// Crouching
  tempFlex = 0.0;
  if (GetParam(2) != 0.0)
   tempFlex = 2.8;
  motionVector = VectorSet(VectorX(motionVector), -tempFlex, VectorZ(motionVector));
  ReturnEx(0.0);
} else
//  if (GetParam(0) == 2.0) {
// Activation will be allowed, since you're possessing a character.
//    call stop_power;
//    ReturnEx(0.0);
//} else
//  if (GetParam(0) == 3.0) {
// Firing is also allowed
//   ReturnEx(0.0);
//   } else
   if (GetParam(0) == 4.0)             // Strafe
   {
      motionVector = VectorSet(GetParam(2), VectorY(motionVector), VectorZ(motionVector));
      ReturnEx(0.0);
   } else
   if (GetParam(0) == 5.0)             // Turn
   {
      tempvec = GetThingRotVel(camera);
      tempvec = VectorSet(VectorX(tempvec), GetParam(2), VectorZ(tempvec));
      SetThingRotVel(camera, tempvec);
      ReturnEx(0.0);
   } else
   if (GetParam(0) == 6.0)             // Fwd / Bkwd Motion
   {
      motionVector = VectorSet(VectorX(motionVector), VectorY(motionVector), GetParam(2));
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 8.0)             // Pitch
   {
      tempvec = GetThingLVecPYR(camera);
      tempFlex = VectorX(tempvec)+(GetParam(1) / 100.0);

      // Limit the pitch vector (flipping over doesn't work right...)
      if (tempFlex < -80.0)
         tempFlex = -80.0;
      else
      if (tempFlex > 80.0)
         tempflex = 80.0;

      tempvec = VectorSet(tempFlex, VectorY(tempvec), VectorZ(tempvec));
      SetThingLookPYR(camera, tempvec);

      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 10.0)         // Select Inventory Item
   {
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 11.0)         // Select Skill
   {
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 12.0)         // Use Inventory Item
   {
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 13.0)         // Use Skill
   {
      ReturnEx(0.0);
   }
   else
   if (GetParam(0) == 14.0)         // Other Actions
   {
      if (GetParam(2) == 0.0)    // Cycle Camera
      {
 	print("3rd person only...wraa");
       ReturnEx(0.0);
      }

      ReturnEx(1.0);
   }
   else
   {
      ReturnEx(0.0);
   }

// Add up the various velocities.
 tempvec  = GetThingLVec(camera);
 tempvec  = VectorScale(tempvec, VectorZ(motionVector) / 3.0);
 tempvec2 = GetThingUVec(camera);
 tempvec2 = VectorScale(tempvec2, VectorY(motionVector) / 3.0);
 tempvec  = VectorAdd(tempvec, tempvec2);
 tempvec2 = GetThingRVec(camera);
 tempvec2 = VectorScale(tempvec2, VectorX(motionVector) / 3.0);
 tempvec  = VectorAdd(tempvec, tempvec2);

 SetThingVel(camera, tempvec);

return;

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

goto_camera:

Print("Camera Activating...");

 motionVector = '0 0 0';
 camera = FireProjectile(player, camera_tpl, -1, -1, '0 0.06 0.02', GetThingLVec(player), 1.0, 0, 0, 0);
 SetCurrentCamera(0);
 SetCameraFocus(0, camera);
TeleportThing(player, telething);
StopThing(player);
 SetActionCog(GetSelfCog(), 0x7FFFFFFF);
 poss = 0;

Print("Camera Activated");

return;

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

killed:
   if(GetSenderRef() != player) Return;

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

stop_camera:
if(poss==1) {
 tghost=CreateThing(ghtemp, player);
 tmodel=GetThingModel(player);
 thealth=GetThingHealth(player);
 TeleportThing(player, telething);
 com0[comnum]=CreateThing(tmodel, tghost);
 SetThingHealth(com0[comnum], thealth);
 SetPulse(0);
}
return;

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

touched:

for(X=0; X<4; X=X+1) {
if(GetSenderRef()==com0[X]) {
if(GetThingHealth(com0[X])>0) {
 tghost=CreateThing(gtemp, com0[X]);
 tmodel=GetThingModel(com0[X]);
 thealth=GetThingHealth(com0[X]);
 SetThingModel(player, tmodel);
 SetThingHealth(player, thealth);
 TeleportThing(player, tghost);
 DestroyThing(tempghost);
 poss = 1;
 comnum = X;
 SetPulse(0.5);
}}}
return;

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

end
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-23, 6:12 AM #19
Code:
else	//  if (GetParam(0) == 2.0) {
// Activation will be allowed, since you're possessing a character.
//    call stop_power;
//    ReturnEx(0.0);
//} else
//  if (GetParam(0) == 3.0) {
// Firing is also allowed
//   ReturnEx(0.0);
//   } else if(GetParam(0) == 4.0)	// Strafe
{
	motionVector = VectorSet(GetParam(2), VectorY(motionVector), VectorZ(motionVector));
	ReturnEx(0.0);
}
else if(GetParam(0) == 5.0)	// Turn


You commented out the condition after the else. Since there's no condition to be false, any else after it is useless.

Now, explain carefully what you're trying to do with this cog. Otherwise, I can't help you.

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-23, 6:17 AM #20
GBK, you can define player as anything you want or not define it all. But even so, it's bad programming to do that. There's no way to know that there's not a difference between things and integers because JK can change a variable's type.

Not assigning player is a bad error because the cog would not work correctly in a level where the player was not 0. This bug would be hard to catch if you weren't looking for it.

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.

[This message has been edited by SaberMaster (edited July 23, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-23, 9:37 AM #21
Well, you could always use jkGetLocalPlayer (I believe).

This cog is meant to be much like an RTS-system for MotS. You start out as the +FarSight camera, and as soon as it's fired, the actual player is teleported to 'tele'. You can then maneuver around as the camera. When you touch one of four (I think it's four) 'commanders', you 'possess' said character, and your player spawns there with that commander's model, etc., replacing the commander.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-23, 12:09 PM #22
Alright, that makes a lot more sense. I read through the cog and fixed several mistakes. A notable one being that you tried to recreate a commander by using the model of the player.

Still, I am unfamiliar with the workings of playeraction and I don't have MotS where I am. [http://forums.massassi.net/html/frown.gif] How much of that playeraction code is copied from force farsight? If you're using LEC's movement system, then you should have no problem.

Code:
# armyo.cog
#
# Lord_Grismath (GrismathDynasty@hotmail.com)
#==============================================================#
flags=0x240
#==============================================================#
symbols

message   startup
message   pulse
message   killed
message   touched
message   playeraction

thing     com0
thing     com1
thing     com2
thing     com3
thing     telething
thing     tghost                 local

vector    tempvec                local
vector    tempvec2               local
vector    motionVector           local

model     tmodel                 local

template  ghtemp=ghost           local
template  camera_tpl=+FarSight   local
template  comTemp0
template  comTemp1
template  comTemp2
template  comTemp3

int       player                 local
int       X=0                    local
int       poss=0                 local
int       comnum=-1              local
int       camera=-1              local

flex      thealth=0              local
flex      tempflex               local

end
#==============================================================#
code
#------------------------------------------------------
startup:
	Sleep(1);
	player = GetLocalPlayerThing();
	Print("Generalship Cog Implemented");
	call goto_camera;

Return;
#------------------------------------------------------
pulse:
	if(GetThingHealth(player) < 1)
	{
		SetThingHealth(player, 100);
		call stop_camera;
		poss = 0;
		Return;
	}

Return;
#------------------------------------------------------
playeraction:
	if(poss)
	{
		ReturnEx(0);
		Return;
	}
	if(GetParam(0) == 0)	//Jumping
	{
		tempflex = 0;
		// Only allow motion at one speed. i.e. disable running
		if(GetParam(2) != 0) tempflex = 2.8;
		motionVector = VectorSet(VectorX(motionVector), tempflex, VectorZ(motionVector));
		ReturnEx(0);
	}
	else if(GetParam(0) == 1)	// Crouching
	{
		tempflex = 0;
		if(GetParam(2) != 0) tempflex = 2.8;
		motionVector = VectorSet(VectorX(motionVector), -tempflex, VectorZ(motionVector));
		ReturnEx(0);
	}
	else if(GetParam(0) == 2)
	{
		// Activation will be allowed, since you're possessing a character.
		// call stop_power;
		// ReturnEx(0);
	}
	else if(GetParam(0) == 3)
	{
		// Firing is also allowed
		// ReturnEx(0);
	}
	else if(GetParam(0) == 4)	// Strafe
	{
		motionVector = VectorSet(GetParam(2), VectorY(motionVector), VectorZ(motionVector));
		ReturnEx(0);
	}
	else if(GetParam(0) == 5)	// Turn
	{
		tempvec = GetThingRotVel(camera);
		tempvec = VectorSet(VectorX(tempvec), GetParam(2), VectorZ(tempvec));
		SetThingRotVel(camera, tempvec);
		ReturnEx(0);
	}
	else if(GetParam(0) == 6)	// Fwd / Bkwd Motion
	{
		motionVector = VectorSet(VectorX(motionVector), VectorY(motionVector), GetParam(2));
		ReturnEx(0);
	}
	else if(GetParam(0) == 8)	// Pitch
	{
		tempvec = GetThingLVecPYR(camera);
		tempflex = VectorX(tempvec) + GetParam(1) / 100;
		// Limit the pitch vector (flipping over doesn't work right...)
		if(tempflex < -80) tempflex = -80;
		else if(tempflex > 80) tempflex = 80;
		tempvec = VectorSet(tempflex, VectorY(tempvec), VectorZ(tempvec));
		SetThingLookPYR(camera, tempvec);
		ReturnEx(0);
	}
	else if(GetParam(0) == 10)	// Select Inventory Item
	{
		ReturnEx(0);
	}
	else if(GetParam(0) == 11)	// Select Skill
	{
		ReturnEx(0);
	}
	else if(GetParam(0) == 12)	// Use Inventory Item
	{
		ReturnEx(0);
	}
	else if(GetParam(0) == 13)	// Use Skill
	{
		ReturnEx(0);
	}
	else if(GetParam(0) == 14)	// Other Actions
	{
		if(GetParam(2) == 0)	// Cycle Camera
		{
			Print("3rd person only...wraa");
			ReturnEx(0);	// This ReturnEx() is useless.
		}
		ReturnEx(1);
	}
	else
	{
		ReturnEx(0);
	}
	// Add up the various velocities.
	tempvec = GetThingLVec(camera);
	tempvec = VectorScale(tempvec, VectorZ(motionVector) / 3);
	tempvec2 = GetThingUVec(camera);
	tempvec2 = VectorScale(tempvec2, VectorY(motionVector) / 3);
	tempvec = VectorAdd(tempvec, tempvec2);
	tempvec2 = GetThingRVec(camera);
	tempvec2 = VectorScale(tempvec2, VectorX(motionVector) / 3);
	tempvec = VectorAdd(tempvec, tempvec2);
	SetThingVel(camera, tempvec);

Return;
#------------------------------------------------------
goto_camera:
	Print("Camera Activating...");
	motionVector = VectorSet(0, 0, 0);
	camera = FireProjectile(player, camera_tpl, -1, -1, '0 06 02', '0 0 0', 0, 0, 0, 0);
	SetThingLook(camera, GetThingLVec(player));
	SetCurrentCamera(0);
	SetCameraFocus(0, camera);
	TeleportThing(player, telething);
	StopThing(player);
	SetActionCog(GetSelfCog(), 0x7FFFFFFF);
	poss = 0;
	Print("Camera Activated");

Return;
#------------------------------------------------------
killed:
	if(GetSenderRef() != player) Return;
	stop_camera:
	if(poss == 1)
	{
		tghost = CreateThing(ghtemp, player);
		tmodel = GetThingModel(player);
		thealth = GetThingHealth(player);
		TeleportThing(player, telething);
		com0[comnum] = CreateThing(comTemp0[comnum], tghost);
		SetThingHealth(com0[comnum], thealth);
		SetPulse(0);
	}

Return;
#------------------------------------------------------
touched:
	for(X = 0; X < 4; X = X + 1)
	{
		if(GetSenderRef() == com0[X])
		{
			if(GetThingHealth(com0[X]) > 0)
			{
				tmodel = GetThingModel(com0[X]);
				thealth = GetThingHealth(com0[X]);
				SetThingModel(player, tmodel);
				SetThingHealth(player, thealth);
				TeleportThing(player, com0[X]);
				DestroyThing(com0[X]);
				poss = 1;
				comnum = X;
				SetPulse(0.5);
			}
		}
	}

Return;
#------------------------------------------------------
end


There you go. See if that works any better. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-24, 6:00 AM #23
I suppose that this is for the nice review I gave for ParSec/Scribe, eh? [http://forums.massassi.net/html/wink.gif]

Thanks a lot, I'll give it a try.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-24, 7:33 AM #24
The camera activation and such worked like a charm, but I was unable to possess the commanders. [http://forums.massassi.net/html/tongue.gif]

I think I migh try tweaking this a bit more... the touched message might be read from the player, and not the camera. Perhaps I should capturething(camera); (if it hasn't ben done)?
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-24, 7:40 AM #25
It also seems to be very crash-prone.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-24, 11:40 AM #26
I thought that might not work. [http://forums.massassi.net/html/frown.gif] The camera, not being a player or actor, cannot
touch things.

You have to understand how the touched message works. It's not called when an
object touches something, it's called when an object is touched by a player or actor.
Since the camera is neither, it can't touch the commanders.

To fix this, you could either have a pulse to check the camera's distance from a
commander or make the camera an actor. The second solution is the more elegant, but
it's definitely more difficult.

Also, the stop_camera message should capture the newly created commander if you want to
recieve his messages.

As for being crash prone, I'm not sure what's causing it. Perhaps a little more
info on that?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited July 24, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-25, 1:27 AM #27
I suppose that I'll have to make it an actor, seeing as I wouldn't want incorrect possessions in case two commanders were in close proximity.

I'll get the +FarSight template up here shortly.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-25, 4:56 AM #28
# DESC:
# BBOX: -.005771 -.015021 -.00466 .005771 .003935 .00466
+farsight none orient=(0/0/0) type=cog collide=1 move=physics timer=25 model3d=farsight.3do size=.05 movesize=.1 airdrag=.5 mass=.05 physflags=0xa00 maxvel=.5

I am currently addressing the feasibility of making this an actor.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-25, 4:58 AM #29
Quote:
<font face="Verdana, Arial" size="2">Also, the stop_camera message should capture the newly created commander if you want to
recieve his messages.</font>


But I'm replacing the commander, and the touched message should be read by the camera, as the Sender is defined as such.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-25, 9:41 AM #30
Enimies don't react to class cogs (type=cog), but I think they react to actors (type=actor). Can anybody confirm or deny this? Anyway, thats how to change the template to an actor.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-25, 2:13 PM #31
What?

Quote:
<font face="Verdana, Arial" size="2"># DESC:
# BBOX: -.005771 -.015021 -.00466 .005771 .003935 .00466
+farsight _actor orient=(0/0/0) type=cog collide=1 move=physics timer=25 model3d=farsight.3do size=.05 movesize=.1 airdrag=.5 mass=.05 physflags=0xa00 maxvel=.5</font>


I thought that that was it.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-25, 5:18 PM #32
Quote:
<font face="Verdana, Arial" size="2">From myself. No, no, no Grismath!</font>
Like this.
Code:
# DESC: 
# BBOX: -.005771 -.015021 -.00466 .005771 .003935 .00466
+farsight none orient=(0/0/0) type=actor collide=1 move=physics timer=25 model3d=farsight.3do size=.05 movesize=.1 airdrag=.5 mass=.05 physflags=0xa00 maxvel=.5
Got it? GBK/SaberMaster, do either of you know the answer to my question above (2 birds with 1 stone and we'll just leave it at that)? Otherwise, I'll do a test on it.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-26, 12:29 AM #33
Yes, but shouldn't the parent template be actor as well?
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-26, 3:53 AM #34
No, it doesn't need to be.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-26, 4:16 AM #35
Quote:
<font face="Verdana, Arial" size="2">But I'm replacing the commander, and the touched message should be read by the camera, as the Sender is defined as such.</font>


Read by the camera? I had assumed that you needed to recieve the touched messages of the commanders as that's the way you have the cog set up. This line from the touched message:
Code:
if(GetSenderRef() == com0[X])

will block any message sent by the camera. Remember, the sender is the thing that was touched; the source is the thing that touched it. If you want the commanders to touch the camera, then they should be the sourceref - not the senderref.


Now, if you decide to have the commanders touch the camera, then you don't need to worry about making the camera an actor. But about the template, it's 'type=actor' that you need to make the thing created from that template an actor - the parent template doesn't matter.

Quote:
<font face="Verdana, Arial" size="2">Enimies don't react to class cogs (type=cog), but I think they react to actors (type=actor).</font>


Eh, not quite sure what you're getting at there. A thing of type cog is not a class cog. What do you mean by "react"? [http://forums.massassi.net/html/confused.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-26, 1:52 PM #36
They will shoot at it. Look at it, or something. That what I mean by react. (Ex. rebels in MotS) *sighs*

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-27, 12:57 AM #37
It's bad enough that all the stormtroopers look at the camera. And walk around on contact.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-27, 6:19 AM #38
Ok, Pilot, I see what you mean. [http://forums.massassi.net/html/smile.gif]

Grismath, can you use the camera to possess commanders now?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited July 27, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-27, 6:25 AM #39
I'm implementing the template as I write this.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-07-27, 6:36 AM #40
Err... when I touch a commander, I seem to lose controlof the camera, and it spins around in circles...

Here's my touched message:


Code:
#------------------------------------------------------
touched:
if(GetSenderRef() == camera) {
for(X = 0; X < 4; X = X + 1)
{
if(GetSourceRef() == com0[X])
{
if(GetThingHealth(com0[X]) > 0)
{
tmodel = GetThingModel(com0[X]);
thealth = GetThingHealth(com0[X]);
SetThingModel(player, tmodel);
SetThingHealth(player, thealth);
TeleportThing(player, com0[X]);
DestroyThing(com0[X]);
poss = 1;
comnum = X;
SetPulse(0.5);
}
}
}
}
Return;
#------------------------------------------------------
end
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
12

↑ Up to the top!