Epoch/Sources/epoch_code/compile/environment/EPOCH_client_loadAnimalBrain.sqf

66 lines
2.3 KiB
Plaintext
Raw Normal View History

2015-12-15 22:43:26 +00:00
/*
Author: Aaron Clark - EpochMod.com
Contributors:
Description:
Creates animals with custom Epoch fsm AI "brain"
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/master/Sources/epoch_code/compile/environment/EPOCH_client_loadAnimalBrain.sqf
Example:
call EPOCH_client_loadAnimalBrain;
Parameter(s):
None
Returns:
NOTHING
*/
2015-09-14 20:55:36 +00:00
private["_fightOrFlight", "_id", "_animal", "_tryAnimalPos", "_animalPos", "_randomIndex", "_randomAIClass", "_aiTables", "_plyrPos"];
if (count(player nearEntities["Animal_Base_F", 200]) >= 1) exitWith{};
_animalAiTables = ["Sheep_random_EPOCH", "Sheep_random_EPOCH", "Goat_random_EPOCH", "Goat_random_EPOCH", "Goat_random_EPOCH", ["Cock_random_EPOCH", "Hen_random_EPOCH"], ["Cock_random_EPOCH", "Hen_random_EPOCH"], "Rabbit_EPOCH", "Rabbit_EPOCH", "Rabbit_EPOCH", "Snake_random_EPOCH", "Snake2_random_EPOCH", ["Fin_random_EPOCH", "Alsatian_Random_EPOCH"]];
_randomIndex = floor(random(count _animalAiTables));
_randomAIClass = _animalAiTables select _randomIndex;
_animalPos = nil;
_plyrPos = position player;
if (typeName _randomAIClass == "ARRAY") then {
_randomIndex = floor(random(count _randomAIClass));
_randomAIClass = _randomAIClass select _randomIndex;
};
for "_i" from 1 to 3 step 1 do {
_tryAnimalPos = [_plyrPos, floor(random 350) + 50, floor(random 360)] call BIS_fnc_relPos;
if!(surfaceIsWater _tryAnimalPos) exitWith {
_animalPos = _tryAnimalPos;
};
};
if!(isNil "_animalPos") then {
// diag_log format["DEBUG: Spawning animal at %1.",_animalPos];
_animal = createAgent[_randomAIClass, _animalPos, [], 5, "NONE"];
_animal setVariable["BIS_fnc_animalBehaviour_disable", true];
// diag_log format["DEBUG: spawned %1", _randomAIClass];
2015-12-28 16:31:54 +00:00
// send to server
[_animal] remoteExec ["EPOCH_localCleanup",2];
2015-09-14 20:55:36 +00:00
{
_animal disableAI _x;
}forEach ["TARGET","AUTOTARGET","FSM"];
if (_randomAIClass in ["Fin_random_EPOCH", "Alsatian_Random_EPOCH"]) then {
_id = [_animal] execFSM "\x\addons\a3_epoch_code\System\Dog_Brain.fsm";
}else{
_id = [_animal, _randomAIClass in ["Snake_random_EPOCH","Snake2_random_EPOCH"]] execFSM "\x\addons\a3_epoch_code\System\Animal_brain.fsm";
};
};