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 → I come with a COG!
I come with a COG!
2004-05-30, 2:24 AM #1
Hi!
Code:
# Jedi Knight Cog Script
#
# WEAP_RAILDET.COG
#
# WEAPON 7 Script - Rail Detonator Gun
#
# This is a missile launcher type of weapon. It sends out an explosive device with
#  two options, impact or trigger explosion. The charge with the trigger option will
#  stick to a wall.
#
# - Not affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

model       povModel=rldv.3do                   local
model       weaponMesh=rldg.3do                 local
sound       mountSound=RailChargeArm01.WAV      local
sound       dismountSound=PutWeaponAway01.wav   local
sound       fireSound0=dev_charge.wav      local
sound       fireSound1=RailChargeFire01.WAV      local
sound       outSound=RailChargeEmpty01.WAV      local
sound		ahpoom=TECHFIRE.wav		local

thing       player                              local

keyframe    mountAnim=rldvmnt.key               local
keyframe    dismountAnim=rldvdis.key            local
keyframe    povfireAnim0=rldvfire3.key            local
keyframe    povfireAnim1=rldvfire1.key            local
keyframe    povfireAnim2=rldvfire2.key            local
keyframe    holsterAnim=kyhlstr.key             local

template    projectile0=+dis_laser1                 local
template    projectile1=+raildet               local
template	speed=+dis_blast1		local
template	ouch=+disrupter			local

thing       rail                                local

flex        fireWait=1.0                        local
flex        powerBoost                          local
flex        autoAimFOV=25                       local
flex        autoAimMaxDist=5                    local
flex        holsterWait                         local

keyframe    railAnim=rld0anim.key               local
model		grenademodel=rld0.3do		local

int         trackID=-1                          local
int         mode                                local
int         holsterTrack                        local

int         selectMode=1                        local

message     activated
message     deactivated
message     selected
message     deselected
#message     newplayer
message     autoselect
message     fire
message     timer

end

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

code

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

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

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


   SetPOVShake('0.0 -.01 0.0', '4.0 0.0 0.0', .05, 80.0);
if(!IsCrouching(player))
{
	jkPlayPOVKey(player, povfireAnim0[mode], 1, 0x30);
   rail = FireProjectile(player, projectile0[mode], fireSound0[mode], 18, '0.0214 0.0 0.00', '0 0 0', 1.0, 0x20, autoAimFOV*4, autoAimFOV*4);
   if((mode == 1) && (rail != -1))
   {
      PlayKey(rail, railAnim, 1, 20);
   }
   // Provide a kick backwards
	if(mode==1)
   ApplyForce(player, VectorScale(GetThingLVec(player), -40));
}
else
{
	if(mode==1)
	{
		jkPlayPOVKey(player, povfireAnim2, 1, 0x38);
		rail=FireProjectile(player,ouch,ahpoom,18,'0.0214 0.0 0.00', '0 0 0',10,0x63,autoAimFOV*4, autoAimFOV*4);
	}
	else
	{
		PlaySoundPos(ahpoom,GetThingPos(player),1,0,100,0x0);
		jkPlayPOVKey(player, povfireAnim0, 1, 0x38);
		rail = FireProjectile(player, speed, fireSound0, 18, '0.0 0.0 0.0', '0 0 0', 0.0, 0x61, autoAimFOV*4, autoAimFOV*4);
		DetachThing(player);
		SetThingVel(player,VectorSet( VectorX( GetThingLVec(rail) )*(100*(powerBoost*10)) , VectorY( GetThingLVec(rail) )*100 , VectorZ( GetThingLVec(rail) )*100 ));
		sleep(0.1);
		PlaySoundPos(ahpoom,GetThingPos(player),1,0,100,0x0);
	}
}

   ChangeInv(player, 15, 0.0);

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

   Return;

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

activated:
   player = GetSourceRef();
   mode = GetSenderRef();
