Jump to content
mattyrepe98

The script works but slows down the scenario too much

Recommended Posts

Good morning everyone. I am not a scripter, but I have tried to create two scrips to create a co10 escape mission like those of neoarmagheddon and scruffy, on the ts_chernobyl redux map by TZR team which has not yet been edited and I like the idea of having to escape from a map with contaminated areas so I added the JSHK gear and contam. zones created by JSHOK. Now the two scripts are used to remove the glasses of the AI, add gas masks to the AIs only when they are close to contaminated areas and remove them when they come out. The scripts work and are executed by triggers placed in the editor, for the first script (the one which removes the glasses to the AI) with this condition and activation and executes this script (RAD_X in the cript are the positions of the contaminated areas and are invisible helipads):

 

Spoiler

//ON TRIGGER CONDITION

 

this && call{count (allUnits select {_x isNotEqualTo player && isNil {_x getVariable "passedMaskB"}}) >0;}

 

Spoiler

//ON TRIGGER ACTIVATION

 

call{{_x setVariable ["passedMaskB",true]; [_x, {allUnits select {_x isNotEqualTo  player}}, nil] execVM "MRscripts\gas_maskAIR.sqf";} forEach (allUnits select {_x isNotEqualTo player && isNil {_x getVariable "passedMaskB"}});

 

Spoiler

//SCRIPT

 

while {true} do {{
removeGoggles _x;

} forEach (allUnits select {_x isNotEqualTo player && {_x distance RAD_1 > 1100} && {_x distance RAD_2 > 1100} && {_x distance RAD_3 > 1100} && {_x distance RAD_4 > 1100} && {_x distance RAD_5 > 1100} && {_x distance RAD_6 > 1100} && {_x distance RAD_7 > 1100} && {_x distance RAD_8 > 1100} && {_x distance RAD_9 > 1100} && {_x distance RAD_10 > 1100} && {_x distance RAD_11 > 1100} && {_x distance RAD_12 > 1100} && {_x distance RAD_13 > 1100} && {_x distance RAD_14 > 1100} && {_x distance RAD_15 > 1100} && {_x distance RAD_16 > 1100} && {_x distance RAD_17 > 1100} && {_x distance RAD_18 > 1100} && {_x distance RAD_19 > 1100} && {_x distance RAD_20 > 1100} && {_x distance RAD_21 > 1100} && {_x distance RAD_22 > 1100} && {_x distance RAD_23 > 1100} && {_x distance RAD_24 > 1100} && {_x distance RAD_25 > 1100} && {_x distance RAD_26 > 1100} && {_x distance RAD_27 > 1100} && {_x distance RAD_28 > 1100} && {_x distance RAD_29 > 1100} && {_x distance RAD_30 > 1100} && {_x distance RAD_31 > 1100} && {_x distance RAD_32 > 1100} && {_x distance RAD_33 > 1100} && {_x distance RAD_34 > 1100} && {_x distance RAD_35 > 1100} && {_x distance RAD_36 > 1100} && {_x distance RAD_37 > 1100} && {_x distance RAD_38 > 1100} && {_x distance RAD_39 > 1100} && {_x distance RAD_40 > 1100} && {_x distance RAD_41 > 1100} && {_x distance RAD_42 > 1100} && {_x distance RAD_43 > 1100} && {_x distance RAD_44 > 1100} && {_x distance RAD_45 > 1100} && {_x distance RAD_46 > 1100} && {_x distance RAD_47 > 1100} && {_x distance RAD_48 > 1100} && {_x distance RAD_49 > 1100} && {_x distance RAD_50 > 1100} && {_x distance RAD_51 > 1100} && {_x distance RAD_52 > 1100} && {_x distance RAD_53 > 1100} && {_x distance RAD_54 > 1100} && {_x distance RAD_55 > 1100} && {_x distance RAD_56 > 1100} && {_x distance RAD_57 > 1100} && {_x distance RAD_58 > 1100} && {_x distance RAD_59 > 1100} && {_x distance RAD_60 > 1100} && {_x distance RAD_61 > 1100} && {_x distance RAD_62 > 1100} && {_x distance RAD_63 > 1100} && {_x distance RAD_64 > 1100} && {_x distance RAD_65 > 1100} && {_x distance RAD_66 > 1100} && {_x distance RAD_67 > 1100} && {_x distance RAD_68 > 1100} && {_x distance RAD_69 > 1100} && {_x distance RAD_70 > 1100} && {_x distance RAD_71 > 1100} && {_x distance RAD_72 > 1100} && {_x distance RAD_73 > 1100} && {_x distance RAD_74 > 1100} && {_x distance RAD_75 > 1100} && {_x distance RAD_76 > 1100} && {_x distance RAD_77 > 1100} && {_x distance RAD_78 > 1100} && {_x distance RAD_79 > 1100} && {_x distance RAD_80 > 1100} && {_x distance RAD_81 > 1100} && {_x distance RAD_82 > 1100} && {_x distance RAD_83 > 1100} && {_x distance RAD_84 > 1100} && {_x distance RAD_85 > 1100} && {_x distance RAD_86 > 1100} && {_x distance RAD_87 > 1100} && {_x distance RAD_88 > 1100} && {_x distance RAD_89 > 1100} && {_x distance RAD_90 > 1100} && {_x distance RAD_91 > 1100} && {_x distance RAD_92 > 1100} && {_x distance RAD_93 > 1100} && {_x distance RAD_94 > 1100} && {_x distance RAD_95 > 1100} && {_x distance RAD_96 > 1100} && {_x distance RAD_97 > 1100} && {_x distance RAD_98 > 1100} && {_x distance RAD_99 > 1100} && {_x distance RAD_100 > 1100} && {_x distance RAD_101 > 1100} && {_x distance RAD_102 > 1100} && {_x distance RAD_103 > 1100} && {_x distance RAD_104 > 1100} && {_x distance RAD_105 > 1100} && {_x distance RAD_106 > 1100} && {_x distance RAD_107 > 1100} && {_x distance RAD_108 > 1100} && {_x distance RAD_M_2 > 1100} && {_x distance RAD_M_1 > 1700}});
};

 

per il secondo script (the one who gives the AI gas masks when they are close to the zones):

 

Spoiler

//ON TRIGGER CONDITION

 

call{count (allUnits select {_x isNotEqualTo  player && isNil {_x getVariable "passedMaskB"} && {_x distance  RAD_1 < 1100 or  _x distance  RAD_2 < 1100 or  _x distance  RAD_3 < 1100 or  _x distance  RAD_4 < 1100 or  _x distance  RAD_5 < 1100 or  _x distance  RAD_6 < 1100 or  _x distance  RAD_7 < 1100 or  _x distance  RAD_8 < 1100 or  _x distance  RAD_9 < 1100 or  _x distance  RAD_10 < 1100 or  _x distance  RAD_11 < 1100 or  _x distance  RAD_12 < 1100 or  _x distance  RAD_13 < 1100 or  _x distance  RAD_14 < 1100 or  _x distance  RAD_15 < 1100 or  _x distance  RAD_16 < 1100 or  _x distance  RAD_17 < 1100 or  _x distance  RAD_18 < 1100 or  _x distance  RAD_19 < 1100 or  _x distance  RAD_20 < 1100 or  _x distance  RAD_21 < 1100 or  _x distance  RAD_22 < 1100 or  _x distance  RAD_23 < 1100 or  _x distance  RAD_24 < 1100 or  _x distance  RAD_25 < 1100 or  _x distance  RAD_26 < 1100 or  _x distance  RAD_27 < 1100 or  _x distance  RAD_28 < 1100 or  _x distance  RAD_29 < 1100 or  _x distance  RAD_30 < 1100 or  _x distance  RAD_31 < 1100 or  _x distance  RAD_32 < 1100 or  _x distance  RAD_33 < 1100 or  _x distance  RAD_34 < 1100 or  _x distance  RAD_35 < 1100 or  _x distance  RAD_36 < 1100 or  _x distance  RAD_37 < 1100 or  _x distance  RAD_38 < 1100 or  _x distance  RAD_39 < 1100 or  _x distance  RAD_40 < 1100 or  _x distance  RAD_41 < 1100 or  _x distance  RAD_42 < 1100 or  _x distance  RAD_43 < 1100 or  _x distance  RAD_44 < 1100 or  _x distance  RAD_45 < 1100 or  _x distance  RAD_46 < 1100 or  _x distance  RAD_47 < 1100 or  _x distance  RAD_48 < 1100 or  _x distance  RAD_49 < 1100 or  _x distance  RAD_50 < 1100 or  _x distance  RAD_51 < 1100 or  _x distance  RAD_52 < 1100 or  _x distance  RAD_53 < 1100 or  _x distance  RAD_54 < 1100 or  _x distance  RAD_55 < 1100 or  _x distance  RAD_56 < 1100 or  _x distance  RAD_57 < 1100 or  _x distance  RAD_58 < 1100 or  _x distance  RAD_59 < 1100 or  _x distance  RAD_60 < 1100 or  _x distance  RAD_61 < 1100 or  _x distance  RAD_62 < 1100 or  _x distance  RAD_63 < 1100 or  _x distance  RAD_64 < 1100 or  _x distance  RAD_65 < 1100 or  _x distance  RAD_66 < 1100 or  _x distance  RAD_67 < 1100 or  _x distance  RAD_68 < 1100 or  _x distance  RAD_69 < 1100 or  _x distance  RAD_70 < 1100 or  _x distance  RAD_71 < 1100 or  _x distance  RAD_72 < 1100 or  _x distance  RAD_73 < 1100 or  _x distance  RAD_74 < 1100 or  _x distance  RAD_75 < 1100 or  _x distance  RAD_76 < 1100 or  _x distance  RAD_77 < 1100 or  _x distance  RAD_78 < 1100 or  _x distance  RAD_79 < 1100 or  _x distance  RAD_80 < 1100 or  _x distance  RAD_81 < 1100 or  _x distance  RAD_82 < 1100 or  _x distance  RAD_83 < 1100 or  _x distance  RAD_84 < 1100 or  _x distance  RAD_85 < 1100 or  _x distance  RAD_86 < 1100 or  _x distance  RAD_87 < 1100 or  _x distance  RAD_88 < 1100 or  _x distance  RAD_89 < 1100 or  _x distance  RAD_90 < 1100 or  _x distance  RAD_91 < 1100 or  _x distance  RAD_92 < 1100 or  _x distance  RAD_93 < 1100 or  _x distance  RAD_94 < 1100 or  _x distance  RAD_95 < 1100 or  _x distance  RAD_96 < 1100 or  _x distance  RAD_97 < 1100 or  _x distance  RAD_98 < 1100 or  _x distance  RAD_99 < 1100 or  _x distance  RAD_100 < 1100 or  _x distance  RAD_101 < 1100 or  _x distance  RAD_102 < 1100 or  _x distance  RAD_103 < 1100 or  _x distance  RAD_104 < 1100 or  _x distance  RAD_105 < 1100 or  _x distance  RAD_106 < 1100 or  _x distance  RAD_107 < 1100 or  _x distance  RAD_108 < 1100 or  _x distance  RAD_M_2 < 1100 or  _x distance  RAD_M_1 < 1700}}) >0;}

 

Spoiler

//ON TRIGGER ACTIVATION

 

call{{_x setVariable ["passedMaskB",false]; [_x, {allUnits select {_x isNotEqualTo  player}}, nil] execVM "MRscripts\gas_maskAIG.sqf";} forEach (allUnits select {_x isNotEqualTo player && {_x distance  RAD_1 < 1100 or  _x distance  RAD_2 < 1100 or  _x distance  RAD_3 < 1100 or  _x distance  RAD_4 < 1100 or  _x distance  RAD_5 < 1100 or  _x distance  RAD_6 < 1100 or  _x distance  RAD_7 < 1100 or  _x distance  RAD_8 < 1100 or  _x distance  RAD_9 < 1100 or  _x distance  RAD_10 < 1100 or  _x distance  RAD_11 < 1100 or  _x distance  RAD_12 < 1100 or  _x distance  RAD_13 < 1100 or  _x distance  RAD_14 < 1100 or  _x distance  RAD_15 < 1100 or  _x distance  RAD_16 < 1100 or  _x distance  RAD_17 < 1100 or  _x distance  RAD_18 < 1100 or  _x distance  RAD_19 < 1100 or  _x distance  RAD_20 < 1100 or  _x distance  RAD_21 < 1100 or  _x distance  RAD_22 < 1100 or  _x distance  RAD_23 < 1100 or  _x distance  RAD_24 < 1100 or  _x distance  RAD_25 < 1100 or  _x distance  RAD_26 < 1100 or  _x distance  RAD_27 < 1100 or  _x distance  RAD_28 < 1100 or  _x distance  RAD_29 < 1100 or  _x distance  RAD_30 < 1100 or  _x distance  RAD_31 < 1100 or  _x distance  RAD_32 < 1100 or  _x distance  RAD_33 < 1100 or  _x distance  RAD_34 < 1100 or  _x distance  RAD_35 < 1100 or  _x distance  RAD_36 < 1100 or  _x distance  RAD_37 < 1100 or  _x distance  RAD_38 < 1100 or  _x distance  RAD_39 < 1100 or  _x distance  RAD_40 < 1100 or  _x distance  RAD_41 < 1100 or  _x distance  RAD_42 < 1100 or  _x distance  RAD_43 < 1100 or  _x distance  RAD_44 < 1100 or  _x distance  RAD_45 < 1100 or  _x distance  RAD_46 < 1100 or  _x distance  RAD_47 < 1100 or  _x distance  RAD_48 < 1100 or  _x distance  RAD_49 < 1100 or  _x distance  RAD_50 < 1100 or  _x distance  RAD_51 < 1100 or  _x distance  RAD_52 < 1100 or  _x distance  RAD_53 < 1100 or  _x distance  RAD_54 < 1100 or  _x distance  RAD_55 < 1100 or  _x distance  RAD_56 < 1100 or  _x distance  RAD_57 < 1100 or  _x distance  RAD_58 < 1100 or  _x distance  RAD_59 < 1100 or  _x distance  RAD_60 < 1100 or  _x distance  RAD_61 < 1100 or  _x distance  RAD_62 < 1100 or  _x distance  RAD_63 < 1100 or  _x distance  RAD_64 < 1100 or  _x distance  RAD_65 < 1100 or  _x distance  RAD_66 < 1100 or  _x distance  RAD_67 < 1100 or  _x distance  RAD_68 < 1100 or  _x distance  RAD_69 < 1100 or  _x distance  RAD_70 < 1100 or  _x distance  RAD_71 < 1100 or  _x distance  RAD_72 < 1100 or  _x distance  RAD_73 < 1100 or  _x distance  RAD_74 < 1100 or  _x distance  RAD_75 < 1100 or  _x distance  RAD_76 < 1100 or  _x distance  RAD_77 < 1100 or  _x distance  RAD_78 < 1100 or  _x distance  RAD_79 < 1100 or  _x distance  RAD_80 < 1100 or  _x distance  RAD_81 < 1100 or  _x distance  RAD_82 < 1100 or  _x distance  RAD_83 < 1100 or  _x distance  RAD_84 < 1100 or  _x distance  RAD_85 < 1100 or  _x distance  RAD_86 < 1100 or  _x distance  RAD_87 < 1100 or  _x distance  RAD_88 < 1100 or  _x distance  RAD_89 < 1100 or  _x distance  RAD_90 < 1100 or  _x distance  RAD_91 < 1100 or  _x distance  RAD_92 < 1100 or  _x distance  RAD_93 < 1100 or  _x distance  RAD_94 < 1100 or  _x distance  RAD_95 < 1100 or  _x distance  RAD_96 < 1100 or  _x distance  RAD_97 < 1100 or  _x distance  RAD_98 < 1100 or  _x distance  RAD_99 < 1100 or  _x distance  RAD_100 < 1100 or  _x distance  RAD_101 < 1100 or  _x distance  RAD_102 < 1100 or  _x distance  RAD_103 < 1100 or  _x distance  RAD_104 < 1100 or  _x distance  RAD_105 < 1100 or  _x distance  RAD_106 < 1100 or  _x distance  RAD_107 < 1100 or  _x distance  RAD_108 < 1100 or  _x distance  RAD_M_2 < 1100 or  _x distance  RAD_M_1 < 1700}});

 

Spoiler

//SCRIPT

 

{
_x addItemToVest "JSHK_contam_detector";

} forEach (allUnits select { _x isNotEqualTo player && {_x distance  RAD_1 < 1100 or  _x distance  RAD_2 < 1100 or  _x distance  RAD_3 < 1100 or  _x distance  RAD_4 < 1100 or  _x distance  RAD_5 < 1100 or  _x distance  RAD_6 < 1100 or  _x distance  RAD_7 < 1100 or  _x distance  RAD_8 < 1100 or  _x distance  RAD_9 < 1100 or  _x distance  RAD_10 < 1100 or  _x distance  RAD_11 < 1100 or  _x distance  RAD_12 < 1100 or  _x distance  RAD_13 < 1100 or  _x distance  RAD_14 < 1100 or  _x distance  RAD_15 < 1100 or  _x distance  RAD_16 < 1100 or  _x distance  RAD_17 < 1100 or  _x distance  RAD_18 < 1100 or  _x distance  RAD_19 < 1100 or  _x distance  RAD_20 < 1100 or  _x distance  RAD_21 < 1100 or  _x distance  RAD_22 < 1100 or  _x distance  RAD_23 < 1100 or  _x distance  RAD_24 < 1100 or  _x distance  RAD_25 < 1100 or  _x distance  RAD_26 < 1100 or  _x distance  RAD_27 < 1100 or  _x distance  RAD_28 < 1100 or  _x distance  RAD_29 < 1100 or  _x distance  RAD_30 < 1100 or  _x distance  RAD_31 < 1100 or  _x distance  RAD_32 < 1100 or  _x distance  RAD_33 < 1100 or  _x distance  RAD_34 < 1100 or  _x distance  RAD_35 < 1100 or  _x distance  RAD_36 < 1100 or  _x distance  RAD_37 < 1100 or  _x distance  RAD_38 < 1100 or  _x distance  RAD_39 < 1100 or  _x distance  RAD_40 < 1100 or  _x distance  RAD_41 < 1100 or  _x distance  RAD_42 < 1100 or  _x distance  RAD_43 < 1100 or  _x distance  RAD_44 < 1100 or  _x distance  RAD_45 < 1100 or  _x distance  RAD_46 < 1100 or  _x distance  RAD_47 < 1100 or  _x distance  RAD_48 < 1100 or  _x distance  RAD_49 < 1100 or  _x distance  RAD_50 < 1100 or  _x distance  RAD_51 < 1100 or  _x distance  RAD_52 < 1100 or  _x distance  RAD_53 < 1100 or  _x distance  RAD_54 < 1100 or  _x distance  RAD_55 < 1100 or  _x distance  RAD_56 < 1100 or  _x distance  RAD_57 < 1100 or  _x distance  RAD_58 < 1100 or  _x distance  RAD_59 < 1100 or  _x distance  RAD_60 < 1100 or  _x distance  RAD_61 < 1100 or  _x distance  RAD_62 < 1100 or  _x distance  RAD_63 < 1100 or  _x distance  RAD_64 < 1100 or  _x distance  RAD_65 < 1100 or  _x distance  RAD_66 < 1100 or  _x distance  RAD_67 < 1100 or  _x distance  RAD_68 < 1100 or  _x distance  RAD_69 < 1100 or  _x distance  RAD_70 < 1100 or  _x distance  RAD_71 < 1100 or  _x distance  RAD_72 < 1100 or  _x distance  RAD_73 < 1100 or  _x distance  RAD_74 < 1100 or  _x distance  RAD_75 < 1100 or  _x distance  RAD_76 < 1100 or  _x distance  RAD_77 < 1100 or  _x distance  RAD_78 < 1100 or  _x distance  RAD_79 < 1100 or  _x distance  RAD_80 < 1100 or  _x distance  RAD_81 < 1100 or  _x distance  RAD_82 < 1100 or  _x distance  RAD_83 < 1100 or  _x distance  RAD_84 < 1100 or  _x distance  RAD_85 < 1100 or  _x distance  RAD_86 < 1100 or  _x distance  RAD_87 < 1100 or  _x distance  RAD_88 < 1100 or  _x distance  RAD_89 < 1100 or  _x distance  RAD_90 < 1100 or  _x distance  RAD_91 < 1100 or  _x distance  RAD_92 < 1100 or  _x distance  RAD_93 < 1100 or  _x distance  RAD_94 < 1100 or  _x distance  RAD_95 < 1100 or  _x distance  RAD_96 < 1100 or  _x distance  RAD_97 < 1100 or  _x distance  RAD_98 < 1100 or  _x distance  RAD_99 < 1100 or  _x distance  RAD_100 < 1100 or  _x distance  RAD_101 < 1100 or  _x distance  RAD_102 < 1100 or  _x distance  RAD_103 < 1100 or  _x distance  RAD_104 < 1100 or  _x distance  RAD_105 < 1100 or  _x distance  RAD_106 < 1100 or  _x distance  RAD_107 < 1100 or  _x distance  RAD_108 < 1100 or  _x distance  RAD_M_2 < 1100 or  _x distance  RAD_M_1 < 1700}});

 

while {true} do {{
_x addGoggles "JSHK_contam_mask_m04_hoodless";

} forEach (allUnits select {_x isNotEqualTo player && {goggles _x != "JSHK_contam_mask_m04_hoodless"} && {_x distance  RAD_1 < 1100 or  _x distance  RAD_2 < 1100 or  _x distance  RAD_3 < 1100 or  _x distance  RAD_4 < 1100 or  _x distance  RAD_5 < 1100 or  _x distance  RAD_6 < 1100 or  _x distance  RAD_7 < 1100 or  _x distance  RAD_8 < 1100 or  _x distance  RAD_9 < 1100 or  _x distance  RAD_10 < 1100 or  _x distance  RAD_11 < 1100 or  _x distance  RAD_12 < 1100 or  _x distance  RAD_13 < 1100 or  _x distance  RAD_14 < 1100 or  _x distance  RAD_15 < 1100 or  _x distance  RAD_16 < 1100 or  _x distance  RAD_17 < 1100 or  _x distance  RAD_18 < 1100 or  _x distance  RAD_19 < 1100 or  _x distance  RAD_20 < 1100 or  _x distance  RAD_21 < 1100 or  _x distance  RAD_22 < 1100 or  _x distance  RAD_23 < 1100 or  _x distance  RAD_24 < 1100 or  _x distance  RAD_25 < 1100 or  _x distance  RAD_26 < 1100 or  _x distance  RAD_27 < 1100 or  _x distance  RAD_28 < 1100 or  _x distance  RAD_29 < 1100 or  _x distance  RAD_30 < 1100 or  _x distance  RAD_31 < 1100 or  _x distance  RAD_32 < 1100 or  _x distance  RAD_33 < 1100 or  _x distance  RAD_34 < 1100 or  _x distance  RAD_35 < 1100 or  _x distance  RAD_36 < 1100 or  _x distance  RAD_37 < 1100 or  _x distance  RAD_38 < 1100 or  _x distance  RAD_39 < 1100 or  _x distance  RAD_40 < 1100 or  _x distance  RAD_41 < 1100 or  _x distance  RAD_42 < 1100 or  _x distance  RAD_43 < 1100 or  _x distance  RAD_44 < 1100 or  _x distance  RAD_45 < 1100 or  _x distance  RAD_46 < 1100 or  _x distance  RAD_47 < 1100 or  _x distance  RAD_48 < 1100 or  _x distance  RAD_49 < 1100 or  _x distance  RAD_50 < 1100 or  _x distance  RAD_51 < 1100 or  _x distance  RAD_52 < 1100 or  _x distance  RAD_53 < 1100 or  _x distance  RAD_54 < 1100 or  _x distance  RAD_55 < 1100 or  _x distance  RAD_56 < 1100 or  _x distance  RAD_57 < 1100 or  _x distance  RAD_58 < 1100 or  _x distance  RAD_59 < 1100 or  _x distance  RAD_60 < 1100 or  _x distance  RAD_61 < 1100 or  _x distance  RAD_62 < 1100 or  _x distance  RAD_63 < 1100 or  _x distance  RAD_64 < 1100 or  _x distance  RAD_65 < 1100 or  _x distance  RAD_66 < 1100 or  _x distance  RAD_67 < 1100 or  _x distance  RAD_68 < 1100 or  _x distance  RAD_69 < 1100 or  _x distance  RAD_70 < 1100 or  _x distance  RAD_71 < 1100 or  _x distance  RAD_72 < 1100 or  _x distance  RAD_73 < 1100 or  _x distance  RAD_74 < 1100 or  _x distance  RAD_75 < 1100 or  _x distance  RAD_76 < 1100 or  _x distance  RAD_77 < 1100 or  _x distance  RAD_78 < 1100 or  _x distance  RAD_79 < 1100 or  _x distance  RAD_80 < 1100 or  _x distance  RAD_81 < 1100 or  _x distance  RAD_82 < 1100 or  _x distance  RAD_83 < 1100 or  _x distance  RAD_84 < 1100 or  _x distance  RAD_85 < 1100 or  _x distance  RAD_86 < 1100 or  _x distance  RAD_87 < 1100 or  _x distance  RAD_88 < 1100 or  _x distance  RAD_89 < 1100 or  _x distance  RAD_90 < 1100 or  _x distance  RAD_91 < 1100 or  _x distance  RAD_92 < 1100 or  _x distance  RAD_93 < 1100 or  _x distance  RAD_94 < 1100 or  _x distance  RAD_95 < 1100 or  _x distance  RAD_96 < 1100 or  _x distance  RAD_97 < 1100 or  _x distance  RAD_98 < 1100 or  _x distance  RAD_99 < 1100 or  _x distance  RAD_100 < 1100 or  _x distance  RAD_101 < 1100 or  _x distance  RAD_102 < 1100 or  _x distance  RAD_103 < 1100 or  _x distance  RAD_104 < 1100 or  _x distance  RAD_105 < 1100 or  _x distance  RAD_106 < 1100 or  _x distance  RAD_107 < 1100 or  _x distance  RAD_108 < 1100 or  _x distance  RAD_M_2 < 1100 or  _x distance  RAD_M_1 < 1700}})
};

 

while {false} do {{
removeGoggles _x;

} forEach (allUnits select {_x isNotEqualTo player && {goggles _x == "JSHK_contam_mask_m04_hoodless"} && {_x distance RAD_1 > 1100} && {_x distance RAD_2 > 1100} && {_x distance RAD_3 > 1100} && {_x distance RAD_4 > 1100} && {_x distance RAD_5 > 1100} && {_x distance RAD_6 > 1100} && {_x distance RAD_7 > 1100} && {_x distance RAD_8 > 1100} && {_x distance RAD_9 > 1100} && {_x distance RAD_10 > 1100} && {_x distance RAD_11 > 1100} && {_x distance RAD_12 > 1100} && {_x distance RAD_13 > 1100} && {_x distance RAD_14 > 1100} && {_x distance RAD_15 > 1100} && {_x distance RAD_16 > 1100} && {_x distance RAD_17 > 1100} && {_x distance RAD_18 > 1100} && {_x distance RAD_19 > 1100} && {_x distance RAD_20 > 1100} && {_x distance RAD_21 > 1100} && {_x distance RAD_22 > 1100} && {_x distance RAD_23 > 1100} && {_x distance RAD_24 > 1100} && {_x distance RAD_25 > 1100} && {_x distance RAD_26 > 1100} && {_x distance RAD_27 > 1100} && {_x distance RAD_28 > 1100} && {_x distance RAD_29 > 1100} && {_x distance RAD_30 > 1100} && {_x distance RAD_31 > 1100} && {_x distance RAD_32 > 1100} && {_x distance RAD_33 > 1100} && {_x distance RAD_34 > 1100} && {_x distance RAD_35 > 1100} && {_x distance RAD_36 > 1100} && {_x distance RAD_37 > 1100} && {_x distance RAD_38 > 1100} && {_x distance RAD_39 > 1100} && {_x distance RAD_40 > 1100} && {_x distance RAD_41 > 1100} && {_x distance RAD_42 > 1100} && {_x distance RAD_43 > 1100} && {_x distance RAD_44 > 1100} && {_x distance RAD_45 > 1100} && {_x distance RAD_46 > 1100} && {_x distance RAD_47 > 1100} && {_x distance RAD_48 > 1100} && {_x distance RAD_49 > 1100} && {_x distance RAD_50 > 1100} && {_x distance RAD_51 > 1100} && {_x distance RAD_52 > 1100} && {_x distance RAD_53 > 1100} && {_x distance RAD_54 > 1100} && {_x distance RAD_55 > 1100} && {_x distance RAD_56 > 1100} && {_x distance RAD_57 > 1100} && {_x distance RAD_58 > 1100} && {_x distance RAD_59 > 1100} && {_x distance RAD_60 > 1100} && {_x distance RAD_61 > 1100} && {_x distance RAD_62 > 1100} && {_x distance RAD_63 > 1100} && {_x distance RAD_64 > 1100} && {_x distance RAD_65 > 1100} && {_x distance RAD_66 > 1100} && {_x distance RAD_67 > 1100} && {_x distance RAD_68 > 1100} && {_x distance RAD_69 > 1100} && {_x distance RAD_70 > 1100} && {_x distance RAD_71 > 1100} && {_x distance RAD_72 > 1100} && {_x distance RAD_73 > 1100} && {_x distance RAD_74 > 1100} && {_x distance RAD_75 > 1100} && {_x distance RAD_76 > 1100} && {_x distance RAD_77 > 1100} && {_x distance RAD_78 > 1100} && {_x distance RAD_79 > 1100} && {_x distance RAD_80 > 1100} && {_x distance RAD_81 > 1100} && {_x distance RAD_82 > 1100} && {_x distance RAD_83 > 1100} && {_x distance RAD_84 > 1100} && {_x distance RAD_85 > 1100} && {_x distance RAD_86 > 1100} && {_x distance RAD_87 > 1100} && {_x distance RAD_88 > 1100} && {_x distance RAD_89 > 1100} && {_x distance RAD_90 > 1100} && {_x distance RAD_91 > 1100} && {_x distance RAD_92 > 1100} && {_x distance RAD_93 > 1100} && {_x distance RAD_94 > 1100} && {_x distance RAD_95 > 1100} && {_x distance RAD_96 > 1100} && {_x distance RAD_97 > 1100} && {_x distance RAD_98 > 1100} && {_x distance RAD_99 > 1100} && {_x distance RAD_100 > 1100} && {_x distance RAD_101 > 1100} && {_x distance RAD_102 > 1100} && {_x distance RAD_103 > 1100} && {_x distance RAD_104 > 1100} && {_x distance RAD_105 > 1100} && {_x distance RAD_106 > 1100} && {_x distance RAD_107 > 1100} && {_x distance RAD_108 > 1100} && {_x distance RAD_M_2 > 1100} && {_x distance RAD_M_1 > 1700}});
};

 

Questo come ho detto rallenta o interferisce con gli altri scripts della missione rallentando le varie funzioni, dalla reanimationi all'hacking delle comuncazioni...

 

Could someone give me a solution to improve the scripts and not slow down the game please?

Share this post


Link to post
Share on other sites

Calling a heavy script in an unscheduled environment - like the onActivation fields are - leads to a nearly system halt as long as the script is executed. U should try to use spawn instead of call to give the system the time to execute other things as well.

Share this post


Link to post
Share on other sites

There are plenty of things to do, so the first question:

why did you use a trigger and why this condition starting with this? I guess, to start, a very bad usage of trigger(s).

It seems to me you took the problem by the wrong side:

 

- triggers are great for repeatable scripts (act/deact) along with their area. So, great for effects on contaminated areas.

- looped scripts  are OK for checking if units (spawned) should be treated by scripts, regardless of triggers

- while {true} loop(s) should always be spawned!  while {false} loop(s), as you wrote, are absolutely, totally useless!

- checking if a unit (or units) are out of all radius "areas" is a non-sense. You just need to act/deact your behavior on units along with triggers condition and their areas.

see also.

 

 

Share this post


Link to post
Share on other sites

I apologize if I did not use the editor tools to the fullest, I am a script noob, I happened to modify and adapt some simple scripts and this is the first one I try to write from scratch.

 

Yes, I used the point triggers only to start the scripts, I didn't know it wasn't the best way.

 

I didn't use the area triggers because I have many contaminated areas and I was afraid that the scenario would become too heavy, in your opinion it would be the best way to give or remove the masks to the AI?

Hmm I thought that while {true} / {false} was interfacing with the trigger and defining the condition under which the script would give or remove the gas masks...

 

What would be the best way to run the scripts and how can I modify these to make them work better?

 

 

Why not just use the spawn command as sarogahtyp suggests?

Share this post


Link to post
Share on other sites

Spawning a code is not the Graal of optimization, even if that's mandatory for infinite loops.

You can use a hundred of triggers, or more, if you need, the good question is to make them resource friendly, starting with their condition. That will be more efficient than scripts checking distance for...

Two ways:

scripted triggers : that's a way for firing codes locally (and only locally). For example, when a player or an AI unit belonging to player (so managed by player's PC) enters a trigger. You can run a code locally (no need to run it everywhere). Depending on what the code is supposed to do.

edited triggers: simple. The area are immediately visible on editor. In MP, You need to pay attention for each command / function used, from where (server or everywhere).

 

The first thing to do is to write in plain but precise language how things must work:

- in MP,

- all players (different sides) can be leader of AI units (or alone),

- have custom loadout at start (with masks orlnot, in backpack or not)

- must wear a mask (player) or automatically wear a mask (from backpack or added)

- when entering one of the area

- I intend to make some areas overlapped... (more conditions)

- that concerns also all playable units (even if no leader played), or all units of a side, allUnits...  because they have waypoints (?)

- I intend to spawn units, so I need to treat also that units (why should they be concerned?)

- units in vehicle are concerned (that needs some extra lines for triggers)

- masks are automatic, so it's just a question of appearance, or...

- masks are not automatic (player only?) and I have script for players/AI not wearing masks...

- masks/effects are reversible when leaving the area.
.....

 

 

Share this post


Link to post
Share on other sites

The problem is also this, some blufor and independent units are equipped with a mask already at spawn (no opfor has a mask when it spawns), but the mod has many masks with different camouflages and assigns them to them randomly, I have to make sure to replace them with only one model.

 

I wish AIs only had masks when they are in or near zones so that players can only get them when they really need the AIs and so I didn't want to put masks in the AI inventory.

 

I also wanted to avoid using triggers because contaminated areas could be eliminated by this script run after init

 

spoiler

Delete_Initial_RadPos =
{
{
    if (distanza giocatore _x < 1500) then 
    {
        deleteVehicle _x;
    };
}forEach _this
};
[RAD_1,RAD_2,RAD_3,RAD_4,RAD_5,RAD_6,RAD_7,RAD_8,RAD_9,RAD_10,RAD_11,RAD_12,RAD_13,RAD_14,RAD_15,RAD_16,RAD_17,RAD_18,RAD_19,RAD_21,20 ,RAD_26,RAD_27,RAD_28,RAD_29,RAD_30,RAD_31,RAD_32,RAD_33,RAD_34,RAD_35,RAD_36,RAD_37,RAD_38,RAD_39,RAD_40,RAD_41,RAD_42,RAD_43,RAD_45,RAD_44,RAD_44 ,RAD_51,RAD_52,RAD_53,RAD_54,RAD_55,RAD_56,RAD_57,RAD_58,RAD_59,RAD_60,RAD_61,RAD_62,RAD_63,RAD_64,RAD_65,RAD_66,RAD_72,RAD,75,RAD_67,RAD_68,RAD_69 ,RAD_76,RAD_77,RAD_78,RAD_79,RAD_80,RAD_81,RAD_82,RAD_83,RAD_84,RAD_85,RAD_86,RAD_87,RAD_88,RAD_89,RAD_90,RAD_91,RAD_92,RAD_93,RAD_94,RAD_93,RAD_94 ,RAD_101,RAD_102,RAD_103,RAD_104,RAD_105,RAD_106,RAD_107,RAD_108] chiama Delete_Initial_RadPos;
    

Delete_Random_RadPos = 


    if ((random 100) > 75) then //in questo momento 25% di possibilità di essere cancellato. cambia da > a < per il 33% di possibilità di essere cancellato 
    { 
        deleteVehicle _x; 
    }; 
}forEach _this; 
}; 

