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 → Another COG problem...
Another COG problem...
2003-07-23, 10:31 PM #1
Hi!
Yes, more COG problems... I thought as I'm waiting for these things to be fixed, I could pass the time by trying new things... But then I get into problems...

The problem is: I can't select this weapon COG!
Code:
# A CANON COG!
#
# By Edward
symbols

message		activated
message		deactivated
message		pulse
message		selected
message		deselected

model		weapmesh=CANON.3DO			local
model		weapon=CANON.3DO			local

keyframe	mountAnim=ConVmnt.key			local
keyframe	dismountAnim=ConVdis.key		local
keyframe	povfireAnim=ConVpst1.key		local
keyframe	holsterAnim=kyhlstr.key			local

template	ball=ball				local

sound		mountSound=df_rif_ready.wav		local
sound		dismountSound=PutWeaponAway01.wav	local
sound		fireSound=expl_09.wav			local
sound		outSound=railchargeattach.wav		local
sound		warmupSound=16metalcreak02.wav		local

int		bigsound=1				local

thing		player					local

int		power=0					local

flex		autoAimFOV=30				local
flex		autoAimMaxDist=5			local

int		trackID=-1				local

end
#
code
activated:
	player=GetSourceRef();
	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;
	}
	power=0;
	SetPulse(0.1);
	bigsound=PlaySoundThing(warmupSound,player,0,-1,10,0xC0);
	ChangeSoundPitch(bigsound,1.05,1);
	ChangeSoundVol(bigsound,1,1);
	ActivateWeapon(player, 0, 1);
return;
deactivated:
	player=GetSourceRef();
	SetPOVShake('0.1 -.05 0.0', '0.5 0.0 0.1', .05, 40.0);
	jkPlayPOVKey(player, povfireAnim, 1, 0x38);
	FireProjectile(player, ball, fireSound, power, '0.02 0.15 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
	StopSound(bigsound,1);
	PlaySoundThing(fireSound,player,1,-1,10,0xC0);
	ChangeInv(player, 12, -1.0);
	DeactivateWeapon( player, 1 );
return;
pulse:
	power=power+1;
	If(power>=20) power=20;
	SetPOVShake('-0.001 -.001 0.0', '0.001 0.0 0.001', .05, 40.0);
return;
selected:
   player = GetSourceRef();

   // Play external mounting animation
   PlayMode(player, 41);

   // Setup the meshes and models.
   jkSetPOVModel(player, weapon);
   SetArmedMode(player, 1);
   jkSetWeaponMesh(player, weapmesh);
   jkSetWaggle(player, '10.0 7.0 0.0', 350);

   // Play mounting sound.
   PlaySoundThing(mountSound, player, 1.0, -1, 10, 0xC0);

   // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
   // The animation is held at the last frame after it is played.
   trackID=jkPlayPOVKey(player, mountAnim, 0, 20);
   SetMountWait(player, GetKeyLen(mountAnim));

   // Clear saber flags, and allow activation of the weapon
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 9);

   // Check Ammo - If we are out, autoselect best weapon.
   if(GetInv(player, 12) < 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);

   SetMountWait(player, 1);
   PlayKey(player, holsterAnim, 1, 0x4);
   if (trackID != -1)
   {
      jkStopPOVKey(player, trackID, 0);
      trackID = -1;
   }
   jkSetWaggle(player, '0.0 0.0 0.0', 0);

Return;
end

It replaces weap_conc.cog, so it should be on number 9 after typing in red5.

/Edward
Edward's Cognative Hazards
2003-07-24, 7:01 AM #2
Hm, this one's a bit trickier.

So what exactly happens when you try to select it, does it just reselect the previous weapon?

------------------
Brutally honest since 1998
2003-07-24, 7:25 AM #3
Actually, nothing happens... Like if I don't have it in my pocket or I'm out of ammo...

/Edward
Edward's Cognative Hazards
2003-07-24, 9:20 AM #4
I think weapon cogs are required to have an

Autoselect:

section. Logically I can't explain why this would be necessary. Datamaster says it one of its functions is to return status while mounting a weapon. I just know if I remove autoselect from LEC weapon cogs, I cannot select them.

------------------
- Wisdom is 99% experience, 1% knowledge. -

