Want more features on Pastebin? Sign Up, it's FREE!
Guest

ZombieIdle

By: a guest on Feb 29th, 2012  |  syntax: None  |  size: 0.98 KB  |  views: 559  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. })
clone this paste RAW Paste Data