Trigger on hostility level?

  1. 7 years ago
    Edited 7 years ago by Bad Quaker

    Hi everyone -- First time posting -- loving this mod. I'm a relatively new mission editor with practically no scripting experience, though I'm familiar with other languages (javascript, php).

    What I wish to do:
    I'm setting up an insurgency mission (story details below) and I'm wanting to set a trigger that is activated when a) the player is in a defined area (let's call it trigger_area), and b) civilian hostility against Blufor is below a certain threshold. I know how to do the first part, but the second one is beyond my level of understanding.

    What I've tried:
    I've tried calling the getGlobalPosture function, but I haven't figured out how to get the data I need (If there's a function to dump the contents of a multi-dimensional array for development purposes in Arma, I haven't found it).

    Other questions/complications
    I'm not sure if civ hostility is calculated at the global level, the civ placement module level, or just at the cluster level -- or if there are multiple levels. Ideally, I would love it if the trigger calculated the average hostility levels contained within trigger_area.

    Mission Story Context
    The players will be a U.S. Green Beret ODA tasked with training local tribal security forces to resist the insurgents. This will involve a sector-by-sector effort to earn the respect and trust of each tribe. Once activated, the trigger described above will activate a new AI commander who will begin populating their tribal area with security forces. There will be several such tribal areas set up across the map.

    Thanks!

  2. Edited 7 years ago by Bad Quaker

    Possible Compromise
    I'll add that if it makes it a lot easier, I'm fine with:

    • setting the trigger in the center of a single town, therfore presumably falling entirely within the within the bounds of a single ALiVE-defined civilian cluster.
    • Then if the player position could be used to identify the relevant cluster, the civ hostility for that cluster could be evaluated.

    I'm guessing that would be far more do-able, I just don't know how. Thanks again to anyone who can offer some guidance.

  3. I'm fairly sure the civ hostility level is calculated 'globally'

    This is one for the devs.. probably @SpyderBlack723

  4. I swore there used to be an ALiVE function to get hostility at a certain position, but I cannot find it.

    Let me create something that finds the hostility of the closest cluster and the average hostility of all clusters.

  5. Edited 7 years ago by SpyderBlack723

    Here's one that should work

    ALiVE_fnc_getAverageClusterHostilityBySide = {
           	 private ["_side","_averageHostility","_clusterCount","_allClusters","_clusterHostility","_clusterHostilityToSide"];
    	_side = _this;
    
    	_averageHostility = 0;
    	_clusterCount = 0;
    
    	_allClusters = [ALiVE_clusterHandler,"clusters"] call ALiVE_fnc_clusterHandler;
    
    	{
    		_cluster = _x;
    		_clusterHostility = [_cluster, "hostility"] call ALIVE_fnc_hashGet;
    		_clusterHostilityToSide = [_clusterHostility,_side, 0] call ALIVE_fnc_hashGet;
    
    		_averageHostility = _averageHostility + clusterHostilityToSide;
    		_clusterCount = _clusterCount + 1;
    	} foreach _allClusters;
    
    	_averageHostility / _clusterCount
    };

    -----------------------------------------------------------------------------
    Example calls

    "WEST" call ALiVE_fnc_getAverageClusterHostilityBySide;
    "EAST" call ALiVE_fnc_getAverageClusterHostilityBySide;
    "GUER" call ALiVE_fnc_getAverageClusterHostilityBySide;
  6. Edited 7 years ago by SpyderBlack723

    Here's the second that should hopefully work

    ALiVE_fnc_getNearestClusterHostilityBySide = {
    	private ["_allClusters","_sectorsByDistance","_nearestSector","_clusterHostility","_clusterHostilityToSide"];
    	params ["_pos","_side"];
    
    	_allClusters = [ALiVE_clusterHandler,"clusters"] call ALiVE_fnc_clusterHandler;
    	_sectorsByDistance = [_allClusters,[_pos],{_input0 distance ([_x,"position"] call ALiVE_fnc_hashGet)},"ASCEND"] call ALiVE_fnc_SortBy;
    	_nearestSector = _sectorsByDistance select 0;
    
    	_clusterHostility = [_nearestSector, "hostility"] call ALIVE_fnc_hashGet;
    	_clusterHostilityToSide = [_clusterHostility,_side, 0] call ALIVE_fnc_hashGet;
    
    	_clusterHostilityToSide
    };

    -----------------------------------------------------------------------------
    Example calls

    [getPos player, "WEST"] call ALiVE_fnc_getNearestClusterHostilityBySide;
    [getPos player, "EAST"] call ALiVE_fnc_getNearestClusterHostilityBySide;
    [getPos player, "GUER"] call ALiVE_fnc_getNearestClusterHostilityBySide;
  7. Edited 7 years ago by Bad Quaker

    Thanks @SpyderBlack723 !

    EDIT: I just noticed that Spyder stated above what I was confirming below. Sorry!

    I'll play with these over the next couple of days an follow up on how it went.

    To make sure I understand --
    * ALiVE_fnc_getAverageClusterHostilityBySide is for getting global hostility by side, and
    * ALiVE_fnc_getNearestClusterHostilityBySide is for getting hostility for the nearest civ cluster?

  8. Edited 7 years ago by Bad Quaker

    I'm running into issues, though it's possible it's my lack of understanding of how Arma scripting wants things. As I said, I'm new to this stuff.

    • I created a file called functions.sqf. It included nothing but Spyder's code for ALiVE_fnc_getNearestClusterHostilityBySide verbatim.
    • I then added the following line to my init.sqf: [] execVM "functions.sqf";
    • I added the following code to a trigger within an Alive Civ Cluster:

    test= [getPos player, "WEST"] call ALiVE_fnc_getNearestClusterHostilityBySide; hint toString[test];
    * When I activate the trigger in-game or via the debug console, I get errors like this:

    21:29:23 ALiVE-15.789 ["#CBA_HASH#",["debug","clusters","clustersActive","clustersInActive"],[true,["#CBA_HASH#",["c_47","c_48","c_49"],[["#CBA_HASH#",["nodes","clusterID","center","size","type","priority","debugColor","debug","debugMarkers","hostility","casualties","sectors","posture"],[[833cf200# 48284: terrace_k_1_ep1.p3d,833cf900# 48283: house_k_1_ep1.p3d,83478100# 48033: house_k_1_ep1.p3d,833d1d00# 48016: terrace_k_1_ep1.p3d,833d0f00# 48026: house_k_5_ep1.p3d,833d1600# 48017: terrace_k_1_ep1.p3d,5c0e8800# 48032: house_k_1_ep1.p3d,5c0e9600# 48024: terrace_k_1_ep1.p3d,5c0e8f00# 48029: house_k_7_ep1.p3d,5c0de400# 48047: house_k_6_ep1.p3d,5c0ea400# 48021: terrace_k_1_ep1.p3d,5c0e9d00# 48022: terrace_k_1_ep1.p3d,5c0e8100# 48034: house_k_1_ep1.p3d,833ceb00# 48023: terrace_k_1_ep1.p3d,833ce400# 48031: house_k_3_ep1.p3d,5c100100# 48027: house_k_5_ep1.p3d,5c100800# 48020: terrace_k_1_ep1.p3d,5c0fab00# 48067: house_k_5_ep1.p3d,5c0fb200# 48062: terrace_k_1_ep1.p3d,5c0d6b00# 48061: terrace_k_1_ep1.p3d,5c0d7900# 48049: house
    21:29:23 Error in expression <", "_input8", "_input9"];
    
    _inputArray =+ _inputArray;
    
    if !(_filterFnc isEqualT>
    21:29:23   Error position: <+ _inputArray;
    
    if !(_filterFnc isEqualT>
    21:29:23   Error +: Type Bool, expected Number,Array,Not a Number
    21:29:23 File x\alive\addons\x_lib\functions\misc\fnc_sortBy.sqf, line 49

    Probably something I am doing wrong. Can anyone help me out?

  9. Looks like I messed up something with my ALIVE_FNC_SORTBY code, does the other function work properly?

    Will try to fix once back to my PC

  10. Just gave the average function a try -- getting a generic error on line 17: foreach _allClusters;

  11. Edited 7 years ago by Bad Quaker

    Hi @SpyderBlack723 ,

    Still haven't figured this out, but I've been poking around in the functions available via Alive and Arma 3. Can ALIVE_fnc_clustersInsideMarker look for clusters inside a vanilla area defined in the A3 mission editor? Ultimately, that's what would work for me best.

    I feel like I could almost figure this out, but figuring out how to dig through multi-dimensional arrays in Arma is still confusing me. I'm wishing I had something akin to Krumo or var_dump in php to help me better understand the data structure.

  12. Edited 7 years ago by SpyderBlack723

    My apologies, forgot about this one! I'll take another look tonight.

    For figuring arrays out better, try running them through ALiVE_fnc_inspectArray

    _array call ALiVE_fnc_inspectArray;

    It scans the array and outputs some neat debug lines to the RPT showing the array in a more user-friendly format

    Edit: Didn't have much time tonight, will set a reminder to continue my quest tomorrow.

  13. Ok here they are fixed
    --

    "WEST" call ALiVE_fnc_getAverageClusterHostilityBySide;
    "EAST" call ALiVE_fnc_getAverageClusterHostilityBySide;
    "GUER" call ALiVE_fnc_getAverageClusterHostilityBySide;
    ALiVE_fnc_getAverageClusterHostilityBySide = {
           	 private ["_side","_averageHostility","_clusterCount","_allClusters","_clusterHostility","_clusterHostilityToSide"];
    	_side = _this;
    
    	_averageHostility = 0;
    	_clusterCount = 0;
    
    	_allClusters = [ALiVE_clusterHandler,"clusters"] call ALiVE_fnc_hashGet;
    
    	{
    		_cluster = _x;
    		_clusterHostility = [_cluster, "hostility"] call ALIVE_fnc_hashGet;
    		_clusterHostilityToSide = [_clusterHostility,_side, 0] call ALIVE_fnc_hashGet;
    
    		_averageHostility = _averageHostility + _clusterHostilityToSide;
    		_clusterCount = _clusterCount + 1;
    	} foreach (_allClusters select 2);
    
    	_averageHostility / _clusterCount
    };

    --

    [getPos player, "WEST"] call ALiVE_fnc_getNearestClusterHostilityBySide;
    [getPos player, "EAST"] call ALiVE_fnc_getNearestClusterHostilityBySide;
    [getPos player, "GUER"] call ALiVE_fnc_getNearestClusterHostilityBySide;
    ALiVE_fnc_getNearestClusterHostilityBySide = {
    	private ["_allClusters","_sectorsByDistance","_nearestSector","_clusterHostility","_clusterHostilityToSide"];
    	params ["_pos","_side"];
    
    	_allClusters = ([ALiVE_clusterHandler,"clusters"] call ALiVE_fnc_hashGet) select 2;
    	_sectorsByDistance = [_allClusters,[_pos],{_input0 distance ([_x,"position"] call ALiVE_fnc_hashGet)},"ASCEND"] call ALiVE_fnc_SortBy;
    	_nearestSector = _sectorsByDistance select 0;
    
    	_clusterHostility = [_nearestSector, "hostility"] call ALIVE_fnc_hashGet;
    	_clusterHostilityToSide = [_clusterHostility,_side, 0] call ALIVE_fnc_hashGet;
    
    	_clusterHostilityToSide
    };
  14. OK, great -- will test out soon. Thanks for taking a second crack at it, and for the tip about ALiVE_fnc_inspectArray -- sounds like what I was hoping to find.

  15. So if I set these functions up in init.sqf, is there a way to have a trigger monitor the level and have it activated when below a certain amount?

    I understand I could have a trigger use "WEST" call ALiVE_fnc_getAverageClusterHostilityBySide;, but how would I set it up that the trigger activates if below a certain amount, for example 100? Also, what's a good number to place here? Don't know what relativity is here, is 100 high or is 1000 high?

  16. Scale is from [-100,100]

    in condition field

    ("WEST" call ALiVE_fnc_getAverageClusterHostilityBySide) > X
  17. inArea and ... areas?
    I apologize for this not being strictly specific to ALiVE, but BI's forums have not yet deemed me worthy/contributory enough to create a new topic for general script troubleshooting, and this issue is related to the original thread I opened here.

    I've been trying to run with Spyder's code and modify it to my mission specifics, but I'm really confused by the relationship between the vanilla inArea command (which is utilized by ALiVE_fnc_inArea) and map area markers. Is inArea not compatible with Area markers? (If so, that feels rather paradoxical). Here's what I'm running into:

    • I set up a map area called testArea in the editor.
    • I also set up a trigger area called testTrigger with essentially the same center point and dimensions
    • I put the player in the dead center of both.
    • I do a test of if (player inArea testArea) then {action} and the action does not trigger.
    • I do a test of if (player inArea testTrigger) then {action} and the action triggers.
    • hint format["%1", (player inArea testArea)]; returns "any"
    • hint format["%1", (player inArea testTrigger)]; returns "true."

    Does inArea seriously not work with with Area markers? Given that these what's used to establish the ALiVE TAoRS, that sucks (on BI, not you guys).

  18. Edited 7 years ago by SpyderBlack723

    I just gave it a whirl and I find the same result. ALiVE TAOR's still work fine however.

    No clue..

  19. Another hostility question I've been trying to figure out -- what's the relationship between the cluster hostility we're using here and the sector hostility discussed here?

    It seems like the hostility system is complex enough to where there should possibly be a page on the wiki dedicated to it. If/when I wrap my head around it sufficiently, I could take a first crack.

    Also, Spyder, I just wanted to thank you again for answering my many questions (I've got plenty more on the way, I'm sure!) and for being such an all-around good guy. You've inspired me to donate to the ALiVE project when my next check comes in.

  20. If you donate enough he won't have to go back to school in the fall and we can keep him locked in the basement working on @alive ;)

  21. Newer ›
 

or Sign Up to reply!