Maff 251 Posted November 9, 2014 First of all I'm new to scripting so bear with me. I am working on a script that allows the player to question civilians. I have managed to work out how to get random responses from them, but I've hit a dead end with getting them to tell me the location of an IED, cache or the enemy. Here is what I have so far... //Iinit.sqf waituntil {!isnil "bis_fnc_init"}; { _x setVariable ["BIS_noCoreConversations",true];} forEach allUnits; player addaction ['<t color="#ffffff">' + "Question Civilian" + '</t>', "Interact\QuestionCiv.sqf", [], 5, false, false, "", "_target == player"]; //QuestionCiv.sqf #define VOICES ["ACE_ahem01","ACE_ahem02","ACE_ahem03","ACE_ahem04"] _civ = cursorTarget; _dist = player distance _civ; if (_dist <5) then { player sideChat "As-salamu alaykum."; sleep (2); player sideChat "Do you have any information about the insurgents?"; sleep (5); _civ playMove "AidlPercSnonWnonDnon_talk1"; [_civ, VOICES call BIS_fnc_selectRandom] call CBA_fnc_globalSay3d; _reply = ["No, but I know where there is an IED. I have marked it on your map.","Go away!","I do not know anything."] call BIS_fnc_selectRandom; [_reply, 0, 0.2, 10, 0, 0, 20] spawn bis_fnc_dynamictext; }; I have my mission set up with 55 empty markers. Basically a crude version of Insurgency. 25 markers on roads for IEDs and 25 markers inside compounds, but outside of buildings, for caches and 5 empty markers for AA. I have 15 IEDs (Land_IED_v1_PMC, Land_IED_v2_PMC, Land_IED_v3_PMC, Land_IED_v4_PMC) grouped to the markers on roads, 5 "GuerillaCacheBox_EP1" grouped to the empty markers inside compounds and 1 "ZU23_TK_INS_EP1" grouped to the 5 AA markers. What I need help with is to get the chance of a reply from a civilian with the location of one of these objects. My mind is drawing an absolute blank! Any help would be great. Cheers. Share this post Link to post Share on other sites
Maff 251 Posted November 11, 2014 Nobody? Someone suggested I use nearestObjects to locate the above. I'm still lost as to how I can get a marker on or near the objects above. Does anyone have any suggestions? I'll keep at it. Share this post Link to post Share on other sites
opusfmspol 282 Posted November 11, 2014 To clarify; are you trying to return the location of one of the randomly placed IED's, to reflect it's location on the map? Share this post Link to post Share on other sites
Maff 251 Posted November 11, 2014 Correct. I'd like to have a civilian tell me the location of either an IED, AA gun or a cache by adding a marker on the map. Share this post Link to post Share on other sites
opusfmspol 282 Posted November 11, 2014 is it single-player, MP coop mission against AI, or MP adversarial mission against players? In single player and coop, createMarker can be used, but in adversarial createMarkerLocal has to be used along with MP communication to have the markers appear only for the target players' machines, otherwise the enemy will see the markers too. Share this post Link to post Share on other sites
Maff 251 Posted November 11, 2014 The mission is MP coop. How would I use createMarker in my _reply line? Share this post Link to post Share on other sites
opusfmspol 282 Posted November 11, 2014 (edited) Here is a thought to start working with (not tested). Give names to each of the search objects grouped to the markers. in Init.sqf: [i]//--- Each player's machine will have the stored variables. //--- Arrays containing the object names segregated by their type. Must exactly match the object names.[/i] IED_Array = [iED1,IED2,IED3,IED4,IED5,IED6,IED7,IED8,IED9,IED10,IED11,IED12,IED13,IED14,IED15]; cache_Array = [cache1,cache2,cache3,cache4,cache5]; ZU_Array = [ZU1]; [i]//--- Store the type arrays.[/i] type_Array = [iEDArray,cacheArray,ZUArray]; [i]//--- Store the names for the array types.[/i] name_Array = ["IED","Ammo Cache","AA Gun"]; In QuestionCiv.sqf: Implement this depending upon the conversation - if they do know of IED, cache or AA: [i]//--- For an IED:[/i] _type = type_Array select 0; //Returns the IED array _name = name_Array select 0; //Returns the name "IED" for use in formatting marker name [i]//--- For a Cache:[/i] _type = type_Array select 1; //Returns the Cache array _name = name_Array select 1; //Returns the name "Ammo Cache" for use in formatting marker name [i]//--- For an AA Gun:[/i] _type = type_Array select 2; //Returns the AA Gun array _name = name_Array select 2; //Returns the name "AA Gun" for use in formatting marker name Generating the marker following the conversation after type and name are selected: _object = _type call BIS_fnc_selectRandom; //Returns a random object from the selected _type array _objIndex = _type find _object; //Returns the object's index number in _type array _object = _type select _objIndex; //[b][i]Selecting[/i][/b] the chosen object (safeguard to ensure select random doesn't occur // again by referencing variable _object) _objPos = getPos _object; //Returns position of the chosen object _replyMarker = format ["%1marker",_object]; //Marker name will include the object's name to be unique _marker = CreateMarker [_replyMarker,_objPos]; //Creates the marker at the object's position _marker SetMarkerColor "ColorRed"; //Marker is Red _marker SetMarkerType "Destroy"; //"Destroy" marker ( + ) _marker SetMarkerAlpha 1; //Marker is fully visible _marker SetMarkerText Format ["%1 reported",_name]; //Marker text shows "IED reported", "Ammo Cache reported" or "AA Gun reported" //--- necessary to keep markers from having the same names _type = _type - [_object]; //Removing the object from it's array so it's not reported again PublicVariable format ["%1",_type]; //Updating the array for the other players. As your script is, it looks like this will occur every time any player comes close and targets the person. You'll need to find a way to stop it from repeating once that particular person has divulged his information, or he'll just keep giving up new objects each time someone comes close and targets him. Edited November 11, 2014 by OpusFmSPol fixing errors observed in review after posting Share this post Link to post Share on other sites
Maff 251 Posted November 11, 2014 How would I use this in my _reply array so I can have a random reply with a chance of a marker. _reply = ["one","two","three","four","Here have a marker"] call BIS_fnc_selectRandom; Am I right in changing your init.sqf example? //--- Each player's machine will have the stored variables. //--- Arrays containing the object names segregated by their type. Must exactly match the object names. IED_Array = [iED1,IED2,IED3,IED4,IED5,IED6,IED7,IED8,IED9,IED10,IED11,IED12,IED13,IED14,IED15]; cache_Array = [cache1,cache2,cache3,cache4,cache5]; ZU_Array = [ZU1]; //--- Store the type arrays. type_Array = [iED_Array,cache_Array,ZU_Array]; //I ADDED UNDERSCORES. //--- Store the names for the array types. name_Array = ["IED","Ammo Cache","AA Gun"]; Share this post Link to post Share on other sites
opusfmspol 282 Posted November 11, 2014 How would I use this in my _reply array so I can have a random reply with a chance of a marker. BIS_fnc_selectRandom returns the selection's actual content, not its index, so it would be: if (_reply == "Here have a marker") then { [color="#808080"][i]....run the marker code....[/i][/color] }; Am I right in changing your init.sqf example? Yeah. Darn it, no matter how many times I review, preview and post-review.... *headslap* (#:> --ow Good catch. Share this post Link to post Share on other sites
Maff 251 Posted November 12, 2014 (edited) I'm not sure where to put that. I'll post what I have in QuestionCiv.sqf as I've added a thing or two. #define VOICES ["ACE_ahem01","ACE_ahem02","ACE_ahem03","ACE_ahem04","ACE_ahem05","ACE_ahem06","ACE_ahem07","ACE_ahem08","ACE_ahem09","ACE_ahem10","ACE_ahem11"] //--- For an IED: _type = type_Array select 0; //Returns the IED array _name = name_Array select 0; //Returns the name "IED" for use in formatting marker name //--- For a Cache: _type = type_Array select 1; //Returns the Cache array _name = name_Array select 1; //Returns the name "Ammo Cache" for use in formatting marker name //--- For an AA Gun: _type = type_Array select 2; //Returns the AA Gun array _name = name_Array select 2; //Returns the name "AA Gun" for use in formatting marker name _civ = cursorTarget; _dist = player distance _civ; if(!alive _civ) exitWith{ hint "This person is obviously dead."; }; if (_dist <5) then { cutText ["Questioning Person...", "PLAIN"]; sleep (1); _civ playMove "AidlPercSnonWnonDnon_talk1"; _reply = ["one","I have marked something on your map."] call BIS_fnc_selectRandom; [_reply, 0, 0.2, 10, 0, 0, 20] spawn bis_fnc_dynamictext; [_civ, VOICES call BIS_fnc_selectRandom] call CBA_fnc_globalSay3d;//Good response if (_reply == "I have marked something on your map.") then { _object = _type call BIS_fnc_selectRandom; //Returns a random object from the selected _type array _objIndex = _type find _object; //Returns the object's index number in _type array _object = _type select _objIndex; //Selecting the chosen object (safeguard to ensure select random doesn't occur // again by referencing variable _object) _objPos = getPos _object; //Returns position of the chosen object _replyMarker = format ["%1marker",_object]; //Marker name will include the object's name to be unique _marker = CreateMarker [_replyMarker,_objPos]; //Creates the marker at the object's position _marker SetMarkerColor "ColorRed"; //Marker is Red _marker SetMarkerType "Destroy"; //"Destroy" marker ( + ) _marker SetMarkerAlpha 1; //Marker is fully visible _marker SetMarkerText Format ["%1 reported",_name]; //Marker text shows "IED reported", "Ammo Cache reported" or "AA Gun reported" //--- necessary to keep markers from having the same names _type = _type - [_object]; //Removing the object from it's array so it's not reported again PublicVariable format ["%1",_type]; //Updating the array for the other players. }; }; Edited November 12, 2014 by Maff spelling Share this post Link to post Share on other sites
opusfmspol 282 Posted November 12, 2014 (edited) I'm not sure where to put that. Would go here (example for a Cache reveal): _reply = ["one","I have marked something on your map."] call BIS_fnc_selectRandom; [_reply, 0, 0.2, 10, 0, 0, 20] spawn bis_fnc_dynamictext; [_civ, VOICES call BIS_fnc_selectRandom] call CBA_fnc_globalSay3d;//Good response if (_reply == "I have marked something on your map.") then { [color="#FF0000"] _type = type_Array select 1; //Returns the Cache array _name = name_Array select 1; //Returns the name "Ammo Cache" for use in formatting marker name[/color] _object = _type call BIS_fnc_selectRandom; //Returns a random object from the selected _type array _objIndex = _type find _object; //Returns the object's index number in _type array _object = _type select _objIndex; //Selecting the chosen object (safeguard) _objPos = getPos _object; //Returns position of the chosen object _replyMarker = format ["%1marker",_object]; //Marker name will include the object's name to be unique _marker = CreateMarker [_replyMarker,_objPos]; //Creates the marker at the object's position _marker SetMarkerColor "ColorRed"; //Marker is Red _marker SetMarkerType "Destroy"; //"Destroy" marker ( + ) _marker SetMarkerAlpha 1; //Marker is fully visible _marker SetMarkerText Format ["%1 reported",_name]; //Marker text shows "Ammo Cache reported" //--- necessary to keep markers from having the same names _type = _type - [_object]; //Removing the object from it's array so it's not reported again PublicVariable format ["%1",_type]; //Updating the array for the other players. }; Edited November 12, 2014 by OpusFmSPol Share this post Link to post Share on other sites
Maff 251 Posted November 12, 2014 I'm getting the reply "I have marked something on your map." but no markers are appearing on the map. How does if (_reply == "I have marked something on your map.") then and _reply = ["one","I have marked something on your map."] call BIS_fnc_selectRandom; link with each other? Share this post Link to post Share on other sites
opusfmspol 282 Posted November 12, 2014 (edited) _reply returns the value that was selected by BIS_fnc_selectRandom. If it randomly selects 0, it returns the string "one"; if it randomly selects 1 it returns the string "I have marked something on your map." == is a true/false Boolean test. It compares the value of _reply against the string "I have marked something on your map."; if they are exactly the same it returns true and the code runs; if not it returns false and the code does not run. As I said, it was a thought I hadn't tested. Check the .rpt log and it should show where it went fubar. Also running startup param -showScriptErrors will help by showing in game when the error occurs while it gets logged. --- Edit -- A quick test shows this part is working _reply = ["one","I have marked something on your map."] call BIS_fnc_selectRandom; [_reply, 0, 0.2, 10, 0, 0, 20] spawn bis_fnc_dynamictext; if (_reply == "I have marked something on your map.") then { _type = type_Array select 1; //Returns the Cache array _name = name_Array select 1; //Returns the name "Ammo Cache" for use in formatting marker name _object = _type call BIS_fnc_selectRandom; //Returns a random object from the selected _type array _objIndex = _type find _object; //Returns the object's index number in _type array _object = _type select _objIndex; //Selecting the chosen object (safeguard) _objPos = getPos _object; //Returns position of the chosen object _replyMarker = format ["%1marker",_object]; //Marker name will include the object's name to be unique _marker = CreateMarker [_replyMarker,_objPos]; //Creates the marker at the object's position _marker SetMarkerColor "ColorRed"; //Marker is Red _marker SetMarkerType "Destroy"; //"Destroy" marker ( + ) _marker SetMarkerAlpha 1; //Marker is fully visible _marker SetMarkerText Format ["%1 reported",_name]; //Marker text shows "Ammo Cache reported" //--- necessary to keep markers from having the same names _type = _type - [_object]; //Removing the object from it's array so it's not reported again PublicVariable format ["%1",_type]; //Updating the array for the other players. }; To test I called it with a trigger. --- Edit -- It may be the publicVariable returning content instead of variable name, stopping your block of code from completing. Remove this: PublicVariable format ["%1",_type]; //Updating the array for the other players. and see if it works Edited November 12, 2014 by OpusFmSPol Share this post Link to post Share on other sites
Maff 251 Posted November 12, 2014 Still nothing, even with removing PublicVariable format ["%1",_type]; I'll keep at it. Thanks for your time. I appreciate it. Share this post Link to post Share on other sites
opusfmspol 282 Posted November 12, 2014 (edited) I would suggest try testing the conversation and marker blocks separate from all else. That's what I did when it worked. I had the named objects grouped to markers on map, "init.sqf" variables set up, and called the code from script "script.sqf" using a radio trigger. With the publicVariable it's a matter of identifying the string "IED_Array", "cache_Array" or "ZU_Array" for broadcast. I see format dumps in the array value instead of the variable name. The variable name is what needs to be broadcast. Edited November 12, 2014 by OpusFmSPol Share this post Link to post Share on other sites