Advertisement
Guest User

ZombieIdle

a guest
Feb 29th, 2012
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. -- ZombieIdle behavior
  2. -- Created by the_grim
  3.  
  4.  
  5. local Behavior = CreateAIBehavior("ZombieIdle",
  6. {
  7. Alertness = 0,
  8.  
  9. Constructor = function (self, entity)
  10. Log("Idling...");
  11. AI.SetBehaviorVariable(entity.id, "AwareOfPlayer", false);
  12. entity:SelectPipe(0,"zombie_idle");
  13. end,
  14.  
  15. Destructor = function(self, entity)
  16. end,
  17.  
  18. OnGroupMemberDiedNearest = function ( self, entity, sender,data)
  19. AI.SetBehaviorVariable(entity.id, "Alerted", true);
  20. end,
  21. OnGroupMemberDied = function( self, entity, sender)
  22. AI.SetBehaviorVariable(entity.id, "Alerted", true);
  23. end,
  24.  
  25. AnalyzeSituation = function (self, entity, sender, data)
  26. local range = 1.0;
  27. local distance = AI.GetAttentionTargetDistance(entity.id);
  28. if(distance > (range)) then
  29. AI.SetBehaviorVariable(entity.id, "IsAttackRange", false);
  30. elseif(distance < (range)) then
  31. AI.SetBehaviorVariable(entity.id, "IsAttackRange", true);
  32. end
  33.  
  34. end,
  35. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement