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 → Weapon elements:
Weapon elements:
2002-07-28, 7:26 AM #1
I started a cog from scratch just to control what went in and I pasted in most of the stuff line by line so I could try and understand it and its helped alot, but im wondering do you HAVE to have powerboost and auto aim in there? heres the problem I wrote it and it works in game, pulls out the write 3do and everything but when I press fire, nothing...

Code:
#
#
# WEAP_AK47.COG
#
# 
#
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

model        povModel=vak47.3do                 local                         
model        weaponMesh=gak47.3do               local                         

keyframe     mountAnim=StrVmnt.key              local                         
keyframe     dismountAnim=StrVdis.key           local                         
keyframe     povfireAnim=StrVpst1.key           local                         
keyframe     holsterAnim=kyhlstr.key            local                         

sound        mountSound=df_bry_ready.wav        local                         
sound        dismountSound=PutWeaponAway01.wav  local                         
sound        fireSound=ak47.wav                 local                         
sound        outSound=trprout.wav               local                         
sound        clickSound=click.wav               local
sound        reloadsound=rel-1.wav              local
sound        reloadsound1=rel-2.wav             local                         

template     projectile=+repeaterball           local                         

thing        player                             local                         

flex         fireWait=0.07                      local                    
flex         holsterWait                        local                              

int          dummy                              local                         
int          trackID=-1                         local                         
int          fireChannel=-1                     local                         
int          holsterTrack                       local                         
int          mode                               local                         
int          count=0                            local                         
int          disID                              local                         

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

end                                                                           

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

code

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

   if(count > 29) 
   { 
   PlaySoundThing(clickSound, player, 1.0, -1, -1, 0x80);
   Sleep(1);    
   Return;  
   }

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

   if(GetInv(player, 12) < 1.0)
   {
      PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
      if((GetAutoSwitch() & 1))
         SelectWeapon(player, AutoSelectWeapon(player, 1));
      Return;

   }
   if(mode == 0)
   {
     randVec = VectorSet((Rand()-0.5)*5,(Rand()-0.2)*5, 0.0);
   dummy = FireProjectile(player, projectile, fireSound, 8, '0.0100 0.1200 0.00');
   ChangeInv( player, 12, -1.0 );
   count = count + 1;
   }
   else
   {

   }

   jkPlayPOVKey( player, povfireAnim, 1, 0x38 );

   Return;

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

   selected:
   player = GetSourceRef();

   PlayMode(player, 41);
   Print("AK-47 7.62x39mm Assault Rifle");
   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, 6);

   Return;

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

   deselected:
   if(fireChannel != -1)
   {
      StopSound(fireChannel, 0.1);
      fireChannel = -1;
   }

   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;
