First off all go get some coffee, this is gonna be a long post.
MachoMan starts looking for snYpirs extensive ECP guide, which he got when he joined ...... Damned can't find it / don't have it anymore
Please keep in mind that I did not design the system, most of the credit has to go to snYpir and some other big brains, so I won't take any credit for it. First of a History lesson
ECP started as a small mod containing something like 20 (I'm just guessing here) scripts. The system developed for calling these scripts was perfectly sensable, although somewhat complicated and cumbersome. But then again it where only a few scripts, so you were still able to oversee it. Today ECP contains over 100 scripts, when I show u the system u will see it will become huge.
An added problem is that the system draws a lot of pc power when starting missions, because many scripts are loaded. Some pc's are unable to handle this and will crash. Also Savegames will become unusable, because Flashpoint will crash when calling all the scripts again.
The history lesson may become boring, so i'll get to my point. If u plan to use a lot of scripts, I would advise you not to use this system, and if you do, do what every good coder does ......
WRITE GOOD COMMENTSBut back to the system, first off the "filesystem"
FilesystemECP uses a lot of map for every script has its own map inside the mod's pbos. In the root ECP map u can find the scripts which create the global variables and even some global scripts, wich are avaible as variables. (using call)
so this creates a situation that looks like this:
\@ECP\ECP_settings.sqs
\@ECP\etc.sqs
@ECP\Addons\ECP_Blood\
@ECP\Addons\ECP_Effects\
The maps I will be focussing on are the ECP_Effects and the root directory, which contain the global variable setting scripts and the init scripts, which excecute and ready the effect scripts.
ECP_Setting.sqsI will focus on the parts which I worked on, because I'm sure I fully understand those.
I will now show u a part of the IR missile jamming scripts
; Jamming system settings
; =======================
;ECP_jam_enable:
; enable jamming system script? (bool)
? [ECP_jam_enable] call ECP_is_null: ECP_jam_enable = true
;ECP_jam_classes:
; List of additional classes that jamming script is init-ed for.
; ("Helicopter" and "Plane" defined Automagicly ;) by ECP )
? [ECP_jam_classes] call ECP_is_scalar: ECP_jam_classes = []
; ECP_jam_exempt
; list of additional subclasses of those superclasses defined above that are
; prohibited from having jamming system effects
? [ECP_jam_exempt] call ECP_is_scalar : ECP_jam_exempt =[]
? [ECP_jam_ammo] call ECP_is_scalar : ECP_jam_ammo = ["AA","9K32"]
; List of ammo considered to be IR guided AA.
As you see this code contains more comments than code, this is very important when trying to understand your or other peoples code.
We will start with the first line of code:
? [ECP_jam_enable] call ECP_is_null: ECP_jam_enable = true
Now what does this do?
It says, if ECP_jam_enable has not been set (ECP hasn't started yet and/or user hasn't changed it), then turn IR jamming on, in other words:
ECP_jam_enable=trueinit_once.sqsSo why the hack does it call ECP_is_null?ECP_is_null is defined in init_once.sqs as:
ECP_is_null = {private["_v","_r"]; _v = _this select 0; _r = true; if (format["%1",_v] != "scalar bool array string 0xfcffffef") then {_r = false}; _r}
So basicly if u get "
scalar bool array string 0xfcffffef" back then ECP is null.
Init.sqsinit_once.sqs is one of the first things excecuted in init.sqs:
; =====================
; OBJECT INITIALISATION
; =====================
_veh = (_this select 0)
_assign_ehs = false
? count _this > 1 : _assign_ehs = _this select 1
_null = "scalar bool array string 0xfcffffef"
; path to ECP_Effects scripts
;ECP_path = "\@ECP\Addons\ECP_Effects\"
ECP_path = "\ECP_Effects\"
; launch seperate scripts for vehicle crew
_is_man = true
? "Man" counttype [_veh] == 0 : {[_x] exec format["%1init.sqs",ECP_path]} foreach (crew _veh); _is_man = false
; count the number of units initialised
? format["%1",ECP_num_units] == _null : ECP_num_units = 0; ECP_num_units_initialised = 0
? _is_man : ECP_num_units = ECP_num_units + 1
; initialise ECP
? format["%1",ECP_system_initialised] == _null : ECP_system_initialised = false; ECP_initialised = false; [] exec format["%1init_once.sqs",ECP_path]
; wait until initialisation is complete
@ECP_system_initialised
Now we go to the actual script launching, which is also done in init.sqs:
I have switched to the altitude warning, because it uses a more standart script calling mechanism (the IR jamming uses event handlers)_arr = ECP_alt_classes; _arr_exempt = ECP_alt_exempt; _rtn = 14; goto "is_class"
#lbl_14
? _is_class : [_veh] exec format["%1altitude\altitude.sqs",ECP_path]
U must be thinking by now, oooow nooooo more variables
, but it gets quite easy right now.
I'll get back to those later, so bare with me, while i explane,
_is_class:
#is_class
_is_class = false
_i = 0
#is_class_l1
? (_arr select _i) counttype [_veh] == 1 : _is_class = true; goto "break1"
~0.001
? _i < (count _arr) - 1 : _i = _i + 1; goto "is_class_l1"
#break1
? !_is_class : goto "break2"
_i = 0
#is_class_l2
? (_arr_exempt select _i) counttype [_veh] == 1 : _is_class = false; goto "break2"
~0.001
? _i < (count _arr_exempt) - 1 : _i = _i + 1; goto "is_class_l2"
#break2
goto format["lbl_%1",_rtn]
So as u see this checks if a unit is supposed to have a given script running. This also clears up the
_rtn = 14 in the last peace of code, it's just a number refering to this piece of code, and tells
is_class where to goto when it's done.
Now back to all those nasty variables, they are defined in
database.sqsdatabase.sqsif we look back to those previous code pieces, we see that they are actually defined by:
ECP_alt_classes & ECP_alt_exempt
; Altitude warning settings
; =========================
; ECP_alt_enable
; enable altitude warning? (bool)
? [ECP_alt_enable] call ECP_is_null: ECP_alt_enable = true
? [ECP_alt_classes] call ECP_is_scalar: ECP_alt_classes = []
ECP_alt_classes = ECP_alt_classes + ["Air"]
? [ECP_alt_exempt] call ECP_is_scalar : ECP_alt_exempt = ["ParachuteEast","ParachuteWest","ParachuteC","ParachuteG"]
Hmm recognize this kind of patern, well u should, let's flash back to the entry in
ECP_settings.sqs. This time i'll take the altitude warning peace:
; Altitude warning Settings
; =========================
; ECP_alt_enable:
; enable altitude warning script? (bool)
? [ECP_alt_enable] call ECP_is_null: ECP_alt_enable = true
; ECP_alt_classes:
; List of additional classes that Altitude warning script is init-ed for.
; ("Helicopter" and "Plane" defined Automagicly ;) by ECP )
? [ECP_alt_classes] call ECP_is_scalar: ECP_alt_classes = []
; ECP_alt_exempt
; list of additional subclasses of those superclasses defined above that are
; prohibited from having altitude warning effects
? [ECP_alt_exempt] call ECP_is_scalar : ECP_alt_exempt = []
U see, so using
database.sqs the empty variables are filled up with whatever u want. (read the comments)
Now if u want to change the fact weather these scripts run, all you need to do is make the global variables defined here changeable by users. (U can use a dialog, like snYpir/ECP did) That's all there's to it.