Jump to content

Mr Elusive

Member
  • Content Count

    3
  • Joined

  • Last visited

  • Medals

Community Reputation

0 Neutral

About Mr Elusive

  • Rank
    Rookie

Profile Information

  • Gender
    Male
  1. Hey BIS Forums, Can anyone explain how SpawnAI unit costs are actually calculated? I'm working on a mission using the SpawnAI modules. The SpawnAI modules have a manpower cap of 50 by default and I'd like to tweak it to spawn more/less units of different types (infantry, armor etc). According to the MP Support Guidelines on the BIS Wiki... a rifleman costs about 0.5 an AA/AT soldier about 6 a MRAP about 6 an APC about 12 a tank about 27 The page says the values are calculated using the cost and threat values defined in the unit's config. I admit I'm not great at math, but I just don't see how they came up with 0.5 as an answer using those two values. Example 1 - a standard NATO rifleman ("B_Soldier_F") and open up his entry in the config viewer: cost = 100000; threat[] = {0.8,0.1,0.1}; Example 2 - NATO AT Missile Specialist ("B_soldier_AT_F"): cost = 130000; threat[] = {0.8,0.8,0.3}; According to the guidelines these units should cost 0.5 and 6 respectively. Clearly I'm missing something, so can anyone tell me how unit costs are actually calculated? Thanks in advance.
  2. Ah, I see what you guys mean. I've not really used the spawn command before. I'll have another go at it. This is a prototype/proof-of-concept just to get it working. Refinement & optimization comes later. My first prototype was running every 30 seconds or so and had no loops. I mean, it worked, but it really wasn't great because the AI only went for the nearest point every single time. Got boring fast unfortunately, so I thought I'd try and improve upon it. Functions would probably be better, but I haven't learned how to write those yet. I'm not a software developer so some of these programming/scripting concepts are bit alien to me - but I'm learning as I go! Once again, thank you both for your input. It's most appreciated. Cheers! 🍺
  3. Greetings! Long time lurker, first time poster. I've tried my best to research and resolve this myself, but I'm completely at a loss right now. What am I trying to do? I'm making a sector control mission with AI support. The idea is that the AI will check an array of enemy-held sectors, then assign a waypoint to attack accordingly. For example: No enemy sectors? Defend the nearest friendly sector. (BIS_fnc_taskDefend) One enemy sector? Assign a waypoint to attack it. Two or more enemy sectors? Pick one from the closest two and assign a waypoint to attack. AI units invoke the script using a normal execVM command when they spawn: [this] execVM "scripts\ai\sectorTacticInfantry.sqf"; What's the issue? The script throws up multiple "undefined variable" errors, but I can't understand why as they've already been defined. For whatever reason, it's like the private variables are not being passed on to the code blocks below. Here's the script so you can take a look yourselves. I should point out that the "all_sectors" global variable is an array containing the sector module names (S1, S2, S3 etc.) defined in initServer.sqf. systemChat "DEBUG: Starting sector tactic."; [] spawn {while {true} do { _unit = (_this select 0); _grp = group (_this select 0); _grp_side = side (_this select 0); _enemy_sectors = []; _friendly_sectors = []; scopeName "start"; // Update arrays of sector ownership. { if !((_x getVariable "owner") == _grp_side) then { [_enemy_sectors, _x] call BIS_fnc_arrayPush; }; } forEach all_sectors; { if ((_x getVariable "owner") == _grp_side) then { [_friendly_sectors, _x] call BIS_fnc_arrayPush; }; } forEach all_sectors; if (count _enemy_sectors == 0) then {breakTo "noEnemySectors"}; if (count _enemy_sectors == 1) then {breakTo "oneEnemySector"}; if (count _enemy_sectors > 1) then {breakTo "multipleEnemySectors"}; while {true} do { scopeName "noEnemySectors"; // There's no enemy sectors. _grp = group (_this select 0); _grp call CBA_fnc_clearWaypoints; _nearest_friendly_sector = [_friendly_sectors, _grp] call BIS_fnc_nearestPosition; [_grp, _nearest_friendly_sector] call CBA_fnc_taskDefend; breakTo "defendLoop"; }; while {true} do { scopeName "oneEnemySectors"; // There's one enemy sector. grp call CBA_fnc_clearWaypoints; _target_sector = (enemy_sectors select 0); [_grp, _target_sector] call CBA_fnc_addWaypoint; breakTo "attackLoop"; }; while {true} do { scopeName "multipleEnemySectors"; // There's more than one enemy sector. _grp call CBA_fnc_clearWaypoints; _sortedenemy_sectors = [_enemy_sectors, [], { _unit distance _x }, "ASCEND"] call BIS_fnc_sortBy; _closestenemy_sectors = []; [_closestenemy_sectors, (_sortedenemy_sectors select 0)] call BIS_fnc_arrayPush; [_closestenemy_sectors, (_sortedenemy_sectors select 1)] call BIS_fnc_arrayPush; _target_sector = (selectRandom _closestenemy_sectors); [_grp, _target_sector] call CBA_fnc_addWaypoint; breakTo "attackLoop"; }; while {true} do { scopeName "defendLoop"; // Keep defending the point until an enemy takes a sector. _enemy_sectors = []; { if !((_x getVariable "owner") == _grp_side) then { [_enemy_sectors, _x] call BIS_fnc_arrayPush; }; } forEach all_sectors; if (count _enemy_sectors > 1) then {breakTo "start"}; sleep 1; }; while {true} do { scopeName "attackLoop"; // Keep attacking the point until it's ours. if ((_target_sector getVariable "owner") == _grp_side) then {breakTo "start"}; sleep 1; }; }; }; This is my most desperate hour. Help me, Obi-Wan Kenobi BIS Forums. You're my only hope. Thanks in advance, Mr Elusive
×