1. -- ZombieApproach behavior
  2. -- Created by the_grim
  3.  
  4. local Behavior = CreateAIBehavior("ZombieApproach",
  5. {
  6. Alertness = 2,
  7.  
  8. Constructor = function (self, entity)
  9. Log("Approaching!");
  10. entity:SelectPipe(0, "zombie_approach");
  11. end,
  12.  
  13. Destructor = function(self, entity)
  14. end,
  15.  
  16. OnGroupMemberDiedNearest = function ( self, entity, sender,data)
  17. AI.SetBehaviorVariable(entity.id, "Alerted", true);
  18. end,
  19.  
  20. OnGroupMemberDied = function( self, entity, sender)
  21. AI.SetBehaviorVariable(entity.id, "Alerted", true);
  22. end,
  23.  
  24. AnalyzeSituation = function (self, entity, sender, data)
  25. local range = 1.0;
  26. local distance = AI.GetAttentionTargetDistance(entity.id);
  27. if(distance > (range)) then
  28. AI.SetBehaviorVariable(entity.id, "IsAttackRange", false);
  29. elseif(distance < (range)) then
  30. AI.SetBehaviorVariable(entity.id, "IsAttackRange", true);
  31. end
  32.  
  33. end,
  34. })