This cog is a big cog, its the main sniper rifle cog. The smaller cog is for the sending of the message and an almost identical one for the increase. When I use it, the cog only goes to the far point, and the near point, and I can't get it to stop inbetween. What's wrong with it, or is there a better, fast, and/or easier way of doing this?
# Jedi Knight Cog Script
#
# WEAP_SNIPER.COG
#
# WEAPON 5 Script - Sniper Rifle
#
# - Affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
model povModel=sniv.3do local
model weaponMesh=snip.3do local
keyframe mountAnim=BowVmnt.key local
keyframe dismountAnim=BowVdis.key local
keyframe povfireAnim=BowVpst1.key local
keyframe holsterAnim=kyhlstr.key local
sound mountSound=df_bry_ready.wav local
sound dismountSound=PutWeaponAway01.wav local
sound outSound=trprout.wav local
template projectile=+snipershot local
flex fireWait=0.6 local
flex delayTime local
flex error local
flex autoAimFOV=30 local
flex autoAimMaxDist=10 local
flex powerBoost local
flex holsterWait local
vector errorVec local
thing player local
int trackID=-1 local
int channel=-1 local
int holsterTrack local
int scope=0 local
int old_cam local
int Stay local
int Dummy local
int Zoom=1 local
int ZoomCount local
flex ZoomMag=0.15 local
vector ZoomFactor local
vector Temp_Vector local
template CameraTpl=+zoom_cam local
message startup
message activated
message deactivated
message selected
message deselected
message newplayer
message autoselect
message fire
message killed
message timer
message pulse
message user0
message user1
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, 12) < 2.0)
{
if((GetAutoSwitch() & 1))
SelectWeapon(player, AutoSelectWeapon(player, 1));
else
PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
Return;
}
if(mode == 0)
{
ActivateWeapon(player, 0, mode);
if(channel == -1)
{
channel = PlaySoundThing(-1, player, 0.0, -1, -1, 0x181);
if(channel != -1)
{
ChangeSoundPitch(channel, 0.3, 0.01);
Sleep(0.03);
// 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, 0.6);
ChangeSoundPitch(channel, 1.0, 1.2);
}
}
}
}
else
{
powerBoost = GetInv(player, 63);
ActivateWeapon( player, fireWait/powerBoost, mode);
}
Return;
# ........................................................................................
fire:
// 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) < 0.0)
{
SelectWeapon(player, AutoSelectWeapon(player, 1));
Return;
}
if(scope == 0)
{
old_cam = GetCurrentCamera();
if(GetCurrentCamera() == 1) CycleCamera();
EnableIRMode(0.5, 1);
ZoomMag = 0.15;
ZoomCount = 0;
Stay = 1;
SetPulse(0.01);
scope = 1;
}
else
if(scope == 1)
{
DisableIRMode();
ZoomMag = 0.15;
SetPulse(0.0);
SetCameraFocus(0, player);
if((old_cam == 1) && (GetCurrentCamera() != 1)) CycleCamera();
scope = 0;
}
powerBoost = GetInv(player, 63);
ChangeFireRate(player, fireWait/powerBoost);
Return;
# ........................................................................................
deactivated:
mode = GetSenderRef();
jkSetWaggle(player, '10.0 7.0 0.0', 350);
if(mode == 0)
{
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, 12) < 1.0) Return;
if(scope == 1)
{
FireProjectile(player, projectile, -1, 8, '0.00 0.00 0.037', '0 0 0', 0, 0, autoAimFOV, autoAimFOV*2);
ChangeInv(player, 12, -2.0);
}
else
if(scope == 0)
{
// Always fire one projectile straight-ahead
SetPOVShake('0.0 -.01 0.0', '2.0 0.0 0.0', .05, 80.0);
FireProjectile(player, projectile, -1, 8, '0.0168 0.1896 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimFOV*2);
ChangeInv(player, 12, -1.0);
if(delayTime > 0.6)
{
if(GetInv(player, 12) > 1.0)
{
FireProjectile(player, projectile, -1, 8, '0.0168 0.1896 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimMaxDist);
FireProjectile(player, projectile, -1, 8, '0.0168 0.1896 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimMaxDist);
ChangeInv(player, 12, -1.0);
}
}
if(delayTime > 1.2)
{
if(GetInv(player, 12) > 1.0)
{
FireProjectile(player, projectile, -1, 8, '0.0168 0.1896 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimMaxDist);
FireProjectile(player, projectile, -1, 8, '0.0168 0.1896 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimMaxDist);
ChangeInv(player, 12, -1.0);
}
}
// Play animation and set delay.
jkPlayPOVKey(player, povfireAnim, 1, 0x20);
}
powerBoost = GetInv(player, 63);
}
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, 5);
scope = 0;
// Check Ammo - If we are out, autoselect best weapon.
if(GetInv(player, 12) < 2.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;
}
scope = 1;
call fire;
Return;
# ........................................................................................
killed:
if (player == GetSenderRef())
{
if(channel != -1)
{
StopSound(channel, 0.1);
channel = -1;
}
}
scope = 1;
call fire;
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, 5) != 0.0)
{
// If the player has ammo
if(GetInv(player, 12) > 1.0)
{
ReturnEx(700.0);
}
else
{
ReturnEx(-1.0);
}
}
else
{
ReturnEx(-1.0);
}
Return;
# ........................................................................................
timer:
StopKey(player, holsterTrack, 0.0);
Return;
# ........................................................................................
pulse:
if(GetCurrentCamera() == 1) CycleCamera();
if(!Stay)
{
if(Zoom)
{
ZoomMag = ZoomMag + ZoomCount * 0.005;
if(ZoomMag > 15) ZoomMag = 15;
}
else
{
ZoomMag = ZoomMag - ZoomCount * 0.005;
if(ZoomMag < 0.15) ZoomMag = 0.15;
}
ZoomFactor = VectorSet(0, ZoomMag, 0.037);
ZoomCount = ZoomCount + 1;
}
Dummy = FireProjectile(player, CameraTpl, -1, -1, ZoomFactor, '0 0 0', 0, 0, 0, 0);
Temp_Vector = VectorAdd(GetThingPos(Dummy), VectorScale(VectorNorm(GetThingLVec(Dummy)), -0.1));
SetThingPos(Dummy, Temp_Vector);
if(GetCurrentCamera() == 1) CycleCamera();
SetCameraFocus(0, Dummy);
Return;
# ........................................................................................
User0:
If(GetInv(player,116))
{
Zoom = 1;
ZoomCount = 0;
Stay = 0;
}
else
{
Stay = 1;
}
Return;
# ........................................................................................
User1:
If(GetInv(player,117))
{
Zoom = 0;
ZoomCount = 0;
Stay = 0;
}
else
{
Stay = 1;
}
Return;
end
Here's the second cog
# Jedi Knight Cog Script
#
# ZOOM_DECREASE.COG
#
# Activates the Zoom Out fuction on the Sniper Rifle.
#
# This Cog is Not supported by LucasArts Entertainment Co
symbols
thing player local
message activated
message deactivated
end
# ========================================================================================
code
activated:
player = GetLocalPlayerThing();
if(GetCurWeapon(player) == 5)
{
SetInv(player, 117, 1);
SendMessage(GetInvCog(player, 5), user1);
}
Return;
deactivated:
player = GetLocalPlayerThing();
if(GetCurWeapon(player) == 5)
{
SetInv(player, 117, 0);
SendMessage(GetInvCog(player, 5), user1);
}
Return;
end
Help Me!![http://forums.massassi.net/html/confused.gif [http://forums.massassi.net/html/confused.gif]](http://forums.massassi.net/html/confused.gif)
------------------
The Sniper Missions. Current project, The X Project
# Jedi Knight Cog Script
#
# WEAP_SNIPER.COG
#
# WEAPON 5 Script - Sniper Rifle
#
# - Affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
model povModel=sniv.3do local
model weaponMesh=snip.3do local
keyframe mountAnim=BowVmnt.key local
keyframe dismountAnim=BowVdis.key local
keyframe povfireAnim=BowVpst1.key local
keyframe holsterAnim=kyhlstr.key local
sound mountSound=df_bry_ready.wav local
sound dismountSound=PutWeaponAway01.wav local
sound outSound=trprout.wav local
template projectile=+snipershot local
flex fireWait=0.6 local
flex delayTime local
flex error local
flex autoAimFOV=30 local
flex autoAimMaxDist=10 local
flex powerBoost local
flex holsterWait local
vector errorVec local
thing player local
int trackID=-1 local
int channel=-1 local
int holsterTrack local
int scope=0 local
int old_cam local
int Stay local
int Dummy local
int Zoom=1 local
int ZoomCount local
flex ZoomMag=0.15 local
vector ZoomFactor local
vector Temp_Vector local
template CameraTpl=+zoom_cam local
message startup
message activated
message deactivated
message selected
message deselected
message newplayer
message autoselect
message fire
message killed
message timer
message pulse
message user0
message user1
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, 12) < 2.0)
{
if((GetAutoSwitch() & 1))
SelectWeapon(player, AutoSelectWeapon(player, 1));
else
PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
Return;
}
if(mode == 0)
{
ActivateWeapon(player, 0, mode);
if(channel == -1)
{
channel = PlaySoundThing(-1, player, 0.0, -1, -1, 0x181);
if(channel != -1)
{
ChangeSoundPitch(channel, 0.3, 0.01);
Sleep(0.03);
// 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, 0.6);
ChangeSoundPitch(channel, 1.0, 1.2);
}
}
}
}
else
{
powerBoost = GetInv(player, 63);
ActivateWeapon( player, fireWait/powerBoost, mode);
}
Return;
# ........................................................................................
fire:
// 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) < 0.0)
{
SelectWeapon(player, AutoSelectWeapon(player, 1));
Return;
}
if(scope == 0)
{
old_cam = GetCurrentCamera();
if(GetCurrentCamera() == 1) CycleCamera();
EnableIRMode(0.5, 1);
ZoomMag = 0.15;
ZoomCount = 0;
Stay = 1;
SetPulse(0.01);
scope = 1;
}
else
if(scope == 1)
{
DisableIRMode();
ZoomMag = 0.15;
SetPulse(0.0);
SetCameraFocus(0, player);
if((old_cam == 1) && (GetCurrentCamera() != 1)) CycleCamera();
scope = 0;
}
powerBoost = GetInv(player, 63);
ChangeFireRate(player, fireWait/powerBoost);
Return;
# ........................................................................................
deactivated:
mode = GetSenderRef();
jkSetWaggle(player, '10.0 7.0 0.0', 350);
if(mode == 0)
{
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, 12) < 1.0) Return;
if(scope == 1)
{
FireProjectile(player, projectile, -1, 8, '0.00 0.00 0.037', '0 0 0', 0, 0, autoAimFOV, autoAimFOV*2);
ChangeInv(player, 12, -2.0);
}
else
if(scope == 0)
{
// Always fire one projectile straight-ahead
SetPOVShake('0.0 -.01 0.0', '2.0 0.0 0.0', .05, 80.0);
FireProjectile(player, projectile, -1, 8, '0.0168 0.1896 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimFOV*2);
ChangeInv(player, 12, -1.0);
if(delayTime > 0.6)
{
if(GetInv(player, 12) > 1.0)
{
FireProjectile(player, projectile, -1, 8, '0.0168 0.1896 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimMaxDist);
FireProjectile(player, projectile, -1, 8, '0.0168 0.1896 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimMaxDist);
ChangeInv(player, 12, -1.0);
}
}
if(delayTime > 1.2)
{
if(GetInv(player, 12) > 1.0)
{
FireProjectile(player, projectile, -1, 8, '0.0168 0.1896 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimMaxDist);
FireProjectile(player, projectile, -1, 8, '0.0168 0.1896 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimMaxDist);
ChangeInv(player, 12, -1.0);
}
}
// Play animation and set delay.
jkPlayPOVKey(player, povfireAnim, 1, 0x20);
}
powerBoost = GetInv(player, 63);
}
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, 5);
scope = 0;
// Check Ammo - If we are out, autoselect best weapon.
if(GetInv(player, 12) < 2.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;
}
scope = 1;
call fire;
Return;
# ........................................................................................
killed:
if (player == GetSenderRef())
{
if(channel != -1)
{
StopSound(channel, 0.1);
channel = -1;
}
}
scope = 1;
call fire;
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, 5) != 0.0)
{
// If the player has ammo
if(GetInv(player, 12) > 1.0)
{
ReturnEx(700.0);
}
else
{
ReturnEx(-1.0);
}
}
else
{
ReturnEx(-1.0);
}
Return;
# ........................................................................................
timer:
StopKey(player, holsterTrack, 0.0);
Return;
# ........................................................................................
pulse:
if(GetCurrentCamera() == 1) CycleCamera();
if(!Stay)
{
if(Zoom)
{
ZoomMag = ZoomMag + ZoomCount * 0.005;
if(ZoomMag > 15) ZoomMag = 15;
}
else
{
ZoomMag = ZoomMag - ZoomCount * 0.005;
if(ZoomMag < 0.15) ZoomMag = 0.15;
}
ZoomFactor = VectorSet(0, ZoomMag, 0.037);
ZoomCount = ZoomCount + 1;
}
Dummy = FireProjectile(player, CameraTpl, -1, -1, ZoomFactor, '0 0 0', 0, 0, 0, 0);
Temp_Vector = VectorAdd(GetThingPos(Dummy), VectorScale(VectorNorm(GetThingLVec(Dummy)), -0.1));
SetThingPos(Dummy, Temp_Vector);
if(GetCurrentCamera() == 1) CycleCamera();
SetCameraFocus(0, Dummy);
Return;
# ........................................................................................
User0:
If(GetInv(player,116))
{
Zoom = 1;
ZoomCount = 0;
Stay = 0;
}
else
{
Stay = 1;
}
Return;
# ........................................................................................
User1:
If(GetInv(player,117))
{
Zoom = 0;
ZoomCount = 0;
Stay = 0;
}
else
{
Stay = 1;
}
Return;
end
Here's the second cog
# Jedi Knight Cog Script
#
# ZOOM_DECREASE.COG
#
# Activates the Zoom Out fuction on the Sniper Rifle.
#
# This Cog is Not supported by LucasArts Entertainment Co
symbols
thing player local
message activated
message deactivated
end
# ========================================================================================
code
activated:
player = GetLocalPlayerThing();
if(GetCurWeapon(player) == 5)
{
SetInv(player, 117, 1);
SendMessage(GetInvCog(player, 5), user1);
}
Return;
deactivated:
player = GetLocalPlayerThing();
if(GetCurWeapon(player) == 5)
{
SetInv(player, 117, 0);
SendMessage(GetInvCog(player, 5), user1);
}
Return;
end
Help Me!
![http://forums.massassi.net/html/confused.gif [http://forums.massassi.net/html/confused.gif]](http://forums.massassi.net/html/confused.gif)
------------------
The Sniper Missions. Current project, The X Project
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
Hello, is anyone out there who can tell me this should work, anything on it at all? Help me, please. Anyone!
Help me Allie, or anyone!![http://forums.massassi.net/html/biggrin.gif [http://forums.massassi.net/html/biggrin.gif]](http://forums.massassi.net/html/biggrin.gif)