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 → Detonate, please.
Detonate, please.
2002-12-21, 2:33 AM #1
Code:
# Sequencer charge cog edited by Hebedee.
# ========================================================================================

symbols

model       povModel=seqv.3do             local
model       weaponMesh=seqg.3do           local

keyframe    mountAnim=SeqVmnt.key         local
keyframe    dismountAnim=SeqVdis.key      local
keyframe    povfireAnim=SeqVpst1.key      local
keyframe    holsterAnim=kyhlstr.key       local

flex        mountWait                     local
flex        fireWait=0.8                  local
flex        holsterWait                   local

template    projectile_tpl2=+seqchrg2     local
template    exp=+sequencer_exp            local
int         projectile                    local
int         projectile2			  local
int         projectile3			  local
int         projectile4			  local
int         projectile5			  local
int         projectile6			  local
int         projectile7			  local
int         num=-1			  local
int         i                             local

material    flashing=seq0mtp3.mat         local
int         cel                           local
int         mode                          local
int         det=0                         local

thing       player                        local
int         trackID=-1                    local
int         holsterTrack                  local

int         selectMode=1                  local

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

end

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

code

startup:
   // Start the material flashing.
   MaterialAnim( flashing, 4, 1 );

   Return;

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

fire:
   player = GetSourceRef();
   mode = GetSenderRef();
   // Check that the player is still alive.
   if(GetThingHealth(player) <= 0)
   {
      for(i=0; i<num; i=i+1)
	{
		print("Detonator!"); 
		SetThingHealth(projectile, 0.01);
	}
	num=0;
      Return;
   }
   projectile[num] = FireProjectile(player, projectile_tpl2, -1, 16, '0 0.05 0.00', '0 0 0', 1.0, 0, 0.0, 0.0);
   num = num + 1;
   if(num > 8)
   {
	for(i=0; i<num; i=i+1)
	{
		print("Detonator!"); 
		SetThingHealth(projectile, 0.01);
	}
	num=0;
   }
   jkPlayPOVKey(player, povfireAnim, 1, 0x38);
   ChangeInv(player, 8, -1.0);

   // If out of ammo try to autoswitch to another weapon
   // if autoswitch is enabled else just switch to fists.
   if(GetInv(player, 8) < 1)
   {
      if(GetAutoSwitch() & 1)
      {
         SelectWeapon(player, AutoSelectWeapon(player, 1));
      }
      else
      {
         SelectWeapon(player, 1);
      }
   }

   Return;

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

activated:
   player = GetSourceRef();
   mode = GetSenderRef();
   printInt(mode);
   if(mode > 1) Return;
   if(mode == 1)
   {
	for(i=-1; i<num; i=i+1)
	{
		print("Detonator!"); 
		SetThingHealth(projectile, 0.01);
	}
	num = 0;
   }
   else
   {
   jkSetWaggle(player, '0.0 0.0 0.0', 0);
   ActivateWeapon( player, fireWait, 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, 40);
   jkSetPOVModel(player, povModel);
   SetArmedMode(player, 0);
   jkSetWeaponMesh(player, weaponMesh);
   trackID = jkPlayPOVKey(player, mountAnim, 0, 20);

   jkSetWaggle(player, '10.0 7.0 0.0', 350);

   SetMountWait(player, GetKeyLen(mountAnim));
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 8);

   Return;

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

deselected:
   player = GetSourceRef();

   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 ammo
   if(GetInv(player, 8) != 0)
   {
      // query for ammo
      if(selectMode == -1)
      {
         ReturnEx(300.0);
         Return;
      }

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

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

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

      ReturnEx(-2.0);
      Return;

   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

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

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

end




[This message has been edited by Hebedee (edited December 21, 2002).]
2002-12-21, 4:10 AM #2
Well, what does your symbols section look like?
Massassi's Official Chatroom: irc.synirc.com #massassi
2002-12-21, 4:56 AM #3
Problems I see. Each time you call the detonator, reset num to 0. Also, move num = num + 1; to right after FireProjectile(). That will fix a few problems, might make it work, but you should just edit the top post and post the whole cog.

------------------
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-12-21, 5:58 AM #4
The problem is your using

SetThingHealth(projectile, 0.01);

when it should be

SetLifeLeft(projectile, 0.01);
- Wisdom is 99% experience, 1% knowledge. -
2002-12-21, 7:01 AM #5
You, my friend, are a genius.
2002-12-21, 7:07 AM #6
Good point, musta missed that New Guy, but both things need to be fixed in order for it to work correctly.

------------------
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-12-22, 2:29 PM #7
Sorry, descent. I had already replaced yours and it still didn't work - it was TheNewGuy's change that did the trick. I didn't mean to not thank you.

↑ Up to the top!