Get SaintAxe&Ror SpeechMaker Now
And build your conversations easily !
 
Using OFDR Mission Editor - How-To
 

This is a page that displays some short How-To to help using OFDR Mission Editor for basic mission editing.
These How-To are not the "best way" or are not endorsed by CodeMasters in any way. They are just the result of the long time I spent coding a lot of Single Player / Coop missions with simple and complex scripting (+ 115) .

Link : Official LUA Documentation

 
 
Back to summary
 

HOWTO 3 : About issueCommandOption usage

In several OFP functions, the last parameter is often the issueCommandOption. In CM forum , We regularly see some threads where people write some code with inapropriated issueCommandOption. That may cause their mission not working properly, or at least, things may not happen as they would.

Here is a simple explanation.I hope it's well understandable because my native language is not english. I do my best ...

Imagine that commands are "stacked" in the memory for the game like this :

Command 1 
Command 2 
Command 3 
Command 4
 


Imagine that commands are executed by the engine from top to bottom of the stack. The engine executes the command that is at the top of the stack. When the command is completed, the engine executes the next one, and so on...

Now imagine you set a new command called Command 5 using "ADDTOFRONT " :

Command 5  <-----
Command 1 
Command 2 
Command 3 
Command 4
 


The next command that will be executed by the engine, will be Command 5
When you write ADDTOFRONT that means the new command is placed at the begining of the queue

Now imagine you set a new command called Command 6 using "ADDTOEND " :

Command 5 
Command 1 
Command 2 
Command 3 
Command 4
Command 6  <-----
 


The Command 6 will be executed AFTER the others ( from top to bottom)
When you write ADDTOEND that means the new command is placed at the end of the queue

Now imagine you set a new command called Command 7 using "OVERRIDE " :

Command 7
 



All previous commands have been deleted (they will never be executed. they are simply lost) . Next command will be Command 7
When you write OVERRIDE that means you empty the queue, then you place the new command in the queue

To make the story short :

- I use most of the time "ADDTOEND "
- I use ADDTOFRONT if I write 2 commands at one time :

OFP:takeoff("eCrewHelo", "ADDTOFRONT")
OFP:move("eCrewHelo", "wpHelop", "ADDTOEND")
 


That way, I'm sure that the echelon will move ONLY after the take-off has been completed.

- I use "OVERRIDE " very rarely in some "reaction" functions.

function onHit(victim,attacker)
     local dist = OFP:getDistance(victim,attacker);
     local parent = OFP:getParentEchelon(victim);
     if dist > 375 and OFP:getSide(victim) == 1 then
          if OFP:getMountedVehicle(victim) == "" then
               OFP:searchAndDestroy(parent,attacker,100,true,"OVERRIDE")
          else
               OFP:rapidMove(parent,attacker,"OVERRIDE")
          end
     else
          if OFP:getMountedVehicle(victim) ~= "" then
               if dist < 100 then
                    OFP:dismountVehicle(parent,"OVERRIDE")
               else
                    OFP:assault(parent,attacker,"OVERRIDE");
               end
         end
     end
end
 


This is a function that I use in all my missions.
Basically, when a PLA unit is hit, he ceases all current action and do what is scripted in the function

If I had used "ADDTOEND" instead of "OVERRIDE", the PLA unit would have completed all previous actions BEFORE doing the orders that are inside the function.

 
Back to summary