Cog Files


System Reference

Verbs dealing with some system things.

jkEndLevel
jkGetSaberCam
AutoSaveGame
BitClear
BitSet
BitTest
ClearDebugModeFlags
ClearGoalFlags
ClearSubModeFlags
GetAutoPickup
GetAutoReload
GetAutoSwitch
GetDebugModeFlags
GetDifficulty
GetFlexGameTime
GetGameTime
GetGoalFlags
GetLevelTime
GetMajorMode
GetMasterCog
GetParam
GetSelfCog
GetSenderId
GetSenderRef
GetSenderType
GetSithMode
GetSourceRef
GetSourceType
GetSubModeFlags
HeapFree
HeapGet
HeapNew
HeapSet
KillTimerEx
ParseArg
Rand
Reset
ReturnEx
SendMessage
SendMessageEx
SendTrigger
SetAutoPickup
SetAutoReload
SetAutoSwitch
SetDebugModeFlags
SetGoalFlags
SetMasterCog
SetParam
SetPulse
SetSubModeFlags
SetTimer
SetTimerex
SkillTarget
Sleep
Takeitem

jkEndLevel() Control

Ends the level.

Use: jkEndLevel(0 | 1); terminates the level indicating failure or success in the mission


jkGetSaberCam() Info

Gets the setting of auto saber camera option in the graphic interface.

Use: set = jkGetSaberCam(); returns 1 if set,0 if not set


AutoSaveGame() Control

Autosaves the game

Use: AutoSaveGame();


BitClear()

Clears a bit within a bit array (flag value).

BitClear(Flag_value, Flag_to_clear);


BitSet()

Sets a bit within a bit array (flag value).
In other words, it adds a flag to an exisitng array of them.

BitSet(Flag_value, Flag_to_add);


BitTest()

Tests two values against each other for equality.

Use: BitTest(flag_a, flag_b);
Example of use: If(BitTest(16, type))
The code would continue if type equaled 16.


ClearDebugModeFlags()

?

? Not Used


ClearGoalFlags()

Clear one or more goal flags for one of the goals. Used for single player objectives

Use: ClearGoalFlags(player, goalNumber, flagsToClear); goalNumber starts at zero.
The first goal (i.e. goal 0) description corresponds to the cogString whose value is in bin 99.
flagsToClear are the Goal Flags. See Goal Flags


ClearSubModeFlags()

?

? Not used


GetAutoPickup()

Gets the status of the auto pickup setting in the graphic interface .

Use: Value = GetAutoPickup();


GetAutoReload()

Gets the status of the autoreload setting in the graphic interface

Use: GetAutoReload();


GetAutoSwitch()

Gets the status of the auto switch setting in the graphic interface

Use: GetAutoSwitch();


GetDebugModeFlags()

?

? Not used


GetDifficulty()

Gets difficulty setting for SP.
0 = easy
1 = medium
2 = hard

Use: GetDifficulty()


GetFlexGameTime()

?

? Not Used in JK


GetGameTime()

?

? Not Used in JK


GetGoalFlags()

Returns the Goal Flags of the selected goal. Used for single player objectives

Use: GetGoalFlags(player, goalNumber); goalNumber starts at zero.
The first goal (i.e. goal 0) description corresponds to the cogString whose value is in bin 99.
This verb returns the Goal Flags of the selected goal. See Goal Flags


GetLevelTime()

?

?


GetMajorMode()

?

?


GetMasterCog()

Returns the cogRef of the current Master cog.

Use: GetMasterCog()
This value can then be passed to cog verbs expecting a cog reference (like SendMessage for instance).


GetParam()

Gets one parameter of a cog message. Each cog message has 4 parameters, but generally only some of them contain useful values.

Use: GetParam(paramNumber);
Where paramNumber can be 0, 1, 2 or 3.

Examples of verbs setting parameters are SendMessageEx, SetTimerEx, SetParam, ...
Note that the engine itself sometimes set parameters when calling a message handler.
For instance in the damaged: message param0 is the amount of damage, and param1 is the type of damage. See Damage Flags


GetSelfCog()

Returns the cogRef of the current cog.

Use: GetSelfCog()
This value can then be passed to cog verbs expecting a cog reference (like SendMessage, SendMessageEx, or SetMasterCog for instance).


GetSenderId()

Returns the ID of the current message's sender.
The ID can be set in various ways: via a cog verb like SetTimerEx or SendTrigger, but also via the linkid= setting in the symbols section of a cog. SEE Symbol Uses

Use : GetSenderId()


GetSenderRef()

Returns what sent a message to the cog.
This is the direct originator of the message, for instance a surface that is being activated:, or an actor that is being damaged:
The Sender should not be confused with the Source (see GetSourceRef)

Use: GetSenderRef()


GetSenderType()

Gets the type of the sender of the message.
I.e. you get a reference to the sender, but what type of object is it ?
Thing = 3
Sector = 5
Surface = 6

Use: GetSenderType()


GetSithMode()

?

? Not Used in JK


GetSourceRef()

Returns what caused a message to be sent to the cog.
This is the indirect originator of the message, for instance the player activating a surface, or that is damaging an actor.
The Source should not be confused with the Sender (see GetSenderRef)

Use: GetSourceRef()


GetSourceType()

Gets the type of the source of the message.
I.e. you get a reference to the source, but what type of object is it ?
Thing = 3
Sector = 5
Surface = 6

Use: GetSourceType()


GetSubModeFlags()

?

? Not Used in JK


HeapFree()

Frees the allocated heap array for a certain cog.

HeapFree();

Note: The heap verbs allocate memory to a system, making it possible to accomplish complex tasks via cog.
The heap verbs may not be retained in singleplayer saved game files.


HeapGet()

Returns the allocation of a heap.

int = HeapGet(int_heap);


HeapNew()

Allocates memory elements of any size (the largest size being a vector) to a cog.

HeapSet(Int_Size);


HeapSet()

Sets a heap size to a certain heap.

HeapSet(int_heap, int_value);


KillTimerEx()

Kills any extended timer with the specified ID.
See SetTimerEx

Use: KillTimerEx(timerID);


ParseArg()

Can be used to set a thing's template dynamically.

Use: ParseArg(ThingRef, "template value");
Template values can be anything found in a template ie: "movesize=3.4", "collide=0", etc...
Note: The testing of the function showed that it is very erratic and many template changes could not be changed dynamically.


Rand()

Returns a random flex value between 0.0 and 1.0

Use: Rand()


Reset()

Resets any existing CALL, WAIT, or WAITFORSTOP contexts. Used to completely reset the state of the COG in the event of an interrupt message.

Use: Reset();


ReturnEx()

Specifies the flex value that the cog message returns to the caller.
Remember the caller can be cog (via SendMessageEx for instance) or the engine itself (using ReturnEx(0) in a damaged: handler will negate the damage for instance).

Use: ReturnEx(flex returnValue);


SendMessage()

Sends a message to a cog.

Use: SendMessage(cogRef, message); SEE Cog Messages


SendMessageEx()

Sends a message to a cog with parameters passing.
This verb returns a value that it what the callee set in a ReturnEx statement.

Use: SendMessageEx(cogRef, message, flex param0, flex param1, flex param2, flex param3);


SendTrigger()

Sends a trigger, that is generates a trigger: message sent to all the cogs on the destination.
The destination can be either a player (local or remote on the network) reference or -1. If it is -1 the message is broadcast to ALL the connected players.
This verb can be used to reduce bandwidth in multiplayer games, as well as to transmit information that is not normally synched over the network.
The receiving cogs are responsible to declare and code a handler for the trigger: message. And they can check that they want to handle a specific triggerID by using GetSenderID as well as retrieve the parameters passed with GetParam.

Use: SendTrigger(destination, triggerID, flex param0, flex param1, flex param2, flex param3);


SetAutoPickup()

Sets the status of the auto pickup setting in the graphic interface

SetAutoPickup(0 | 1);


SetAutoReload()

Sets the status of the auto reload setting in the graphic interface

SetAutoReload(0 | 1);


SetAutoSwitch()

Sets the status of the auto switch setting in the graphic interface

SetAutoSwitch(0 | 1);


SetDebugModeFlags()

?

? not used


SetGoalFlags()

Sets a goal flag for one of the goals. Used for single player objectives

Use: SetGoalFlags(player, goalNumber, flagsToSet); goalNumber starts at zero.
The first goal (i.e. goal 0) description corresponds to the cogString whose value is in bin 99.
flagsToSet are the Goal Flags. See Goal Flags


SetMasterCog()

Sets the Master cog for a single player level.
Usually used for endlevel cogs of single player levels, the MasterCog is actually an easy way to access a cog reference from another cog without having to link the cog.

Use: SetMasterCOG(cogRef);
cogRef is often passed as GetSelfCog, the current cog.


SetParam()

Sets one parameter of a cog message. Each cog message has 4 parameters, but generally only some of them contain useful values.
This function was probably only added for completeness.

Use: SetParam(paramNumber, flex value);
Where paramNumber can be 0, 1, 2 or 3.


SetPulse()

Sets the pulse for the current cog's.
This will generate a pulse: message every interval.

Use: SetPulse(flex interval);
Use SetPulse(0); to stop the pulse.


SetSubModeFlags()

Sets the Sith Sub Mode.

SetSubModeFlags(flag);
See SubMode Flags


SetTimer()

Sets the timer for the cog, that will result in a timer: message being sent to the cog when delay seconds elapse.

Use: SetTimer(delay);


SetTimerex()

Sets an timer of delay seconds for the cog, allowing to use multiple timers with IDs and pass parameters to them.

Use: SetTimerEx(delay, timerID, flex param0, flex param1);
In the timer: handler you can check what the ID is with GetSenderID as well as retrieve the parameters passed with GetParam.
Note that it is allowed to have multiple timers with the same ID waiting to be sent to the cog, each will keep its own parameters.


SkillTarget()

Tells a target that a certain skill is being applied to it.
Mainly used for force powers, this is akin to a SendMessageEx that would reach accross the network.

Use: returnValue = SkillTarget(victim, player, binNumber, rank);
Note that when SkillTarget is sent over the network the return value is undefined, the cog DOES NOT wait for an answer (which is very logical, you don't want to wait for a double lag before continuing the execution). So in multiplayer the return value is not used to specify immunities and such as in single player.


Sleep()

Pauses the cog and its actions for a defined time.

Use: Sleep(sleeptime);
Note that this verb is very dangerous to use in cogs that could be reentered...


TakeItem()

Requests to take an item from the server. If the server agrees the taken: message is sent to the cog.
This does not occur in MOTS (except for backpacks) to reduce lag at the expense of risking a little inconsistency (i.e. two players taking the same powerup at the "same time").

Use: TakeItem(item, player);