Global Mobilization Script Snippets: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(→‎Searchlight Guard Towers: updated guard tower script snippet)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[image:gm picture ca.png|borderless|60px|right|link=Global Mobilization]]
{{TOC|side}}<div class="float-right">[[image:gm picture ca.png|borderless|60px|link= Global Mobilization]]</div>
This page serves as a place to collect all smaller known script snippets (and other tricks) related to using the content of [[Global Mobilization]]
This page serves as a place to collect all smaller known script snippets (and other tricks) related to using the content of [[Global Mobilization]].
 
 
== Destroy specific chunks of a house ==
== Destroy specific chunks of a house ==
Use this code on an invisible object nearby the house. chunk_01_hp to chunk_11_hp. But most homes only have 3-4 chunks.
Use this code on an invisible object nearby the house. chunk_01_hp to chunk_11_hp. But most homes only have 3-4 chunks.
<sqf>
<sqf>
(nearestBuilding this) setHit ["chunk_03_hp",1,false]
(nearestBuilding this) setHit ["chunk_03_hp", 1, false];
</sqf>
</sqf>


== Extend a vehicle's large antenna ==  
 
== Extend a vehicle's large antenna ==
 
<sqf>
<sqf>
_vic animateSource ['antennamast_01_elev_source',1,true]
_vic animateSource ["antennamast_01_elev_source", 1, true];
</sqf>
</sqf>
To lower it again, set the second parameter from 1 to 0. If you want to have a slow assembly/disassembly animation, omit the last parameter that is set to true in this example.
To lower it again, set the second parameter from 1 to 0. If you want to have a slow assembly/disassembly animation, omit the last parameter that is set to true in this example.
Line 15: Line 20:
== Close the XSW-30 target searchlight on the Leopard tanks ==
== Close the XSW-30 target searchlight on the Leopard tanks ==
<sqf>
<sqf>
leo animateSource ["MainTurret_searchLight_door_source", 0, true]
leo animateSource ["MainTurret_searchLight_door_source", 0, true];
</sqf>
</sqf>
Set the second parameter to 1 to open it again. Warning: This doesn't affect the searchlight functionality. It will shine through closed doors.
Set the second parameter to 1 to open it again. Warning: This doesn't affect the searchlight functionality. It will shine through closed doors.


== Open doors and hatches on a vehicle ==
== Open doors and hatches on a vehicle ==
<sqf>
<sqf>
<object> animatedoor ["<DoorName>",1];
<object> animatedoor ["<DoorName>", 1];
</sqf>
</sqf>
// animate the M113's main rear hatch:
 
Animate the M113's main rear hatch:
<sqf>
<sqf>
m113dk animatedoor ["hatch_2_1_source",1];
m113dk animatedoor ["hatch_2_1_source", 1];
</sqf>
</sqf>


Line 34: Line 42:


A list of most commonly found doors and hatches:
A list of most commonly found doors and hatches:
<syntaxhighlight lang="cpp">
{{Columns|2|
hatch_1_1_source
* {{hl|hatch_1_1_source}}
hatch_1_2_source
* {{hl|hatch_1_2_source}}
hatch_2_1_source
* {{hl|hatch_2_1_source}}
hatch_2_2_source
* {{hl|hatch_2_2_source}}
* {{hl|door_1_1_source}}
* {{hl|door_1_2_source}}
* {{hl|door_2_1_source}}
* {{hl|door_2_2_source}}
}}


door_1_1_source
It varies per asset, so you may have to try a few combinations until you find the right animation.
door_1_2_source
door_2_1_source
door_2_2_source
</syntaxhighlight>


It varies per asset, so you may have to try a few combinations until you find the right animation.


== Set a vehicle's tactical sign ==
== Set a vehicle's tactical sign ==
<sqf>
<sqf>
[myM113, ["1", "gm_din_norm_gry","gm_tacticalSign_nato_mechanizedInfantry","100","gm_din_norm_gry"]] call gm_core_vehicles_fnc_setTacticalSign
[myM113, ["1", "gm_din_norm_gry", "gm_tacticalSign_nato_mechanizedInfantry", "100", "gm_din_norm_gry"]] call gm_core_vehicles_fnc_setTacticalSign;
</sqf>
</sqf>


The syntax of the large array:  
The array is in format [preIconNumber, preIconNumberFont, tacticalSymbol, postIconNumber, postIconNumberFont]:
<syntaxhighlight lang="cpp">
* preIconNumber: [[String]] - pre-icon number
0: Pre-Icon Number
* preIconNumberFont: [[String]] - pre-icon number font
1: Pre-Icon Number Font
* tacticalSymbol: [[String]] - tactical symbol; for available tactical symbols browse <sqf inline>configFile >> "gm_tacticalSigns"</sqf>; possible values:
2: Tactical Symbol
** {{hl|"gm_tacticalSign_nato_armored"}}
3: Post Icon Number
** {{hl|"gm_tacticalSign_nato_armoredEngineer"}}
4: Post Icon Number Font
** {{hl|"gm_tacticalSign_nato_armoredRecon"}}
** {{hl|"gm_tacticalSign_nato_artillery"}}
* postIconNumber: [[String]] - post-icon number
* postIconNumberFont: [[String]] - post-icon number font


</syntaxhighlight>
For available tactical symbols browse:
<sqf>
configfile >> "gm_tacticalSigns"
</sqf>
<syntaxhighlight lang="cpp">
"gm_tacticalSign_nato_armored"
"gm_tacticalSign_nato_armoredEngineer"
"gm_tacticalSign_nato_armoredRecon"
"gm_tacticalSign_nato_artillery"
</syntaxhighlight>


== GM flags present on a flagpole ==
== GM flags present on a flagpole ==
Line 77: Line 78:
Place an existing flagpole, and write the following into the init-field of this object:
Place an existing flagpole, and write the following into the init-field of this object:
<sqf>
<sqf>
this setFlagTexture "\gm\gm_core\data\flags\gm_flag_gc_co.paa"
this setFlagTexture "\gm\gm_core\data\flags\gm_flag_gc_co.paa";
</sqf>
</sqf>


The following flags are available from within GM:
The following flags are available from within GM:
<syntaxhighlight lang="cpp">
{{Columns|4|
gm_flag_au_co.paa
* {{hl|gm_flag_au_co.paa}}
gm_flag_be_co.paa
* {{hl|gm_flag_be_co.paa}}
gm_flag_bu_co.paa
* {{hl|gm_flag_bu_co.paa}}
gm_flag_ca_co.paa
* {{hl|gm_flag_ca_co.paa}}
gm_flag_cs_co.paa
* {{hl|gm_flag_cs_co.paa}}
gm_flag_cz_co.paa
* {{hl|gm_flag_cz_co.paa}}
gm_flag_dk_co.paa
* {{hl|gm_flag_dk_co.paa}}
gm_flag_fi_co.paa
* {{hl|gm_flag_fi_co.paa}}
gm_flag_fr_co.paa
* {{hl|gm_flag_fr_co.paa}}
gm_flag_gc_co.paa
* {{hl|gm_flag_gc_co.paa}}
gm_flag_ge_co.paa
* {{hl|gm_flag_ge_co.paa}}
gm_flag_gr_co.paa
* {{hl|gm_flag_gr_co.paa}}
gm_flag_hu_co.paa
* {{hl|gm_flag_hu_co.paa}}
gm_flag_ic_co.paa
* {{hl|gm_flag_ic_co.paa}}
gm_flag_it_co.paa
* {{hl|gm_flag_it_co.paa}}
gm_flag_lu_co.paa
* {{hl|gm_flag_lu_co.paa}}
gm_flag_nato_co.paa
* {{hl|gm_flag_nato_co.paa}}
gm_flag_nl_co.paa
* {{hl|gm_flag_nl_co.paa}}
gm_flag_no_co.paa
* {{hl|gm_flag_no_co.paa}}
gm_flag_pl_co.paa
* {{hl|gm_flag_pl_co.paa}}
gm_flag_po_co.paa
* {{hl|gm_flag_po_co.paa}}
gm_flag_ro_co.paa
* {{hl|gm_flag_ro_co.paa}}
gm_flag_se_co.paa
* {{hl|gm_flag_se_co.paa}}
gm_flag_sp_co.paa
* {{hl|gm_flag_sp_co.paa}}
gm_flag_tu_co.paa
* {{hl|gm_flag_tu_co.paa}}
gm_flag_uk_co.paa
* {{hl|gm_flag_uk_co.paa}}
gm_flag_ur_co.paa
* {{hl|gm_flag_ur_co.paa}}
gm_flag_us_co.paa
* {{hl|gm_flag_us_co.paa}}
</syntaxhighlight>
}}


They are assigned via the NATO 2-Letter Nation code from STANAG 1059 7th Edition.
They are assigned via the NATO 2-Letter Nation code from STANAG 1059 7th Edition.


Find the 9th edition (which differs) here:
Find the 9th edition (which differs) here: {{Link|https://en.wikipedia.org/wiki/List_of_NATO_country_codes}}
https://en.wikipedia.org/wiki/List_of_NATO_country_codes
GE = West Germany
GC = East Germany


GE = West Germany
GC = East Germany


== Toggle vehicle beacons and sirens ==
== Toggle vehicle beacons and sirens ==
<sqf>
<sqf>
[this,'gm_beacons_org',true] call gm_core_vehicles_fnc_beaconSwitch
[this, "gm_beacons_org", true] call gm_core_vehicles_fnc_beaconSwitch;
</sqf>
</sqf>
<sqf>
[this, "", true] call gm_core_vehicles_fnc_beaconSwitch;
</sqf>


<sqf inline>true</sqf> for on, <sqf inline>false</sqf> for off.
<sqf inline>true</sqf> for on, <sqf inline>false</sqf> for off.


<sqf inline>gm_beacons_org</sqf> for the orange one, and <sqf inline>gm_beacons_blu</sqf> for blue.
<sqf inline>gm_beacons_org</sqf> for the orange one, and <sqf inline>gm_beacons_blu</sqf> for blue. Leave it empty <sqf inline>""</sqf> as secondary method.


To toggle beacons on a car via script: (also possible gm_beacons_orn on vehicles with orange beacon lights).
To toggle beacons on a car via script: (also possible gm_beacons_orn on vehicles with orange beacon lights).


Toggle on:
Toggle on:
<sqf inline>[this,'gm_beacons_blu',true] call gm_core_vehicles_fnc_beaconSwitch</sqf>
<sqf inline>[this, "gm_beacons_blu", true] call gm_core_vehicles_fnc_beaconSwitch;</sqf>


Toggle off:
Toggle off:
<sqf inline>[this,'gm_beacons_blu',false] call gm_core_vehicles_fnc_beaconSwitch</sqf>
<sqf inline>[this, "gm_beacons_blu", false] call gm_core_vehicles_fnc_beaconSwitch;</sqf>


Sirens on:
Sirens on:
<sqf inline>[this,'CustomSoundController1',1,0.2] remoteExec ['BIS_fnc_setCustomSoundController'];</sqf>
<sqf inline>[this, "CustomSoundController1", 1, 0.2] remoteExec ["BIS_fnc_setCustomSoundController"];</sqf>


Sirens off:
Sirens off:
<sqf inline>[this,'CustomSoundController1',0,0.4] remoteExec ['BIS_fnc_setCustomSoundController'];</sqf>
<sqf inline>[this, "CustomSoundController1", 0, 0.4] remoteExec ["BIS_fnc_setCustomSoundController"];</sqf>
 




Line 155: Line 160:


2)
2)
Include this in CfgSounds:
Include this in [[Description.ext#CfgSounds|CfgSounds]]:
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
class gm_teletype_stroke_01
class gm_teletype_stroke_01
{
{
    name = "";
name = "";
    titles[] = {};
titles[] = {};
    sound[] = { "@gm\gm_missions\gm_campaign_01\missions\gm_campaign_intro.gm_weferlingen_summer\sounds\gm_teletype_stroke_01.ogg", 3, 1, 100};
sound[] = { "@gm\gm_missions\gm_campaign_01\missions\gm_campaign_intro.gm_weferlingen_summer\sounds\gm_teletype_stroke_01.ogg", 3, 1, 100 };
};
};
class gm_teletype_stroke_02 : gm_teletype_stroke_01
class gm_teletype_stroke_02 : gm_teletype_stroke_01
{
{
    sound[] = { "@gm\gm_missions\gm_campaign_01\missions\gm_campaign_intro.gm_weferlingen_summer\sounds\gm_teletype_stroke_01.ogg", 3, 0.98, 100};
sound[] = { "@gm\gm_missions\gm_campaign_01\missions\gm_campaign_intro.gm_weferlingen_summer\sounds\gm_teletype_stroke_01.ogg", 3, 0.98, 100 };
};
};
class gm_teletype_stroke_03 : gm_teletype_stroke_01
class gm_teletype_stroke_03 : gm_teletype_stroke_01
{
{
    sound[] = { "@gm\gm_missions\gm_campaign_01\missions\gm_campaign_intro.gm_weferlingen_summer\sounds\gm_teletype_stroke_01.ogg", 3, 1.02, 100};
sound[] = { "@gm\gm_missions\gm_campaign_01\missions\gm_campaign_intro.gm_weferlingen_summer\sounds\gm_teletype_stroke_01.ogg", 3, 1.02, 100 };
};
};
</syntaxhighlight>


</syntaxhighlight>
3)
3)
Create  script called typeText.sqf.
Create  script called typeText.sqf.
<sqf>
<sqf>
_text = _this;
private _text = _this;


if (isNull (uiNameSpace getVariable ["gm_teleraet_overlay", displayNull])) then {91 cutRsc ["gm_teleraet_overlay", "PLAIN"]};
if (isNull (uiNameSpace getVariable ["gm_teleraet_overlay", displayNull])) then {91 cutRsc ["gm_teleraet_overlay", "PLAIN"]};
_o = uiNameSpace getVariable ["gm_teleraet_overlay", displayNull];
private _o = uiNameSpace getVariable ["gm_teleraet_overlay", displayNull];
_len = count _text;
private _len = count _text;
_cache = [""];
private _cache = [""];
_curLnLen = 0;
private _curLnLen = 0;
_cln = 0;
private _cln = 0;
_maxLines = 7;
private _maxLines = 7;
 
