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 → Another Cog Problem
Another Cog Problem
2002-05-02, 3:45 PM #1
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]

------------------
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
2002-05-03, 5:01 AM #2
Any ideas? [http://forums.massassi.net/html/frown.gif] Hello, is anyone out there who can tell me this should work, anything on it at all? Help me, please. Anyone! [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
2002-05-05, 2:51 PM #3
Help me, Please. I'm begging on my knees, someone out there, help me, or this project might just go in the scrap pile. I don't want that. [http://forums.massassi.net/html/mad.gif] Help me Allie, or anyone!

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

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

Completed
Judgement Day (HLP), My level pack
2002-05-06, 4:55 PM #4
have you checked the syntax with a cog editor?

------------------
"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-05-06, 5:34 PM #5
Tried it, came up clean on all three of them. Thanks for the thought

------------------
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
2002-05-07, 2:06 AM #6
And btw, you should consider rethinking the whole way you are zooming. The way you currently implemented is very bad for MP. Better use fixed steps (2x, 4x, 8x, maybe) and concentrate on creating some decent new crosshairs or a nice scope effect...
It's anyway not very realistic to have a "smoothly" zooming in. Actual sniper rifles use fixed steps.

------------------
"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-05-07, 4:13 AM #7
Good point. That should make it easier for the cogging, thank you very very much. [http://forums.massassi.net/html/biggrin.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
2002-05-08, 12:23 PM #8
That's what these forums are for. And I'd like to see your final work, if allowed (tried myself to create a sniper rifle in 2 mods, PWP1 + 2, but failed at both).

------------------
"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-05-08, 3:46 PM #9
As soon as I finish it, I'll let you be the first one to beta test my levels. When I say finish it, means in a few hours from this post.

------------------
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
2002-05-10, 2:53 AM #10
Have you received my e-mail?

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)

[This message has been edited by zagibu (edited May 10, 2002).]
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-05-10, 4:00 AM #11
Yep, I'll be sending the entire project folder to you.

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

↑ Up to the top!