Search the Community
Showing results for tags 'agent'.
Found 1 result
-
So, I'm having some serious problems with agents. Objectives: 1. Spawn 200 fish near three markers 2. Have the fish roam freely about within around 100m of the marker. 3. Have fish visible on all clients simultaneously. I've tested performance, and there's no impact from the initial 600 fish that get generated... the problem I have is, they all swim north continuously, and no matter what I script in, the fish don't respond in any way. The monitor script then sees that there aren't 200 fish near the markers anymore, so spawns another 200 fish... For reference, these are both executed on the server only. /* filename: fn_generateFish.sqf Author: Stevo Description: Generates additional fish at server startup */ Private ["_fish","_markers","_fishIndex","_markerPos","_fishExist","_fishCount","_index","_type","_posDiff1","_posDiff2","_fishPos","_newFish"]; _fish = ["Salema_F","Ornate_random_F","Mackerel_F","Tuna_F","Mullet_F","CatShark_F","Turtle_F"]; _fishIndex = 6; _markers = ["m_fish_1","m_fish_2","m_fish_3"]; { _marker = _x; _markerPos = getMarkerPos _x; _fishExist = nearestObjects [_markerPos, _fish, 125, false]; _fishCount = count _fishExist; if (_fishCount < 200) then { while {_fishcount < 200} do { _index = round(random(_fishIndex)); _type = _fish select _index; _posDiff1 = round(random(25)); _posDiff2 = round(random(25)); if (round(random(1)) == 0) then { _posDiff1 = (_posDiff1 - _posDiff1) - _posDiff1; }; if (round(random(1)) == 0) then { _posDiff2 = (_posDiff2 - _posDiff2) - _posDiff2; }; _fishPos = [(_markerPos select 0) + _posDiff1, (_markerPos select 1) + _posDiff2, (_markerPos select 2) - 5]; _newfish = createAgent [_type, _fishPos,[],0,"NONE"]; _newFish setVariable ["BIS_fnc_animalBehaviour_disable",true]; _newFish disableAI "FSM"; _newFish setVariable ["home",_marker]; _newFish enableSimulation true; _newFish allowDamage true; _fishCount = _fishCount + 1; }; }; } forEach _markers; [] spawn life_fnc_monitorFish; /* filename: fn_monitorFish.sqf Author: Stevo Description: Recreates fish that have been "caught" in another location. */ Private ["_markers"]; _markers = ["m_fish_1","m_fish_2","m_fish_3"]; { [_x] spawn { Private ["_fish","_marker","_fishIndex","_markerPos","_fishExist","_fishCount","_index","_type","_posDiff1","_posDiff2","_fishPos","_newFish"]; _fish = ["Salema_F","Ornate_random_F","Mackerel_F","Tuna_F","Mullet_F","CatShark_F","Turtle_F"]; _fishIndex = 6; _marker = _this select 0; _markerPos = getMarkerPos _marker; while {true} do { sleep 600; _fishExist = nearestObjects [_markerPos, _fish, 125, false]; _fishCount = count _fishExist; if (_fishCount < 200) then { while {_fishcount < 200} do { _units = []; _index = round(random(_fishIndex)); _type = _fish select _index; _tooNear = true; while {_tooNear} do { _posDiff1 = round(random(100)); _posDiff2 = round(random(100)); if (round(random(1)) == 0) then { _posDiff1 = (_posDiff1 - _posDiff1) - _posDiff1; }; if (round(random(1)) == 0) then { _posDiff2 = (_posDiff2 - _posDiff2) - _posDiff2; }; _fishPos = [(_markerPos select 0) + _posDiff1, (_markerPos select 1) + _posDiff2, (_markerPos select 2) - 5]; { if (_x distance2D _fishPos < 20) then {_units pushBack _x;}; } forEach playableUnits; if (count _units != 0) then {_tooNear = true} else {_tooNear = false}; }; _newfish = createAgent [_type, _fishPos,[],0,"NONE"]; _newFish setVariable ["home",_marker]; _newFish enableSimulation true; _newFish allowDamage true; _fishCount = _fishCount + 1; }; }; }; }; } forEach _markers; while {true} do { { _marker = _x getVariable ["home","m_fish_1"]; _pos = [(getMarkerPos _marker) select 0,(getMarkerPos _marker) select 1,-1]; if (_x distance2D _pos > 100) then { _x MoveTo _pos; }; } forEach entities "Fish_Base_F"; sleep 10; };
- 1 reply
-
- ai movement
- agents
-
(and 2 more)
Tagged with: