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 → Zoom scope slowing down mouse
Zoom scope slowing down mouse
2003-01-03, 10:51 PM #1
For ages I have been getting annoyed at the head pitch which JK features, seems like LEC forgot to add a few verbs or something. One thing which was greatly effected was the ability to adjust the Z axis position or speed, which is very essential to the success of a zoom scope.

Anyways this afternoon I sat down and attempted to re-address the issue. This is what I came up with. Its far from perfect but with alittle more coding and stuff it will be ok. The coding behind it isnt very hard so most people will be able to understand it. (This cog is the bryar, right click to zoom in, right click again to zoom out) Sorry about some of the comments, their alittle incomplete.

http://24.46.164.108:81/jkteambattle/images/media/weap_bryar.cog

I need some help with this (btw feel free to use it how you like, if you find it useful). I need to make it so you cant zoom through walls and get the mad homs and stuff. I also need to improve movement on the z axis (Its still buggy)

Heres the bulk of the code:

[edit]The code tags suck, d/l the cog to read[/edit]

Thanks.

[This message has been edited by Hellcat (edited January 04, 2003).]
Team Battle.
2003-01-04, 3:24 AM #2
While there are loads of other very useful new verbs in MotS, the main reason I chose to edit that over JK was the zoom verbs. To me, the zoom solutions that have been presented for JK thus far have been far to buggy and clumsy. But maybe you can change my opinion.

I haven't downloaded the cog, but I'm assuming you're using an eyeoffset. Why not fire a projectile through a pulse and have that projectiles explosion, or removed message report its position to the weapon cog. Then you can calculate the distance the eyeoffset should be and prevent it from going through 3dos. This should all be done locally of course.
2003-01-04, 7:55 AM #3
I did it!

Code:
# Jedi Knight Cog Script
#
# WEAP_BRYAR.COG
#
# WEAPON 2 Script - Bryar Pistol
#
# The trusty weapon of Kyle Katarn. This is actually an older modified rifle
# that has been cut down to more of a pistol size. It is very accurate but
# somewhat of a low power weapon. This weapon has only one type of fire.
#
# - Affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

model        povModel=bryv.3do                  local                         
model        weaponMesh=bryg.3do                local                         

keyframe     mountAnim=bryvmnt.key              local                         
keyframe     dismountAnim=bryvdis.key           local                         
keyframe     povfireAnim=bryvpst1.key           local                         
keyframe     holsterAnim=kyhlstr.key            local                         

sound        outSound=pistout1.wav              local                         
sound        mountSound=df_bry_ready.wav        local                         
sound        dismountSound=PutWeaponAway01.wav  local                         
sound        fireSound=pistol-1.wav             local                         

template     projectile=+bryarbolt              local       

template     lookghost=+ghost                   local                  

thing        player                             local                         
thing        victim                             local                         
thing        potential                          local                         

flex         dot                                local                         
flex         maxDot                             local                         

flex         fireWait=0.5                       local                         
flex         holsterWait                        local                         
flex         fireDelay=0.6                      local                         
flex         powerBoost                         local                         
flex         autoAimFOV=30                      local                         
flex         autoAimMaxDist=5                   local

flex         look_y                  	       local                       

int          weaponIndex                        local                         
int          trackID=-1                         local                         
int          dummy=0                            local                         
int          mode                               local                         
int          holsterTrack                       local                         
int          new=0                              local

message      activated                                                        
message      deactivated                                                      
message      selected                                                         
message      deselected                                                       
message      autoselect                                                       
message      fire                                                             
message      timer                                                            
message      pulse                                                            

end                                                                           

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

code

fire:
   player = GetSourceRef();

   // Check that the player is still alive.
   if(GetThingHealth(player) <= 0)
   {
      Return;
   }

	if(mode == 1) 
	{
		If(zoom == 1)
		{
				ParseArg(player, "eyeoffset=(0.000000/0.000000/0.037000)");
				setpulse(0);
				SetCameraFocus(0, player);
				zoom = 0;
				return;
		}
		setpulse(0.01);
		zoom = 1;
		return;
	}

   // Check Ammo - If we are out, autoselect best weapon.
   if(GetInv(player, 11) < 1.0)
   {
      PlaySoundThing(outSound, player, 1.0, -1.0, -1.0, 0x80);
      if(GetAutoSwitch() & 1)
         SelectWeapon(player, AutoSelectWeapon(player, 1));
      Return;
   }

   SetPOVShake('0.0 -.003 0.0', '1.0 0.0 0.0', .05, 80.0);
   dummy = FireProjectile(player, projectile, fireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
	If(zoom == 1)
	{
		SetThingLook(dummy, GetThingLVec(current_look));
		SetThingVel(dummy, VectorSet(0, 0, 0));
		SetThingVel(dummy, VectorScale(GetThingLVec(dummy), 4.000000));
	}
   ChangeInv(player, 11, -1.0);
   jkPlayPOVKey(player, povfireAnim, 1, 0x38);

   powerBoost = GetInv(player, 63);
   ChangeFireRate(player, fireWait/powerBoost);

   Return;

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

activated:
   player = GetSourceRef();
   mode = GetSenderRef();

   jkSetWaggle(player, '0.0 0.0 0.0', 0);
   powerBoost = GetInv(player, 63);
   ActivateWeapon( player, fireWait/powerBoost, mode );
   Return;

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

deactivated:
   player = GetSourceRef();
   mode = GetSenderRef();

   jkSetWaggle(player, '10.0 7.0 0.0', 350);
   DeactivateWeapon( player, mode );
   Return;

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

selected:
   player = GetSourceRef();

   // Setup the meshes and models.
   jkSetPOVModel(player, povModel);
   jkSetWeaponMesh(player, weaponMesh);
   SetArmedMode(player, 1);

   // Play mounting sound.
   PlayMode(player, 41);
   PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80);

   // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
   // The animation is held at the last frame after it is played.
   trackID = jkPlayPOVKey(player, mountAnim, 0, 0x14);
   jkSetWaggle(player, '10.0 7.0 0.0', 350);

   // Clear saber flags, and allow activation of the weapon
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 2);
   SetMountWait(player, GetKeyLen(mountAnim));

   Return;

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

