Cog Files


Please Note: Due to the amount of time it is taking to do the cog specs,we decided to release the specs before ,they are completed. So you will find somethings still blank and pieces missing here and there.There is quite abit of information available as they are however. We will try to have this section completed when we release the next version of specs 0.3.

PS: Please remember this is not meant to be a cog tutor. We`ll leave that for somebody else to write.
Thanks


Cog Files General

Cog Files control/manipulate many aspects in Jedi Knight, some uses are weapons,force powers,animations,sound playing,doors elevators etc.

Cog files are written in a language specific to Jedi Knight. It is somewhat similar to "C".

There are a few conventions through out cog files.

First off is "comment markers".

Example 1: # Jedi Knight Cog Script
Example 2: // Create the sphere


Some common symbology found in Cog files

 Common Operator Symbols

=     ( Assigment ,assigns right side parameter/value to left side parameter/value)  
==    ( Left side equals Right side )
!=    ( Left side is not equal Right side )
>     ( Left side is greater than Right side )
<     ( Left side is less than Right side ) 
=>    ( Left side is greater than or equals Right side )
<=    ( Left side is less than or equals Right side )
|     ( Bitwise  OR )
&     ( Bitwise AND )
{     ( Begining of the body of the function )
}     ( End of function body )
;     ( End of statement )
*     ( multiply )
-     ( subtract or sign )
+     ( add )
/     ( divide )
!     ( Logical NOT )
&&    ( Logical AND )
||    ( Logical OR )


Cog files normaly have three main sections.

The comment and information section will resemble the table below. This sections function is pretty self explanatory. No further detail will be provided.

 Main comment and information section

# Jedi Knight Cog Script           ( what type of file it is )
#
# FORCE_DESTRUCTION.COG            ( file name ) 
#
# FORCEPOWER Script - Destruction  (  decription of Cog )
#  Bin 33                 
#
#
# [YB]          ( Authors Initials ,this one is written by Yves Borckmans (well known by DF fans))
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved   ( Copyright Info )
# ========================================================================================


Next what follows is the symbols section. This is where parameters are defined and values if any from the JKL Section: COGS are passed from the asociated cog line .

The symbols section is generaly broken up into 3 columns

SymbolType          SymbolName+Assignment         SymbolUse

An example symbols section, of note it normaly starts with the word "symbols" and ends with "end".Depending what the Cog is used for a Flag may be preceding the word symbols this is normaly in multiplayer cogs,and decides how the cog is used.

A few of the lines are colored and are directly linked to the code section as you can see in the next table.

flags=0x240 (Optional Flag)
 
symbols

thing       player                           local
flex        cost=200.0                       local
int         rank                             local
sound       healingSound=ForceHealing01.WAV  local
int         soundChannel=-1                  local
template    sphere_tpl=+force_heal           local
vector      position                         local
message     startup
message     activated
message     newplayer
message     killed
message     selected

end

Check Symbols for more information on the preceding section. An explained example is at Symbol Example Explained .


Finaly the Code section, this is where the actual functions reside.

The Code section starts with the word "code" and continues until "end". You will normaly find several modules of these code functions, the one shown is "startup" normaly there is one of these code modules for each "message" in the symbols section. Each performing a different task.You will also find some "Labels" that are also functions.

code

startup:                                // some comment
        player = GetLocalPlayerThing();
        call stop_power;
        Return;

#........................................................................
stop_power:                             // a label
        SetPulse(0);
        Return;
end


Section: Symbols


Flags

The flags determine how the cog information is to be processed.These are normaly used in multiplayer cog files.

LOCAL    0x40    Cog runs on the client and server
SERVER   0x80    Cog runs only on the server, client messages are forwarded to the server
GLOBAL   0x100   Cog runs locally on all machines
NOSYNC   0x200   COG results are not broadcast to the other machines.


Symbol Types

Below is a list of the symbol types.

ai
cog
flex
float
int
keyframe
material
message
model
sector
sound
surface
template
thing
vector


Ai

The symbol value will be of type "AI" (artificial intellegence) ".AI" file used for pedestrians and enemies etc.

A typical assignment would be ai flee_ai=noweapon.ai . The symbol "flee_ai" would be used in the code section where something would eventualy trigger the noweapon .ai file.


Cog

The symbol value will be of type cog file.

A typical assignment would be cog pipedoorc nolink The symbol "pipedoorc" Is a symbol for the cog reference passed to it from the Section : Cogs of the JKL file.


Flex

The symbol value will be of type floating point number. It appears the Float type was abandoned in favor of the Flex judging by some of the cog file dates. Perhaps there was problems using Float.

A typical assignment would be flex movespeed=12 or flex animtime=3.92.This assigns a value to the symbol "animtime=3.92" , in the code the symbol "animtime" would be the same as writing 3.92


Float

The symbol value will be of type floating point number. SEE Flex , float appears to be no longer used. Or has problems.

A typical assignment would be float patrolspeed=1.0. Assigns the value "1.0" to the "symbol patrolspeed".


Int

The symbol value will be of type signed Integer number. The range is -2,147,483,648 to +2,147,483,648 signed 32 bit whole number.

A typical assignment would be int closed=1 or int closed=-1. Assigns the value " 1" or "-1" to the symbol "closed".As with other symbols they will be used in the code section.


Keyframe

The symbol value will be of type keyframe ".Key" file.

A typical assignment would be keyframe povBlockAnim0=SabVblk0.key . Assigns the value "SabVblk0.key" to the symbol "povBlockAnim0".This will be refered to in the code section.


Material

The symbol value will be of type Material ".Mat" file.

A typical assignment would be material flashing=seq0mtp3.mat.Assigns a material to be used with the symbol in code section.


Message

The symbol value will be of type Message. Most code modules start with the name of messages in the symbols section, in a few cases this is not so.

The messages are sent by the "system" (Jk.exe or Sith engine ). There is a list of these plus their functions which will be covered in the Message section.

Example :

symbols          ( symbol section )

message	startup
message	activated
.....
end
#--------------------
code             ( code section )

startup:
.....
activated:
.....
end


Model

The symbol will be of type Model which is a ".3DO" file

A typical assignment would look like "model povModel=seqv.3do". This assigns the 3do file "seqv.3do " to the symbol "povModel" which is used in the code section.


Sector

The symbol will be of type sector from the JKL fileSection: SECTORS.The value for the sector to reference is passed to the cog by the Section: COGS

A typical assignment would look like "sector gosector linkid=1". This assigns the sector symbol "gosector " to the value passed from Section: Cogs and the appropriate cog line.


Sound

The symbol will be of type Sound which is a standard ".WAV" file.

A typical assignment would look like "sound wav0=lvrclik2.wav". This assigns the sound symbol "wav0 " the value "lvrclik2.wav".


Surface

The symbol will be of type surface which is a surface as defined in the JKl file Section: GEORESOURCE / World surfaces the actual surface to use is passed to the cog from the Section: COG and the appropriate line.

A typical assignment would look like "surface lower_adjoin0 linkid=1". This assigns the surface symbol "lower_adjoin0 " the value "Passed from section cog" of note is the "linkid=1" , this tells the cog that the surface can be referenced in the code section with either the symbol or the linkid value.


Template

The symbol will be of type template which is found in the JKl Section: TEMPLATES

A typical assignment would look like "template trail=+dest_trail local". This assigns the template symbol "trail " the values assigned to "+dest_trail" in the templates.


Thing

The symbol will be of type thing which is an object found in the Jkl Section: THINGS the actual thing to make a refernce to is passed by the value in the Section: COG appropriate line.

A typical assignment would look like "thing door linkid=10". This assigns the thing symbol "door " the thing in world things passed to it from section: cog


Vector

The symbol will be of type math vector in the x,y,z axis, not all axis are used at all times.

A typical assignment would look like "vector updirection local". This defines the vector symbol as "updirection " it has no value at this point, that would be done in the code,


Section: Code

Cog code has many predefined command verbs you may utilise in your code. To help sort them out They have been grouped together into reference lists.

Reference Lists

Actor Ref
Inventory Ref
Animation/Keys Ref
Multiplayer Ref
Output Ref
Player Ref
Sector Ref
Sound Ref
Special Effects Ref
Surface Ref
System Ref
Thing Ref
Vector Ref
Weapon Ref
World Ref