Code:
# Jedi Knight Cog Script # # WEAP_STRIFLE.COG # # WEAPON 3 script - Stormtrooper Rifle # # The standard rifle used by the stormtroopers. You can hold a rifle in each hand # and fire them both at the same time, or have them alternate. # # - Affected by MagSealed sectors/surfaces. # # # [YB & CYW] + [Stormtrooper] # # NOT SUPPORTED by LucasArts Entertainment Co. symbols # =Double================================================================================= model povModel=2strv.3do local model weaponMesh=strg.3do local model weaponMesh2=2strglk.3do local model lukusmodel=kyf2.3do local # =Single================================================================================= model povModels=strv.3do local model weaponMeshs=strg.3do local # =Double================================================================================= keyframe mountAnim=2StrVmnt.key local keyframe dismountAnim=2strvdis.key local keyframe povfireAnim1=2strvfirer.key local keyframe povfireAnim2=2strvfirel.key local keyframe povfireAnim3=2strvfireb.key local keyframe drawgunAnim=2strgdraw.key local keyframe holdgunAnim=2weapstand.key local keyframe leftfireAnim=2strgfirel.key local keyframe rightfireAnim=2strgfirer.key local keyframe bothfireAnim=2strgfireb.key local keyframe holsterAnim=kyhlstr.key local # =Single================================================================================= keyframe mountAnims=StrVmnt.key local keyframe dismountAnims=StrVdis.key local keyframe povfireAnims=StrVpst1.key local keyframe holsterAnims=kyhlstr.key local # ======================================================================================== sound mountSound=df_rif_ready.wav local sound dismountSound=PutWeaponAway01.wav local sound fireSound=trprsht2.wav local sound outSound=trprout.wav local template projectile=+stlaser local thing player local vector randVec local vector randVec1 local # =Single================================================================================= flex firewaits=0.2 # ======================================================================================== flex fireWait=0.5 local flex holsterWait local flex powerBoost local flex autoAimFOV=25 local flex autoAimMaxDist=5 local int dummy=0 local int trackID=-1 local int trackID2=-1 local int fireChannel=-1 local int holsterTrack local int mode local int shootframe=0 local # =Single================================================================================== int trackID1=-1 local # ========================================================================================= message activated message deactivated message selected message deselected message autoselect message fire message timer end # ======================================================================================== code fire: player = GetSourceRef(); mode = GetSenderRef(); // 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) < 1.0) { PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80); if((GetAutoSwitch() & 1)) SelectWeapon(player, AutoSelectWeapon(player, 1)); Return; } // Get random aiming error randVec = VectorSet((Rand()-0.25)*5, (Rand()-0.25)*5, 0.0); // Get random aiming error for the second gun randVec1 = VectorSet((Rand()-0.25)*5, (Rand()-0.25)*5, 0.0); SetPOVShake('0.0 -.003 0.0', '1.5 0.0 0.0', .05, 80.0); // If we have one rifle if((GetInv(player, 3) == 1)) //Copied this from original weap_strifle { // SetPOVShake('0.0 -.003 0.0', '1.5 0.0 0.0', .05, 80.0); dummy = FireProjectile(player, projectile, fireSound, 8, '0.0168 0.1896 0.00', randVec, 1.0, 0x30, autoAimFOV, autoAimFOV*2); // SetThingVel(dummy, vectorScale(GetThingVel(dummy), 0.01)); ChangeInv( player, 11, -2.0 ); jkPlayPOVKey( player, povfireAnims, 1, 0x38 ); powerBoost = GetInv(player, 63); ChangeFireRate(player, fireWaits/powerBoost); } // If we have 2 rifles if((GetInv(player, 3) == 2)) { if(mode == 0) { if(shootframe == 0) //right weapon { JKPlayPOVKey(player, povfireAnim1, 1, 0x38); dummy = FireProjectile(player, projectile, firesound, 8, '0.0325 0.1624 0.0', randVec, 1.0, 0x20, autoAimFOV, autoAimFOV*2); if(trackID2 != -1) { Stopkey(player, trackID2, 0.0); trackID2 = -1; } playkey(player, rightfireAnim, 1, 0x38); shootframe = 1; } else if(shootframe == 1) //left weapon { jkPlayPOVKey(player, povfireAnim2, 1, 0x38); dummy = FireProjectile(player, projectile, firesound, 8, '-0.0325 0.1624 0.0', randVec, 1.0, 0x20, autoAimFOV, autoAimFOV*2); if(trackID2 != -1) { Stopkey(player, trackID2, 0.0); trackID2 = -1; } playkey(player, leftfireAnim, 1, 0x38); shootframe = 0; } ChangeInv(player, 11, -1.0); powerBoost = GetInv(player, 63); ChangeFireRate(player, fireWait/2/powerBoost); } if(mode == 1) { if(GetInv(player, 11) > 1) { jkPlayPOVKey(player, povfireAnim3, 1, 0x38); { dummy = FireProjectile(player, projectile, fireSound, -1, '0.0325 0.1624 0.0', randVec, 1.0, 0x20, autoAimFOV, autoAimFOV*2); dummy = FireProjectile(player, projectile, fireSound, -1, '-0.0325 0.1624 0.0', randVec1, 1.0, 0x20, autoAimFOV, autoAimFOV*2); } ChangeInv(player, 11, -2.0); } else { jkPlayPOVKey(player, povfireAnim1, 1, 0x38); dummy = FireProjectile(player, projectile, fireSound, 8, '0.0325 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2); ChangeInv(player, 11, -1.0); } if(trackID2 != -1) { Stopkey(player, trackID2, 0.0); trackID2 = -1; } playkey(player, bothfireAnim, 1, 0x38); SetTimerEx(GetKeyLen(bothfireAnim), 2, 0, 0); powerBoost = GetInv(player, 63); ChangeFireRate(player, fireWait/powerBoost); } } Return; # ........................................................................................ activated: player = GetSourceRef(); mode = GetSenderRef(); jkSetWaggle(player, '0.0 0.0 0.0', 0); powerBoost = GetInv(player, 63); ActivateWeapon( player, fireWait/powerBoost, mode ); Return; # ........................................................................................ deactivated: player = GetSourceRef(); jkSetWaggle(player, '10.0 7.0 0.0', 350); DeactivateWeapon( player, mode ); // If we have one if((GetInv(player, 3) == 1)) // Another from weap_strifle { DeactivateWeapon(player, mode); } // If we have 2 if((GetInv(player, 3) == 2)) { if(trackID2 == -1) trackID2 = playkey(player, holdgunAnim, 1, 0x4); } Return; # ........................................................................................ selected: player = GetSourceRef(); // If we have 1 if((GetInv(player, 3) == 1)) // From weap_strifle { PlayMode(player, 41); PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80); jkSetPOVModel(player, povModels); SetArmedMode(player, 1); jkSetWeaponMesh(player, weaponMeshs); jkSetWaggle(player, '10.0 7.0 0.0', 350); trackID1 = jkPlayPOVKey(player, mountAnims, 0, 20); SetMountWait(player, GetKeyLen(mountAnims)); jkClearFlags(player, 0x5); SetCurWeapon(player, 3); } // If we have 2 if((GetInv(player, 3) == 2)) { jkSetPOVModel(player, povModel); // two Rifles SetThingModel(player, weaponMesh2); jkSetWeaponMesh(player, weaponMesh); SetArmedMode(player, 1); PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80); trackID = jkPlayPOVKey(player, mountAnim, 0, 20); PlayKey(player, drawgunAnim, 1, 0x38); SetTimerEx(GetKeyLen(drawgunAnim), 2, 0, 0); jkClearFlags(player, 0x5); jkSetWaggle(player, '10.0 7.0 0.0', 350); SetMountWait(player, GetKeyLen(mountAnim)); SetCurWeapon(player, 3); } Return; # ........................................................................................ deselected: player = GetSourceRef(); // If we have 1 if((GetInv(player, 3) == 1)) { PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80); jkPlayPOVKey(player, dismountAnims, 0, 0x18); holsterWait = GetKeyLen(holsterAnims); SetMountWait(player, holsterWait); holsterTrack = PlayKey(player, holsterAnims, 1, 0x4); SetTimerEx(holsterWaits, 2, 0.0, 0.0); if (trackID1 != -1) { jkStopPOVKey(player, trackID1, 0); trackID1 = -1; } jkSetWaggle(player, '0.0 0.0 0.0', 0); } if((GetInv(player, 3) == 2)) { 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, 1, 0.0, 0.0); if (trackID != -1) { jkStopPOVKey(player, trackID, 0); trackID = -1; } if (trackID2 != -1) { StopKey(player, trackID2, 0); trackID2 = -1; } jkSetWaggle(player, '0.0 0.0 0.0', 0); } Return; # ........................................................................................ autoselect: player = GetSourceRef(); // If the player has the weapon if(GetInv(player, 3) != 0.0) { // If the player has ammo if(GetInv(player, 11) != 0.0) { ReturnEx(600.0); } else { ReturnEx(-1.0); } } else { ReturnEx(-1.0); } Return; # ........................................................................................ timer: // If we have 1 if((GetInv(player, 3) == 1)) { StopKey(player, holsterTrack, 0.0); } // If we have 2 if((GetInv(player, 3) == 2)) { if(GetSenderID() == 1) { StopKey(player, holsterTrack, 0.0); SetThingModel(player, lukusmodel); } else if(GetSenderID() == 2 && trackID2 == -1) trackID2 = playkey(player, holdgunAnim, 1, 0x4); } Return; end
It won't change the the model(POV or external) when bin 3 is set at 2, It just keeps the models as they are until you deselect the weapon and select it again, then it's correct. Any ideas on how to make it work?
[EDIT]I spelled code wrong for the tags
![http://forums.massassi.net/html/frown.gif [http://forums.massassi.net/html/frown.gif]](http://forums.massassi.net/html/frown.gif)
------------------
Look for my current project, The Force in Your Soul.
Last week I cudn't evn spel grajuat, but now I is one.
*Takes out his blaster and fires shots at the wall, the blastmarks leave the words "S-TROOPER WUZ 'ERE!!!"
[This message has been edited by Stormtrooper (edited July 11, 2003).]