Advertisement
Guest User

Untitled

a guest
Feb 29th, 2012
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  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. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement