-- ZombieAttack behavior by the_grim
-- Based on FogOfWarAttack by Francesco Roccucci
local Behavior = CreateAIBehavior("ZombieAttack",
{
Alertness = 2,
Constructor = function (self, entity)
entity:MakeAlerted();
entity:DrawWeaponNow();
Log("Attack!")
entity:SelectPipe(0,"zombie_attack");
end,
OnGroupMemberDiedNearest = function ( self, entity, sender,data)
AI.SetBehaviorVariable(entity.id, "Alerted", true);
end,
OnGroupMemberDied = function( self, entity, sender)
AI.SetBehaviorVariable(entity.id, "Alerted", true);
end,
AnalyzeSituation = function (self, entity, sender, data)
local range = 1.0;
local distance = AI.GetAttentionTargetDistance(entity.id);
if(distance > (range)) then
AI.SetBehaviorVariable(entity.id, "IsAttackRange", false);
elseif(distance < (range)) then
AI.SetBehaviorVariable(entity.id, "IsAttackRange", true);
end
end,
})