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 → Weapons problems
Weapons problems
2002-01-28, 10:26 PM #1
K, I am using Hideki's C/S weapon setup *Custom projectiles in multiplayer*. I can't seem to get these cogs to run. It is supposed to pick a random pistol. When it fires, it uses the random int it got before and sends it to the client cog so it knows what projectile to fire. But I never get a weapon mesh to come up, and it crashes when I press the fire button. Everything checks out in CogWriter, so I doubt it's syntax. Here are the cogs:

The main cog:
Code:
# Jedi Knight Cog Script
#
# WEAP_BRYAR.COG
#
# WEAPON 2 Script - Random Blaster
#
# Chooses random blaster upon game start.  Choices are the Byrar,
# A Mandolorian Pistol, Blastech DL-66, Blastech DL-44, Stouker 
# Magnum or the Goldwave Sharpshooter.
#
# - Affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# (C) 1998, 2002 Tazz --Modifications not supported by LEC.


symbols

model        povModel0=bryv.3do                 local                         
model        weaponMesh0=bryg.3do               local                         
model        povModel1=manv.3do                 local                         
model        weaponMesh1=mang.3do               local                         
model        povModel2=pistv.3do                local                         
model        weaponMesh2=pistg.3do              local                         
model        povModel3=skinv.3do                local                         
model        weaponMesh3=sking.3do              local                         
model        povModel4=magv.3do                 local                         
model        weaponMesh4=magg.3do               local                         
model        povModel5=gozblastechv.3do         local                         
model        weaponMesh5=gozblastechg.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        fireSound0=pistol-1.wav            local                         
sound        fireSound1=firestream.wav          local                         
sound        fireSound2=blastek.wav             local                         
sound        fireSound3=laser3.wav              local                         
sound        fireSound4=magnum.wav              local                         
sound        fireSound5=blastechfire.wav        local                         

template     projectile0=+bryarbolt             local                         

thing        player                             local                         
thing        victim                             local                         
thing        potential                          local                         
thing        dummy                              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                         

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

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

end                                                                           

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

code

//startup:

//pick a random pistol

Sleep(2);
Return;


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

fire:
   player = GetSourceRef();

   // Check that the player is still alive.
   if(GetThingHealth(player) <= 0)
   {
      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);

   //Take away the FireProjectile command, take it to the client cog and replacing it with triggering.
   ID = GetCurWeapon(player) * 10 + GetSenderRef();
   SendTrigger(-1, ID, player, blah, 0, 0);

   //keys should be left here, or somehow broadcasing will make it play more than twice... from the 4th parameter of FireProjectile.
   PlayMode(player, 8);

   //Sounds should be left here, or somehow broadcasing will make it play more than twice... from the 3rd parameter of FireProjectile.
   PlaySoundThing(fireSound[blah], player, 1, -1, -1, 0x80);

   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();

   blah=rand()*6;

   // Setup the meshes and models.
   jkSetPOVModel(player, povModel0[blah]);
   jkSetWeaponMesh(player, weaponMesh0[blah]);

   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;

end


The client cog:
Code:
# Jedi Knight Cog Script
#
# Client_Bryar.COG
#
# Description
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

# This flag makes the cog act locally, no broadcasting, less lag.
flags=0x404

symbols

flex         autoAimFOV=30                      local                         
flex         autoAimMaxDist=5                   local                         
template     projectile0=+bryarbolt             local                         
template     projectile1=+mandalorbolt          local                         
template     projectile2=+dl66bolt              local                         
template     projectile3=+sharpshooterbolt      local                         
template     projectile4=+magnumbolt            local                         
template     projectile5=+blastechbolt          local                         
int          blah                               local                         

message      trigger                                                          

end                                                                           

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

code

trigger:

	if( (GetSourceRef() == 20) || (GetSourceRef() == 21) ) //Either sent with primary or secondary fire mode...
	{
		blah = GetParam(1);	
		FireProjectile(GetParam(0), projectile0[blah] -1, -1, '0.0135 0.1624 0.0', '0 0 0', 1, 0x20, autoAimFOV, autoAimFOV*2);
	}

	return;

end


Eventually all of the weapons for Rogue Squadron CTF 2.0 will be C/S, but I have to debug this first.

------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2002-01-29, 1:20 AM #2
Don't know about weapon mesh not coming up, but the reason it crashes is that you have
PlaySoundThing(fireSound[blah], player, 1, -1, -1, 0x80);

You should make fireSound[blah] to fireSound0[blah]. That should avoid crashing.

sidenote : If you want to use fireSound[blah], you can't register fireSound0, but fireSound, fireSound1, fireSound2 and so on.

------------------
http://millennium.massassi.net - Millennium
Sniper Arena! - Enhancement Pack!
2002-01-29, 9:24 AM #3
You need to use the 0x240 Cog Flags for your client cog. Does the cog work now?

-----

Could you fix that flag error in your tutorial, Hideki? I think someone said it was still in the downloadable version.

------------------
Each cog better than the next
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-29, 11:27 AM #4
Hmm... I didn't even see that. I believe that was how it was laid out when I downloaded it, as I figured the flags were right. Ah well, I'll fix it asap.

*update*
The sounds now work, but the 3dos still do not show up, and no projectiles. I think SM is right about the flags causing the client cog to malfunction.

------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2002-01-29, 12:26 PM #5
I assume you downloaded the tutorial.
I checked it in the resouce files, it was flagged 0x404 [http://forums.massassi.net/html/eek.gif]

I fixed them now.

[That's "Error, page not found 404"]

------------------
http://millennium.massassi.net - Millennium
Sniper Arena! - Enhancement Pack!

↑ Up to the top!