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 → Autoswitch
Autoswitch
2002-09-23, 11:11 AM #1
I got problems with my weapons being automatically deselected when they are out of ammo. The following code works, but there is always a one second delay which is not with JK's original cogs. Please tell me what I'm doing wrong:
Code:
IN THE FIRE MESSAGE

if(GetInv(player, 12) < 5)
	{
		// Play "out of ammo" sound
		PlaySoundThing(outSound, player, 1, -1, -1, 0x80);
		if(GetAutoSwitch() & 1)
			SelectWeapon(player, AutoSelectWeapon(player, 1));
		Return;
	}


------------------
"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)
2002-09-23, 11:18 AM #2
I don't see anything wrong with that code. Make sure there's no delay in the selected message of the weapon that JK selects or in any autoselect message (though i doubt that would cause the problem).

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-09-23, 4:08 PM #3
Make sure auto-switch is on. Edit - in STRifle cogs, it has double () in the arguments of the If statement. Like this, for those who need example [http://forums.massassi.net/html/tongue.gif] If((GetAutoSwitch() & 1)) [http://forums.massassi.net/html/wink.gif]

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

The Magician Saber System.

[This message has been edited by Descent_pilot (edited September 23, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-09-23, 11:16 PM #4
Autoswitch is on. The problem only occurs when you run out of ammo. There's no delay when you normally select another weapon. Here is my autoselect and deselected code:
Code:
autoselect:
	player = GetSourceRef();

	// If the player has the weapon
	if(GetInv(player, 5) != 0)
	{
		// If the player has ammo
		if(GetInv(player, 12) >= 5)
		{
			// Set the crossbow as available
			ReturnEx(700);
		}
		else
		{
			// Return failure
			ReturnEx(-1);
		}
	}
	else
	{
		// Return failure
		ReturnEx(-1);
	}

	Return;

Code:
deselected:
	player = GetSourceRef();

	if(zoom != 0)
		call zoomout;

	// Play dismounting sound
	PlaySoundThing(dismountSound, player, 1, -1, -1, 0x80);

	// Play internal dismounting animation
	jkPlayPOVKey(player, dismountAnim, 0, 0x18);

	// Play external dismounting animation
	holsterWait = GetKeyLen(holsterAnim);
	SetMountWait(player, holsterWait);
	holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
	SetTimerEx(holsterWait, 2, 0, 0);
	if (trackID != -1)
	{
		jkStopPOVKey(player, trackID, 0);
		trackID = -1;
	}

	// Disable the waggle
	jkSetWaggle(player, '0 0 0', 0);

	Return;

It's a bowcaster replacement (weapon #5), BTW.


------------------
"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)
2002-09-24, 7:19 AM #5
Pilot, parentheses only raise an operation's precedence, they don't change the returned value.

Zagibu, does the delay stop the weapon from mounting, firing, or both? If the delay only prevents firing, check for any SetFireWait() commands that may run on deselected or selected. Since SetMountWait() does not affect verbs like SelectWeapon(), it can't be a problem.

Also, check to see whether the new weapon's selected message runs before or after the delay.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-09-24, 8:17 AM #6
The delay is between the deselection of the current weapon and the selection of the new one. It's shorter than one second, but still recognizable. The deselection animation loops during this delay, which looks kind of stupid. If you want to have a closer look, let me know, and I send you the cog. Thanks for your help so far.

------------------
"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)
2002-09-24, 10:41 AM #7
Alright, send me the weapon cog, and I'll see what I can find. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-09-24, 10:53 AM #8
Hmm, I just experienced the same delay with weapon #9, which is the (untouched) LEC concrifle. Any ideas what the heck (not necessarily cog) could cause such a delay?

------------------
"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)
2002-09-24, 11:27 AM #9
Wow, I just created a weapon cog, which has the above mentioned delay when running out of ammo in the secondary fire mode only.

------------------
"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)
2002-09-24, 11:51 AM #10
I was wrong. It is not happening with LEC's weapons. The delay only occurs in my own cogs. Damn it. Maybe it has to do with the loop key flags...

------------------
"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)
2002-09-24, 11:59 AM #11
Ok, I got it. There is still a small delay, but that doesn't matter. The deselect animation loops no more. I just changed the keyframe flags in jkPlayPOVKey() to 0x38, et voilà. That easy.

------------------
"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)
2002-09-26, 5:01 AM #12
I've had this problem with my weapons as well, and I believe it also occurs in LECs own cogs too (although less frequently)

I fixed it the same way you did, by turning off the looping flag on the POV deselection keys animation.
2002-09-26, 6:37 AM #13
Wave, it's because JK has firewait problems when you try to select a new weapon while the current one is still firing. Use SetFireWait(player, 0) before SelectWeapon() command in the fire message.

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

↑ Up to the top!