for "_i" from 1 to _len do
for "_i" from 1 to _len do
{
{
_curC = _text select [_i-1,1];
private _curC = _text select [_i-1, 1];
switch true do
switch true do
{
{
Line 193: Line 202:
case (_curC == " ") :
case (_curC == " ") :
{
{
_ct = (_cache select _cln);
private _ct = (_cache select _cln);
_ct = _ct + _curC;
_ct = _ct + _curC;
_cache set [_cln, _ct];
_cache set [_cln, _ct];
Line 202: Line 211:
case (_curC == "@") :
case (_curC == "@") :
{
{
_cache pushback linebreak;
_cache pushBack linebreak;
_cache pushBack "";
_cache pushBack "";
_cln = _cln +2;
_cln = _cln +2;
Line 212: Line 221:
default
default
{
{
_ct = (_cache select _cln);
private _ct = _cache select _cln;
_ct = _ct + _curC;
_ct = _ct + _curC;
_cache set [_cln, _ct];
_cache set [_cln, _ct];
_curLnLen = _curLnLen + 1;
_curLnLen = _curLnLen + 1;
playSound [selectRandom ["gm_teletype_stroke_01","gm_teletype_stroke_02","gm_teletype_stroke_03"], true];
playSound [selectRandom ["gm_teletype_stroke_01", "gm_teletype_stroke_02", "gm_teletype_stroke_03"], true];
sleep 0.06;
sleep 0.06;
};
};
Line 222: Line 231:


// adjust cacheLines to follow the max visible lines
// adjust cacheLines to follow the max visible lines
_dif = ((count _cache - ({_x isEqualTo linebreak} count _cache)) - _maxLines) max 0;
private _dif = ((count _cache - ({_x isEqualTo linebreak} count _cache)) - _maxLines) max 0;
if (_dif > 0) then {_dif = _dif + 1};
if (_dif > 0) then { _dif = _dif + 1 };
_cache deleteRange [0,_dif];
_cache deleteRange [0, _dif];
_cln = _cln - _dif;
_cln = _cln - _dif;


Line 230: Line 239:
};
};
</sqf>
</sqf>
 
 
4)
4)
Call the script via <sqf inline>"My Text Is This" execVM "typeText.sqf"</sqf>. You can also make it a function and spawn it.
Call the script via <sqf inline>"My Text Is This" execVM "typeText.sqf"</sqf>. You can also make it a function and spawn it.


'''Using the @ character in the input text will cause a line break.'''
{{Feature|informative|Using the @ character in the input text will cause a line break.}}




== Add helmet camo to any unit ==
== Add helmet camo to any unit ==
<sqf inline>player linkItem  "gm_hmd_foliage_summer_grass_01"</sqf>
 
<sqf>player linkItem  "gm_hmd_foliage_summer_grass_01";</sqf>


You can use these types:
You can use these types:
<syntaxhighlight lang="cpp">
{{Columns|3|
gm_hmd_foliage_summer_grass_01
* {{hl|gm_hmd_foliage_summer_grass_01}}
gm_hmd_foliage_summer_grass_02
* {{hl|gm_hmd_foliage_summer_grass_02}}
gm_hmd_foliage_summer_grass_03
* {{hl|gm_hmd_foliage_summer_grass_03}}
gm_hmd_foliage_summer_grass_04
* {{hl|gm_hmd_foliage_summer_grass_04}}
* {{hl|gm_hmd_foliage_autumn_grass_01}}
* {{hl|gm_hmd_foliage_autumn_grass_02}}
* {{hl|gm_hmd_foliage_autumn_grass_03}}
* {{hl|gm_hmd_foliage_autumn_grass_04}}
* {{hl|gm_hmd_foliage_summer_forest_01}}
* {{hl|gm_hmd_foliage_summer_forest_02}}
* {{hl|gm_hmd_foliage_summer_forest_03}}
* {{hl|gm_hmd_foliage_summer_forest_04}}
}}


gm_hmd_foliage_autumn_grass_01
gm_hmd_foliage_autumn_grass_02
gm_hmd_foliage_autumn_grass_03
gm_hmd_foliage_autumn_grass_04
gm_hmd_foliage_summer_forest_01
gm_hmd_foliage_summer_forest_02
gm_hmd_foliage_summer_forest_03
gm_hmd_foliage_summer_forest_04
</syntaxhighlight>


== Eject parachutists out of a vehicle ==
== Eject parachutists out of a vehicle ==
Line 264: Line 274:
temp = this spawn
temp = this spawn
{
{
    {
{
        _d = _x select 0;
private _d = _x select 0;
        moveOut _d;
moveOut _d;
        unassignVehicle _d;
unassignVehicle _d;
        (sleep (0.7 + random 0.2))
sleep (0.7 + random 0.2);
    } forEach fullCrew [vehicle leader _this, "cargo"];
} forEach fullCrew [vehicle leader _this, "cargo"];
}
};
</sqf>
</sqf>
 
 
== Mi-2Ch Smoke Generator control ==
== Mi-2Ch Smoke Generator control ==
Turn On:
Turn On:
<sqf inline>[this] call gm_countermeasures_fnc_engine_smoke_toggle</sqf>
<sqf inline>[this] call gm_countermeasures_fnc_engine_smoke_toggle;</sqf>


Turn Off:
Turn Off:
<sqf inline>[this, true] call gm_countermeasures_fnc_engine_smoke_toggle</sqf>  
<sqf inline>[this, true] call gm_countermeasures_fnc_engine_smoke_toggle;</sqf>
 


== Override Bridge Laying Restrictions ==
== Override Bridge Laying Restrictions ==
If you want to override the red indicator and deploy/pickup the bridge regardless:
If you want to override the red indicator and deploy/pickup the bridge regardless:


<sqf>
<sqf>
vehicle player setVariable ['GM_BRIDGE_ACCEPTED',true,true];
vehicle player setVariable ["GM_BRIDGE_ACCEPTED", true, true];
vehicle player setVariable ['GM_BRIDGE_INPOSITION',true,true];
vehicle player setVariable ["GM_BRIDGE_INPOSITION", true, true];
</sqf>
</sqf>


== Start a bridge deployment ==
== Start a bridge deployment ==
<sqf inline>[yourBridgeLayer] spawn gm_core_vehicles_fnc_bridge_deploy;</sqf>
<sqf inline>[yourBridgeLayer] spawn gm_core_vehicles_fnc_bridge_deploy;</sqf>


Line 294: Line 310:


<sqf>
<sqf>
yourBridgeLayer setVariable ['GM_BRIDGE_ACCEPTED',true,true];
yourBridgeLayer setVariable ["GM_BRIDGE_ACCEPTED", true, true];
yourBridgeLayer setVariable ['GM_BRIDGE_INPOSITION',true,true];
yourBridgeLayer setVariable ["GM_BRIDGE_INPOSITION", true, true];
</sqf>
</sqf>


''There may be side effects from forcing the deployment in an unsuitable location though.''
{{Feature|informative|There may be side effects from forcing the deployment in an unsuitable location.}}
 


== Spawn a bridgelayer without bridge ==
== Spawn a bridgelayer without bridge ==


<sqf>
<sqf>
this setVariable ['GM_BRIDGE_BRIDGELOADED',false,true];
this setVariable ["GM_BRIDGE_BRIDGELOADED", false, true];
this setVariable ['GM_BRIDGE_STATUS',false,true];
this setVariable ["GM_BRIDGE_STATUS", false, true];
this animateSource ['gm_bridgePrepare_source',1,true];
this animateSource ["gm_bridgePrepare_source", 1, true];
this animateSource ['gm_bridgeDetach_source',1,true];
this animateSource ["gm_bridgeDetach_source", 1, true];
this animateSource ['gm_bridgeReady_source',1,true];
this animateSource ["gm_bridgeReady_source", 1, true];
</sqf>
</sqf>


== Nuclear Warhead for the 2P16 Luna ==
== Nuclear Warhead for the 2P16 Luna ==
To quickly change the 2P16 over to the nuclear missile use the following code to circumvent the long reload time the missile otherwise would have:
To quickly change the 2P16 over to the nuclear missile use the following code to circumvent the long reload time the missile otherwise would have:


<sqf inline>myLuna</sqf> is the given variable name of the vehicle. You can use <sqf inline>this</sqf> instead when pasting this into the vehicle's init line.
<sqf inline>myLuna</sqf> is the given variable name of the vehicle. You can use <sqf inline>this</sqf> instead when pasting this into the vehicle's init line.
<sqf>
<sqf>
myLuna removeMagazinesTurret ["gm_1Rnd_luna_he_3r9",[0]];  
myLuna removeMagazinesTurret ["gm_1Rnd_luna_he_3r9", [0]];
myLuna removeWeaponTurret ["gm_luna_launcher",[0]];  
myLuna removeWeaponTurret ["gm_luna_launcher", [0]];
myLuna addMagazineTurret ["gm_1Rnd_luna_nuc_3r10",[0]];  
myLuna addMagazineTurret ["gm_1Rnd_luna_nuc_3r10", [0]];
myLuna addWeaponTurret ["gm_luna_launcher",[0]];
myLuna addWeaponTurret ["gm_luna_launcher", [0]];
</sqf>
</sqf>


== Searchlight Guard Towers ==
== Searchlight Guard Towers ==
To easily turn the BT-6 and BT-11 guard towers in functioning towers that scan with search lights, raise alarm and shoot flares:
To easily turn the BT-6 and BT-11 guard towers in functioning towers that scan with search lights, raise alarm and shoot flares:


Paste this code into your init.sqf:
Paste this code into your [[Event Scripts#init.sqf|init.sqf]]:


<sqf>
<sqf>
if isServer then
if isServer then
{
{
     gm_fr_guardTowerCrew = ["gm_gc_army_rifleman_mpiak74n_80_str"]; // change the classnames in here to the type of solider you want
     gm_fr_guardTowerCrew = ["gm_gc_army_rifleman_mpiak74n_80_str"]; // change the classnames in here to the type of soldier you want
     gm_fr_alarmSirenSound = "gm_alarmHorn"; // you can change this to other sounds
     gm_fr_alarmSirenSound = "gm_alarmHorn"; // you can change this to other sounds
     gm_fr_alarmFlareAmmoType = "gm_flare_illum_red"; // you can change this to other flare sounds
     gm_fr_alarmFlareAmmoType = "gm_flare_illum_red"; // you can change this to other flare sounds
    gm_fr_side_friendly = west; // use the appropriate side for your enemies
     gm_fr_side_enemy = east; // use the appropriate side for your enemies
     gm_fr_side_enemy = east; // use the appropriate side for your enemies
     gm_fr_extendedDebugMode = 0; // leave it as 0
     gm_fr_extendedDebugMode = 0; // leave it as 0
     gm_alias_fr_fnc_debugMarker = [{""}]; // leave this the way it is
     gm_alias_fr_fnc_debugMarker = [{ "" }]; // leave this the way it is
gm_alias_fr_fnc_raiseAlarm = [gm_fr_fnc_raiseAlarm];
gm_alias_fr_fnc_shootFlare = [gm_core_fnc_shootIllumFlare];
     {
     {
         _x call gm_fr_fnc_makeBorderTurret;
         _x call gm_fr_fnc_makeBorderTurret;
Line 341: Line 365:


Then go around the map in Weferlingen and place the '''Guard Tower Mission Context object''' <sqf inline>gm_missionHelper_guardtower</sqf> near any of the guard towers you wish to equip.
Then go around the map in Weferlingen and place the '''Guard Tower Mission Context object''' <sqf inline>gm_missionHelper_guardtower</sqf> near any of the guard towers you wish to equip.


[[Category:Global Mobilization]]
[[Category:Global Mobilization]]

Latest revision as of 17:24, 13 January 2024

borderless

This page serves as a place to collect all smaller known script snippets (and other tricks) related to using the content of Global Mobilization.


Destroy specific chunks of a house

Use this code on an invisible object nearby the house. chunk_01_hp to chunk_11_hp. But most homes only have 3-4 chunks.

(nearestBuilding this) setHit ["chunk_03_hp", 1, false];


Extend a vehicle's large antenna

_vic animateSource ["antennamast_01_elev_source", 1, true];

To lower it again, set the second parameter from 1 to 0. If you want to have a slow assembly/disassembly animation, omit the last parameter that is set to true in this example.

Close the XSW-30 target searchlight on the Leopard tanks

leo animateSource ["MainTurret_searchLight_door_source", 0, true];

Set the second parameter to 1 to open it again. Warning: This doesn't affect the searchlight functionality. It will shine through closed doors.


Open doors and hatches on a vehicle

<object> animatedoor ["<DoorName>", 1];

Animate the M113's main rear hatch:

m113dk animatedoor ["hatch_2_1_source", 1];

All doors and hatches in GM follow a unified naming standard:

<type>_<row>_<side>_source

A list of most commonly found doors and hatches:

  • hatch_1_1_source
  • hatch_1_2_source
  • hatch_2_1_source
  • hatch_2_2_source
  • door_1_1_source
  • door_1_2_source
  • door_2_1_source
  • door_2_2_source

It varies per asset, so you may have to try a few combinations until you find the right animation.


Set a vehicle's tactical sign

[myM113, ["1", "gm_din_norm_gry", "gm_tacticalSign_nato_mechanizedInfantry", "100", "gm_din_norm_gry"]] call gm_core_vehicles_fnc_setTacticalSign;

The array is in format [preIconNumber, preIconNumberFont, tacticalSymbol, postIconNumber, postIconNumberFont]:

  • preIconNumber: String - pre-icon number
  • preIconNumberFont: String - pre-icon number font
  • tacticalSymbol: String - tactical symbol; for available tactical symbols browse configFile >> "gm_tacticalSigns"; possible values:
    • "gm_tacticalSign_nato_armored"
    • "gm_tacticalSign_nato_armoredEngineer"
    • "gm_tacticalSign_nato_armoredRecon"
    • "gm_tacticalSign_nato_artillery"
  • postIconNumber: String - post-icon number
  • postIconNumberFont: String - post-icon number font


GM flags present on a flagpole

Place an existing flagpole, and write the following into the init-field of this object:

this setFlagTexture "\gm\gm_core\data\flags\gm_flag_gc_co.paa";

The following flags are available from within GM:

  • gm_flag_au_co.paa
  • gm_flag_be_co.paa
  • gm_flag_bu_co.paa
  • gm_flag_ca_co.paa
  • gm_flag_cs_co.paa
  • gm_flag_cz_co.paa
  • gm_flag_dk_co.paa
  • gm_flag_fi_co.paa
  • gm_flag_fr_co.paa
  • gm_flag_gc_co.paa
  • gm_flag_ge_co.paa
  • gm_flag_gr_co.paa
  • gm_flag_hu_co.paa
  • gm_flag_ic_co.paa
  • gm_flag_it_co.paa
  • gm_flag_lu_co.paa
  • gm_flag_nato_co.paa
  • gm_flag_nl_co.paa
  • gm_flag_no_co.paa
  • gm_flag_pl_co.paa
  • gm_flag_po_co.paa
  • gm_flag_ro_co.paa
  • gm_flag_se_co.paa
  • gm_flag_sp_co.paa
  • gm_flag_tu_co.paa
  • gm_flag_uk_co.paa
  • gm_flag_ur_co.paa
  • gm_flag_us_co.paa

They are assigned via the NATO 2-Letter Nation code from STANAG 1059 7th Edition.

Find the 9th edition (which differs) here: List of NATO country codes

GE = West Germany
GC = East Germany


Toggle vehicle beacons and sirens

[this, "gm_beacons_org", true] call gm_core_vehicles_fnc_beaconSwitch;

[this, "", true] call gm_core_vehicles_fnc_beaconSwitch;


true for on, false for off.

gm_beacons_org for the orange one, and gm_beacons_blu for blue. Leave it empty "" as secondary method.

To toggle beacons on a car via script: (also possible gm_beacons_orn on vehicles with orange beacon lights).

Toggle on: [this, "gm_beacons_blu", true] call gm_core_vehicles_fnc_beaconSwitch;

Toggle off: [this, "gm_beacons_blu", false] call gm_core_vehicles_fnc_beaconSwitch;

Sirens on: [this, "CustomSoundController1", 1, 0.2] remoteExec ["BIS_fnc_setCustomSoundController"];

Sirens off: [this, "CustomSoundController1", 0, 0.4] remoteExec ["BIS_fnc_setCustomSoundController"];


Use the teletype effect from the Campaign Intro

1) Include this in your description.ext in class RscTitles

"\gm\gm_missions\gm_campaign_01\missions\gm_campaign_intro.gm_weferlingen_summer\resources.inc"


2) Include this in CfgSounds:

class gm_teletype_stroke_01
{
	name = "";
	titles[] = {};
	sound[] = { "@gm\gm_missions\gm_campaign_01\missions\gm_campaign_intro.gm_weferlingen_summer\sounds\gm_teletype_stroke_01.ogg", 3, 1, 100 };
};

class gm_teletype_stroke_02 : gm_teletype_stroke_01
{
	sound[] = { "@gm\gm_missions\gm_campaign_01\missions\gm_campaign_intro.gm_weferlingen_summer\sounds\gm_teletype_stroke_01.ogg", 3, 0.98, 100 };
};

class gm_teletype_stroke_03 : gm_teletype_stroke_01
{
	sound[] = { "@gm\gm_missions\gm_campaign_01\missions\gm_campaign_intro.gm_weferlingen_summer\sounds\gm_teletype_stroke_01.ogg", 3, 1.02, 100 };
};


3) Create script called typeText.sqf.

private _text = _this; if (isNull (uiNameSpace getVariable ["gm_teleraet_overlay", displayNull])) then {91 cutRsc ["gm_teleraet_overlay", "PLAIN"]}; private _o = uiNameSpace getVariable ["gm_teleraet_overlay", displayNull]; private _len = count _text; private _cache = [""]; private _curLnLen = 0; private _cln = 0; private _maxLines = 7; for "_i" from 1 to _len do { private _curC = _text select [_i-1, 1]; switch true do { // add a space, which is a bit faster than regular typing. case (_curC == " ") : { private _ct = (_cache select _cln); _ct = _ct + _curC; _cache set [_cln, _ct]; _curLnLen = _curLnLen + 1; sleep 0.03; }; // add a linebreak, which means writer head needs to readjust and travel back the lenngth of current line case (_curC == "@") : { _cache pushBack linebreak; _cache pushBack ""; _cln = _cln +2; _curLnLen = 0; sleep (0.14 +(_curLnLen * 0.05)); }; // text, so we write and wait, plus play sound default { private _ct = _cache select _cln; _ct = _ct + _curC; _cache set [_cln, _ct]; _curLnLen = _curLnLen + 1; playSound [selectRandom ["gm_teletype_stroke_01", "gm_teletype_stroke_02", "gm_teletype_stroke_03"], true]; sleep 0.06; }; }; // adjust cacheLines to follow the max visible lines private _dif = ((count _cache - ({_x isEqualTo linebreak} count _cache)) - _maxLines) max 0; if (_dif > 0) then { _dif = _dif + 1 }; _cache deleteRange [0, _dif]; _cln = _cln - _dif; (_o displayCtrl 2) ctrlSetStructuredText composeText _cache; };


4) Call the script via "My Text Is This" execVM "typeText.sqf". You can also make it a function and spawn it.

Using the @ character in the input text will cause a line break.


Add helmet camo to any unit

player linkItem "gm_hmd_foliage_summer_grass_01";

You can use these types:

  • gm_hmd_foliage_summer_grass_01
  • gm_hmd_foliage_summer_grass_02
  • gm_hmd_foliage_summer_grass_03
  • gm_hmd_foliage_summer_grass_04
  • gm_hmd_foliage_autumn_grass_01
  • gm_hmd_foliage_autumn_grass_02
  • gm_hmd_foliage_autumn_grass_03
  • gm_hmd_foliage_autumn_grass_04
  • gm_hmd_foliage_summer_forest_01
  • gm_hmd_foliage_summer_forest_02
  • gm_hmd_foliage_summer_forest_03
  • gm_hmd_foliage_summer_forest_04


Eject parachutists out of a vehicle

Inside "On Activation" of a waypoint for the plane (not the squad to jump out!)

temp = this spawn { { private _d = _x select 0; moveOut _d; unassignVehicle _d; sleep (0.7 + random 0.2); } forEach fullCrew [vehicle leader _this, "cargo"]; };


Mi-2Ch Smoke Generator control

Turn On: [this] call gm_countermeasures_fnc_engine_smoke_toggle;

Turn Off: [this, true] call gm_countermeasures_fnc_engine_smoke_toggle;


Override Bridge Laying Restrictions

If you want to override the red indicator and deploy/pickup the bridge regardless:

vehicle player setVariable ["GM_BRIDGE_ACCEPTED", true, true]; vehicle player setVariable ["GM_BRIDGE_INPOSITION", true, true];


Start a bridge deployment

[yourBridgeLayer] spawn gm_core_vehicles_fnc_bridge_deploy;

Once activated you can force the process into the next phase of actively deploying it via the above mentioned lines:

yourBridgeLayer setVariable ["GM_BRIDGE_ACCEPTED", true, true]; yourBridgeLayer setVariable ["GM_BRIDGE_INPOSITION", true, true];

There may be side effects from forcing the deployment in an unsuitable location.


Spawn a bridgelayer without bridge

this setVariable ["GM_BRIDGE_BRIDGELOADED", false, true]; this setVariable ["GM_BRIDGE_STATUS", false, true]; this animateSource ["gm_bridgePrepare_source", 1, true]; this animateSource ["gm_bridgeDetach_source", 1, true]; this animateSource ["gm_bridgeReady_source", 1, true];


Nuclear Warhead for the 2P16 Luna

To quickly change the 2P16 over to the nuclear missile use the following code to circumvent the long reload time the missile otherwise would have:

myLuna is the given variable name of the vehicle. You can use this instead when pasting this into the vehicle's init line.

myLuna removeMagazinesTurret ["gm_1Rnd_luna_he_3r9", [0]]; myLuna removeWeaponTurret ["gm_luna_launcher", [0]]; myLuna addMagazineTurret ["gm_1Rnd_luna_nuc_3r10", [0]]; myLuna addWeaponTurret ["gm_luna_launcher", [0]];


Searchlight Guard Towers

To easily turn the BT-6 and BT-11 guard towers in functioning towers that scan with search lights, raise alarm and shoot flares:

Paste this code into your init.sqf:

if isServer then { gm_fr_guardTowerCrew = ["gm_gc_army_rifleman_mpiak74n_80_str"]; // change the classnames in here to the type of soldier you want gm_fr_alarmSirenSound = "gm_alarmHorn"; // you can change this to other sounds gm_fr_alarmFlareAmmoType = "gm_flare_illum_red"; // you can change this to other flare sounds gm_fr_side_friendly = west; // use the appropriate side for your enemies gm_fr_side_enemy = east; // use the appropriate side for your enemies gm_fr_extendedDebugMode = 0; // leave it as 0 gm_alias_fr_fnc_debugMarker = [{ "" }]; // leave this the way it is gm_alias_fr_fnc_raiseAlarm = [gm_fr_fnc_raiseAlarm]; gm_alias_fr_fnc_shootFlare = [gm_core_fnc_shootIllumFlare]; { _x call gm_fr_fnc_makeBorderTurret; } forEach allMissionObjects "gm_missionHelper_guardtower"; // you can change the logic type to any object you want, best to leave it this way };

Then go around the map in Weferlingen and place the Guard Tower Mission Context object gm_missionHelper_guardtower near any of the guard towers you wish to equip.