- Quick Links -


Jedi Knight modifying site

Visitor No.72282
Since July 1999

Theme :

Massassi Temple MILLENNIUM
LucasArts Entertainment Company

- Random Picture -

Lightstaff 2.0 JK

Lightstaff 2.0 JK

Forum Projects Documents Features Extra Links
Making a Zoom Scope

DOWNLOAD


1

Let's make a zoom scope shall we?

First of all, the way it works is that you create a ghost object in front of you repeatedly and constantly changing the view on the newly created camera. The old ones will be destroyed by the timer set in the template. The rate is around 40-50 cams per second.(on a faster computer that is)


2

Now, let's make a template. This is just a ghost object that has no model but it sticks to surfaces so it won't slide when hitting it. It also has to have a small size or won't go through narrow areas and stuck.

So open a new static.jkl and simply add those status to the template based on "_weapon", so it already has all the base information. Typeflags adds, so it will stick to surfaces, it doesn't need to make splash entering water, so thingflags can be 0. It doesn't move by itself, so velocity to 0 vector size must be small enough to go throw narrow areas.

   ###### Template information ####
   Section: templates
   World templates 2

   #Name:   Based On:   Params:
   _weapon   none   orient=(0/0/0) type=weapon collide=1 move=physics thingflags=0x20000000
   mass=5 physflags=0x200 maxrotvel=90 damageclass=0x2 typeflags=0x1

   +Zoom_Cam   _weapon   size=0.001 movesize=0.001 maxvel=0 vel=(0/0/0)
   timer=0.01 thingflags=0 damageclass=0 typeflags=0xd

All for the template.


3

Now let's implement this on the Bryar. Open up the weap_bryar.cog. This zoom function will zoom once held, and unzoom once let go of the button and held again. It will also cancel zooming if the player just taps the button for a quick gameplay.

Now going to implement zooming on the secondary fire mode. So add appropriate line to separate the primary and secondary fire mode. Then add this in the secondary fire mode space in the activated message.

   if(Zoom)      //If going to zoom, do this part, else don't.
   {
      //Get internal or external mode so we can retrieve it when finished zooming.
      OldFocus = GetCurrentCamera();

      //This just makes player rotate slower for keyboard users, doesn't affect mouse though.
      ParseArg(player, "maxrotvel=20 maxrotthrust=20");
      SetPulse(0.01);      //Start firing camera and changing view to it.
   }

   //If the camera wants to keep the magnification or not. When you press the button, it zooms, so stay is 0.
   Stay = 0;

   //ZoomCount just increases to calculate the zooming distance. Starting with 0.
   ZoomCount = 0;

Done for activated message.


4

This time, put the pulse section, where it controls the distance of zooming and changing the camera. Add a pulse message and paste the following.

   pulse:

   if(!Stay)      //If not keeping the current magnification, which means either zooming or unzooming...
   {
      if(Zoom)      //If zooming, do this
      {
         //Increase magnification every time the pulse is called.
         ZoomMag = ZoomMag + ZoomCount * 0.005;
         if(ZoomMag > 5) ZoomMag = 5;      //If gone too much, don't let it.
      }
      else      //else, do that
      {
         //Decrease magnification every time the pulse is called
         ZoomMag = ZoomMag - ZoomCount * 0.005;
         if(ZoomMag < 0.15) ZoomMag = 0.15;      //If too less, don't let it.
      }

      //Make the magnification to the level of player's eye and make it a vector.
      ZoomFactor = VectorSet(0, ZoomMag, 0.037);

      //Rate of magnification used above. Increase it every time pulse is called.
      ZoomCount = ZoomCount + 1;
   }

   if( (ZoomMag == 0.15) && !Zoom)      //If unzoomed enough, go back to normal view.
   {
      //Call the custom message, custom message doesn't need to be declared in the symbols like pulse.
      call stop_power;
      return;
   }

   //Fire the dummy camera at the magnification spot.
   Dummy = FireProjectile(player, CameraTpl, -1, -1, ZoomFactor, '0 0 0', 0, 0, 0, 0);

   //Set position a bit behind where it got fired, so it won't HOM.
   SetThingPos(Dummy, VectorAdd(GetThingPos(Dummy), VectorScale(VectorNorm(GetThingLVec(Dummy)), -0.1))); 

   SetCameraFocus(0, Dummy);      //Set the view to the dummy camera.

   if(GetCurrentCamera() == 1) CycleCamera();      //If player tried to switch to external view, I won't let ya.

   Return;

All for pulse.


5

Now, a few more message will make the whole zoom cog functioning. Deactivated and stop_power.

For the deactivated, you must do the same with activated and make it separate with the primary and secondary fire mode. Then paste this in the secondary fire mode space.

   //Changes if it wants to zoom or unzoom each time pressed. Set the "Zoom=1" in symbols so it starts with 1.
   Zoom = 1 - Zoom;
   Stay = 1;      //Don't change magnification.

   //If you let go of the button with less than 3 pulse counts, that means you tapped! Cancel zooming.
   if(ZoomCount <= 3) call stop_power;

stop_power can just be pasted as is.

   stop_power:

   SetPulse(0);      //No more pulse.

   //Set the least magnification for next use, otherwise going to see your own weapon mesh...
   //Set this in symbols section as 0.15.
   ZoomMag = 0.15;
   ParseArg(player, "maxrotvel=200 maxrotthrust=180");      //Make the player rotate at the normal speed.
   SetCameraFocus(0, player);      //Turn the view back to player.

   //If the player had his view mode external, and it isn't external already, switch it back for him.
   if( (OldFocus == 1) && (GetCurrentCamera() != 1) ) CycleCamera();

   return;

Small thing, but let's take "dummy = " away in the FireProjectile function in the fire message, so it won't be confused by cog with the camera.

And for the last, zooming function shouldn't be working with other weapons so add this in the deselected message.

   call stop_power;
   Zoom = 1;      //Next time, start with zooming.

All for coding and everything.


6

Sounds these codes work?

Try it out yourself!

Make sure you add all the symbols as well.


Resources

weap_bryar.cog

static.jkl


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.