For the past month I've been working on a JK TC. The main feature of it will be a MotS-style weapons system. Instead of pressing a number twice, you use a hotkey to switch to the secondary weapon.
However, I am not the best with cogs and I've run into an error with the fists cog I don't know how to fix.
First of all, here's the weap_fists cog:
This cog has fists as the primary weapon, and kick as it's secondary fire. Vibroblade(alias Saber & Knife) is the secondary weapon.
Now, the problem. In my last cog post I was asking how to stop the glow - Vibroblade didn't need it. Well, changing the jksetflags in the timer message of Weap_saber from 0x5 to 0x1 did that, but somehow that got screwed up when I had two saber cogs.
So, could you look my cog over and tell me how to fix my lighting problem and any other errors that it has?
Thanks![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)
------------------
Yub-Yub, Commander.
[This message has been edited by SaberMaster (edited March 31, 2001).]
[This message has been edited by Hideki (edited April 03, 2001).]
However, I am not the best with cogs and I've run into an error with the fists cog I don't know how to fix.
First of all, here's the weap_fists cog:
Code:
# Jedi Knight Cog Script
#
#This cog is Not supported by LEC.
symbols
#Models#
model povModel1=fistv.3do local
model weaponMesh1=fistg.3do local
model povModel2=vibrov.3do local
model saberMesh2=vibrog.3do local
# POV Keyframes#
keyframe FpovfireAnim1=FistVl.key local
keyframe FpovfireAnim2=FistVr.key local
keyframe mountAnim=SabVmnt.key local
keyframe dismountAnim=SabVdis.key local
keyframe holdAnim=SabVhold.key local
keyframe povSnapAnim1=SabVf1.key local
keyframe povSnapAnim2=SabVf2.key local
keyframe povSnapAnim3=SabVf1.key local
keyframe povPreFireAnim=SabVrdy.key local
keyframe povFireAnimF1=SabVsnp1.key local
keyframe povFireAnimF2=SabVsnp2.key local
keyframe povFireAnimB1=SabVb1.key local
keyframe povFireAnimB2=SabVb2.key local
keyframe povFireAnimL1=SabVl1.key local
keyframe povFireAnimR1=SabVr1.key local
keyframe povChargeAnim=SabVch.key local
# External Keyframes#
keyframe FmountAnim=FistVmnt.key local
keyframe FdismountAnim=FistVdis.key local
keyframe kick=kick.key local
keyframe preFireAnimL=KYreadyl.key local
keyframe preFireAnimR=KYreadyr.key local
keyframe fireAnimF1=KYsnap1.key local
keyframe fireAnimF2=KYsnap2.key local
keyframe fireAnimB1=KYsabrb1.key local
keyframe fireAnimB2=KYsabrb2.key local
keyframe fireAnimL1=KYsabrl1.key local
keyframe fireAnimR1=KYsabrr1.key local
keyframe snapAnim1=KYsabrf1.key local
keyframe snapAnim2=KYsabrf2.key local
keyframe snapAnim3=KYsabrf1.key local
keyframe chargeAnim=KYcharge.key local
keyframe holsterAnim=kyhlstr.key local
#Sounds#
sound fireSound1=SwingFist01.wav local
sound fireSound2=SwingFist04.wav local
sound dismountSound=putweaponaway01.WAV local
sound mountSound=kyhlstr.WAV local
sound hitSound01=kn1.WAV local
sound hitSound02=kn2.WAV local
sound hitSound03=kn3.WAV local
sound hitSound12=kn4.WAV local
sound hitSound14=kn5.WAV local
sound Smallswing=vibroreg.WAV local
sound Bigswing=vibrobig.WAV local
#Templates#
template projectile=+punch local
template kickproj=+kickproj local
template tpl_wall=+ssparks_wall local
template tpl_blood=+ssparks_blood local
template tpl_saber=+ssparks_saber local
#Things#
thing player local
#Cogs#
cog kyleCog local
#Flex#
flex leftWait=0.25 local
flex rightWait=0.25 local
flex FmountWait local
flex FholsterWait local
flex holsterWait local
#Integers#
int trackID=-1 local
int nextAnim=0 local
int FholsterTrack local
int assign local
int nosaber local
int mountAnimID local
int preAnimID local
int povPreAnimID local
int slashAnimID local
int povSlashAnimID local
int mode local
int slash local
int nextAttack local # 0=right 1=left
int holsterTrack local
int vibrofists=119 local
int firsttime1=1 local
int stopchang1 local
int desel1=0 local
int lastweap1=0 local
int knifewait local
#Messages#
message startup
message activated
message deactivated
message selected
message deselected
message newplayer
message autoselect
message timer
message fire
message user3
message loadlast
message changeselect
end
# =============================================
code
startup:
player = GetLocalPlayerThing();
kyleCog = GetThingClassCog(player);
ClearActorFlags(player, 0x2000);
jkDisableSaber(player);
leftWait = GetKeyLen(FpovfireAnim1);
rightWait = GetKeyLen(FpovfireAnim2);
FmountWait = GetKeyLen(FmountAnim);
Return;
#===========================================
fire:
if(!getinv(player, vibrofists))
{
if(mode == 0)
{
// Check that the player is still alive.
if(GetThingHealth(player) <= 0)
{
Return;
}
// Alternate fists.
if(nextAnim == 0)
{
SetPOVShake('-0.01 -.01 0.0', '1.0 0.0 0.0', .05, 80.0);
PlaySoundThing(fireSound1, player, 1.0, 0.5, 2.5, 0x80);
FireProjectile(player, projectile, -1, 8, '-0.02 0.03 0', '0 0 0', 1.0, 0, 0.0, 0.0);
SetFireWait(player, leftWait);
}
else
{
SetPOVShake('0.01 -.01 0.0', '1.0 0.0 0.0', .05, 80.0);
PlaySoundThing(fireSound1, player, 1.0, 0.5, 2.5, 0x80);
FireProjectile(player, projectile, -1, 18, '0.02 0.03 0', '0 0 0', 1.0, 0, 0.0, 0.0);
SetFireWait(player, rightWait);
}
jkPlayPOVKey(player, FpovfireAnim1[nextAnim], 1, 0x0a);
nextAnim = 1-nextAnim;
}
if(mode == 1)
{
player = GetLocalPlayerThing();
SetPOVShake('0.03 -.03 0.0', '3.0 0.0 0.0', .05, 80.0);
PlaySoundThing(firesound2, player, 1.0, 0.5, 2.5, 0x80);
jkPlayPOVKey(player, FpovfireAnim1, 2, 0x32);
PlayKey(player, kick, 1, 0x38);
SetTimerEx(0.4, 5, 0, 0);
}
}
if(getinv(player, vibrofists))
{
// Stop block animations, by sending a message to kyle.cog.
SendMessage( kyleCog, user0 );
// Underwater saber attacks.
if (GetMajorMode(player) == 5)
{
jkEnableSaber( player, 20, 0.12, 0.25 );
if (nextAttack == 0)
{
PlayMode( player, 8);
jkPlayPOVKey( player, povFireAnimR1, 2, 0x38 );
knifewait = getkeylen(povfireanimr1);
nextAttack = 1;
}
else
{
PlayMode( player, 18);
jkPlayPOVKey( player, povFireAnimL1, 2, 0x38 );
knifewait = getkeylen(povfireaniml1);
nextAttack = 0;
}
shakePos = VectorScale(RandVec(),.001);
shakeAngle = VectorScale(RandVec(),.5);
SetPOVShake(shakePos, shakeAngle, .05, 80.0);
SetFireWait(player, knifewait);
PlaySoundThing(smallswing, player, 1.0, -1, -1, 0x80);
}
else
{
mode = GetSenderRef();
if (mode == 0)
{
// If we do another attack, reset the quick slash counter.
thrust = GetThingThrust( player );
// RIGHT Regular Strike
if (VectorX(thrust) > 0)
{
jkEnableSaber( player, 20, 0.1, 0.25 );
jkPlayPOVKey( player, povFireAnimR1, 2, 0x38 );
PlayKey(player, fireAnimR1, 1, 0x38);
knifewait = getkeylen(fireanimr1);
shakePos = VectorScale(RandVec(),.001);
shakeAngle = VectorScale(RandVec(),.5);
SetPOVShake(shakePos, shakeAngle, .05, 80.0);
PlaySoundThing(smallswing, player, 1.0, -1, -1, 0x80);
SetFireWait(player, knifewait);
}
else
// LEFT Regular Strike
if (VectorX(thrust) < 0)
{
jkEnableSaber( player, 20, 0.1, 0.25 );
jkPlayPOVKey( player, povFireAnimL1, 2, 0x38 );
PlayKey(player, fireAnimL1, 1, 0x38);
knifewait = getkeylen(fireaniml1);
shakePos = VectorScale(RandVec(),.001);
shakeAngle = VectorScale(RandVec(),.5);
SetPOVShake(shakePos, shakeAngle, .05, 80.0);
PlaySoundThing(smallswing, player, 1.0, -1, -1, 0x80);
SetFireWait(player, knifewait);
}
else
// BACKWARDS Strike
if (VectorY(thrust) < -0.1)
{
jkEnableSaber( player, 20, 0.1, 0.25 );
if (nextAttack == 0)
{
jkPlayPOVKey( player, povFireAnimB1, 2, 0x38 );
PlayKey(player, fireAnimB1, 2, 0x38);
knifewait = getkeylen(fireanimb1);
nextAttack = 1;
}
else
{
jkPlayPOVKey( player, povFireAnimB2, 2, 0x38 );
PlayKey(player, fireAnimB2, 2, 0x38);
knifewait = getkeylen(fireanimb2);
nextAttack = 0;
}
shakePos = VectorScale(RandVec(),.001);
shakeAngle = VectorScale(RandVec(),.5);
SetPOVShake(shakePos, shakeAngle, .05, 80.0);
PlaySoundThing(smallswing, player, 1.0, -1, -1, 0x80);
SetFireWait(player, knifewait);
}
else
// STANDING Strike
if (VectorY(thrust) < 0.1)
{
jkEnableSaber( player, 20, 0.1, 0.7 );
if (nextAttack == 0)
{
jkPlayPOVKey( player, povFireAnimF1, 2, 0x38 );
PlayKey(player, fireAnimF1, 2, 0x38);
knifewait = getkeylen(fireanimf1);
nextAttack = 1;
}
else
{
jkPlayPOVKey( player, povFireAnimF2, 2, 0x38 );
PlayKey(player, fireAnimF2, 2, 0x38);
knifewait = getkeylen(fireanimf2);
nextAttack = 0;
}
shakePos = VectorScale(RandVec(),.001);
shakeAngle = VectorScale(RandVec(),.5);
SetPOVShake(shakePos, shakeAngle, .05, 80.0);
PlaySoundThing(smallswing, player, 1.0, -1, -1, 0x80);
SetFireWait(player, knifewait);
}
else
{
// QUICK slash.
if (slash == 0)
{
// If after a second, we haven't attacked again, reset slash to 0.
jkEnableSaber( player, 16, 0.1, 0.25 );
povSlashAnimID = jkPlayPOVKey( player, povSnapAnim1, 2, 0x38);
slashAnimID = PlayKey(player, snapAnim1, 1, 0x38);
PlaySoundThing(smallswing, player, 1.0, -1, -1, 0x80);
knifewait = getkeylen(snapanim1);
shakePos = VectorScale(RandVec(),.001);
shakeAngle = VectorScale(RandVec(),.5);
SetPOVShake(shakePos, shakeAngle, .05, 80.0);
SetFireWait(player, knifewait);
slash = 1;
}
else
if (slash == 1)
{
// Allow another second for the 3rd attack.
jkEnableSaber( player, 16, 0.1, 0.25 );
povSlashAnimID = jkPlayPOVKey( player, povSnapAnim2, 2, 0x38 );
slashAnimID = PlayKey(player, snapAnim2, 1, 0x38);
PlaySoundThing(smallswing, player, 1.0, -1, -1, 0x80);
knifewait = getkeylen(snapanim2);
shakePos = VectorScale(RandVec(),.001);
shakeAngle = VectorScale(RandVec(),.5);
SetPOVShake(shakePos, shakeAngle, .05, 80.0);
SetFireWait(player, knifewait);
slash = 2;
}
else
if (slash == 2)
{
jkEnableSaber( player, 24, 0.1, 0.25 );
povSlashAnimID = jkPlayPOVKey( player, povSnapAnim3, 2, 0x38 );
slashAnimID = PlayKey(player, snapAnim3, 1, 0x38);
knifewait = getkeylen(snapanim3);
PlaySoundThing(smallswing, player, 1.0, -1, -1, 0x80);
shakePos = VectorScale(RandVec(),.001);
shakeAngle = VectorScale(RandVec(),.5);
SetPOVShake(shakePos, shakeAngle, .05, 80.0);
SetFireWait(player, knifewait);
slash = 0;
}
}
}
// mode == 1
else
{
// HEAVY slash.
{
jkEnableSaber( player, 64, 0.13, 1.2 );
jkPlayPOVKey( player, povChargeAnim, 2, 0x38 );
PlayKey(player, chargeAnim, 2, 0x38);
knifewait = getkeylen(chargeanim);
shakePos = VectorScale(RandVec(),.001);
shakeAngle = VectorScale(RandVec(),.5);
SetPOVShake(shakePos, shakeAngle, .05, 80.0);
PlaySoundThing(bigswing, player, 1.0, -1, -1, 0x80);
SetFireWait(player, knifewait-0.4);
}
}
}
}
Return;
# ..........................................
activated:
player = GetSourceRef();
mode = GetSenderRef();
jkSetWaggle(player, '0.0 0.0 0.0', 0);
if(!getinv(player, vibrofists))
{
ActivateWeapon( player, leftWait, mode );
}
if(getinv(player, vibrofists))
{
mode = GetSenderRef();
ActivateWeapon( player, 0.5, mode );
ClearActorFlags(player, 0x2000);
}
Return;
# ..........................................
deactivated:
player = GetSourceRef();
mode = GetSenderRef();
jkSetWaggle(player, '10.0 7.0 0.0', 350);
DeactivateWeapon( player, mode );
if(getinv(player, vibrofists))
{
SetTimerEx(0.5, 1, 0, 0);
}
Return;
# ..........................................
selected:
player = GetSourceRef();
if(getinv(player, 125))
{
if ((jkGetSaberCam() == 1) && (GetCurrentCamera() == 0) && (GetPrimaryFocus(0) == player))
CycleCamera();
}
if(!getinv(player, 125))
{
if ((jkGetSaberCam() == 1) && (GetCurrentCamera() == 1) && (GetPrimaryFocus(1) == player))
CycleCamera();
}
call loadlast;
call changeselect;
SetCurWeapon(player, 1);
jkSetWaggle(player, '10.0 7.0 0.0', 350);
if(!getinv(player, vibrofists))
{
PlayMode(player, 40);
Print("Fists");
jkSetPOVModel(player, povModel1);
jkSetWeaponMesh(player, weaponMesh1);
SetArmedMode(player, 0);
trackID = jkPlayPOVKey(player, FmountAnim, 0, 20);
SetMountWait(player, FmountWait);
jkClearFlags(player, 0x5);
lastweap1 = 0;
}
if(getinv(player, vibrofists))
{
assign = GetSenderRef();
Print("Vibroblade");
jkSetSaberInfo(player, side_mat, tip_mat, 0, 0, 0, tpl_wall, tpl_blood, tpl_saber);
jkSetPOVModel( player, povModel2 );
SetArmedMode( player, 2 );
jkSetWeaponMesh( player, saberMesh2 );
if (assign == 0)
{
PlayMode(player, 42);
mountAnimID = jkPlayPOVKey( player, mountAnim, 0, 0x14 );
SetTimerEx(0.7, 0, 0, 0);
}
else
{
PlayMode(player, 42);
mountAnimID = jkPlayPOVKey( player, holdAnim, 0, 0x14 );
jkSetFlags(player, 0x80);
}
SetMountWait(player, GetKeyLen(mountAnim));
jkDisableSaber(player);
nosaber = 0;
lastweap1=1;
}
Return;
# ..........................................
deselected:
player = GetSourceRef();
if(getcurrentcamera() == 0) Setinv(player, 125, 0);
if(getcurrentcamera() == 1) Setinv(player, 125, 1);
if(!getinv(player, vibrofists))
{
jkPlayPOVKey(player, FdismountAnim, 0, 18);
FholsterWait = GetKeyLen(holsterAnim);
SetMountWait(player, FholsterWait);
holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
SetTimerEx(FholsterWait, 2, 0.0, 0.0);
if (trackID != -1)
{
jkStopPOVKey(player, trackID, 0);
trackID = -1;
}
jkSetWaggle(player, '0.0 0.0 0.0', 0);
}
if(getinv(player, vibrofists))
{
jkSetFlags(player, 0x8);
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 (mountAnimID != -1)
{
jkStopPOVKey( player, mountAnimID, 0 );
mountAnimID = -1;
}
jkSetWaggle(player, '0.0 0.0 0.0', 0);
KillTimerEx(1);
ClearActorFlags(player, 0x2000);
jkDisableSaber(player);
nosaber = 1;
}
desel1=1;
Return;
# ..........................................
autoselect:
ReturnEx(100.0);
Return;
# ..........................................
timer:
if(!getinv(player, vibrofists))
{
id = GetSenderId();
if (id == 2)
{
StopKey(player, holsterTrack, 0.0);
}
if (id == 5)
{
FireProjectile(player, kickproj, -1, 0, '-0.02 0.03 0', '0 0 0', 1.0, 0, 0.0, 0.0);
SetFireWait(player, 1.0);
}
}
if(getinv(player, vibrofists))
{
id = GetSenderId();
if (id == 0)
{
PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
jkSetFlags(player, 0x5);
}
else
if (id == 1)
{
if (nosaber == 0)
ClearActorFlags(player, 0x2000);
}
else
if (id == 2)
{
StopKey(player, holsterTrack, 0.0);
}
}
Return;
# ..........................................
changeselect:
stopchang1=0;
if(getinv(player, vibrofists))
{
setinv(player, vibrofists, 0);
stopchang1=1;
}
if(!getinv(player, vibrofists))
{
if(stopchang1 != 1)
{
setinv(player, vibrofists, 1);
}
}
If(firsttime1 == 1)
{
setinv(player, vibrofists, 0);
firsttime1 = 0;
}
Return;
# ..........................................
loadlast:
if(desel1 == 1)
{
if(lastweap1 == 0)
{
Setinv(player, vibrofists, 1);
}
if(lastweap1 == 1)
{
Setinv(player, vibrofists, 0);
}
desel1=0;
}
Return;
# ..........................................
user3:
{
if(getcurrentcamera() == 0) Setinv(player, 125, 0);
if(getcurrentcamera() == 1) Setinv(player, 125, 1);
call selected;
call timer;
}
Return;
# ..........................................
newplayer:
nosaber = 1;
ClearActorFlags(player, 0x2000);
jkDisableSaber(player);
Return;
endThis cog has fists as the primary weapon, and kick as it's secondary fire. Vibroblade(alias Saber & Knife) is the secondary weapon.
Now, the problem. In my last cog post I was asking how to stop the glow - Vibroblade didn't need it. Well, changing the jksetflags in the timer message of Weap_saber from 0x5 to 0x1 did that, but somehow that got screwed up when I had two saber cogs.
So, could you look my cog over and tell me how to fix my lighting problem and any other errors that it has?
Thanks
![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)
------------------
Yub-Yub, Commander.
[This message has been edited by SaberMaster (edited March 31, 2001).]
[This message has been edited by Hideki (edited April 03, 2001).]
![http://forums.massassi.net/html/smile.gif [http://forums.massassi.net/html/smile.gif]](http://forums.massassi.net/html/smile.gif)
![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/confused.gif [http://forums.massassi.net/html/confused.gif]](http://forums.massassi.net/html/confused.gif)