kovvalsky 13 Posted November 27, 2014 Hi, if the AI unit is in your team, you can select it >> Then press 6 >> And then you can order it to run the custom action. is there a possibility to perform this via script? thanks! Share this post Link to post Share on other sites
Larrow 2826 Posted November 27, 2014 (edited) action ["User" will make the unit use an action placed on it. e.g create a unit called bob and place this in his init. this setVariable [ "myActionID", this addAction [ "myAction", { ( _this select 0 ) setUnitPos "DOWN" }] ]; This adds an action to the unit, storing the actions ID on him in a variable called myActionID. Then in the players init give him an action.. player addAction [ "unitAction", { player action [ "User", bob, bob getVariable "myActionID" ] }]; On the player using his action it will make the AI unit use its action as specified via the ID stored on it in myActionID variable. Hmmm could of most likely given a less confusing example than an action activating an action, oh well done now :/ Edited November 27, 2014 by Larrow Share this post Link to post Share on other sites
kovvalsky 13 Posted November 27, 2014 thanks Larrow, it work's! from biki: [b]User[/b] Description: Soldier 'unitName' does nothing. Executes the custom action with the given index of the the target unit. Indexes are based upon the order in which the actions are added to the unit. See addAction. Syntax: unitName action ["User", target unit, action index] Example: gameLogic action ["User", player, 3]; Share this post Link to post Share on other sites
kovvalsky 13 Posted November 28, 2014 (edited) I made a very simple function for this, simply perform an addAction command and store the action ID to the object with the action: [color="#FF8040"]addActionWithID [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#191970"][b]private[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"_ActionID"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_accVarName"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_accObject"[/color][color="#8B3E2F"][b],[/b][/color] [color="#7A7A7A"]"_accTitle"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_accCode"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_accArgs"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_accPriority"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_accShowWindow"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_accHideOnUse"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_accShortcut"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_accCondition"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accVarName[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"ActionID"[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_param[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accObject[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]objNull[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#000000"]objNull[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_param[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accTitle[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]2[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"noTitle"[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_param[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accCode[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]3[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b]{[/b][/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_param[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accArgs[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]4[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]nil[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_param[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accPriority[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]5[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]1.5[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_param[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accShowWindow[/color] [color="#8B3E2F"][b]=[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]6[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_param[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accHideOnUse[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]7[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_param[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accShortcut[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]8[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_param[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accCondition[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_this[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]9[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"true"[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_param[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_ActionID[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_accObject[/color] [color="#191970"][b]addAction[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#1874CD"]_accTitle[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_accCode[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_accArgs[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_accPriority[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_accShowWindow[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_accHideOnUse[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_accShortcut[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_accCondition[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_accObject[/color] [color="#191970"][b]setVariable[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#1874CD"]_accVarName[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_ActionID[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color] Made with KK's SQF to BBCode Converter USAGE: [b][[/b] [color="#696969"]STRING[/color]: VariableNameOfActionID[b],[/b] [color="#696969"]OBJECT[/color]: ObjectToAssignAction[b],[/b] [color="#696969"]STRING[/color]: ActionTitle[b],[/b] [color="#696969"]STRING or CODE[/color]: ActionScript[b], [/b] [color="#696969"]ANYTHING[/color]: ActionArguments[b], [/b] [color="#696969"]NUMBER[/color]: ActionPriority[b], [/b] [color="#696969"]BOOLEAN[/color]: ShowActionInMiddleScreen[b],[/b] [color="#696969"]BOOLEAN[/color]: HideActionOnUse[b],[/b] [color="#696969"]STRING[/color]: ActionShortcut[b],[/b] [color="#696969"]STRING[/color]: ActionConditionToShow [b]] call addActionWithID; [/b] i.e: [b][[[/b]"MyActionID",player,"Say Hello",{hint "HELLO";}[b]],[/b] "addActionWithID"[b], false, true] call BIS_fnc_MP;[/b] player [b]removeAction [/b](player [b]getVariable [/b]"MyActionID"); Edited November 28, 2014 by KoVValsky Share this post Link to post Share on other sites