# ........................................................................................
   autoselect:
   player = GetSourceRef();

   // If the player has the weapon
   if(GetInv(player, 6) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 12) != 0.0)
      {
         ReturnEx(600.0);
      }
      else
      {
         ReturnEx(-1.0);
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;
 
# ........................................................................................

   user0:
   disID = jkPlayPOVKey(player, dismountAnim, 0, 0x4);
   SetMountWait(player, GetKeyLen(holsterAnim));
   holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
   if(trackID != -1) { jkStopPOVKey(player, trackID, 0); trackID = -1; }
   PlaySoundThing(reloadsound, player, 1.0, -1, -1, 0x80);
   Sleep(1);
   PlaySoundThing(reloadsound1, player, 1.0, -1, -1, 0x80);
   StopKey(player, holsterTrack, 0);
   PlayMode(player, 41);
   jkStopPOVKey(player, disID, 0);
   trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
   SetMountWait(player, GetKeyLen(mountAnim));
   count = 0;
   Return;

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

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

end



Whee ya I am trying to figure stuff out but hopefully there isnt tooooo much wrong with it [http://forums.massassi.net/html/wink.gif]

------------------
Blue Spandex.
WHEEEEEEEEEE.

[This message has been edited by sgt_mischa (edited July 28, 2002).]
2002-07-28, 7:34 AM #2
It doesnt work, because the Fireprojectile() command isnt complete. Refer to the JKspecs (or, the Datamaster) for the proper syntax.


And no, you dont NEED powerup or autoaim code. Those are just nice little extras that one can throw in.

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-07-28, 7:46 AM #3
Code:
FireProjectile(fire_thing, template, sound, submode, offset_vec, error_vec, vel_flex, proj_flags, AA_FOV, AA_dist);

thats the layout, it has the auto aim stuff in there as complete so should I put those in?
Code:
FireProjectile(player, projectile, fireSound, 8, '0.0100 0.1200 0.00');

original, then modified:
Code:
FireProjectile(player, projectile, fireSound, 8, '0.0100 0.1200 0.00', 1.0, 0x30,);

is that all I need? or do I have to add the autoaim bits [http://forums.massassi.net/html/frown.gif]

well I applied changes now the gun doesnt even pull out:
Code:
#
#
# WEAP_AK47.COG
#
# 
#
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

model        povModel=vak47.3do                 local                         
model        weaponMesh=gak47.3do               local                         

keyframe     mountAnim=StrVmnt.key              local                         
keyframe     dismountAnim=StrVdis.key           local                         
keyframe     povfireAnim=StrVpst1.key           local                         
keyframe     holsterAnim=kyhlstr.key            local                         

sound        mountSound=df_bry_ready.wav        local                         
sound        dismountSound=PutWeaponAway01.wav  local                         
sound        fireSound=ak47.wav                 local                         
sound        outSound=trprout.wav               local                         
sound        clickSound=click.wav               local
sound        reloadsound=rel-1.wav              local
sound        reloadsound1=rel-2.wav             local                         

template     projectile=+repeaterball           local                         

thing        player                             local

vector       randVec                            local                        

flex         fireWait=0.07                      local                    
flex         holsterWait                        local                              

int          dummy                              local                         
int          trackID=-1                         local                         
int          fireChannel=-1                     local                         
int          holsterTrack                       local                         
int          mode                               local                         
int          count=0                            local                         
int          disID                              local                         

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

end                                                                           

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

code

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

   if(count > 29) 
   { 
   PlaySoundThing(clickSound, player, 1.0, -1, -1, 0x80);
   Sleep(1);    
   Return;  
   }

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

   if(GetInv(player, 12) < 1.0)
   {
      PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
      if((GetAutoSwitch() & 1))
         SelectWeapon(player, AutoSelectWeapon(player, 1));
      Return;

   }
   if(mode == 0)
   {
     randVec = VectorSet((Rand()-0.5)*5,(Rand()-0.2)*5, 0.0);
   dummy = FireProjectile(player, projectile, fireSound, 8, '0.0100 0.1200 0.00', randVec, 1.0, 0x30,);
   ChangeInv( player, 12, -1.0 );
   count = count + 1;
   }
   else
   {

   }

   jkPlayPOVKey( player, povfireAnim, 1, 0x38 );

   Return;

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

   selected:
   player = GetSourceRef();

   PlayMode(player, 41);
   Print("AK-47 7.62x39mm Assault Rifle");
   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, 6);

   Return;

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

   deselected:
   if(fireChannel != -1)
   {
      StopSound(fireChannel, 0.1);
      fireChannel = -1;
   }

   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;
# ........................................................................................
   autoselect:
   player = GetSourceRef();

   // If the player has the weapon
   if(GetInv(player, 6) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 12) != 0.0)
      {
         ReturnEx(600.0);
      }
      else
      {
         ReturnEx(-1.0);
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;
 
# ........................................................................................

   user0:
   disID = jkPlayPOVKey(player, dismountAnim, 0, 0x4);
   SetMountWait(player, GetKeyLen(holsterAnim));
   holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
   if(trackID != -1) { jkStopPOVKey(player, trackID, 0); trackID = -1; }
   PlaySoundThing(reloadsound, player, 1.0, -1, -1, 0x80);
   Sleep(1);
   PlaySoundThing(reloadsound1, player, 1.0, -1, -1, 0x80);
   StopKey(player, holsterTrack, 0);
   PlayMode(player, 41);
   jkStopPOVKey(player, disID, 0);
   trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
   SetMountWait(player, GetKeyLen(mountAnim));
   count = 0;
   Return;

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

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

end

c0gg1ng r pwn m3

------------------
Blue Spandex.
WHEEEEEEEEEE.



[This message has been edited by sgt_mischa (edited July 28, 2002).]
2002-07-28, 8:03 AM #4
For no Auto-Aim, do it like this.
Code:
FireProjectile(player, projectile, fireSound, 8, '0.01 0.12 0', randVec, 1.0, 0x30, 0, 0);
(PS - That 1.0 is not the velocity. That is set in the template)

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-28, 8:24 AM #5
d'oh... hopefully I can finish this quickly but here is what I changed:
Code:
#
#
# WEAP_AK47.COG
#
# 
#
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

model        povModel=vak47.3do                 local                         
model        weaponMesh=gak47.3do               local                         

keyframe     mountAnim=StrVmnt.key              local                         
keyframe     dismountAnim=StrVdis.key           local                         
keyframe     povfireAnim=StrVpst1.key           local                         
keyframe     holsterAnim=kyhlstr.key            local                         

sound        mountSound=df_bry_ready.wav        local                         
sound        dismountSound=PutWeaponAway01.wav  local                         
sound        fireSound=ak47.wav                 local                         
sound        outSound=trprout.wav               local                         
sound        clickSound=click.wav               local
sound        reloadsound=rel-1.wav              local
sound        reloadsound1=rel-2.wav             local                         

template     projectile=+repeaterball           local                         

thing        player                             local

vector       randVec                            local                      

flex         fireWait=0.07                      local                    
flex         holsterWait                        local                              

int          dummy                              local                         
int          trackID=-1                         local                         
int          fireChannel=-1                     local                         
int          holsterTrack                       local                         
int          mode                               local                         
int          count=0                            local                         
int          disID                              local                         

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

end                                                                           

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

code

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

   if(count > 29) 
   { 
   PlaySoundThing(clickSound, player, 1.0, -1, -1, 0x80);
   Sleep(1);    
   Return;  
   }

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

   if(GetInv(player, 12) < 1.0)
   {
      PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
      if((GetAutoSwitch() & 1))
         SelectWeapon(player, AutoSelectWeapon(player, 1));
      Return;

   }
   if(mode == 0)
   {
     randVec = VectorSet((Rand()-0.5)*5,(Rand()-0.2)*5, 0.0);
   dummy = FireProjectile(player, projectile, fireSound, 8, '0.01 0.12 0', randVec, 1.0, 0x30, 0, 0);
   ChangeInv( player, 12, -1.0 );
   count = count + 1;
   }
   else
   {

   }

   jkPlayPOVKey( player, povfireAnim, 1, 0x38 );

   Return;

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

   selected:
   player = GetSourceRef();

   PlayMode(player, 41);
   Print("AK-47 7.62x39mm Assault Rifle");
   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, 6);

   Return;

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

   deselected:
   if(fireChannel != -1)
   {
      StopSound(fireChannel, 0.1);
      fireChannel = -1;
   }

   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;
# ........................................................................................
   autoselect:
   player = GetSourceRef();

   // If the player has the weapon
   if(GetInv(player, 6) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 12) != 0.0)
      {
         ReturnEx(600.0);
      }
      else
      {
         ReturnEx(-1.0);
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;
 
# ........................................................................................

   user0:
   disID = jkPlayPOVKey(player, dismountAnim, 0, 0x4);
   SetMountWait(player, GetKeyLen(holsterAnim));
   holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
   if(trackID != -1) { jkStopPOVKey(player, trackID, 0); trackID = -1; }
   PlaySoundThing(reloadsound, player, 1.0, -1, -1, 0x80);
   Sleep(1);
   PlaySoundThing(reloadsound1, player, 1.0, -1, -1, 0x80);
   StopKey(player, holsterTrack, 0);
   PlayMode(player, 41);
   jkStopPOVKey(player, disID, 0);
   trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
   SetMountWait(player, GetKeyLen(mountAnim));
   count = 0;
   Return;

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

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

end

im thinking there might be something wrong with randVec (could be wrong) or that I didnt define mode 0 (I think I did) but the gun still isnt shooting... and I have the complete fire command now

------------------
Blue Spandex.
WHEEEEEEEEEE.

[This message has been edited by sgt_mischa (edited July 28, 2002).]
2002-07-28, 9:18 AM #6
Run it by Parsec, see if it chatches anything. You can get rid of mode stuff, because you are using a secondary fire. Everything else seems to be in order.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-07-28, 9:41 AM #7
grrr everything but fire works. cogwriter didnt catch anything...whoa look what parsec caught:

Quote:
<font face="Verdana, Arial" size="2">
Error Box
The symbol, firewait, was assigned, but never used.
The symbol, dummy, was assigned but never used.
Parse Complete. Time elapsed: .539 seconds.
</font>

okay so... how would I go about fixing something I dont have a clue about?
------------------
Blue Spandex.
WHEEEEEEEEEE.

[This message has been edited by sgt_mischa (edited July 28, 2002).]
2002-07-28, 11:31 AM #8
Misha, those are relatively minor errors explaining that you have extra variables that you're not using.

Quote:
<font face="Verdana, Arial" size="2">
(PS - That 1.0 is not the velocity. That is set in the template)</font>


Pilot, it's not exactly the velocity, but you assumed that's what vel_flex meant. That flex is used to scale the velocity if the 0x1 Projectile Flag is used. Otherwise, the vel_flex param isn't used.

Well for starters, the cog has no activated and deactivated messages. These are needed to start and stop the fire message via ActivateWeapon() and DeactivateWeapon() respectively.

Also, if you're going to leave autoaim at zero, don't use the 0x30 or 0x20 projectile flags.

Fix those errors and then see how it works. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited July 28, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-07-28, 12:16 PM #9
Oh boy *whistles* Didnt notice I forgot the activate/deactivate DOH.. so if I dont use 0x30 or 0x20, what flags should I use? cuz now it shoots but it shoots..nothing!

ahaha 0x1 works
for some odd reason when I had 0x30 NONE of the weapons shot projectiles...
------------------
Blue Spandex.
WHEEEEEEEEEE.

[This message has been edited by sgt_mischa (edited July 28, 2002).]
2002-07-29, 1:32 PM #10
You don't have to use any projectile flags. 0x20 and 0x30 affect the autoaim settings.
Since you had the autoaim parameters set to 0, JK had a problem and the projectiles
weren't visible.


Good luck. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited July 29, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!