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 → 3 round burst
3 round burst
2002-09-12, 11:24 PM #1
I got a problem implementing 3 round burst fire mode in my weapon cogs. I tried a fire/sleep/fire/sleep/fire approach, but that doesn't fire all three shots when the user taps the firebutton for a short time only. Then I tried to stick the firing code in a new message and call that in the fire message, but that's buggy as hell. Any other ideas on how to implement that?

------------------
"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-13, 12:18 PM #2
Fire w/o sleep, but that's not quite the same. [http://forums.massassi.net/html/frown.gif] I dunno.

------------------
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-09-13, 12:59 PM #3
I have a habit of ripping apart others cogs and mods to figure things out. So i'm gonna start this off with a thanks to SavageX and his ever-awsome SS3 [http://forums.massassi.net/html/smile.gif]

I tore his M-16 apart, examining the firing code, and came up with this burst-fire bryar example [http://forums.massassi.net/html/cool.gif]

I hope he doesn't mind... [http://forums.massassi.net/html/redface.gif]

Quote:
<font face="Verdana, Arial" size="2">
# Jedi Knight Cog Script
#
# WEAP_BRYAR.COG
#
# WEAPON SCRIPT 2 - Burstfire Bryar Pistol
#
# Supports normal and 'right-click burstfire' for example.
#
# [CYBER_Aeon]
#
symbols

model povModel=bryv.3do local
model weaponMesh=bryg.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 fireSound=pistol-1.wav local

template projectile=+bryarbolt local

thing player local
thing victim local
thing potential 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 dummy=0 local
int mode local
int holsterTrack local

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

end

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

code

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);
dummy = FireProjectile(player, projectile, fireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
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);

if ( mode == 0 ) ActivateWeapon( player, fireWait/powerBoost, mode );
if ( mode == 1 ) call burst_fire;

Return;

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

//
// Based on the M-16's Burstfire Code from SS3 - Thank you, SavageX [http://forums.massassi.net/html/smile.gif]
// Description: Fires a burst of 3 Bryar bolts, with a short delay between each shot.
//
burst_fire:
// SetMountWait(player, (fireWait1*3)/2);
call guncheck;
Sleep(fireWait1/2);
call guncheck;
Sleep(fireWait1/2);
call guncheck;
Sleep(fireWait1);
return;

guncheck:
if(GetInv(player, 11) <= 0)
{
PlaySoundThing(outSound, player, 1.0, -1.0, -1.0, 0x80);
ChangeFireRate(player, GetSoundLen(outSound)+0.1);
return;
}
else call gunfire;
return;

gunfire:
SetPOVShake('0.0 -.003 0.0', '1.0 0.0 0.0', .05, 80.0);
dummy = FireProjectile(player, projectile, fireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
ChangeInv(player, 11, -1.0);
jkPlayPOVKey(player, povfireAnim, 1, 0x38);

powerBoost = GetInv(player, 63);
ChangeFireRate(player, fireWait/powerBoost);

return;

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

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

jkSetWaggle(player, '10.0 7.0 0.0', 350);
DeactivateWeapon( player, mode );
Return;

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

selected:
player = GetSourceRef();

// Setup the meshes and models.
jkSetPOVModel(player, povModel);
jkSetWeaponMesh(player, weaponMesh);
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
</font>


Lemme know if that works or if it doesn't. Seems to, but worth double checking.
2002-09-14, 10:52 AM #4
That's it. You don't even activate the weapon. Thanks.

------------------
"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)

↑ Up to the top!