[This message has been edited by The_New_Guy (edited July 24, 2003).]
- Wisdom is 99% experience, 1% knowledge. -
2003-07-24, 11:05 AM #5
Right, you need to have an autoselect message that uses ReturnEx() to give a value of at least 0 back to the exe. Otherwise, you won't be able to select the weapon.

Knew it was in the DM somewhere:
Quote:
<font face="Verdana, Arial" size="2">
SelectWeapon()
Mounts a weapon for the player. Remember that the weapon cog's autoselect message must return a value greater than -1 or the weapon will not be selected. Syntax:
</font>


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

[This message has been edited by SaberMaster (edited July 24, 2003).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-24, 11:36 AM #6
Hay! That autoselect did help! I can select and fire my canon!
But the only problem now is that any weapon I select after that, the external model is stuck on the holster animation. What do I need to add for it to be normal?
Code:
# A CANON COG!
#
# By Edward
symbols

message		activated
message		deactivated
message		pulse
message		selected
message		deselected
message		autoselect

model		weapmesh=CANON.3DO			local
model		weapon=CANON.3DO			local

keyframe	mountAnim=ConVmnt.key			local
keyframe	dismountAnim=ConVdis.key		local
keyframe	povfireAnim=ConVpst1.key		local
keyframe	holsterAnim=kyhlstr.key			local

template	ball=ball				local

sound		mountSound=df_rif_ready.wav		local
sound		dismountSound=PutWeaponAway01.wav	local
sound		fireSound=expl_09.wav			local
sound		outSound=railchargeattach.wav		local
sound		warmupSound=16metalcreak02.wav		local

int		bigsound=1				local

thing		player					local

int		power=0					local

flex		autoAimFOV=30				local
flex		autoAimMaxDist=5			local

int		trackID=-1				local
int		selectMode=1				local
int		holsterTrack=-1				local

end
#
code
activated:
	player=GetSourceRef();
	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;
	}
	power=0;
	SetPulse(0.1);
	bigsound=PlaySoundThing(warmupSound,player,0,-1,10,0xC0);
	ChangeSoundPitch(bigsound,1.05,1);
	ChangeSoundVol(bigsound,1,1);
	ActivateWeapon(player, 0, 1);
return;
deactivated:
	player=GetSourceRef();
	SetPOVShake('0.1 -.05 0.0', '0.5 0.0 0.1', .05, 40.0);
	jkPlayPOVKey(player, povfireAnim, 1, 0x38);
	FireProjectile(player, ball, fireSound, power, '0.02 0.15 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
	StopSound(bigsound,1);
	PlaySoundThing(fireSound,player,1,-1,10,0xC0);
	ChangeInv(player, 12, -1.0);
	DeactivateWeapon( player, 1 );
return;
pulse:
	power=power+1;
	If(power>=1000) power=1000;
	SetPOVShake('-0.001 -.001 0.0', '0.001 0.0 0.001', .05, 40.0);
return;
selected:
   player = GetSourceRef();

   // Play external mounting animation
   PlayMode(player, 41);

   // Setup the meshes and models.
   jkSetPOVModel(player, weapon);
   SetArmedMode(player, 1);
   jkSetWeaponMesh(player, weapmesh);
   jkSetWaggle(player, '10.0 7.0 0.0', 350);

   // Play mounting sound.
   bigsound=PlaySoundThing(mountSound, player, 1.0, -1, 10, 0xC0);
   ChangeSoundPitch(bigsound,.25,0.01);

   // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
   // The animation is held at the last frame after it is played.
   trackID=jkPlayPOVKey(player, mountAnim, 0, 20);
   SetMountWait(player, GetKeyLen(mountAnim));

   // Clear saber flags, and allow activation of the weapon
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 9);

   // Check Ammo - If we are out, autoselect best weapon.
   if(GetInv(player, 12) < 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);

   SetMountWait(player, 1);
   holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
   if (trackID != -1)
   {
      jkStopPOVKey(player, trackID, 0);
      trackID = -1;
   }
   jkSetWaggle(player, '0.0 0.0 0.0', 0);

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

   // If the player has the weapon
   if(GetInv(player, 9) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 12) > 1.0)
      {

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

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

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

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

         ReturnEx(-2.0);
         Return;

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

   Return;

end


/Edward
Edward's Cognative Hazards
2003-07-24, 11:58 AM #7
Oh, and one more thing... How do I make a template, where the type=debris, give damage 100 to any who touches it?

/Edward
Edward's Cognative Hazards
2003-07-26, 11:56 PM #8
HAY! I still need help here!!!
Code:
# A CANON COG!
#
# By Edward
symbols

message		activated
message		deactivated
message		pulse
message		selected
message		deselected
message		autoselect

model		weapmesh=CANON.3DO			local
model		weapon=CANON.3DO			local

keyframe	mountAnim=CanonUp.key			local
keyframe	dismountAnim=CanonDown.key		local
keyframe	povfireAnim=ConVpst1.key		local
keyframe	holsterAnim=kyhlstr.key			local
keyframe	warmup=CanonWarmUp.key			local

template	ball=ball				local

sound		mountSound=df_rif_ready.wav		local
sound		dismountSound=PutWeaponAway01.wav	local
sound		fireSound=expl_09.wav			local
sound		outSound=railchargeattach.wav		local
sound		warmupSound=16metalcreak02.wav		local

int		bigsound=1				local

thing		player					local

int		power=0					local

flex		autoAimFOV=30				local
flex		autoAimMaxDist=5			local

int		trackID=-1				local
int		selectMode=1				local
int		holsterTrack=-1				local
int		warm=-1					local

end
#
code
activated:
	player=GetSourceRef();
	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;
	}
	warm=jkPlayPOVKey(player, warmup, 1, 0x4);
	power=0;
	SetPulse(0.1);
	bigsound=PlaySoundThing(warmupSound,player,0,-1,10,0xC0);
	ChangeSoundPitch(bigsound,1.05,1);
	ChangeSoundVol(bigsound,1,1);
	ActivateWeapon(player, 0, 1);
