- Quick Links -


Jedi Knight modifying site

Visitor No.72282
Since July 1999

Theme :

Massassi Temple MILLENNIUM
LucasArts Entertainment Company

- Random Picture -

Enhancement Pack 1.0

Enhancement Pack 1.0

Forum Projects Documents Features Extra Links
Techniques on Multiple Firing in client cogs

DOWNLOAD


1

Maybe you don't understand what this tutorial is about. But let me explain, this might be necessary to use if your mod is going to be used in multiplayer games.

For example, you made a laser pointer. And you want this to be used in multiplayer games, and you read this. But there's something that you can't really get.

It lags so bad! Because you try to send SendTrigger() in pulse message, which is just plain too heavy for phone lines. So rather I suggest you to pulse in local cog after a trigger and stop the pulse after another trigger.

So in this laser pointer case, it means, you place SendTrigger in selected message and create a new local cog and do pulse in that cog. So you don't have to send 50 triggers per second. And place trigger in the deselected to stop the pulse.

Maybe that was the whole solution to it. But there is another problem and the whole concept of this tutorial.


2

Ok. You got laser pointer working in multiplayer playing alone. Get your friend playing with you and both of you activate laser pointer. Yours/His pointer is gone!

Because it only handles 1 player as the "player", the value is being overridden by the player who activated later. For any other projectiles, it's fine, because it just fires instantly and that's it. Anyone can use the "player" value in that trigger at any other time, but this case you have to keep firing and you don't want your own "player" value to be interfered while shooting. Now let's get this solved.

Let's think of the rough concept here. How on earth do you have multiple pulse in a cog??? Maybe I need to create more cogs? Well, no. That's too tough. You only need to put players in different variables and get all of the players to fire the laser pointer at the same time. Sounds complicated? Well, let's begin.


3

Now, create a new cog and flag it local(0x240), place trigger message and define this cog in items.dat, so JK will use it, and let's just keep that cog there for a sec. In this tutorial I'm going to use the cogs done in the laser pointer tutorial, so if you already don't have one, get one here.

Replace SetPulse(0.01); with SendTrigger(-1, 0, 0, 0, 0);
Replace SetPulse(0); (2 of them) with SendTrigger(-1, 0, 1, 0, 0, 0);

Cut all the pulse section and necessary symbols. Paste them in the new client cog.


4

Now in the new cog, add the trigger message and paste the following. Now we put players into different "shooter"s. From shooter1, shooter2 ...etc. And we'll get him out of the variable once he stops shooting the laser.

In the stopping procedure, I'll take the player out of the variable as well as put all the players into the right order again, so it won't be shooter1, shooter3, shooter6 firing, that will mess up the pulse message, so every time player is taken away, I'll replace the spot with the shooter 1 behind him and all the behinds gets 1 up.

If that explanation is too messed up, here's an example. Currently 4 people using laser pointer. shooter1 to shooter4. shooter2 has stopped shooting. I'll put shooter3 and shooter4 into shooter2 and shooter3, get shooter4 as a null variable. So it's always shooter from 1 are available.

   trigger:

   if(GetSourceRef() == 0)      //If ID sent is 0 in the second parameter)
   {
      if(!GetParam(0))      //if paramter0(3rd parameter) is false(0) it should be SetPulse(0.01);
      {
         NumShooters = NumShooters + 1;      //We have 1 more number of shooters.
         shooter0[NumShooters] = Sender;      //Now put him in the shooterX. Starting from shooter1.
         SetPulse(0.01);      //starts the laser
      }
      else      //else if it's true(1), SetPulse(0); and take the player out of the variable
      {
         for(i=1; i<=NumShooters; i=i+1)      //Find which variable the player who stopped shooting was.
         {
            if(shooter0[i] == Sender)      //If found(which has to get found) "i" is the ID
            {
               //If the shooter"i" is not the last of the shooters, get everyone behind to advance ID by 1
               if(i != NumShooters) for(m=i+1; m<=NumShooters; m=m+1) shooter0[m-1] = shooter0[m];

               shooter0[NumShooters] = -1;      //The last shooter will be null, as he should've got advanced.
               i = NumShooters + 1;      // Now get out of the top "for" loop. No more checking needed.
            }
         }
      }

      NumShooters = NumShooters - 1;      //Now we have 1 less shooter altogether.

      if(NumShooters == 0) SetPulse(0);      //If no one is shooting, stop the pulse, but otherwise, keep the pulse all the time
   }

   return;

Now you have done the trigger part correctly. Next onto the pulse code. This seemed tough, but it can always be useful in these situations =)

The pulse section is quite easier compared to the last section. See and paste the following.

   pulse:

   //from shooter1 to shooter"NumShooters", which is the last guy.
   //Use "z" not to be confused by cog with "m" and "i" in above "for" message.
   for(z=1; z<=NumShooters; z=z+1)
   {
      FireProjectile(shooter0[z], pointer, -1, -1, '0.029 -0.006 0.003', '0 0 0', 1, 0, 0, 0);      //Fire
   }

   return;

Well, that was simple =) All for coding! Yay.


5

Add the symbols sections.

Now get your laser pointer files (laser 3do, static.jkl) and test this method! or apply to your own mod today!


Resources

else_client.cog

items.dat


Forum Projects Documents Features Extra Links

Top - Home - Back

PHP Apache Valid XHTML 1.0! Valid CSS!

This site is developed using PHP under Apache server
with XHTML, JavaScript, CSS and Cookie technology.

Certain parts of this site require Cookie support.

This site is best viewed with Internet Explorer 5.5, Netscape 6.0, Opera 6.0 or Mozilla 1.0 and above
at resolution 800 * 600 and higher.

Nothing on this site is made, distributed, or supported by LEC.
Please use and download all materials at your own risk.

© 1999-2004 Hideki.

This page was last modified on Sat, 30 Jul 2011 17:28:41 +0000.