Coolinator 10 Posted December 10, 2014 i googled, found some hostage scripts but tested them on dedicated server, ended up not working :( Is there a hostage script out there that works in dedicated server? or they all only work for SP? Share this post Link to post Share on other sites
jshock 512 Posted December 10, 2014 (edited) Well, I don't know about the other scripts, but below is an alteration of some code from a private project of mine, I don't know if it works on dedicated or not (yet :D), but I can make the necessary changes to it to make it work (hopefully, if needed). Step 1: Make a trigger named "capturePoint" set it as Civilian, Present, Repeatedly. Condition: *blank* onAct: missionNameSpace setVariable ["haveHostagesBeenRescued",true]; onDeact: *blank* Set radius to whatever (I use 5x5), and place the trigger where ever you want the "hostage collection point" to be. Step 2: Copy the following code into JSHK_hostages.sqf _marker = [_this,0,"",[""]] call BIS_fnc_param; JSHK_fnc_hostageRescue = { private ["_marker","_civTypes","_pos","_grp","_hostageArr","_task"]; _marker = (_this select 0); _civTypes = ["C_man_1", "C_man_pilot_F", "C_scientist_F", "C_man_w_worker_F", "C_man_p_fugitive_F_afro"]; _pos = [([_marker,100] call JSHK_fnc_buildingPositions)] call BIS_fnc_selectRandom; _grp = createGroup CIVILIAN; _hostageArr = []; _marker setMarkerPos (_pos); for "_i" from 0 to (floor(random 4)+1) step 1 do { _rndType = _civTypes call BIS_fnc_selectRandom; _unit = _grp createUnit [_rndType, _pos, [], 1, "NONE"]; _unit addAction ["Capture/Rescue","[] call JSHK_captureAddAction",[],6,true,true,"","_this distance _target < 2"]; _unit addEventHandler ["Killed", "['Hostage', 'Failed', true] call BIS_fnc_taskSetState;"]; _unit setCaptive true; _unit setUnitPos "DOWN"; _unit disableAI "MOVE"; _hostageArr pushBack _unit; }; _task = ["Hostage", WEST, ["Rescue the Hostages", "Hostage Rescue", _marker], (getMarkerPos _marker), "CREATED", 5, true, true] call BIS_fnc_setTask; capturePoint setTriggerStatements [ format ["this && {_x in thisList} count %1 isEqualTo count %1",_hostageArr], triggerStatements capturePoint select 1, triggerStatements capturePoint select 2 ]; while {true} do { if ([_task] call BIS_fnc_taskState isEqualTo "Failed") exitWith { capturePoint setTriggerStatements [ "", (triggerStatements (capturePoint select 1)), (triggerStatements (capturePoint select 2)) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",false]; }; if (missionNameSpace getVariable ["haveHostagesBeenRescued",false]) exitWith { [_task, "Succeeded", true] call BIS_fnc_taskSetState; capturePoint setTriggerStatements [ "", (triggerStatements (capturePoint select 1)), (triggerStatements (capturePoint select 2)) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",false]; }; sleep 3; }; _hostageArr; }; JSHK_fnc_buildingPositions = { private ["_center","_radius","_houses","_insideHousePos","_singlePosArray"]; _center = [_this,0,objNull,["",objNull,[]],[3]] call BIS_fnc_param; _radius = [_this,1,200,[0]] call BIS_fnc_param; switch (typeName _center) do { case "OBJECT": { _center = getPos _center; }; case "STRING": { _center = getMarkerPos _center; }; case "ARRAY": { _center; }; default { diag_log "Center position undefined >> JSHK_garrison\fn_buildingPositions.sqf"; }; }; _houses = nearestObjects [_center, ["House"], _radius]; _insideHousePos = []; { if ([_x] call BIS_fnc_isBuildingEnterable) then { _buildPos = [_x] call BIS_fnc_buildingPositions; _insideHousePos pushBack _buildPos; }; }forEach _houses; _singlePosArray = []; for "_i" from 0 to ((count _insideHousePos) - 1) step 1 do { _singleHouse = _insideHousePos select _i; for "_a" from 0 to ((count _singleHouse) - 1) step 1 do { _singlePos = _singleHouse select _a; _singlePosArray pushBack _singlePos; }; }; _singlePosArray; }; JSHK_captureAddAction = { private ["_unit","_player","_actionID"]; _unit = (_this select 0); _player = (_this select 1); _actionID = (_this select 2); ["Hostage", (getPos capturePoint)] call BIS_fnc_taskSetDestination; _civGroup = units group _unit; _civGroup joinSilent (group _player); { _x removeAction _actionID; _x setUnitPos "UP"; _x enableAI "MOVE"; } forEach _civGroup; }; [_marker] call JSHK_fnc_hostageRescue; Step 3: When you want to create the hostage rescue task and such, call line below, where "markerName" is the name of the marker at the center of the area you would like to create this situation. null = ["markerName"] execVM "JSHK_hostages.sqf"; I have no clue if all this will work straight away, as I did quite a bit of alteration to all the original stuff from my personal project, so this is all untested, but give it a go :p. To understand how it flows, basically, you call it, it creates 1-4 hostages in a building position within 100m of the marker used in step 3, then creates a task to get those hostages, the trigger from step 1 gets its condition changed to wait for all the hostages to arrive in it's radius, if they are all there, task success, if any hostage at any point gets killed, task failed. Hostages get addAction to rescue them, after using that action, the civs will join the player's group, and the group TL can order the civs around to get them back to base (or wherever the capturePoint trigger is placed). Edited December 10, 2014 by JShock Share this post Link to post Share on other sites
Coolinator 10 Posted December 10, 2014 Well, I don't know about the other scripts, but below is an alteration of some code from a private project of mine, I don't know if it works on dedicated or not (yet :D), but I can make the necessary changes to it to make it work (hopefully, if needed).Step 1: Make a trigger named "capturePoint" set it as Civilian, Present, Repeatedly. Condition: *blank* onAct: missionNameSpace setVariable ["haveHostagesBeenRescued",true]; onDeact: *blank* Set radius to whatever (I use 5x5), and place the trigger where ever you want the "hostage collection point" to be. Step 2: Copy the following code into JSHK_hostages.sqf _marker = [_this,0,"",[""]] call BIS_fnc_param; JSHK_fnc_hostageRescue = { private ["_marker","_civTypes","_pos","_grp","_hostageArr","_task"]; _marker = (_this select 0); _civTypes = ["C_man_1", "C_man_pilot_F", "C_scientist_F", "C_man_w_worker_F", "C_man_p_fugitive_F_afro"]; _pos = [([_marker,100] call JSHK_fnc_buildingPositions)] call BIS_fnc_selectRandom; _grp = createGroup CIVILIAN; _hostageArr = []; for "_i" from 0 to (floor(random 4)+1) step 1 do { _rndType = _civTypes call BIS_fnc_selectRandom; _unit = _grp createUnit [_rndType, _pos, [], 1, "NONE"]; _unit addAction ["Capture/Rescue","[] call JSHK_captureAddAction",[],6,true,true,"","_this distance _target < 2"]; _unit addEventHandler ["Killed", "['Hostage', 'Failed', true] call BIS_fnc_taskSetState;"]; _unit setCaptive true; _unit setUnitPos "DOWN"; _unit disableAI "MOVE"; _hostageArr pushBack _unit; }; _task = ["Hostage", WEST, ["Rescue the Hostages", "Hostage Rescue", _marker], (getMarkerPos _marker), "CREATED", 5, true, true] call BIS_fnc_setTask; capturePoint setTriggerStatements [ format ["this && {_x in thisList} count %1 isEqualTo count %1",_hostageArr], triggerStatements capturePoint select 1, triggerStatements capturePoint select 2 ]; while {true} do { if ([_task] call BIS_fnc_taskState isEqualTo "Failed") exitWith { capturePoint setTriggerStatements [ "", (triggerStatements (capturePoint select 1)), (triggerStatements (capturePoint select 2)) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",false]; }; if (missionNameSpace getVariable ["haveHostagesBeenRescued",false]) exitWith { [_task, "Succeeded", true] call BIS_fnc_taskSetState; capturePoint setTriggerStatements [ "", (triggerStatements (capturePoint select 1)), (triggerStatements (capturePoint select 2)) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",false]; }; sleep 3; }; _hostageArr; }; JSHK_fnc_buildingPositions = { private ["_center","_radius","_houses","_insideHousePos","_singlePosArray"]; _center = [_this,0,objNull,["",objNull,[]],[3]] call BIS_fnc_param; _radius = [_this,1,200,[0]] call BIS_fnc_param; switch (typeName _center) do { case "OBJECT": { _center = getPos _center; }; case "STRING": { _center = getMarkerPos _center; }; case "ARRAY": { _center; }; default { diag_log "Center position undefined >> JSHK_garrison\fn_buildingPositions.sqf"; }; }; _houses = nearestObjects [_center, ["House"], _radius]; _insideHousePos = []; { if ([_x] call BIS_fnc_isBuildingEnterable) then { _buildPos = [_x] call BIS_fnc_buildingPositions; _insideHousePos pushBack _buildPos; }; }forEach _houses; _singlePosArray = []; for "_i" from 0 to ((count _insideHousePos) - 1) step 1 do { _singleHouse = _insideHousePos select _i; for "_a" from 0 to ((count _singleHouse) - 1) step 1 do { _singlePos = _singleHouse select _a; _singlePosArray pushBack _singlePos; }; }; _singlePosArray; }; JSHK_captureAddAction = { private ["_unit","_player","_actionID"]; _unit = (_this select 0); _player = (_this select 1); _actionID = (_this select 2); ["Hostage", (getPos capturePoint)] call BIS_fnc_taskSetDestination; _civGroup = units group _unit; _civGroup joinSilent (group _player); { _x removeAction _actionID; _x setUnitPos "UP"; _x enableAI "MOVE"; } forEach _civGroup; }; [_marker] call JSHK_fnc_hostageRescue; Step 3: When you want to create the hostage rescue task and such, call line below, where "markerName" is the name of the marker at the center of the area you would like to create this situation. null = ["markerName"] execVM "JSHK_hostages"; I have no clue if all this will work straight away, as I did quite a bit of alteration to all the original stuff from my personal project, so this is all untested, but give it a go :p. To understand how it flowa, basically, you call it, it creates 1-4 hostages in a building position within 100m of the marker used in step 3, then creates a task to get those hostages, the trigger from step 1 gets its condition changed to wait for all the hostages to arrive in it's radius, if they are all there, task success, if any hostage at any point gets killed, task failed. Hostages get addAction to rescue them, after using that action, the civs will join the player's group, and the group TL can order the civs around to get them back to base (or wherever the capturePoint trigger is placed). Thank you Jshock!!! :) I will test it in a dedicated server and tell you the results later :) eating dinner right now ;) ---------- Post added at 06:58 ---------- Previous post was at 05:06 ---------- i finished testing it, but only in LAN MP editor first, not in dedicated server. i followed your instructions and did everything but there were no hostages in the building were i put the marker at.. am i suppose to put civilian in the building, or does the script automatically create hostage in the building? i named my marker "hostage". i also put the call line in my init.sqf: null = ["hostage"] execVM "JSHK_hostages.sqf"; Share this post Link to post Share on other sites
jshock 512 Posted December 10, 2014 (edited) i finished testing it, but only in LAN MP editor first, not in dedicated server. i followed your instructions and did everything but there were no hostages in the building were i put the marker at.. am i suppose to put civilian in the building, or does the script automatically create hostage in the building?i named my marker "hostage". i also put the call line in my init.sqf: null = ["hostage"] execVM "JSHK_hostages.sqf"; Ok, sorry my fault, so the way my building position finder works is it gets the buildings within a radius around that marker, then chooses a random building position, so the hostages won't be right on the marker's position. Now there are two possible changes, we can limit the radius search for building positions (as in limit it so it really only checks one house), or we have your marker moved over the position of the hostages. I updated the code above for the latter of the two choices, let me know if you want to try the first way. EDIT: Derp tired moment, updated again...sorry. Edited December 10, 2014 by JShock Share this post Link to post Share on other sites
Coolinator 10 Posted December 10, 2014 Ok, sorry my fault, so the way my building position finder works is it gets the buildings within a radius around that marker, then chooses a random building position, so the hostages won't be right on the marker's position.Now there are two possible changes, we can limit the radius search for building positions (as in limit it so it really only checks one house), or we have your marker moved over the position of the hostages. I updated the code above for the latter of the two choices, let me know if you want to try the first way. Is there a way i can put the hostage in a specific location? not by random position? can i just place a civilian in the mission editor so i can put him in any specific location i want? and make him a captured hostage? But i also still want to try the random position though :) havent tested the new updated script yet, will now :) Share this post Link to post Share on other sites
jshock 512 Posted December 10, 2014 Ok, yea, so simply change the following line (near the top of script): _pos = [([_marker,100] call JSHK_fnc_buildingPositions)] call BIS_fnc_selectRandom; //change to this _pos = (getMarkerPos _marker); Share this post Link to post Share on other sites
Coolinator 10 Posted December 10, 2014 Ok, yea, so simply change the following line (near the top of script): _pos = [([_marker,100] call JSHK_fnc_buildingPositions)] call BIS_fnc_selectRandom; //change to this _pos = (getMarkerPos _marker); Ahh kk so the first one, wherever u place the marker at, that's where the hostages will spawn? The new one, the line you posted here, will make the hostages spawn in random positions? Share this post Link to post Share on other sites
jshock 512 Posted December 10, 2014 Ahh kk so the first one, wherever u place the marker at, that's where the hostages will spawn? The new one, the line you posted here, will make the hostages spawn in random positions? Ok the following line is for the random positions in a radius: _pos = [([_marker,100] call JSHK_fnc_buildingPositions)] call BIS_fnc_selectRandom; And this is for specific marker position: _pos = (getMarkerPos _marker); Share this post Link to post Share on other sites
Coolinator 10 Posted December 10, 2014 Ahh kk I see thnx :) be back in a bit haven't tested it yet, I tell you the results soon as possible after I test it. Need to walk my dog. ---------- Post added at 08:23 ---------- Previous post was at 07:46 ---------- Finished testing it, still no hostages :( i tested both lines Share this post Link to post Share on other sites
Persian MO 81 Posted December 10, 2014 Easy Hostage script by dj otacon ver 1.1 Makes any unit in the game a hostage usage: add _null=[this]execVM "hostage.sqf"; to the unit INIT /* Easy Hostage script by dj otacon ver 1.1 Makes any unit in the game a hostage usage: add _null=[this]execVM "hostage.sqf"; to the unit INIT */ // Set Variables _hostage = _this select 0; _callergroup = _this select 1; _id = 0; // Actions if (isnil "secured_hostage") then { _hostage setCaptive true; sleep 0.001; // Making hostage captive removeAllWeapons _hostage; removeAllAssignedItems _hostage; removeBackpack _hostage; removeVest _hostage; _hostage setUnitPos "middle"; _hostage disableAI "autoTarget"; _hostage setBehaviour "Careless"; _hostage allowFleeing 0; _hostage disableAI "Move"; secured_hostage = false; Follow_Squad=false; ungroup = false; sure = false; _sec = _hostage addaction ["<t color=""#0000FF"">" + ("Secure prisioner") + "</t>","hostage.sqf"]; porte = false; agrupa = false; liberado = false; }; if (secured_hostage && sure ) then { _id = _this select 2; _hostage removeAction _id; _hostage stop true; _hostage setUnitPos "down"; hintsilent "Securing hostage..."; sleep 3; hint "Hostage secured!"; _hostage setUnitPos "down"; _hostage addaction ["<t color=""#0000FF"">" + ("Follow squad") + "</t>","hostage.sqf"]; sure = false; agrupa = true; }; if (Follow_squad && porte) then { hintsilent "Follow the squad"; _hostage stop false; _hostage setUnitPos "UP"; //_hostage switchmove ""; _hostage setCaptive false; _hostage setBehaviour "CARELESS"; _hostage enableAI "Move"; _id = _this select 2; _hostage removeAction _id; _hostage addaction ["<t color=""#0000FF"">" + ("Free hostage") + "</t>","hostage.sqf"]; [_hostage] joinsilent _callergroup; agrupa = false; }; if (ungroup && porte && !agrupa && !liberado) then { _id = _this select 2; //_hostage removeAction _id; _hostage stop false; _hostage setUnitPos "UP"; _hostage setBehaviour "CARELESS"; _hostage enableAI "Move"; _hostage allowFleeing 1; removeallactions _hostage; [_hostage] join grpNull; hint "Released"; ungroup = false; agrupa = false; porte = true; liberado=true; Follow_Squad=false; }; // Flow control if (!secured_hostage && !sure) then { secured_hostage=true; sure=true; }; if (!Follow_squad && !porte && agrupa) then { Follow_squad = true; porte = true; }; if (!ungroup && porte && !agrupa) then { ungroup = true; }; To find a random location inside the houses for hostage, put a marker and name it "centerpos_mrk", name your hostage: Hostage , and init.sqf: _nearesthouses = getMarkerPos "centerpos_mrk" nearObjects ["House",200]; _houseList = []; { for "_i" from 0 to 20 do { if ( [(_x buildingPos _i), [0,0,0]] call BIS_fnc_arrayCompare ) exitWith { if (_i > 0) then { _houseList set [count _houseList, [_x, _i]]; }; }; }; }forEach _nearesthouses; _randomHouse = _houseList select (floor (random (count _houseList))); _housePos = (_randomHouse select 0) buildingPos (floor (random (_randomHouse select 1))); _marker = createMarker ["hostage_mrk", _housePos]; _marker setMarkerType "mil_join"; _marker setMarkerColor "ColorRed"; _marker setMarkerText " Hostage"; _marker setMarkerSize [1,1]; hostage setpos (getmarkerpos "hostage_mrk"); Share this post Link to post Share on other sites
Coolinator 10 Posted December 10, 2014 Easy Hostage script by dj otacon ver 1.1Makes any unit in the game a hostage usage: add _null=[this]execVM "hostage.sqf"; to the unit INIT /* Easy Hostage script by dj otacon ver 1.1 Makes any unit in the game a hostage usage: add _null=[this]execVM "hostage.sqf"; to the unit INIT */ // Set Variables _hostage = _this select 0; _callergroup = _this select 1; _id = 0; // Actions if (isnil "secured_hostage") then { _hostage setCaptive true; sleep 0.001; // Making hostage captive removeAllWeapons _hostage; removeAllAssignedItems _hostage; removeBackpack _hostage; removeVest _hostage; _hostage setUnitPos "middle"; _hostage disableAI "autoTarget"; _hostage setBehaviour "Careless"; _hostage allowFleeing 0; _hostage disableAI "Move"; secured_hostage = false; Follow_Squad=false; ungroup = false; sure = false; _sec = _hostage addaction ["<t color=""#0000FF"">" + ("Secure prisioner") + "</t>","hostage.sqf"]; porte = false; agrupa = false; liberado = false; }; if (secured_hostage && sure ) then { _id = _this select 2; _hostage removeAction _id; _hostage stop true; _hostage setUnitPos "down"; hintsilent "Securing hostage..."; sleep 3; hint "Hostage secured!"; _hostage setUnitPos "down"; _hostage addaction ["<t color=""#0000FF"">" + ("Follow squad") + "</t>","hostage.sqf"]; sure = false; agrupa = true; }; if (Follow_squad && porte) then { hintsilent "Follow the squad"; _hostage stop false; _hostage setUnitPos "UP"; //_hostage switchmove ""; _hostage setCaptive false; _hostage setBehaviour "CARELESS"; _hostage enableAI "Move"; _id = _this select 2; _hostage removeAction _id; _hostage addaction ["<t color=""#0000FF"">" + ("Free hostage") + "</t>","hostage.sqf"]; [_hostage] joinsilent _callergroup; agrupa = false; }; if (ungroup && porte && !agrupa && !liberado) then { _id = _this select 2; //_hostage removeAction _id; _hostage stop false; _hostage setUnitPos "UP"; _hostage setBehaviour "CARELESS"; _hostage enableAI "Move"; _hostage allowFleeing 1; removeallactions _hostage; [_hostage] join grpNull; hint "Released"; ungroup = false; agrupa = false; porte = true; liberado=true; Follow_Squad=false; }; // Flow control if (!secured_hostage && !sure) then { secured_hostage=true; sure=true; }; if (!Follow_squad && !porte && agrupa) then { Follow_squad = true; porte = true; }; if (!ungroup && porte && !agrupa) then { ungroup = true; }; To find a random location inside the houses for hostage, put a marker and name it "centerpos_mrk", name your hostage: Hostage , and init.sqf: _nearesthouses = getMarkerPos "centerpos_mrk" nearObjects ["House",200]; _houseList = []; { for "_i" from 0 to 20 do { if ( [(_x buildingPos _i), [0,0,0]] call BIS_fnc_arrayCompare ) exitWith { if (_i > 0) then { _houseList set [count _houseList, [_x, _i]]; }; }; }; }forEach _nearesthouses; _randomHouse = _houseList select (floor (random (count _houseList))); _housePos = (_randomHouse select 0) buildingPos (floor (random (_randomHouse select 1))); _marker = createMarker ["hostage_mrk", _housePos]; _marker setMarkerType "mil_join"; _marker setMarkerColor "ColorRed"; _marker setMarkerText " Hostage"; _marker setMarkerSize [1,1]; hostage setpos (getmarkerpos "hostage_mrk"); I saw this on armaholic but it says never tested in MP dedicated server, so I'm assuming that it doesn't work for Dedicated server? Share this post Link to post Share on other sites
Persian MO 81 Posted December 10, 2014 I used in dedicated server and worked Share this post Link to post Share on other sites
Coolinator 10 Posted December 10, 2014 I used in dedicated server and worked Ahh cool!!! Awesome!! :) quick question, lets say we secured the hostage, what happens if the squad leader dies? Will the hostage still follow orders to a new squad leader? Share this post Link to post Share on other sites
Persian MO 81 Posted December 10, 2014 Will the hostage still follow orders to a new squad leader? yes.hostage ll follow the new leader Share this post Link to post Share on other sites
Coolinator 10 Posted December 10, 2014 yes.hostage ll follow the new leader THank you so much!!! :) Share this post Link to post Share on other sites
jshock 512 Posted December 11, 2014 Ok, well, if your still interested in it, myself and Lala14 did some digging into this script to make it work, and maybe a bit better overall. First change, instead of a blank condition in the editor placed trigger, put in "this". And then just copy and paste and replace all the code in the JSHK_hostages.sqf with the below code: _marker = [_this,0,"",[""]] call BIS_fnc_param; JSHK_fnc_hostageRescue = { private ["_marker","_civTypes","_pos","_grp","_task"]; _marker = (_this select 0); _civTypes = ["C_man_1", "C_man_pilot_F", "C_scientist_F", "C_man_w_worker_F", "C_man_p_fugitive_F_afro"]; //uncomment the next two lines if you want random building position //_pos = [_marker,100] call JSHK_fnc_buildingPositions; //_posNew = _pos call BIS_fnc_selectRandom; //comment out the following line if the two above are uncommented _posNew = (getMarkerPos _marker); _grp = createGroup CIVILIAN; JSHK_hostageArr = []; for "_i" from 0 to (floor(random 4)+1) step 1 do { _rndType = _civTypes call BIS_fnc_selectRandom; _unit = _grp createUnit [_rndType, _posNew, [], 1, "NONE"]; _unit addAction ["Capture/Rescue",{call JSHK_captureAddAction},[],6,true,true,"","_this distance _target < 2 && alive _target"]; //added alive _target _unit addEventHandler ["Killed", "['Hostage', 'Failed', true] call BIS_fnc_taskSetState; ['Hostage',['A Hostage was killed','Hostage Rescue', _marker]] call BIS_fnc_taskSetDescription"]; _unit setCaptive true; _unit setUnitPos "DOWN"; _unit disableAI "MOVE"; JSHK_hostageArr pushBack _unit; }; _task = ["Hostage", WEST, ["Rescue the Hostages", "Hostage Rescue", _marker], (getMarkerPos _marker), "AUTOASSIGNED", 5, true, true] call BIS_fnc_setTask; capturePoint setTriggerStatements [ "({_x in ([thisList] call LALA_fnc_ConvertArray2StringCopy)} count ([JSHK_hostageArr] call LALA_fnc_ConvertArray2StringCopy)) isEqualTo (count ([JSHK_hostageArr] call LALA_fnc_ConvertArray2StringCopy))", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; while {true} do { sleep 3; if ([_task] call BIS_fnc_taskState isEqualTo "Failed") exitWith { capturePoint setTriggerStatements [ "this", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",false]; }; if (!isNil {missionNameSpace getVariable "haveHostagesBeenRescued"}) exitWith { [_task, "Succeeded", true] call BIS_fnc_taskSetState; capturePoint setTriggerStatements [ "this", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",nil]; }; }; _hostageArr; }; LALA_fnc_ConvertArray2StringCopy = { //converts everything inside the array to a string (does not replace original) // THIS SELECT 0: ARRAY private "_array"; _array = + _this select 0; { if (typeName _x != "STRING") then { _array set [_foreachindex,str _x]; }; }forEach _array; _array }; JSHK_fnc_buildingPositions = { private ["_center","_radius","_houses","_insideHousePos","_singlePosArray"]; _center = [_this,0,objNull,["",objNull,[]],[3]] call BIS_fnc_param; _radius = [_this,1,200,[0]] call BIS_fnc_param; switch (typeName _center) do { case "OBJECT": { _center = getPos _center; }; case "STRING": { _center = getMarkerPos _center; }; case "ARRAY": { _center; }; default { diag_log "Center position undefined >> JSHK_garrison\fn_buildingPositions.sqf"; }; }; _houses = nearestObjects [_center, ["House"], _radius]; _insideHousePos = []; { if ([_x] call BIS_fnc_isBuildingEnterable) then { _buildPos = [_x] call BIS_fnc_buildingPositions; _insideHousePos pushBack _buildPos; }; }forEach _houses; _singlePosArray = []; for "_i" from 0 to ((count _insideHousePos) - 1) step 1 do { _singleHouse = _insideHousePos select _i; for "_a" from 0 to ((count _singleHouse) - 1) step 1 do { _singlePos = _singleHouse select _a; _singlePosArray pushBack _singlePos; }; }; _singlePosArray; }; JSHK_captureAddAction = { private ["_unit","_player","_actionID","_civGroup"]; _unit = (_this select 0); _player = (_this select 1); _actionID = (_this select 2); ["Hostage", (getPos capturePoint)] call BIS_fnc_taskSetDestination; _civGroup = units (group _unit); _civGroup joinSilent (group _player); { _x removeAction _actionID; _x setUnitPos "UP"; _x enableAI "MOVE"; } forEach _civGroup; }; [_marker] call JSHK_fnc_hostageRescue; Kudos to Lala for his function that he provided, and I have the different types of spawning (on marker or random building) commented on in the top of the script for your ease of use. Hopefully it works as intended this go around :D. Share this post Link to post Share on other sites
Coolinator 10 Posted December 11, 2014 Ok, well, if your still interested in it, myself and Lala14 did some digging into this script to make it work, and maybe a bit better overall.First change, instead of a blank condition in the editor placed trigger, put in "this". And then just copy and paste and replace all the code in the JSHK_hostages.sqf with the below code: _marker = [_this,0,"",[""]] call BIS_fnc_param; JSHK_fnc_hostageRescue = { private ["_marker","_civTypes","_pos","_grp","_task"]; _marker = (_this select 0); _civTypes = ["C_man_1", "C_man_pilot_F", "C_scientist_F", "C_man_w_worker_F", "C_man_p_fugitive_F_afro"]; //uncomment the next two lines if you want random building position //_pos = [_marker,100] call JSHK_fnc_buildingPositions; //_posNew = _pos call BIS_fnc_selectRandom; //comment out the following line if the two above are uncommented _posNew = (getMarkerPos _marker); _grp = createGroup CIVILIAN; JSHK_hostageArr = []; for "_i" from 0 to (floor(random 4)+1) step 1 do { _rndType = _civTypes call BIS_fnc_selectRandom; _unit = _grp createUnit [_rndType, _posNew, [], 1, "NONE"]; _unit addAction ["Capture/Rescue",{call JSHK_captureAddAction},[],6,true,true,"","_this distance _target < 2 && alive _target"]; //added alive _target _unit addEventHandler ["Killed", "['Hostage', 'Failed', true] call BIS_fnc_taskSetState; ['Hostage',['A Hostage was killed','Hostage Rescue', _marker]] call BIS_fnc_taskSetDescription"]; _unit setCaptive true; _unit setUnitPos "DOWN"; _unit disableAI "MOVE"; JSHK_hostageArr pushBack _unit; }; _task = ["Hostage", WEST, ["Rescue the Hostages", "Hostage Rescue", _marker], (getMarkerPos _marker), "AUTOASSIGNED", 5, true, true] call BIS_fnc_setTask; capturePoint setTriggerStatements [ "({_x in ([thisList] call LALA_fnc_ConvertArray2StringCopy)} count ([JSHK_hostageArr] call LALA_fnc_ConvertArray2StringCopy)) isEqualTo (count ([JSHK_hostageArr] call LALA_fnc_ConvertArray2StringCopy))", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; while {true} do { sleep 3; if ([_task] call BIS_fnc_taskState isEqualTo "Failed") exitWith { capturePoint setTriggerStatements [ "this", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",false]; }; if (!isNil {missionNameSpace getVariable "haveHostagesBeenRescued"}) exitWith { [_task, "Succeeded", true] call BIS_fnc_taskSetState; capturePoint setTriggerStatements [ "this", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",nil]; }; }; _hostageArr; }; LALA_fnc_ConvertArray2StringCopy = { //converts everything inside the array to a string (does not replace original) // THIS SELECT 0: ARRAY private "_array"; _array = + _this select 0; { if (typeName _x != "STRING") then { _array set [_foreachindex,str _x]; }; }forEach _array; _array }; JSHK_fnc_buildingPositions = { private ["_center","_radius","_houses","_insideHousePos","_singlePosArray"]; _center = [_this,0,objNull,["",objNull,[]],[3]] call BIS_fnc_param; _radius = [_this,1,200,[0]] call BIS_fnc_param; switch (typeName _center) do { case "OBJECT": { _center = getPos _center; }; case "STRING": { _center = getMarkerPos _center; }; case "ARRAY": { _center; }; default { diag_log "Center position undefined >> JSHK_garrison\fn_buildingPositions.sqf"; }; }; _houses = nearestObjects [_center, ["House"], _radius]; _insideHousePos = []; { if ([_x] call BIS_fnc_isBuildingEnterable) then { _buildPos = [_x] call BIS_fnc_buildingPositions; _insideHousePos pushBack _buildPos; }; }forEach _houses; _singlePosArray = []; for "_i" from 0 to ((count _insideHousePos) - 1) step 1 do { _singleHouse = _insideHousePos select _i; for "_a" from 0 to ((count _singleHouse) - 1) step 1 do { _singlePos = _singleHouse select _a; _singlePosArray pushBack _singlePos; }; }; _singlePosArray; }; JSHK_captureAddAction = { private ["_unit","_player","_actionID","_civGroup"]; _unit = (_this select 0); _player = (_this select 1); _actionID = (_this select 2); ["Hostage", (getPos capturePoint)] call BIS_fnc_taskSetDestination; _civGroup = units (group _unit); _civGroup joinSilent (group _player); { _x removeAction _actionID; _x setUnitPos "UP"; _x enableAI "MOVE"; } forEach _civGroup; }; [_marker] call JSHK_fnc_hostageRescue; Kudos to Lala for his function that he provided, and I have the different types of spawning (on marker or random building) commented on in the top of the script for your ease of use. Hopefully it works as intended this go around :D. awesome i will test it!!! :) Share this post Link to post Share on other sites
Coolinator 10 Posted December 11, 2014 finished testing it works!!! :) but how do you limit the numbers of hostages? instead of spawning 4 hostages every time? By the way i took a screen shot :) looks like human centipede lol ---------- Post added at 03:44 ---------- Previous post was at 03:40 ---------- ALso, about the trigger part , when i put "this" it didn't work, but i tried again but this time took off "this", task completed :) So you don't need to put "this" on the condition of the trigger, just leave it blank :) Share this post Link to post Share on other sites
Lala14 135 Posted December 11, 2014 finished testing it works!!! :) but how do you limit the numbers of hostages? instead of spawning 4 hostages every time?By the way i took a screen shot :) looks like human centipede lol http://i59.tinypic.com/2l87lnm.jpg ---------- Post added at 03:44 ---------- Previous post was at 03:40 ---------- ALso, about the trigger part , when i put "this" it didn't work, but i tried again but this time took off "this", task completed :) So you don't need to put "this" on the condition of the trigger, just leave it blank :) No you need the this so the trigger does not activate until the hostages are in the capture zone/rescue zone otherwise the task will be instantly completed Also the hostages are randomized from 2 - 8 I think Share this post Link to post Share on other sites
jshock 512 Posted December 11, 2014 (edited) Added a second parameter for number of hostages (call line: ["mrkName",2] execVM "JSHK_hostages.sqf"): _marker = [_this,0,"",[""]] call BIS_fnc_param; _numHostages = [_this,1,1,[0]] call BIS_fnc_param; JSHK_fnc_hostageRescue = { private ["_marker","_numHostages","_civTypes","_pos","_grp","_task"]; _marker = (_this select 0); _numHostages = (_this select 1); _civTypes = ["C_man_1", "C_man_pilot_F", "C_scientist_F", "C_man_w_worker_F", "C_man_p_fugitive_F_afro"]; //uncomment the next two lines if you want random building position //_pos = [_marker,100] call JSHK_fnc_buildingPositions; //_posNew = _pos call BIS_fnc_selectRandom; //comment out the following line if the two above are uncommented _posNew = (getMarkerPos _marker); _grp = createGroup CIVILIAN; JSHK_hostageArr = []; if (_numHostages <= 0) then { _numHostages = 1; systemChat "Number of Hostages undefined, used 1 instead."; }; for "_i" from 0 to (_numHostages) step 1 do { _rndType = _civTypes call BIS_fnc_selectRandom; _unit = _grp createUnit [_rndType, _posNew, [], 1, "NONE"]; _unit addAction ["Capture/Rescue",{call JSHK_captureAddAction},[],6,true,true,"","_this distance _target < 2 && alive _target"]; //added alive _target _unit addEventHandler ["Killed", "['Hostage', 'Failed', true] call BIS_fnc_taskSetState; ['Hostage',['A Hostage was killed','Hostage Rescue', _marker]] call BIS_fnc_taskSetDescription"]; _unit setCaptive true; _unit setUnitPos "DOWN"; _unit disableAI "MOVE"; JSHK_hostageArr pushBack _unit; }; _task = ["Hostage", WEST, ["Rescue the Hostages", "Hostage Rescue", _marker], (getMarkerPos _marker), "AUTOASSIGNED", 5, true, true] call BIS_fnc_setTask; capturePoint setTriggerStatements [ "({_x in ([thisList] call LALA_fnc_ConvertArray2StringCopy)} count ([JSHK_hostageArr] call LALA_fnc_ConvertArray2StringCopy)) isEqualTo (count ([JSHK_hostageArr] call LALA_fnc_ConvertArray2StringCopy))", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; while {true} do { sleep 3; if ([_task] call BIS_fnc_taskState isEqualTo "Failed") exitWith { capturePoint setTriggerStatements [ "this", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",false]; }; if (!isNil {missionNameSpace getVariable "haveHostagesBeenRescued"}) exitWith { [_task, "Succeeded", true] call BIS_fnc_taskSetState; capturePoint setTriggerStatements [ "this", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",nil]; }; }; _hostageArr; }; LALA_fnc_ConvertArray2StringCopy = { //converts everything inside the array to a string (does not replace original) // THIS SELECT 0: ARRAY private "_array"; _array = + _this select 0; { if (typeName _x != "STRING") then { _array set [_foreachindex,str _x]; }; }forEach _array; _array }; JSHK_fnc_buildingPositions = { private ["_center","_radius","_houses","_insideHousePos","_singlePosArray"]; _center = [_this,0,objNull,["",objNull,[]],[3]] call BIS_fnc_param; _radius = [_this,1,200,[0]] call BIS_fnc_param; switch (typeName _center) do { case "OBJECT": { _center = getPos _center; }; case "STRING": { _center = getMarkerPos _center; }; case "ARRAY": { _center; }; default { diag_log "Center position undefined >> JSHK_garrison\fn_buildingPositions.sqf"; }; }; _houses = nearestObjects [_center, ["House"], _radius]; _insideHousePos = []; { if ([_x] call BIS_fnc_isBuildingEnterable) then { _buildPos = [_x] call BIS_fnc_buildingPositions; _insideHousePos pushBack _buildPos; }; }forEach _houses; _singlePosArray = []; for "_i" from 0 to ((count _insideHousePos) - 1) step 1 do { _singleHouse = _insideHousePos select _i; for "_a" from 0 to ((count _singleHouse) - 1) step 1 do { _singlePos = _singleHouse select _a; _singlePosArray pushBack _singlePos; }; }; _singlePosArray; }; JSHK_captureAddAction = { private ["_unit","_player","_actionID","_civGroup"]; _unit = (_this select 0); _player = (_this select 1); _actionID = (_this select 2); ["Hostage", (getPos capturePoint)] call BIS_fnc_taskSetDestination; _civGroup = units (group _unit); _civGroup joinSilent (group _player); { _x removeAction _actionID; _x setUnitPos "UP"; _x enableAI "MOVE"; } forEach _civGroup; }; [_marker,_numHostages] call JSHK_fnc_hostageRescue; No you need the this so the trigger does not activate until the hostages are in the capture zone/rescue zone otherwise the task will be instantly completedAlso the hostages are randomized from 2 - 8 I think 1-5 :D, well at least before the fix above. And Coolinator, remember, it should create a hostage rescue task, then you get the civs to join your group, then you take them to wherever the "capturePoint" trigger is located and the task should trigger successful. Edited December 11, 2014 by JShock Share this post Link to post Share on other sites
Coolinator 10 Posted December 11, 2014 (edited) No you need the this so the trigger does not activate until the hostages are in the capture zone/rescue zone otherwise the task will be instantly completedAlso the hostages are randomized from 2 - 8 I think when i put this in the trigger, and brought the hostages in the trigger, the task did not complete. But when i leave blank for trigger condition and brought the hostages in the trigger, task completed. (task did not instantly complete when hostages spawned, i had to bring them to the trigger area to complete task, so its works perfectly fine :) ) ---------- Post added at 04:51 ---------- Previous post was at 04:48 ---------- Added a second parameter for number of hostages (call line: ["mrkName",2] execVM "JSHK_hostages.sqf"): _marker = [_this,0,"",[""]] call BIS_fnc_param; _numHostages = [_this,1,1,[0]] call BIS_fnc_param; JSHK_fnc_hostageRescue = { private ["_marker","_numHostages","_civTypes","_pos","_grp","_task"]; _marker = (_this select 0); _numHostages = (_this select 1); _civTypes = ["C_man_1", "C_man_pilot_F", "C_scientist_F", "C_man_w_worker_F", "C_man_p_fugitive_F_afro"]; //uncomment the next two lines if you want random building position //_pos = [_marker,100] call JSHK_fnc_buildingPositions; //_posNew = _pos call BIS_fnc_selectRandom; //comment out the following line if the two above are uncommented _posNew = (getMarkerPos _marker); _grp = createGroup CIVILIAN; JSHK_hostageArr = []; if (_numHostages <= 0) then { _numHostages = 1; systemChat "Number of Hostages undefined, used 1 instead."; }; for "_i" from 0 to (_numHostages) step 1 do { _rndType = _civTypes call BIS_fnc_selectRandom; _unit = _grp createUnit [_rndType, _posNew, [], 1, "NONE"]; _unit addAction ["Capture/Rescue",{call JSHK_captureAddAction},[],6,true,true,"","_this distance _target < 2 && alive _target"]; //added alive _target _unit addEventHandler ["Killed", "['Hostage', 'Failed', true] call BIS_fnc_taskSetState; ['Hostage',['A Hostage was killed','Hostage Rescue', _marker]] call BIS_fnc_taskSetDescription"]; _unit setCaptive true; _unit setUnitPos "DOWN"; _unit disableAI "MOVE"; JSHK_hostageArr pushBack _unit; }; _task = ["Hostage", WEST, ["Rescue the Hostages", "Hostage Rescue", _marker], (getMarkerPos _marker), "AUTOASSIGNED", 5, true, true] call BIS_fnc_setTask; capturePoint setTriggerStatements [ "({_x in ([thisList] call LALA_fnc_ConvertArray2StringCopy)} count ([JSHK_hostageArr] call LALA_fnc_ConvertArray2StringCopy)) isEqualTo (count ([JSHK_hostageArr] call LALA_fnc_ConvertArray2StringCopy))", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; while {true} do { sleep 3; if ([_task] call BIS_fnc_taskState isEqualTo "Failed") exitWith { capturePoint setTriggerStatements [ "this", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",false]; }; if (!isNil {missionNameSpace getVariable "haveHostagesBeenRescued"}) exitWith { [_task, "Succeeded", true] call BIS_fnc_taskSetState; capturePoint setTriggerStatements [ "this", ((triggerStatements capturePoint) select 1), ((triggerStatements capturePoint) select 2) ]; missionNameSpace setVariable ["haveHostagesBeenRescued",nil]; }; }; _hostageArr; }; LALA_fnc_ConvertArray2StringCopy = { //converts everything inside the array to a string (does not replace original) // THIS SELECT 0: ARRAY private "_array"; _array = + _this select 0; { if (typeName _x != "STRING") then { _array set [_foreachindex,str _x]; }; }forEach _array; _array }; JSHK_fnc_buildingPositions = { private ["_center","_radius","_houses","_insideHousePos","_singlePosArray"]; _center = [_this,0,objNull,["",objNull,[]],[3]] call BIS_fnc_param; _radius = [_this,1,200,[0]] call BIS_fnc_param; switch (typeName _center) do { case "OBJECT": { _center = getPos _center; }; case "STRING": { _center = getMarkerPos _center; }; case "ARRAY": { _center; }; default { diag_log "Center position undefined >> JSHK_garrison\fn_buildingPositions.sqf"; }; }; _houses = nearestObjects [_center, ["House"], _radius]; _insideHousePos = []; { if ([_x] call BIS_fnc_isBuildingEnterable) then { _buildPos = [_x] call BIS_fnc_buildingPositions; _insideHousePos pushBack _buildPos; }; }forEach _houses; _singlePosArray = []; for "_i" from 0 to ((count _insideHousePos) - 1) step 1 do { _singleHouse = _insideHousePos select _i; for "_a" from 0 to ((count _singleHouse) - 1) step 1 do { _singlePos = _singleHouse select _a; _singlePosArray pushBack _singlePos; }; }; _singlePosArray; }; JSHK_captureAddAction = { private ["_unit","_player","_actionID","_civGroup"]; _unit = (_this select 0); _player = (_this select 1); _actionID = (_this select 2); ["Hostage", (getPos capturePoint)] call BIS_fnc_taskSetDestination; _civGroup = units (group _unit); _civGroup joinSilent (group _player); { _x removeAction _actionID; _x setUnitPos "UP"; _x enableAI "MOVE"; } forEach _civGroup; }; [_marker,_numHostages] call JSHK_fnc_hostageRescue; 1-5 :D, well at least before the fix above. And Coolinator, remember, it should create a hostage rescue task, then you get the civs to join your group, then you take them to wherever the "capturePoint" trigger is located and the task should trigger successful. Thank you so much!!! :) yea everything worked perfectly including bringing the hostages in the capturepoint trigger, i didn't need to put the "this", i just leave it blank and it works :) task did not instantly finish, i had to bring them to the trigger area :) and yea created task works too :) Reminder i've only tested in LAN MP editor, i havent tested it in Dedicated server yet, but i will soon :) i just need to finish the mission im currently working on, so far it took me two weeks T_T, kinda almost done :) Do you know a way how to make an ending like credits, like in the movies you know? i want to list the names who helped me making my mission :) im including you for sure Jshock :) Edited December 11, 2014 by Coolinator Share this post Link to post Share on other sites
Coolinator 10 Posted December 11, 2014 I forgot to tell you this, im using the hostage script mentioned by persian since he already told me that it works already in dedicated server. And im only using 1 hostage. But i will make a test mission jut for your hostage script and test it in a dedicated server whenever i get a chance to do it, and when have a lot of free time :) Share this post Link to post Share on other sites
jshock 512 Posted December 11, 2014 Do you know a way how to make an ending like credits, like in the movies you know? No clue but the following look promising: BIS_fnc_3Dcredits BIS_fnc_credits BIS_fnc_credits_movie BIS_fnc_credits_movieConfig BIS_fnc_credits_movieSupport But i will make a test mission jut for your hostage script and test it in a dedicated server whenever i get a chance to do it Don't worry about it, no need to test it specifically just for my feedback, like I said early on I just got bored and decided to pull that from a private project of mine, so I know it works, it's just the modifications I made could have been some trouble :p. Share this post Link to post Share on other sites
Coolinator 10 Posted December 11, 2014 No clue but the following look promising:BIS_fnc_3Dcredits BIS_fnc_credits BIS_fnc_credits_movie BIS_fnc_credits_movieConfig BIS_fnc_credits_movieSupport Don't worry about it, no need to test it specifically just for my feedback, like I said early on I just got bored and decided to pull that from a private project of mine, so I know it works, it's just the modifications I made could have been some trouble :p. Thank you so much Jshock!!! :) Share this post Link to post Share on other sites
jandrews 116 Posted January 9, 2015 Good work everyone. Always like hostage scripts. Share this post Link to post Share on other sites