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 → Charge weapon cog with sounds
Charge weapon cog with sounds
2000-12-16, 12:12 PM #1
Hi!

I'm trying to do a charge weapon. The charging itself went fine, but I've problems with the sound. When charging up the weapon, after about 2 seconds there should be an other sound (completely different .wav file). Can anybody help me doing the source code? I need just the changes for the sound, it doesn't seem to work with "delayTime".
2000-12-18, 10:54 AM #2
could you post the weapon cog up?
2000-12-21, 8:21 AM #3
Ok, here you go:


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
sound fireSound1=powershot.wav local
sound chargeSound=charge.wav local
sound chargeSound1=charge_max.wav local


template projectile=+bryarbolt local
template projectile2=+force_dest_p4 local
template projectile1=+crossbowbolt2 local


flex fireWait=0.4 local
flex delayTime local
flex error local
flex autoAimFOV=25 local
flex autoAimMaxDist=4 local
flex powerBoost local
flex holsterWait local

vector errorVec local

thing player local

int trackID=-1 local
int channel=-1 local
int holsterTrack local

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

end

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

code

startup:
player = GetLocalPlayerThing();

Return;

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

activated:
mode = GetSenderRef();

jkSetWaggle(player, '0.0 0.0 0.0', 0);

// Check Ammo - If we are out, autoselect best weapon.
if(GetInv(player, 11) < 1.0)
{
if((GetAutoSwitch() & 1))
SelectWeapon(player, AutoSelectWeapon(player, 1));
else
PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);

Return;
}

if(mode == 1)
{

delayTime = ActivateWeapon(player, 0, mode);

Set(delayTime == 0);
ActivateWeapon(player, 0, mode);

if(channel == -1)
{
channel = PlaySoundThing(chargeSound, player, 0.0, -1, -1, 0x181);

{if(delayTime > 2.602)

{if(channel != -1)
{
StopSound(channel, 0);
channel = -1;
}
}
{if(channel == -1)
{

channel = PlaySoundThing(chargeSound1, player, 0.0, -1, -1, 0x181);

if(channel != -1)
{
ChangeSoundPitch(channel, 1.0, 1.0);
Sleep(0.0000001);

// looks stupid... but if the user taps quickly deactivated:
// gets called during the sleep, and channel becomes invalid !
if(channel != -1)
{
ChangeSoundVol(channel, 1.0, 1.0);
ChangeSoundPitch(channel, 1.0, 1.0);
}
}
}
}

}

if(channel != -1)
{
ChangeSoundPitch(channel, 1.0, 1.0);
Sleep(0.0000001);

// looks stupid... but if the user taps quickly deactivated:
// gets called during the sleep, and channel becomes invalid !
if(channel != -1)
{
ChangeSoundVol(channel, 1.0, 1.0);
ChangeSoundPitch(channel, 1.0, 1.0);
}
}
}
}




#--------
else
{
powerBoost = GetInv(player, 63);
ActivateWeapon( player, fireWait/powerBoost, mode);
}

Return;

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

fire:


if (mode == 0)
{

// 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) < 2.0)
{
SelectWeapon(player, AutoSelectWeapon(player, 1));
Return;
}

SetPOVShake('0.0 -.01 0.0', '2.0 0.0 0.0', .05, 80.0);

dummy = FireProjectile(player, projectile, fireSound, 18, '0.0207 0.0888 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimFOV*2);
ChangeInv(player, 11, 0.0);

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

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


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

deactivated:
mode = GetSenderRef();

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

if(mode == 1)
{
delayTime = DeactivateWeapon(player, mode);

if(channel != -1)
{
StopSound(channel, 0);
channel = -1;
}

// Set a delay, even if we don't fire here.
SetMountWait(player, fireWait/powerBoost);

// Make sure both keys are up before continuing.
if (GetCurWeaponMode() != -1) Return;

// make sure we still have ammo
if(GetInv(player, 11) < 1.0) Return;

if(delayTime < 1.0)
{
if(GetInv(player, 11) > 1.0)
{
FireProjectile(player, projectile, fireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
// Play animation and set delay.
jkPlayPOVKey(player, povfireAnim, 1, 0x38);


}
}

if(delayTime > 1.0)
{

if(delayTime < 2.2)
{
if(GetInv(player, 11) > 1.0)
{
FireProjectile(player, projectile1, fireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
// Play animation and set delay.
jkPlayPOVKey(player, povfireAnim, 1, 0x38);

}
}

if(delayTime > 2.2)
{
if(GetInv(player, 11) > 1.0)
{
FireProjectile(player, projectile2, fireSound1, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
// Play animation and set delay.
jkPlayPOVKey(player, povfireAnim, 1, 0x38);


}
}


}

}
else
{
DeactivateWeapon(player, mode);
}

Return;

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

selected:
// Play external animation
PlayMode(player, 41);

// Set up meshes and models.
jkSetPOVModel(player, povModel);
SetArmedMode(player, 1);
jkSetWeaponMesh(player, weaponMesh);
jkSetWaggle(player, '10.0 7.0 0.0', 350);

// Play sound and animation.
PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
SetMountWait(player, GetKeyLen(mountAnim));

// Set flags, etc.
jkClearFlags(player, 0x5);
SetCurWeapon(player, 2);

// Check Ammo - If we are out, autoselect best weapon.
if(GetInv(player, 11) < 1.0)
{
if((GetAutoSwitch() & 1))
SelectWeapon(player, AutoSelectWeapon(player, 1));
}

Return;

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

deselected:
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);

if(channel != -1)
{
StopSound(channel, 0.1);
channel = -1;
}

Return;

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

killed:
if (player == GetSenderRef())
{
if(channel != -1)
{
StopSound(channel, 0.1);
channel = -1;
}
}
Return;

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

newplayer:
// // Make sure that if the player is respawning, the old mount isn't playing anymore.
// if (trackID != -1)
// {
// jkStopPOVKey(player, trackID, 0);
// trackID = -1;
// }

if(channel != -1)
{
StopSound(channel, 0.1);
channel = -1;
}

Return;

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

autoselect:
// If the player has the weapon
if(GetInv(player, 2) != 0.0)
{
// If the player has ammo
if(GetInv(player, 11) > 0.0)
{
ReturnEx(700.0);
}
else
{
ReturnEx(-1.0);
}
}
else
{
ReturnEx(-1.0);
}

Return;

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

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

end


It looks a bit like the JK Blastech COG, because I looked into their source code to find out how to make the sound stop, but the rest is mine. As said, after about 2 seconds the charging sound should be another wav file, and the volume should be continously on one level and not rise. I don't know how to do that.
2000-12-21, 8:56 AM #4
I may be wrong, but I don't think you can't raise volume in cog.

------------------
All that is gold does not glitter, Not all those who wander are lost; The old that is strong does not wither,
Deep roots are not reached by the frost. From the ashes a fire shall be woken, A light from the shadows shall spring; Renewed shall be blade that was broken, The crownless again shall be king.

[This message has been edited by Aglar (edited December 21, 2000).]

↑ Up to the top!