[RAD_1,RAD_2,RAD_3,RAD_4,RAD_5,RAD_6,RAD_7,RAD_8,RAD_9,RAD_10,RAD_11,RAD_12,RAD_13,RAD_14,RAD_15,RAD_16,RAD_17,RAD_18,RAD_19,RAD_21,20 ,RAD_26,RAD_27,RAD_28,RAD_29,RAD_30,RAD_31,RAD_32,RAD_33,RAD_34,RAD_35,RAD_36,RAD_37,RAD_38,RAD_39,RAD_40,RAD_41,RAD_42,RAD_43,RAD_45,RAD_44,RAD_44 ,RAD_51,RAD_52,RAD_53,RAD_54,RAD_55,RAD_56,RAD_57,RAD_58,RAD_59,RAD_60,RAD_61,RAD_62,RAD_63,RAD_64,RAD_65,RAD_66,RAD_72,RAD_75,RAD_67,RAD_68,RAD_69 ,RAD_76,RAD_77,RAD_78,RAD_79,RAD_80,RAD_81,RAD_82,RAD_83,RAD_84,RAD_85,RAD_86,RAD_87,RAD_88,RAD_89,RAD_90,RAD_91,RAD_92,RAD_93,RAD_94,RAD_93,RAD_94 ,RAD_101,RAD_102,RAD_103,RAD_104,RAD_105,RAD_106,RAD_107,RAD_108] chiama Delete_Random_RadPos;

 

I delete the initial wastes because the players will start without a mask and I don't want them to die at the beginning (the starting position is random because it is defined by the co10 escape scripts).

 

This is mainly a cooperative MP scenario and the AIs I have to supply the masks to are all player enemies or civilians and not grouped to the player and it has to work for the AI only, players will put them on manually and have to carry some with self because I want to make sure that if you hit there is a% chance that they will break.

 

What could be the best solution?

Share this post


Link to post
Share on other sites

The type of mask can be set as a variable on any unit/player by setVariable, so you can getVariable when needed. But it's not your 1st problem.

 

"In or near"...  is typically the kind of expression you can't translate in script. That just mean you don't have a clear view on what you want exactly.


you can enable/disable simulation on triggers, you can delete them as well.

 

I can't ask for solutions with part of scripts and ideas about how to make things, just after saying you are not a scripter. So, as far as I can help, start with a trigger a single unit (player), an extra unit (AI) and check for what you want to do. As second step, make it MP compatible (for server/clients), as 3rd step, extend to multiple triggers/areas, different groups/sides. Manage the mission optimization (which is something different from code optimization).

Share this post


Link to post
Share on other sites

Ok, tonight i will try with the triggers as you suggested.

 

But I admit that the idea of learning how to create scripts has always teased me and I have seen that you give a lot of advice and your solutions always work (I say this because some solutions you have given to other people have also helped me) as well as to your great work with your mod "MGI enhanced modules", could you suggest me some guides to learn the fundamentals of scripting?

Share this post


Link to post
Share on other sites

Sorry for the long absence but I had some problems.

 

I was able to run tests to solve the problem in the way you indicated, but nothing, I haven't been able to find a solution this way.

 

But I got what I wanted by further modifying that "sort" of script I created by removing a part and adding a string "sleep 10;" to delay the execution of the while command.

 

Thanks for the help anyway guys

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×