return;
deactivated:
	player=GetSourceRef();
	SetPOVShake('0.1 -.05 0.0', '0.0 -0.5 0.0', .05, 40.0);
	SetPulse(0);
	jkStopPOVKey(player, warm, 0);
	sleep(0.001);
	jkPlayPOVKey(player, povfireAnim, 1, 0x38);
	FireProjectile(player, ball, fireSound, power, '0.02 0.15 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
	StopSound(bigsound,1);
	PlaySoundThing(fireSound,player,1,-1,10,0xC0);
	ChangeInv(player, 12, -1.0);
	DeactivateWeapon( player, 1 );
return;
pulse:
	power=power+1;
	If(power>=1000) power=1000;
	SetPOVShake('-0.01 -.001 0.0', '0.001 0.0 0.01', .05, 40.0);
return;
selected:
   player = GetSourceRef();

   // Play external mounting animation
   PlayMode(player, 41);

   // Setup the meshes and models.
   jkSetPOVModel(player, weapon);
   SetArmedMode(player, 1);
   jkSetWeaponMesh(player, weapmesh);
   jkSetWaggle(player, '10.0 7.0 0.0', 350);

   // Play mounting sound.
   bigsound=PlaySoundThing(mountSound, player, 1.0, -1, 10, 0xC0);
   ChangeSoundPitch(bigsound,.25,0.01);

   // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
   // The animation is held at the last frame after it is played.
   trackID=jkPlayPOVKey(player, mountAnim, 0, 20);
   SetMountWait(player, GetKeyLen(mountAnim));

   // Clear saber flags, and allow activation of the weapon
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 9);

   // Check Ammo - If we are out, autoselect best weapon.
   if(GetInv(player, 12) < 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);

   SetMountWait(player, 1);
   holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
   if (trackID != -1)
   {
      jkStopPOVKey(player, trackID, 0);
      trackID = -1;
   }
   jkSetWaggle(player, '0.0 0.0 0.0', 0);

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

   // If the player has the weapon
   if(GetInv(player, 9) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 12) > 1.0)
      {

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

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

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

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

         ReturnEx(-2.0);
         Return;

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

   Return;

end

How do I do so that the player doesn't get stuck on the holster anim?

/Edward
Edward's Cognative Hazards

↑ Up to the top!