-
Content Count
827 -
Joined
-
Last visited
-
Medals
Posts posted by wogz187
-
-
@sil.lau@free.fr,
Loop the condition and identify the nearest activator.//method 1 [obj_0, obj_1] spawn { waitUntil { sleep 1; _near= _this select {_x distance player < 20}; if !(_near isEqualTo []) then {systemChat str (_near #0); true} else {false} } }; //method 2 (probably faster) [obj_0, obj_1] spawn { waitUntil { sleep 1; _near= _this findIf {_x distance player < 20}; if (_near> -1) then {systemChat str (_this select _near); true} else {false} } };
Have fun!
- 2
-
Convert just about anything into a position array,
you_convertToPos={ private _pos= objNull; if (typeName _this== "ARRAY") exitWith {_this}; if (typeName _this== "LOCATION") exitWith {_pos = locationPosition _this; _pos}; if !(typeName _this== "STRING") then {_pos = (_this ModelToWorld [0,0,0])} else {_pos = (getMarkerPos [_this, true])} _pos }; Example: _arr =[(nearestLocation [getPos player, "nameCity"]), (player modelToWorld [0,3,0]), trigger_0, "marker_0"] apply {systemChat str (_x call you_convertToPos)};
Have fun!
- 2
-
@Coladebote,
Check out this topic,The provided function can hide/show/remove EDEN layers.
Have fun!- 3
-
@xXPinkFloyd92Xx,
I don't have ACE installed so I tested with,(units ((player modelToWorld [0,5,0]) call fnc_createGrouplost)) apply {systemChat str _x};
I can't account for what happens inside the apply scope.
- 1
-
Spoilerfnc_createGroupLost= { if isNil '_this' exitWith {false}; private _grp = createGroup [WEST, true]; for "_i" from 0 to 3 do {_grp createUnit ["C_man_hunter_1_F", _this, [], 0, "FORM"]}; _grp }; (units ((player modelToWorld [0,5,0]) call fnc_createGrouplost)) apply { _x setVariable ["ace_medical_ai_lastFired",9999999]; [_x, 0.8, "rightleg","bullet"] call ace_medical_fnc_addDamageToUnit; [_x, 0.8, "leftleg","bullet"] call ace_medical_fnc_addDamageToUnit };
Have fun!
-
_markerArray = ["l_1", "l_2", "l_3", "l_4", "l_5", "l_6", "l_7", "l_8", "l_9", "l_10"]; _IEDarray = ["IEDUrbanSmall_Remote_Ammo","IEDLandSmall_Remote_Ammo","IEDUrbanBig_Remote_Ammo","IEDLandBig_Remote_Ammo"]; _markerArray apply { private _veh= (selectRandom _iedArray) createVehicle (getMarkerPos _x); _veh spawn { waitUntil { sleep 1; if !((_this nearEntities ["Man", 20]) select {_x in allPlayers} isEqualTo []) then {_this setDamage 1}; !alive _this } }; _veh };
Create an IED at each marker position. Detonation radius is set to 20 which you may change as you please.
Have fun!- 1
-
It's a relatively simple function,
MMF_fnc_conversation={ { _this addAction [(_x #0), { params ["_target", "_caller", "_actionId", "_arguments"]; [(getDir _caller)-180] apply {_target setFormDir _x; _target setDir _x}; private _prompt= _target getVariable ["you_prompt", [""]]; [ [name _caller, (_prompt select _actionID select 1)], [name _target, (_arguments select 0), (_arguments #1)] ] spawn BIS_fnc_EXP_camp_playSubtitles; [_target, _caller] spawn (_arguments #2) },(_this getVariable ["you_dialog", []] select _forEachIndex),9,false, true,"", "alive _target", 3] }forEach (_this getVariable ["you_prompt", []]) };
with a lot of instructions,
Spoiler/*======MMF_fnc_conversation======CALL======Add dialog actions to NPCs ===================================instructions=============readme Configure and paste each variable into the speaker unit's init ===================Prompt variable: This determines the player's menu prompt and subtitle display text [["string", "string"]] Array(s) containing 2 strings, a short menu prompt and a long subtitle prompt EXAMPLE: this setVariable ["you_prompt", [ ["MENU Prompt One", "SUBTITLE Prompt One"], ["MENU Prompt Two", "SUBTITLE Prompt Two"] ]]; ==================Dialog (response) variable: This determines the NPC response, delay to respond and spawned code **NOTE: within spawned code "_this" is array with params [speaker, player] [["string", number, {code}]] Array(s) containing 1 response string, delay number and code to spawn (optional) EXAMPLE: this setVariable ["you_dialog", [ ["Response One", 5, {}], ["Response Two (with code)", 5, {systemChat str _this}] ]]; ==================Spawn from unit init this call MMF_fnc_conversation; ==========================examples============================see bottom for supplemental dialog (branching dialog) ===================demo example (see NPC init field) this setVariable ["you_prompt", [ ["Enemy?", "Seen any bad guys creepin' around?"],["Supplies?", "Where's all my shit?"],["More?", "Got anything else to say?"] ]]; this setVariable ["you_dialog", [ ["None...", 5, {}], ["Not my business...", 5, {}], ["Nope...", 5, {systemChat str _this}] ]]; this call MMF_fnc_conversation; ==================simple example this setVariable ["you_prompt", [ ["Greet", "Hello! Nice to see you!"] ]]; this setVariable ["you_dialog", [ ["Nope...", 5, {removeAllActions (_this #0)}] ]]; this call MMF_fnc_conversation; =========================extra=====================Add "Talk" action to initiate conversation and remove when distant (optional) this addAction ["Talk", { params ["_target", "_caller", "_actionId", "_arguments"]; _target removeAction _actionID; _target call MMF_fnc_conversation; [_target, _caller] spawn { waitUntil {sleep 1; if ((_this #0) distance (_this #1)>5) then {removeAllActions (_this #0); true} else {false}} }; },[],0,false, true,"", "alive _target", 3]; /*================================supplemental dialog Spawn from the appropriate response field to initiate multi-line conversation on selected topic dialog_1= { private _caller= (_this select 1); private _target= (_this select 0); sleep 5; [ [name _caller, "This is the player's first line after the initial response"], [name _target, "I see. How about more responses?", 5], [name _caller, "Techinically we could keep this up forever...", 10], [name _target, "Great! Tell me more...", 15] ] spawn BIS_fnc_EXP_camp_playSubtitles; }; ======================================*/
Have fun!
- 1
-
QuoteI've been playing around with _this and this for a while, and sometimes it works, sometimes it doesn't...
this spawn { waitUntil {sleep 1; if alive _this then {systemChat str _this}; !alive _this } } [this, name this, group this] call { params ["_unit", "_name", "_grp"]; _this spawn { waitUntil {sleep 1; if alive (_this #0) then {systemChat str _this}; !alive (_this #0) } } }
_this is the argument(s) passed to a script. A magic variable from which other variables may be derived.
THIS is just another way to refer to the unit, object, vehicle into which you paste script. If you name a unit "bob" then THIS is bob in bob's init field.
Have fun!
- 3
-
@Play3r,
Here's a more recent version that handles weapon dropping,Spoilerthis addEventHandler ["handledamage", { params ["_unit","_part","_dam","_shooter"]; if (!alive _unit) exitWith {_unit removeEventHandler ["handleDamage", _thisEventHandler]}; if (_unit getVariable ["parts_handle", false]) exitWith {false}; private _parts= ["arms", "hands", "head"]; if (_part in _parts) then { private _holder = createVehicle ["WeaponHolderSimulated",ASLtoATL eyePos _unit, [], 0, "CAN_COLLIDE"]; if !(_part == "head" && _dam > 0.4 && currentWeapon _unit != "" && local _unit) then { _holder addItemCargoGlobal [currentWeapon _unit,1]; _unit removeWeapon (currentWeapon _unit); }; if (_part == "head" && _dam > 0.4 && headgear _unit != "" && local _unit) then { _holder addItemCargoGlobal [headgear _unit,1]; { _unit unlinkItem _x; }forEach [goggles _unit, hmd _unit, headgear _unit]; }; _holder setVelocity [5 * sin (_shooter getdir _unit), 5 * cos (_shooter getDir _unit), 0.3]; _holder addTorque [random 0.02, random 0.02, random 0.02]; }; _unit setVariable ["parts_handle", true]; _unit spawn {sleep 1; _this setVariable ["parts_handle", false]}; }];
from @omri2050's script goodies discord
It will work in a loop,
{ _x addEventHandler... }foreach allUnits select {side _x == EAST};
Change "this" to "_x" inside forEach.
Have fun!- 1
- 1
-
Remove all this classname from the calling unit,
[this, "ACE_plasmaIV_250"] call {{(_this #0) removeItem _x} forEach (((uniformItems (_this #0) + vestItems (_this #0) + backpackItems (_this #0))) select {_x== (_this #1)})}
If you'll be calling this often,
you_remove_strings= { {(_this #0) removeItem _x} forEach (((uniformItems (_this #0) + vestItems (_this #0) + backpackItems (_this #0))) select {_x== (_this #1)}) }; //call [this, "ACE_plasmaIV_250"] call you_remove_strings
Have fun!
- 1
-
@Coladebote,
Try the alt-syntax of createVehicle,private _fire = createVehicle ["test_EmptyObjectForSmoke", getMarkerPos "SMOKE_1", [], 0, "CAN_COLLIDE"];
Have fun!
smoke_effect={ if !isServer exitWith {}; params [["_pos", [0,0,0]], ["_time", 900], ["_mark", ""], ["_effect", ["Land_d_House_Small_02_V1_F", "test_EmptyObjectForSmoke"]], ["_code", {{deleteVehicle _x} forEach _this}], ["_arr", []]]; if !(_mark isEqualTo "") then {(createMarker [_mark, _pos]) setMarkerShape "ICON"}; {private _veh= createVehicle [_x, _pos, [], 0, "CAN_COLLIDE"]; _arr pushBack _veh}forEach _effect; [_arr, _time, _code] spawn { params ["_arr", "_time", "_code"]; sleep _time; _arr spawn _code }; _arr };
EXAMPLES:
Your coordinates, default params[[13413.9,6621.1]] call smoke_effect
10 second test,
[(player modelToWorld [0, 20, 0]), 10, "FIRE"] call smoke_effect
Hunter wreck (smoke and fire)
[ (player modelToWorld [(random 100), (random 100), 0]), 600, "Hunter Wreck", ["Land_wreck_hunter_f", "test_EmptyObjectForFireBig", "test_EmptyObjectForSmoke"] ] call smoke_effect
- 1
- 1
-
3 hours ago, gc8 said:also don't forget to put ; after each }
Add a semicolon before starting a new line within the same scope,this spawn { waitUntil { sleep 1; if alive _this then {systemChat str alive _this}; !alive _this } }
this spawn { waitUntil { sleep 1; if alive _this then {systemChat str alive _this}; !alive _this }; systemChat "exited loop" }
Have fun!
- 1
-
QuoteDo i put that code in the trigger activation or the waypoint activation?
Paste the script into the init field of one of the units. The first NPC is the "trigger area" (10 m). No waypoints or triggers required.
Quotewill it affect all nearby AI as there is lots of other ai stood about that i dont want affected
It will only affect the units listed in the array.
I edited the script so the NPCs listed in the array will move to, then board the vehicle listed last in the array,
[NPC_0, NPC_1, NPC_2, truck_1] spawn { private _veh= _this select (count _this) -1; waitUntil { sleep 1; if (player distance (_this select 0) < 10) then { { [_x, _veh] spawn { params ["_unit", "_veh"]; sleep 10; _unit switchMove ""; _unit enableAI "ALL"; _unit doMove (getPos _veh); waitUntil {sleep 1; _unit distance _veh < 5}; _unit moveInAny _veh } }forEach _this }; (player distance (_this select 0)<10) }; waitUntil {sleep 1; {_x in _veh} count _this == count _this -1}; driver _veh spawn {_this doMove (_this getVariable ["move_pos", (_this modelToWorld [0,0])])}; };
Have fun!
- 2
-
@Nicole_UK,
I'm not sure why your NPC isn't moving but I am sure that triggers and waypoints are holding you back![NPC_0, NPC_1, NPC_2] spawn { waitUntil { sleep 1; if (player distance (_this select 0) < 10) then { { _x spawn { sleep 10; _this switchMove ""; _this enableAI "ALL"; _this doMove (_this getVariable ["move_pos", (_this modelToWorld [100, 100, 0])]) } }forEach _this }; (player distance (_this select 0)<10) } };
Uses the first NPC in the array as an area center, 10 m. When player enters the area wait 10 seconds and release the NPCs listed in the array from their animation. Send them to the variable "move_pos" default: 100 meters that way. Exit loop.
Have fun!- 3
-
QuoteI am trying to engineer it to work with my already-made mission.
It's best to install MMF to a freshly created scenario with the intention of using if from the start. That way you can embrace the design philosophy and accomplish with 1 line what used to take a jumble of triggers and webs of waypoints— those are the complicated things— MMF is easy-to-use (it says so right on the tin!).
Some recent additions, like MMF_fnc_unit_maker, make designing missions even easier.some_object spawn MMF_fnc_unit_maker;
I cannot simplify it any further.
Have fun! -
Check out the new demo, MMF_games_demo
9+1 missions in a single scenario!
MissionsSpoilerDEATHMATCH
Score 1000 points before 3 respawnsHOSTAGE
Rescue and return 1 hostage
EXTRACTION
Hold out until the rescue chopper arrives
TARGETS
Score 1000 points shooting zombie targets
PATROL
Conduct a routine patrol
ESCAPE
Insert via parachute and quickly make your way to the safehouse
SNIPER
Score 1000 points on the nearby targets
CAPTURE
Capture 3 areas around town
SPY
Locate the target building, gain access by locating a key and steal the computer
SANDBOX
Try the version 8 blufor sandbox
Bonus: Log out of the game to access your player's apartment
- 1
-
@Nicole_UK,
To do what you originally asked,{ deleteVehicle _x } forEach (nearestObjects [thisTrigger, ["all"], (triggerArea thisTrigger) select 0]);
in a trigger which includes all the base objects within its area.
Have fun!- 4
-
QuoteSo I just add this code to a layer and it will remove everything?
1) Create a new layer (folder) in the editor and title it something like "base_objects"
2) Place your base objects into this new folder
3) Create a trigger on your base, player activated (not present)
4) Paste, (to delete)[["base_objects"], false, true] call you_hide_layers
in the trigger ON ACTIVATION field
or
3) Create a trigger on your base, player activated (present), repeatable
4) Paste, (to toggle show/hide)
ON ACTIVATION:[["base_objects"]] call you_hide_layers
ON DEACTIVATION:
[["base_objects"] true] call you_hide_layers
5) Paste the function somewhere, it only has to be loaded once. It can go basically anywhere. Paste it in your player's init field if you like.
you_hide_layers={ params [["_layers", []], ["_show", false], ["_remove", false], ["_exec", {}]]; if _remove then {_exec ={deleteVehicle _x}} else {_exec= {_x hideObjectGlobal _show}}; for "_i" from 0 to count _layers -1 do { {call _exec} forEach ((getMissionLayerEntities (_layers select _i)) select 0) } };
Have fun!
- 3
-
@Nicole_UK,
Remove or hide/show all objects in a layer,Spoiler=========================hide or remove layers========================== EXAMPLE: hide layers [["layer_0", "layer_1"] true] call you_hide_layers EXAMPLE: show layers [["layer_0", "layer_1"]] call you_hide_layers EXAMPLE: remove (permanent) [["layer_0", "layer_1"], false, true] call you_hide_layers ======================================================================== you_hide_layers={ params [["_layers", []], ["_show", false], ["_remove", false], ["_exec", {}]]; if _remove then {_exec ={deleteVehicle _x}} else {_exec= {_x hideObjectGlobal _show}}; for "_i" from 0 to count _layers -1 do { {call _exec} forEach ((getMissionLayerEntities (_layers select _i)) select 0) } };
Put your base objects in a layer and then call this function on the layer. You can delete the objects (see 3rd example) or just hide/show them when appropriate.
Have fun!
- 3
-
@Joe98,
Generally speaking this is my favorite type of loop,SpoilerwaitUntil {sleep 1; if (_condition) then {}; _condition }
Which acts like a trigger.
Here is an outline for a loop which can do just about anything,this spawn { private _doStuff = {systemChat format ["%1 is %2", name _this, lifeState _this]}; waitUntil { sleep 1; if alive _this then _doStuff; !alive _this }; systemChat format ["R.I.P. %1", name _this] };
Chat the unit's name and life state until they are dead and bids fair adieu
Have fun!- 1
-
@GamersFortitude,
This does what the script above is supposed to do,Spoilerplane1 spawn { if !isServer exitWith {}; private _arr= [0, 50, 0]; for "_i" from 0 to 3 do { _arr= [0, (_arr select 1)-10, (_arr select 2)+ -5]; private _bomb = "Bomb_03_F" createVehicle ((getpos _this) vectorAdd [0,0,-1]); _bomb setDir getDir _this; _bomb setVelocityModelSpace _arr; sleep 1 } };
However I'm not sure that's exactly what you want it to do.
As a function it can work repeatedly but mostly for visual effect (there's no aim),Spoilerbomb_target= { params ["_caller", "_target", "_area"]; if !isServer exitWith {}; waitUntil {sleep 1; if !(_caller distance _target < _area) then {false} else { for "_i" from 0 to 3 do { private _bomb = "Bomb_03_F" createVehicle ((getpos _caller) vectorAdd [0,0,-1]); _bomb setDir getDir _caller; _bomb setVelocityModelSpace [0, 50, -5]; sleep 1 }; true } } }; [plane_1, player, 500] spawn bomb_target
Have fun!- 2
-
@sarogahtyp
My favorite line from the script above,_down_start > 0 and (diag_tickTime - _down_start) > _down_time
now that's how you return bool like a pro!
Thanks, man!- 2
- 1
-
@BluBoi,
This topic reminds me of myself.
Here is your script running without errors,SpoilermissionNameSpace setVariable ["manage_npcs", true]; [] spawn { waitUntil {sleep 1; if !(missionNameSpace getVariable ["manage_npcs", false]) then {false} else { systemChat "started"; { _x setVariable ["HAF_spawned",true]; _x setSkill ["courage", 1.0]; _x enableAttack false; _x setCombatBehaviour "AWARE"; private _target = _x findNearestEnemy (getPosATL _x); systemChat str _target; if !isNull _target then { _x setBehaviour "CARELESS"; _x suppressFor 10; _x doMove position _target; _x spawn {sleep 10; _this setBehaviour "AWARE"}; } } forEach (allUnits select { !(_x getVariable ["HAF_spawned", false]) && side _x == WEST}); sleep 12; false } } };
However there are still a number of problems (I don't think it does what you want it to do).
Like was said before,
1) system chat stuff to debug your script
2) read the wiki 10x for each command you use
3) make little experiments instead of full blown scripts (then compile successes together)
Have fun!- 3
-
@Dyeg0,
Check this out,Spoilerplayer spawn { "auto recruit nearby units"; waitUntil {sleep 1; if ( (_this nearEntities ["Man", 3]) - [_this] isEqualTo []) then {false} else { private _recruit= ((_this nearEntities ["Man", 3])- [_this]) select 0; if ( side _recruit == side _this && group _recruit !=group _this ) then { [_recruit] join _this; false }else{false} } } }
Simple recruit addAction,
[player, "Recruit Unit", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "side cursorTarget == side _this && cursorTarget distance _this < 3 && group cursorTarget != group _this", "alive cursorTarget",{},{},{ params ["_target", "_caller", "_actionId", "_arguments"]; [cursorTarget] join _target; },{},[],2,0,false,true] call BIS_fnc_holdActionAdd;
Have fun!
- 2
- 1
Deleting all objects within a certain radius.
in ARMA 3 - MISSION EDITING & SCRIPTING
Posted
Check out this topic,
The provided function can hide/show/remove EDEN layers.
Have fun!