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 → It doesn't work. Why?
It doesn't work. Why?
2001-09-18, 9:34 AM #1
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.
2001-09-18, 11:41 AM #2
JK only allows 28 models to be defined in one cog. To get around that, you can send messages or triggers to other cogs to see if cmodel matches one of the models defined there.

------------------
Fiction must be more realistic than truth or no one will believe it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-09-25, 8:23 PM #3
Thanks for the reply

hmmm... I also tryed to comment out many models so I had less than 28, but didn't work yet...

any other idea?

------------------
"May the SourceCode be with you..."
"May the SourceCode be with you..."
Nemios, MOD developer.
2001-09-25, 9:55 PM #4
Have you got the "."'s in the action code?? Cause they will make the cog so it doesnt work I think.
Team Battle.
2001-09-26, 12:57 AM #5
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Nemios:

Code:
model    cmodel                        local

.
.
.

int      color=5                                
[/B]</font>


Do you mean these points? Obviosly they arent in the original cog! They are there only to say that some very large parts are missing. [http://forums.massassi.net/html/smile.gif]

------------------
"May the SourceCode be with you..."
"May the SourceCode be with you..."
Nemios, MOD developer.
2001-09-26, 1:00 AM #6
Quote:
Originally posted by Nemios:
Code:
model    cmodel                        local

.
.
.

int      color=5                                
[/b]</QUOTE>

Do you mean these points? Obviosly they arent in the original cog! They are there only to say that some very large parts are missing. [http://forums.massassi.net/html/smile.gif]


------------------
"May the SourceCode be with you..."
"May the SourceCode be with you..."
Nemios, MOD developer.
2001-09-26, 2:57 PM #7
no, he means the # comment lines in the code.. use // in the code section
2001-09-26, 9:27 PM #8
hehehe, yeah I meant the "."'s... I didnt realise they wernt in there [http://forums.massassi.net/html/biggrin.gif]

I have no idea why it doesnt work then.
Team Battle.
2001-09-27, 9:45 PM #9
I FOUND IT!

The problem was about model declarations. You can see I declared them like this
Code:
model   firstvar   =firstmodel.3do   local
model   secondvar  =secondmodel.3do  local
model   thirdvar   =thirdmodel.3do   local

just to have them lined.

The problem was spaces between "=" and varnames. If I write like this
Code:
model   firstvar=firstmodel.3do    local
model   secondvar=secondmodel.3do  local
model   thirdvar=thirdmodel.3do    local

it works! Incredible!

I also noticed another thing about the limit of 28 model. It is not strictly true. I noticed same cases where with more than 28 worked and others with less didn't work. I think I have understand why.
When I used more complex models or levels it didn't work unless I take out some models. It depends also on the complexity of the level.
Examples:
- Level Complex, Greedo skin (head is more complex), few models --> works
- Level Complex, Greedo skin (head is more complex), many models --> doesn't work
- Level Simple, Greedo skin (head is more complex), many models --> works
- Level Complex, Yun skin (head is less complex), many models --> works
(N.B.: for "doesn't work" I mean that is not as expected; in some cases it crashed, in other cases it used kyle model instead of the right skin)

Can anyone confirm this? Try it!
I hope this is useful for the community...

------------------
"May the SourceCode be with you..."
"May the SourceCode be with you..."
Nemios, MOD developer.
2001-09-30, 6:35 AM #10
I've 'heard' this is actaully whats happening:

The problem isnt the number of models, its the number of MATS. Try listing every MAT and 3D0 your extra models use in static.jkl and then try again.
- Wisdom is 99% experience, 1% knowledge. -

↑ Up to the top!