with an advanced question.
Requirements - This one is not for the simple cogger, you must be familiar and crafty with the use of sounds.
Background - I'm creating a sniper rifle cog for my mods and System Overrides' mod. This is totally different then what you've seen before because of certain characteristics, and you're going to help me with one.
The problem/question - to cancel out all of the sounds that the ghost fired would hear and play the sounds that the player would normally hear, so that the user will be able to hear them as if the user was the player, not the scope's ghost (perferably local).
The cog so far (inc right now, but scope can be tested).
------------------
The Sniper Missions. Current project, The Sniper Missions
The Magician Saber System.
[This message has been edited by Descent_pilot (edited April 23, 2003).]
Requirements - This one is not for the simple cogger, you must be familiar and crafty with the use of sounds.
Background - I'm creating a sniper rifle cog for my mods and System Overrides' mod. This is totally different then what you've seen before because of certain characteristics, and you're going to help me with one.
The problem/question - to cancel out all of the sounds that the ghost fired would hear and play the sounds that the player would normally hear, so that the user will be able to hear them as if the user was the player, not the scope's ghost (perferably local).
The cog so far (inc right now, but scope can be tested).
Code:
All ideas are welcome.# Jedi Knight Cog Script
#
# WEAP_CONCRIFLE.COG
#
# WEAPON 9 Script - Sniper Rifle
#
# Sniper Rifle
#
# - Not affected by MagSealed sectors/surfaces.
#
# [DP]
#
symbols
model povModel=conv.3do local
model weaponMesh=cong.3do local
keyframe mountAnim=ConVmnt.key local
keyframe dismountAnim=ConVdis.key local
keyframe povfireAnim=ConVpst1.key local
keyframe holsterAnim=kyhlstr.key local
sound mountSound=df_rif_ready.wav local
sound dismountSound=PutWeaponAway01.wav local
sound fireSound=srfire.wav local
sound outSound=concuss1.wav local
sound zoomSound=scope.wav local
flex fireWait=1.5 local
flex powerBoost local
flex autoAimFOV=30 local
flex autoAimMaxDist=5 local
flex holsterWait local
int dummy local
template projectile=+concbullet local
template camera=+zoom local
thing player local
int trackID=-1 local
int mode local
int holsterTrack local
int selectMode=1 local
flex mag=0.25 local
flex zoom=0 local
flex temp local
int reloading=0 local
int moving=0 local
int count=0 local
int scope=-1 local
int oldCam local
int on=0 local
int zoomChannel=-1 local
vector tempVec local
vector zoomVec local
message activated
message deactivated
message selected
message deselected
message autoselect
message user1
message timer
message pulse
end
# ========================================================================================
code
User1:
If(reloading) Return;
// Check that the player is still alive.
If(GetThingHealth(player) <= 0)
Return;
// Check Ammo - If we are out, autoselect best weapon.
If(GetInv(player, 12) < 1)
{
PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
if(GetAutoSwitch() & 1)
SelectWeapon(player, AutoSelectWeapon(player, 1));
Return;
}
SetPOVShake('0 -.03 0', '4 0 0', .05, 80);
FireProjectile(player, projectile, fireSound, 8, '0.02 0.15 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
ChangeInv(player, 12, -1);
reloading = 1;
jkPlayPOVKey(player, povfireAnim, 1, 0x38);
// Provide a kick backwards
ApplyForce(player, VectorScale(GetThingLVec(player), -80));
powerBoost = GetInv(player, 63);
SetTimerEx(fireWait/powerBoost, 1, 0, 0);
Return;
# ........................................................................................
Activated:
player = GetSourceRef();
mode = GetSenderRef();
If(!on)
{
oldCam = GetCurrentCamera();
If(mode == 1) mag = 5;
}
jkSetWaggle(player, '0 0 0', 0);
zoomChannel = PlaySoundLocal(zoomSound, 1, 0, 0x1);
count = 0;
moving = 1;
on = 1;
zoom = .5 - mode;
SetPulse(0.01);
Return;
# ........................................................................................
Deactivated:
player = GetSourceRef();
mode = GetSenderRef();
jkSetWaggle(player, '10 7 0', 350);
moving = 0;
If(zoomChannel != -1)
{
StopSound(zoomChannel, 0);
zoomChannel = -1;
}
If(count <= 2) // If the zoom keys are tapped
{
If(mode == 1)
{
If(mag < 5) call scope_off;
Else mag = 2.5;
}
Else
{
If(mag < 2.5) mag = 2.5;
Else If(mag < 5) mag = 5;
Else call scope_off;
}
}
Return;
# ........................................................................................
Selected:
player = GetSourceRef();
// Play external mounting animation
PlayMode(player, 41);
// Setup the meshes and models.
jkSetPOVModel(player, povModel);
SetArmedMode(player, 1);
jkSetWeaponMesh(player, weaponMesh);
jkSetWaggle(player, '10.0 7.0 0.0', 350);
// Play mounting sound.
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, 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) < 2)
{
PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
if(GetAutoSwitch() & 1)
SelectWeapon(player, AutoSelectWeapon(player, 1));
}
mag = 0.25;
If(reloading) SetTimerEx(fireWait/powerBoost, 1, 0, 0);
Return;
# ........................................................................................
Deselected:
player = GetSourceRef();
If(on) call scope_off;
If(reloading) KillTimerEx(1);
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);
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 the weapon
if(GetInv(player, 9) != 0.0)
{
// If the player has ammo
if(GetInv(player, 12) > 7.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;
# ........................................................................................
Timer:
If(GetSenderID() == 1)
{
reloading = 0;
Return;
}
StopKey(player, holsterTrack, 0.0);
Return;
# ........................................................................................
Scope_off:
If(zoomChannel != -1)
{
StopSound(zoomChannel, 0);
zoomChannel = -1;
}
SetPulse(0);
mag = 0.25;
on = 0;
SetCameraFocus(0, player);
If(oldCam) CycleCamera();
Return;
#.........................................................................................
Pulse:
If(GetThingHealth(player) <= 0)
{
call scope_off;
Return;
}
If(GetCurrentCamera()) CycleCamera();
If(moving)
{
mag = mag + zoom * count * 0.005;
If(mag > 5) mag = 5;
If(mag < .25) mag = .25;
count = count + 1;
}
zoomVec = VectorSet(0, mag, 0.037);
If(mag <= 0.25 && zoom < 0)
{
call scope_off;
Return;
}
scope = FireProjectile(player, camera, -1, -1, zoomVec, '0 0 0', 1, 0, 0, 0);
temp = mag;
// This is to see if the scope thing is on the direct straight ahead line from the player
// The reason is that the scope slides one way or another when the mag gets too great
While(VectorSub(GetThingPos(scope), GetThingPos(player)) != GetThingLVec(player))
{
temp = temp - .005;
zoomVec = VectorSet(0, temp, 0.037);
DestroyThing(scope);
scope = FireProjectile(player, camera, -1, -1, zoomVec, '0 0 0', 1, 0, 0, 0);
}
tempVec = VectorAdd(GetThingPos(scope), VectorScale(VectorNorm(GetThingLVec(scope)), -0.1));
SetThingPos(scope, tempVec);
SetCameraFocus(0, scope);
Return;
end------------------
The Sniper Missions. Current project, The Sniper Missions
The Magician Saber System.
[This message has been edited by Descent_pilot (edited April 23, 2003).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms
Completed
Judgement Day (HLP), My level pack
SATNRT, JK Pistol Mod, Aliens TC, Firearms
Completed
Judgement Day (HLP), My level pack
![http://forums.massassi.net/html/frown.gif [http://forums.massassi.net/html/frown.gif]](http://forums.massassi.net/html/frown.gif)
![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)