if(!IsCrouching(player))
{
if(mode==0)
{
	fireWait = 0.01;
}
else
{
	fireWait = 1.00;
}
}
else
{
if(mode==0)
{
	fireWait = 0.10;
}
else
{
	fireWait = 1.00;
}
}
   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();

   PlayMode(player, 41);
   PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
   jkSetPOVModel(player, povModel);
   SetArmedMode(player, 1);
   jkSetWeaponMesh(player, weaponMesh);
   jkSetWaggle(player, '10.0 7.0 0.0', 350);

   trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
   SetMountWait(player, GetKeyLen(mountAnim));
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 7);

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

   Return;

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

deselected:
   player = GetSourceRef();

   PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
   jkPlayPOVKey( player, dismountAnim, 0, 18 );

   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;

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

//newplayer:
//   player = GetSourceRef();
//
//   // Make sure that if the player is respawning, the old mount isn't playing anymore.
//   if (trackID != -1)
//      jkStopPOVKey(player, trackID, 0);
//
//   Return;

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

autoselect:
   selectMode = GetSenderRef();
   player = GetSourceRef();

   // If the player has the weapon
   if(GetInv(player, 7) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 15) != 0.0)
      {

         // query for ammo
         if(selectMode == -1)
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 0) && !(GetAutoPickup() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 1) && !(GetAutoSwitch() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 2) && !(GetAutoPickup() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         ReturnEx(-2.0);
         Return;

      }
      else
      {
         ReturnEx(-1.0);
         Return;
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

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

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

end



In the Fire message, when crouched, and using mode 0, I am to be thrusted in the direction I'm looking at at 100 m/s. Problem: I look at a person, he's in my crosshair, and I miss him. An example of missing the target:
Level 08, Escape from the palace. I stand next to the elevator, and I look up through the hole in the roof (blown the wires), and I aim my gun so that the crosshair is in the middle of the hole, I shoot, but I don't come out. I end up on the other side of the elevator in the corner.
Another example of missing the target. I stand a meter away from a stormtrooper, I have him under the crosshair, I fire, and he's OK, but I'm on the other side of him, a few meters away.

Please Help!

/Edward
Edward's Cognative Hazards
2004-05-30, 8:24 AM #2
Set the player's physics and actor flags to fly before launching him. Your being pulled off course by the ground.

------------------
I used to believe that we must fight the future, lest change come without our consent. I was wrong. The truth is that we must embrace the future, for only with change can we remain the same.
:wq
And when the moment is right, I'm gonna fly a kite.
2004-05-30, 10:27 AM #3
I attempted to take away gravity and make me fly, but no affect. I've even added a StopThing... Nothing...

/Edward
Edward's Cognative Hazards
2004-05-31, 12:21 AM #4
Are you sure you want the powerboost value only to affect the x value of the vector? Didn't you mean:
Code:
SetThingVel(player, VectorScale(VectorSet(VectorX(GetThingLVec(rail)), VectorY(GetThingLVec(rail)), VectorZ(GetThingLVec(rail))), powerboost*1000));

And remember, 10*10*10 = 10*(10*10) = (10*10)*10.

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2004-05-31, 8:10 AM #5
Quote:
<font face="Verdana, Arial" size="2">Originally posted by zagibu:

And remember, 10*10*10 = 10*(10*10) = (10*10)*10.

</font>


Oh, you mean.. What's word? *Looks up Tom Lehrer* commutative?

And yes, Only adding extra speed to the X would get me off corse... Thanks! And now that I think about it, I'm not going at 100 m/s, I'm going at 1000. 2000 if you count PB... Hm... Oh well... Thanks!

/Edward


[This message has been edited by Edward (edited May 31, 2004).]
Edward's Cognative Hazards
2004-05-31, 10:01 AM #6
It's actually 10000 m/s, since it's measured in JKU, which are 10 m long. And I don't think you will notice the difference between 100, 1000 or 10000 m/s in most levels...

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2004-05-31, 10:20 AM #7
Asspecially if you hold down the fire button... [http://www.uruobsession.com/forum/html/emoticons/evil.gif]
Edward's Cognative Hazards

↑ Up to the top!