Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 29th, 2012  |  syntax: None  |  size: 0.96 KB  |  views: 363  |  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. -- ZombieAttack behavior by the_grim
  2. -- Based on FogOfWarAttack by Francesco Roccucci
  3.  
  4.  
  5. local Behavior = CreateAIBehavior("ZombieAttack",
  6. {
  7.         Alertness = 2,
  8.        
  9.         Constructor = function (self, entity)
  10.                 entity:MakeAlerted();
  11.                 entity:DrawWeaponNow();
  12.                 Log("Attack!")
  13.                 entity:SelectPipe(0,"zombie_attack");
  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. })
clone this paste RAW Paste Data