Thread: NPC combat
View Single Post
  #5  
Old 03-21-2011, 12:11 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by skillmaster19 View Post
That is nice, but it seems a little too complicated for me at the time (im new to gscript2)

is there any basic ways to make a simple baddy?
Well it's about breaking it down into pieces...

PHP Code:
function onCreated() {
  
setTimer(0.1);
}

function 
onTimeout() {
  
setTimer(1);
  
baddyLogic();
}

function 
baddyLogic() {
  if (
hasTarget()) {
    if (
targetInAttackRange()) {
      
attackTarget();
    } else {
      if (
targetInChaseRange()) {
        
chaseTarget();
      } else {
        
returnHome();
      }
    }
  } else {
    
findTarget();
  }

__________________
Quote:
Reply With Quote