Grim5667 3 Posted August 26, 2018 Hey I have looked for a script that adds an action to the OPFOR unit everytime one of them spawns but could not find one. Would someone be willing to help to create one? I am new to scripting btw. Share this post Link to post Share on other sites
stanhope 411 Posted August 26, 2018 How are you spawning your OPFOR guys in? Via scripts, in the editor, in zeus, ...? 1 Share this post Link to post Share on other sites
Grim5667 3 Posted August 27, 2018 On 26/08/2018 at 4:27 PM, stanhope said: How are you spawning your OPFOR guys in? Via scripts, in the editor, in zeus, ...? Ok i believe they are spawned in through script. All OPFOR will be spawned in at once. Maybe there a way to place down a invis marker that can grab the nearest units? Share this post Link to post Share on other sites
HazJ 1289 Posted August 28, 2018 If OPFOR are spawned throughout the mission and you can't directly create the addAction on them. You can add the action to the player and have some conditions there. If you can create addAction when they are spawning after createUnit then: object addAction [title, script, arguments, priority, showWindow, hideOnUse, shortcut, condition, radius, unconscious, selection, memoryPoint] https://community.bistudio.com/wiki/addAction What exactly do you want the action to do? You didn't say and not guessing so just customise it yourself. If you get stuck, just ask. All arguments are explained on the Wiki, see link above. Future tip: Please descriptive as possible when making post/thread. The first reply was @stanhope who was asking a basic question which should of been mentioned really in the first place. You don't have to show anything fancy or code. Plain words can go a long way. It just makes it easier for us people trying to help. Share this post Link to post Share on other sites
pierremgi 4850 Posted August 28, 2018 0 = [] spawn { while {true} do { { _x addAction ["bla bla", {code},etc]; _x setVariable ["actionAdded",true] } forEach allUnits select {isNil {_x getVariable "actionAdded"} && side _x == EAST }; // as you said east are enemies. sleep 3 }}; Share this post Link to post Share on other sites
Grim5667 3 Posted August 28, 2018 1 hour ago, HazJ said: If OPFOR are spawned throughout the mission and you can't directly create the addAction on them. You can add the action to the player and have some conditions there. If you can create addAction when they are spawning after createUnit then: object addAction [title, script, arguments, priority, showWindow, hideOnUse, shortcut, condition, radius, unconscious, selection, memoryPoint] https://community.bistudio.com/wiki/addAction What exactly do you want the action to do? You didn't say and not guessing so just customise it yourself. If you get stuck, just ask. All arguments are explained on the Wiki, see link above. Future tip: Please descriptive as possible when making post/thread. The first reply was @stanhope who was asking a basic question which should of been mentioned really in the first place. You don't have to show anything fancy or code. Plain words can go a long way. It just makes it easier for us people trying to help. Ahh ok will be more descriptive next time. The script is to "search" the OPFOR units for possibly intel and it can return with No Intel found or Intel found. 1 hour ago, pierremgi said: 0 = [] spawn { while {true} do { { _x addAction ["bla bla", {code},etc]; _x setVariable ["actionAdded",true] } forEach allUnits select {isNil {_x getVariable "actionAdded"} && side _x == EAST }; // as you said east are enemies. sleep 3 }}; Ok ty will check if this works. Edit: After a couple minutes with the code it works but it constantly shows the Search which i dont want and it would just stack up and if you did removeAllActions Player; It would still stack up on the enemies so I put it removeAllActions allUnits; . Which did work but would always show a search and would also show search twice when looking at the OPFOR unit. Share this post Link to post Share on other sites
HazJ 1289 Posted August 28, 2018 1 hour ago, pierremgi said: 0 = [] spawn { while {true} do { { _x addAction ["bla bla", {code},etc]; _x setVariable ["actionAdded",true] } forEach allUnits select {isNil {_x getVariable "actionAdded"} && side _x == EAST }; // as you said east are enemies. sleep 3 }}; I do not recommend this approach. If you really need something like this, add the action the player. 1 Share this post Link to post Share on other sites
pierremgi 4850 Posted August 28, 2018 20 minutes ago, HazJ said: I do not recommend this approach. If you really need something like this, add the action the player. Not mine. I just answered to the title. No clue what is for. Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted August 28, 2018 standard method for this sort of thing is to add the action to the player object, and use the condition to hide/show it (such as when aiming at an enemy) heres an example my_condition = { private _return = false; _cursortarget = cursortarget; if (!isnull _cursortarget) then { if (_cursortarget iskindof 'camanbase') then { if ((side (group _cursortarget)) in (playerside call bis_fnc_enemysides)) then { if ((tolower (lifestate _cursortarget)) in ['healthy','injured']) then { _return = true; }; }; }; }; _return; }; player addAction ['Enemy!',{hint (format ["Enemy! %1",diag_ticktime]);},nil,0,true,true,'','call my_condition',-1,false,'','']; player addEventHandler [ 'Respawn', { player addAction ['Enemy!',{hint (format ["Enemy! %1",diag_ticktime]);},nil,0,true,true,'','call my_condition',-1,false,'','']; } ]; 2 2 Share this post Link to post Share on other sites
Grim5667 3 Posted August 28, 2018 13 hours ago, fn_Quiksilver said: standard method for this sort of thing is to add the action to the player object, and use the condition to hide/show it (such as when aiming at an enemy) heres an example my_condition = { private _return = false; _cursortarget = cursortarget; if (!isnull _cursortarget) then { if (_cursortarget iskindof 'camanbase') then { if ((side (group _cursortarget)) in (playerside call bis_fnc_enemysides)) then { if ((tolower (lifestate _cursortarget)) in ['healthy','injured']) then { _return = true; }; }; }; }; _return; }; player addAction ['Enemy!',{hint (format ["Enemy! %1",diag_ticktime]);},nil,0,true,true,'','call my_condition',-1,false,'','']; player addEventHandler [ 'Respawn', { player addAction ['Enemy!',{hint (format ["Enemy! %1",diag_ticktime]);},nil,0,true,true,'','call my_condition',-1,false,'','']; } ]; Ahh thank you so much. This is just what I wanted. 3 Share this post Link to post Share on other sites
Grim5667 3 Posted September 4, 2018 On 28/08/2018 at 7:22 AM, fn_Quiksilver said: standard method for this sort of thing is to add the action to the player object, and use the condition to hide/show it (such as when aiming at an enemy) heres an example my_condition = { private _return = false; _cursortarget = cursortarget; if (!isnull _cursortarget) then { if (_cursortarget iskindof 'camanbase') then { if ((side (group _cursortarget)) in (playerside call bis_fnc_enemysides)) then { if ((tolower (lifestate _cursortarget)) in ['healthy','injured']) then { _return = true; }; }; }; }; _return; }; player addAction ['Enemy!',{hint (format ["Enemy! %1",diag_ticktime]);},nil,0,true,true,'','call my_condition',-1,false,'','']; player addEventHandler [ 'Respawn', { player addAction ['Enemy!',{hint (format ["Enemy! %1",diag_ticktime]);},nil,0,true,true,'','call my_condition',-1,false,'','']; } ]; Hey is there a way to have the action show up on AAF too? Share this post Link to post Share on other sites
pierremgi 4850 Posted September 5, 2018 Shift AAF as enemy (in editor / attributes/general/misc)... or change the condition: (side (group _cursortarget)) in (playerside call bis_fnc_enemysides) for something else: (side _cursortarget != playerSide) ... but change the addAction title/hint: "not our side" Share this post Link to post Share on other sites
Grim5667 3 Posted September 5, 2018 11 hours ago, pierremgi said: Shift AAF as enemy (in editor / attributes/general/misc)... or change the condition: (side (group _cursortarget)) in (playerside call bis_fnc_enemysides) for something else: (side _cursortarget != playerSide) ... but change the addAction title/hint: "not our side" That wouldnt work because that means the action would show on the civs Share this post Link to post Share on other sites
pierremgi 4850 Posted September 5, 2018 1 hour ago, Grim5667 said: That wouldnt work because that means the action would show on the civs add a condition. Share this post Link to post Share on other sites