The saber is always blue (color=5). What's wrong?
Code:
# Jedi Knight Cog Script # # WEAP_SABER.COG # # WEAPON Script - Lightsaber (edited by Nemios) # ======================================================================================== symbols message startup message activated message deactivated message selected message deselected message newplayer message autoselect message timer message fire message killed # ........................................................................................ model povModel=sabv.3do local model saberMesh=sabg.3do local model povsaber=sabv-g.3do local model povsaber1=sabv-y.3do local model povsaber2=sabv-o.3do local model povsaber3=sabv-r.3do local model povsaber4=sabv-p.3do local model povsaber5=sabv-b.3do local model saber=sabg-g.3do local model saber1=sabg-y.3do local model saber2=sabg-o.3do local model saber3=sabg-r.3do local model saber4=sabg-p.3do local model saber5=sabg-b.3do local # ........................................................................................ model katarn =ky.3do local // blue model cyborg =kyb3.3do local // green model red1eye =kyc5.3do local // yellow model trainer =kyd0.3do local // green model darkkyle =kye6.3do local // red model silver =kyf2.3do local // orange model admiral =kyg7.3do local // purple model bobafett =kyh4.3do local // green model darkrahn =kyj1.3do local // red model angry =kyk7.3do local // blue model scarface =kyl8.3do local // red model sariss =kya9.3do local // blue model janors =kya10.3do local // yellow model commando =kya11.3do local // purple model officer =kya12.3do local // purple model trooper =kym13.3do local // purple model bossk =kyi14.3do local // orange model tusken =kya15.3do local // orange model c3po =kya16.3do local // yellow model greedo =kya17.3do local // orange model yun =kya18.3do local // yellow model jerec =kya19.3do local // red model green =kyt0.3do local // green model yellow =kyu0.3do local // yellow model blue =kyv0.3do local // blue model purple =kyw0.3do local // purple model red =kyx0.3do local // red model orange =kyy0.3do local // orange model cmodel local . . . int color=5 local vector shakePos local vector shakeAngle local cog kyleCog local end # ======================================================================================== code startup: // Set up player with saber. player = GetLocalPlayerThing(); kyleCog = GetThingClassCog(player); ClearActorFlags(player, 0x2000); jkDisableSaber(player); slash = 0; nextAttack = 0; slashAnimID = -1; povSlashAnimID = -1; return; # ........................................................................................ timer: id = GetSenderId(); if (id == 0) { // Play mounting sound. PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80); humChannel = PlaySoundThing(humSound01, player, 1.0, -1, -1, 0x81); jkSetFlags(player, 0x5); // Model limit of 28. Can't have models for each color... jkSetPOVModel(player, povsaber ); mountAnimID = jkPlayPOVKey( player, holdAnim, 0, 0x14 ); jkSetWeaponMesh(player, saber ); } else if (id == 1) { // Make sure a loose timer doesn't come in and reset the block after we deselect the saber. if (nosaber == 0) SetActorFlags(player, 0x2000); } else if (id == 2) { StopKey(player, holsterTrack, 0.0); } return; # ........................................................................................ selected: assign = GetSenderRef(); // Setup the meshes and models. cmodel = GetThingModel(player); if ((cmodel==cyborg) || (cmodel==trainer) || (cmodel==bobafett) || (cmodel==green)) color = 0; //green if ((cmodel==red1eye) || (cmodel==janors) || (cmodel==c3po) || (cmodel==yun) || (cmodel==yellow)) color = 1; //yellow if ((cmodel==silver) || (cmodel==bossk) || (cmodel==tusken) || (cmodel==greedo) || (cmodel==orange)) color = 2; //orange if ((cmodel==darkkyle) || (cmodel==darkrahn) || (cmodel==scarface) || (cmodel==jerec) || (cmodel==red)) color = 3; //red if ((cmodel==admiral) || (cmodel==commando) || (cmodel==officer) || (cmodel==trooper) || (cmodel==purple)) color = 4; //purple if ((cmodel==katarn) || (cmodel==angry) || (cmodel==sariss) || (cmodel==blue)) color = 5; //blue // Go to external if ((jkGetSaberCam() == 1) && (GetCurrentCamera() == 0) && (GetPrimaryFocus(0) == player)) CycleCamera(); jkSetPOVModel( player, povModel ); SetArmedMode( player, 2 ); jkSetWeaponMesh( player, saberMesh ); jkSetWaggle(player, '10.0 7.0 0.0', 350); if (assign == 0) { // Play the animation (NOLOOP + UNIQUE + ENDPAUSE). // The animation is held at the last frame after it is played. PlayMode(player, 42); mountAnimID = jkPlayPOVKey( player, mountAnim, 0, 0x14 ); SetTimerEx(0.7, 0, 0, 0); } else { mountAnimID = jkPlayPOVKey( player, holdAnim, 0, 0x14 ); humChannel = PlaySoundThing(humSound01, player, 1.0, -1, -1, 0x81); jkSetFlags(player, 0x80); } SetMountWait(player, GetKeyLen(mountAnim)); // Set saber flags, and allow activation of the weapon SetCurWeapon( player, 10 ); // Set autoblock on. SetActorFlags(player, 0x2000); jkDisableSaber(player); nosaber = 0; return; # ........................................................................................ deselected: // Back to POV if ((jkGetSaberCam() == 1) && (GetCurrentCamera() == 1) && (GetPrimaryFocus(1) == player)) CycleCamera(); // Shrink saber. jkSetFlags(player, 0x8); // Dismount the Lightsaber. 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; } // Clear variables jkSetWaggle(player, '0.0 0.0 0.0', 0); slash = 0; nextAttack = 0; slashAnimID = -1; povSlashAnimID = -1; StopSound( humChannel, 0.5 ); // Disable autoblock KillTimerEx(1); ClearActorFlags(player, 0x2000); jkDisableSaber(player); nosaber = 1; return; # ........................................................................................ activated: mode = GetSenderRef(); jkSetWaggle(player, '0.0 0.0 0.0', 0); if (mode > 1) return; povPreAnimID = -1; preAnimID = -1; ActivateWeapon( player, 0.5, mode ); // Disable autoblock ClearActorFlags(player, 0x2000); return; # ........................................................................................ deactivated: mode = GetSenderRef(); jkSetWaggle(player, '10.0 7.0 0.0', 350); DeactivateWeapon( player, mode ); // Enable autoblock SetTimerEx(0.5, 1, 0, 0); return; . . . # ........................................................................................ newplayer: slash = 0; nextAttack = 0; slashAnimID=-1; povSlashAnimID=-1; // Disable autoblock ClearActorFlags(player, 0x2000); jkDisableSaber(player); // Back to POV, since the saber should never get autoselected at start for a multiplayer game. if ((jkGetSaberCam() == 1) && (GetCurrentCamera() == 1) && (GetPrimaryFocus(1) == player)) CycleCamera(); return; # ........................................................................................ autoselect: // Return the saber when out of everthing except the fists // If the player has the weapon if(GetInv(player, 10) != 0.0) { ReturnEx(200.0); } else { ReturnEx(-1.0); } return; # ........................................................................................ killed: if (player == GetSenderRef()) { if (GetCurWeapon(player) == 10) { jkSetWeaponMesh( player, saberMesh); //Disable glowsaber. PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80); nosaber = 1; } } return; end
"May the SourceCode be with you..."
Nemios, MOD developer.
Nemios, MOD developer.