exevankeko 10 Posted March 26, 2014 Hello everyone how are you? I need a little help I'm using the "AISpawnScriptPack_v0.90" script: http://www.armaholic.com/page.php?id=19833 to make a night mission, and I want to use the flashlights units only. There a script or something to achieve this? and tried to put this: { if (side _x == east) then { unassignItem _x "NVGoggles"; removeItem _x "NVGoggles"; removeItemFromPrimaryWeapon _x "acc_pointer_IR"; addPrimaryWeaponItem _x "acc_flashlight"; enableGunLights _x "forceon"; }; Foreach} allunits; in the condition of a trigger, but it did not work me. The "AISpawnScriptPack_v0.90" script is used with a game logic. and tried to put that code also in the "game logic" and did not work. Share this post Link to post Share on other sites
Rocksteady 10 Posted March 26, 2014 _x enableGunLights "forceon"; Share this post Link to post Share on other sites
weparo 10 Posted March 26, 2014 If the units spawn in, you will have to reissue them flashlights and force them to use them too. Call a script that performs an loop ever 5 seconds like this while (true) do { { if (side _x == east) then { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; _x removeItemFromPrimaryWeapon "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceon"; } } ForEach allUnits; sleep 5; } Share this post Link to post Share on other sites
haleks 8212 Posted March 26, 2014 Using flashlights for AIs depends on their behaviour : have you tried to set them to "Safe"? Do not use "Careless" though - they won't engage anyone if you do so. Share this post Link to post Share on other sites
weparo 10 Posted March 26, 2014 Using flashlights for AIs depends on their behaviour : have you tried to set them to "Safe"?Do not use "Careless" though - they won't engage anyone if you do so. Problem is that they'll 'swich' out of that safe behaviour when engaged, and then turning off the flashlight. Using _x enableGunLights "forceon"; will force them to keep the lights on which makes for easier and (imho) cooler looking enemies. Share this post Link to post Share on other sites
exevankeko 10 Posted March 29, 2014 If the units spawn in, you will have to reissue them flashlights and force them to use them too. Call a script that performs an loop ever 5 seconds like this while (true) do { { if (side _x == east) then { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; _x removeItemFromPrimaryWeapon "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceon"; } } ForEach allUnits; sleep 5; } Hey guys thanks for your help the issue is that I use a script, they appear random and patrol units. And usually all have night vision. So I need some script or something to delete your nightvision and force using flashlights. I will try this code and comment if I have worked ---------- Post added at 00:35 ---------- Previous post was at 00:18 ---------- I did not work. Here's the mission: http://www59.zippyshare.com/v/6890462/file.html So understand what I do. So tell me what I did wrong. Share this post Link to post Share on other sites
weparo 10 Posted March 29, 2014 OK, I've looked at this. Now, what I saw was that you put { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; _x RemovePrimaryWeaponItem "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceon"; } foreach units group this; in the init of one soldier. Now, units group this; will execute the code for every member of the group. However the soldier wasn't grouped (a group isn't the same as a side), so it didn't work. Here is what you need to do if you want only CSAT to have flashlights (and no NVGs). Create a file called "flashlight.sqf" in your misssion folder. (just like a text file, but name it flashlight.sqf instead of flashlight.txt) In that file you put this code here : while (true) do { { if (side _x == east) then { _x unassignItem "NVGoggles_OPFOR"; _x removeItem "NVGoggles_OPFOR"; _x removeItemFromPrimaryWeapon "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceon"; } } ForEach allUnits; sleep 5; } This little script checks if a soldier is CSAT (east), and if he is, it will remove his NVGs, the IR pointer and add the flashlight. The script is in a 5sec loop, that means that it will re execute itself every 5 seconds. If any new soldiers spawn, it will also affect these because it is repeatedly executed. To execute the above code, put in the init of an object : execVM "flashlight.sqf"; If you also want NATO soldiers to use flashlights, let me know :) Share this post Link to post Share on other sites
spunfin 34 Posted March 29, 2014 (edited) Hey exevankeko, You could probably use 'custom init' -parameter in AISSP to achieve this, like: "this unassignItem 'NVGoggles_OPFOR'; this removeItem 'NVGoggles_OPFOR'; this removeItemFromPrimaryWeapon 'acc_pointer_IR'; this addPrimaryWeaponItem 'acc_flashlight'; this enableGunLights 'forceon';" So no need to loop it all the time. If you spawn other than OPFOR units with them, you would want to include side check condition on this. Or, maybe simplier, call your custom script via 'custom init', check side there etc. Example with external script on ambient combat: - Create flashlight.sqf: //flashlight.sqf _unit = _this select 0; _goggles = switch(side _unit)do{ case east: {"NVGoggles_OPFOR"}; case west: {"NVGoggles"}; case resistance: {"NVGoggles_INDEP"}; }; _unit unassignItem _goggles; _unit removeItem _goggles; _unit removePrimaryWeaponItem "acc_pointer_IR"; _unit addPrimaryWeaponItem "acc_flashlight"; _unit enableGunLights "forceon"; - Then start ambientCombat and make it use flashlight.sqf: nul = [450,900,2,12,8,[1,1,1],player,"default",0,1500,[color="#008000"]"nul = [this] execVM 'flashlights.sqf';"[/color],["SAFE","SAD"],false] execVM "LV\ambientCombat.sqf"; Happy hunting! :) Edited March 29, 2014 by spunFIN Share this post Link to post Share on other sites
exevankeko 10 Posted March 29, 2014 (edited) Hey exevankeko,You could probably use 'custom init' -parameter in AISSP to achieve this, like: "this unassignItem 'NVGoggles_OPFOR'; this removeItem 'NVGoggles_OPFOR'; this removeItemFromPrimaryWeapon 'acc_pointer_IR'; this addPrimaryWeaponItem 'acc_flashlight'; this enableGunLights 'forceon';" So no need to loop it all the time. If you spawn other than OPFOR units with them, you would want to include side check condition on this. Or, maybe simplier, call your custom script via 'custom init', check side there etc. Example with external script on ambient combat: - Create flashlight.sqf: //flashlight.sqf _unit = _this select 0; _goggles = switch(side _unit)do{ case east: {"NVGoggles_OPFOR"}; case west: {"NVGoggles"}; case resistance: {"NVGoggles_INDEP"}; }; _unit unassignItem _goggles; _unit removeItem _goggles; _unit removePrimaryWeaponItem "acc_pointer_IR"; _unit addPrimaryWeaponItem "acc_flashlight"; _unit enableGunLights "forceon"; - Then start ambientCombat and make it use flashlight.sqf: nul = [450,900,2,12,8,[1,1,1],player,"default",0,1500,[color="#008000"]"nul = [this] execVM 'flashlights.sqf';"[/color],["SAFE","SAD"],false] execVM "LV\ambientCombat.sqf"; Happy hunting! :) thanks for your help I just tested the script I put a "Game Logic" and the init field put this code: nul = [this,2,15,[true,false,false],[false,false,false],false,[5,0],[0,0],"default",nil,nil,3,"nul = [this] execVM 'flashlight.sqf';",["SAFE","SAD"],false] execVM "LV\militarize.sqf"; but I did not work, but the units appear with night vision without lights that's what I did wrong? ---------- Post added at 19:47 ---------- Previous post was at 19:34 ---------- OK, I've looked at this. Now, what I saw was that you put { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; _x RemovePrimaryWeaponItem "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceon"; } foreach units group this; in the init of one soldier. Now, units group this; will execute the code for every member of the group. However the soldier wasn't grouped (a group isn't the same as a side), so it didn't work. Here is what you need to do if you want only CSAT to have flashlights (and no NVGs). Create a file called "flashlight.sqf" in your misssion folder. (just like a text file, but name it flashlight.sqf instead of flashlight.txt) In that file you put this code here : while (true) do { { if (side _x == east) then { _x unassignItem "NVGoggles_OPFOR"; _x removeItem "NVGoggles_OPFOR"; _x removeItemFromPrimaryWeapon "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceon"; } } ForEach allUnits; sleep 5; } This little script checks if a soldier is CSAT (east), and if he is, it will remove his NVGs, the IR pointer and add the flashlight. The script is in a 5sec loop, that means that it will re execute itself every 5 seconds. If any new soldiers spawn, it will also affect these because it is repeatedly executed. To execute the above code, put in the init of an object : execVM "flashlight.sqf"; If you also want NATO soldiers to use flashlights, let me know :) Also probe your code and I did not work = ( an object (flag): put execVM "flashlight.sqf"; and throws me an error: "Type script, expected nothing" ------------ Here is the mission for you to see http://www24.zippyshare.com/v/68510668/file.html Edited March 29, 2014 by exevankeko Share this post Link to post Share on other sites
spunfin 34 Posted March 29, 2014 thanks for your helpI just tested the script I put a "Game Logic" and the init field put this code: nul = [this,2,15,[true,false,false],[false,false,false],false,[5,0],[0,0],"default",nil,nil,3,"nul = [this] execVM 'flashlight.sqf';",["SAFE","SAD"],false] execVM "LV\militarize.sqf"; but I did not work, but the units appear with night vision without lights that's what I did wrong? Ah yes, ambientCombat has a bit different syntax, so correct one for militarize would be: nul = [this,2,15,[true,false,false],[false,false,false],false,[5,0],[0,0],"default",nil,"nul = [this] execVM 'flashlight.sqf';",3] execVM "LV\militarize.sqf"; Share this post Link to post Share on other sites
haleks 8212 Posted March 29, 2014 Aren't NVGs considered as a weapon? You might try removeWeapon instead of removeItem. Share this post Link to post Share on other sites
weparo 10 Posted March 29, 2014 thanks for your helpI just tested the script I put a "Game Logic" and the init field put this code: nul = [this,2,15,[true,false,false],[false,false,false],false,[5,0],[0,0],"default",nil,nil,3,"nul = [this] execVM 'flashlight.sqf';",["SAFE","SAD"],false] execVM "LV\militarize.sqf"; but I did not work, but the units appear with night vision without lights that's what I did wrong? ---------- Post added at 19:47 ---------- Previous post was at 19:34 ---------- Also probe your code and I did not work = ( an object (flag): put execVM "flashlight.sqf"; and throws me an error: "Type script, expected nothing" ------------ Here is the mission for you to see http://www24.zippyshare.com/v/68510668/file.html My bad! Scripts called with execVM need to be executed in an init like this : _null = execVM "flashlight.sqf"; I know that this method works because I used it a couple days back in my mission :) Please let me know if you run into any other trouble, Weparo Share this post Link to post Share on other sites
exevankeko 10 Posted March 30, 2014 Ah yes, ambientCombat has a bit different syntax, so correct one for militarize would be: nul = [this,2,15,[true,false,false],[false,false,false],false,[5,0],[0,0],"default",nil,"nul = [this] execVM 'flashlight.sqf';",3] execVM "LV\militarize.sqf"; Thanx for you help! Now works perfectly! many thanks to all =) Share this post Link to post Share on other sites
Kommiekat 11 Posted April 27, 2014 Hello, I know this is A3 section, but................ I need a code like this to work for A2, opfor patrols _x enableGunLights "forceon"; If anybody is wondering, does not work in A2 Share this post Link to post Share on other sites
tomturner 10 Posted April 27, 2014 In the militarize.sqf (if used) search for the first line below where the unit is created. Copy and paste the following as you see it here. _unit = _milGroup createUnit [_unitType, _pos, [], 0, "NONE"]; _unit setPos _pos; if (_nvgs == "false") then{ if (side _unit == east) then { _unit unassignItem "NVGoggles_OPFOR"; _unit removeItem "NVGoggles_OPFOR"; _unit RemovePrimaryWeaponItem "acc_pointer_IR"; _unit addPrimaryWeaponItem "acc_flashlight"; _unit enableGunLights "forceon"; }; if (side _unit == west) then { _unit unassignItem "NVGoggles"; _unit removeItem "NVGoggles"; }; }; NOTE: This excerpt contains a check whether nvgs are used or not taken from the mission.init. If you don't want to use the feature, then remove the line "if (_nvgs == "false" then {" and its closing "};" at the end. Share this post Link to post Share on other sites
darkxess 60 Posted April 27, 2014 You guys mind sharing an example missions with script of this working? :) Thanks. Share this post Link to post Share on other sites
meatshield 13 Posted September 18, 2014 I know this is an old thread, but non of the above works if you copy/paste it. Heres a current working one, its just a slight tweak to the ones above, prolly wont work with "spawned in" units create a flashlight.sqf with the following code { if (side _x == east) then { _x unassignItem "NVGoggles_OPFOR"; _x removeItem "NVGoggles_OPFOR"; _x removePrimaryWeaponItem "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceon"; } } ForEach allUnits; then in the init file of the unit/units put _nul = [] execVM "flashlight.sqf" Share this post Link to post Share on other sites
jandrews 116 Posted September 18, 2014 I know this is an old thread, but non of the above works if you copy/paste it. Heres a current working one, its just a slight tweak to the ones above, prolly wont work with "spawned in" unitscreate a flashlight.sqf with the following code { if (side _x == east) then { _x unassignItem "NVGoggles_OPFOR"; _x removeItem "NVGoggles_OPFOR"; _x removePrimaryWeaponItem "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceon"; } } ForEach allUnits; then in the init file of the unit/units put _nul = [] execVM "flashlight.sqf" Is there a way to do this once an enemy gets killed. For example, they are in safe mode and don't have flashlights on, BUT once one is killed the lights switch on? Share this post Link to post Share on other sites
jshock 513 Posted September 18, 2014 (edited) Is there a way to do this once an enemy gets killed. For example, they are in safe mode and don't have flashlights on, BUT once one is killed the lights switch on? Use a killed EH, maybe. { if (side _x = EAST) then { _x addEventHandler ["Killed", {_x unassignItem "NVGoggles_OPFOR"; _x removeItem "NVGoggles_OPFOR"; _x removePrimaryWeaponItem "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceon";} foreach units (_this select 0);]; }; } forEach allunits; Edited September 18, 2014 by JShock Share this post Link to post Share on other sites