AI GetNearestHidespot
From CryWiki
In the behaviors of the AI, game/scripts/AI/Behaviors/Personalities.
You can edit and add new things to what they do at certain situations
To make them find the nearest hide spot:
local closestCover = AI.GetNearestHidespot(entity.id, 3, 15, sender:GetPos());
That is one example of what you can put in for the AI to locate the nearest hide point, you can insert this line anywhere fitted, for example, you can put this in the cover2attack bullet reaction.
To make the AI use this method wisely, after putting that line in there. Make the AI call a goalpipe, for example:
entity:SelectPipe(AIGOALPIPE_NOTDUPLICATE,"cv_scramble"); In that goalpipe, (located in game/scripts/Ai/goalpipes/PipemanagerCover2.lua)
It states AI.PushGoal("+hide",0,20,HM_NEAREST_PREFER_SIDE,0,0);
That means the AI should use the closest cover point, (the prefer side means the AI will try to take cover on the side of the target i believe)
An example i did for my AI were:
OnBulletRain = function(self, entity, sender, data)
-- local dta = _time - entity.AI.lastAdvanceTime;
-- if (dta > 3.0) then
-- if (AI.IsMoving(entity.id,2) == 0) then
local dt = _time - entity.AI.lastBulletReactionTime;
local reactionTime = 0.5;
local closestCover = AI.GetNearestHidespot(entity.id, 3, 15, sender:GetPos());
AI.SetBeaconPosition(entity.id, closestCover);
if (AI.IsMoving(entity.id,1) == 1) then reactionTime = 1.5;
entity:SelectPipe(AIGOALPIPE_NOTDUPLICATE,"suppressive_fire");
else
entity.AI.lastBulletReactionTime = _time;
entity:Readibility("bulletrain",1,2, 0,0.2);
entity:Readibility("incoming",0,5);
entity:InsertSubpipe(AIGOALPIPE_NOTDUPLICATE,"look_at_target");
end
if(dt < reactionTime) then
entity.AI.lastBulletReactionTime = _time;
entity:Readibility("bulletrain",1,2, 0,0.2);
entity:Readibility("incoming",0,5);
entity:SelectPipe(AIGOALPIPE_NOTDUPLICATE,"suppressive_fire");
entity:InsertSubpipe(AIGOALPIPE_NOTDUPLICATE,"look_at_target");
AI.NotifyGroupTacticState(entity.id, 0, GN_NOTIFY_HIDING);
end
end,
---------------------------------------------
NOTE: Some of this may not be Right, so feel free to edit it or pm me or email me on crymod. Also some of the things you see in here like the goalpipes were created by me, so you wont find some of them in the defauly crysis goalpipes and behaviors
--Rad15 02:17, 2 July 2008 (CEST)