deselected:
   player = GetSourceRef();
   weaponIndex = GetSenderRef();
   
   PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
   jkPlayPOVKey(player, dismountAnim, 0, 0x18);
   
   holsterWait = GetKeyLen(holsterAnim);
   SetMountWait(player, holsterWait);
   holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
   SetTimerEx(holsterWait, 2, 0.0, 0.0);
   if (trackID != -1)
   {
      jkStopPOVKey(player, trackID, 0);
      trackID = -1;
   }
   jkSetWaggle(player, '0.0 0.0 0.0', 0);

   Return;

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

autoselect:
   player = GetSourceRef();

   // If the player has the weapon
   if(GetInv(player, 2) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 11) != 0.0)
      {
         ReturnEx(500.0);
      }
      else
      {
         ReturnEx(-1.0);
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

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

timer:
   StopKey(player, holsterTrack, 0.0);
   Return;
# ........................................................................................

pulse:
	//Set the old view to the start vector so we can compare how much the mouse has moved since last cycle
	start_vector = VectorSet(VectorX(final_vector), VectorY(final_vector), VectorZ(scaled_vector));


	if(new != 0)
	{
		DestroyThing(current_look);
	}
	//Get the current look of the player by firing a ghost. Thats our current look
	current_look=FireProjectile(player, lookghost, -1, 8, '0.00 0.1624 0.037', '0 0 0', 1.0, 0x20, 0.0, 0.0);

	//Get the change in player look so we can compare it to final vector from last cycle.
	new_vector = GetThingLVec(current_look);
	scaled_vector = GetThingLVec(current_look);

	//Now subtract the start vector from the new vector and scale by 0.25. Add it to our final look
	final_vector = VectorAdd(final_vector, VectorScale(VectorSub(new_vector, start_vector), 0.25));

	//Now we set the ghosts rotation to final vector so then we can attack the z axis using a camera focus
	SetThingLook(current_look, final_vector);

	//Set up the new vector with a 0 so then the Z doesnt go crazy. This keeps the X and Y synced with the players.
	new_vector = VectorSet(VectorX(final_vector), VectorY(final_vector), 0.0);

	//Set the players look to the new position. Apply the new position
	SetThingLook(player, new_vector);

	if(new != 0)
	{
		DestroyThing(current_camera);
	}
	current_camera=FireProjectile(current_look, lookghost, -1, 8, '0.00 0.84 0.00', '0 0 0', 1.0, 0x20, 0.0, 0.0);
	ParseArg(player, "eyeoffset=(0.000000/0.000000/0.000000)");

	//Set the current camera to internal camera - (0)
	SetCurrentCamera(0); 

	//Set the camera too the current look.
	SetCameraFocus(0, current_camera);
	new=1;
   Return;

end


For the homs change the ghost projectile to this:
Code:
_weapon2          none             orient=(0.000000/0.000000/0.000000) type=weapon collide=1 move=physics thingflags=0x20000000 mass=5.000000 physflags=0x200 maxrotvel=90.000000 damageclass=0x2 typeflags=0x1
+ghost            _weapon2         timer=0.011 size=0.050000 movesize=0.050000


[This message has been edited by Ace1 (edited January 04, 2003).]
I am _ Ace_1 _ , and I approve this message.
2003-01-04, 11:38 AM #4
Wave_Of_Mutilation jk zooms will never be as good as the mots one, no matter how much cogging.

Ace1 that works, good job!! Its abit funny when you look at the floor though. Still a great job. Thanks very much.
Team Battle.
2003-01-05, 11:46 AM #5
i noticed a fov=(i think 70?) thingo in kyles actor template

i couldn't get it to change the fov around though, and the fov listed there might have been for LOS calculations for force-grip and pull and stuff

↑ Up to the top!