Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AI Template
#1
here is an AI for template that can kill most original characters (due to deadly jump attack abuse i have to admit)

my aim is however to turn this into a real modular template script, where you only have to enter the ranges of all basic attacks at the top and then only worry about:
special moves/combos and most of all
testing opponent specific decisions (timing function) that will make your character do the right choices when it comes to breaking or performing a combo

sometimes for example when your character really could start off many different combos without much difference on the damage output the current hp/mp of you and your opponent can really help you decide as they can determine whether you are able to turn this into an unbreakable combo or whether the opponent doesnt have the energy to break an even stronger but breakable version; kind of what i wasted most of my time on with davis

right now there is still a little too much clutter inside the basic actions which i really need to condense and rather put inside the timing function (i have barely started with them ...)

if you want to have a good challenge against a computer without special moves go pop this in as 0.chai

    C-Code:
{
//CHARACTER SPECIFIC DECISIONS
 var timing = fun(id,frame,smp,tmp,shp,thp){
  if (id == 0){return true
 }else if (id == 1){return true
 }else if (id == 2){if (frame >= 70 && frame <= 72){return false}else{return true}
 }else if (id == 4){return true
 }else if (id == 5){return true
 }else if (id == 6){return true
 }else if (id == 7){if (frame >= 70 && frame <= 74){return false}else{return true}
 }else if (id == 8){return true
 }else if (id == 9){return true
 }else if (id == 10){return true
 }else if (id == 11){if ((frame >= 70 && frame <= 73) || frame >= 305){return false}else{return true}
 }else{return true}
 }
//SETTINGS
 var defense = 1    //0: none, 1: aktive, 2: always
 var evasion = 1   //0: none, 1: aktive, 2: always
 var control = 1  //0: none, 1: follow, 2: flee
 var facing = 1  //0: none, 1: against, 2: same
 var attack = 1 //0: none, 1: aktive, 2: always
 var basic = 0 //0: basic AI, 1: no basic AI (enable control & facing)
//VARIABLES
 var xdst = self.x-target.x
 var ydst = self.y-target.y
 var zdst = self.z-target.z
 var zbgu = self.z-bg_zwidth1
 var zbgb = bg_zwidth2-self.z
 var xbgr = bg_width-self.x
 var xabs = abs(xdst)
 var yabs = abs(ydst)
 var zabs = abs(zdst)
 var xdir = xdst*(2*self.facing-1)
 
//COMBOS
 if (target.state == 16 || target.state == 8){
//ground
  if (target.hp <= 50){A();return basic}
  else if (target.state == 16 && target.hp <= 71){{if (xdst > 0){left()}else {right()};return basic}}
  else if (target.state == 16 && self.frame == 212){A();return 1}
  else if (target.state == 16){J();return 1}
  else {A();return basic}
}else if (target.frame == 181 || target.frame == 187){
//juggling
  if (self.state <= 1){if (xdst > 0){left()}else {right()};return 1}
  else if (self.state == 2){A();return 1}
 }
 
//DASH
 if (self.state == 5){A();return basic}
 
//CATCH
 if (self.state == 9){
  if (self.ctimer <= 50 && target.hp <= 30){if (self.x < xbgr){right()}else{left()}}
  A();return basic}
if (self.state == 12){print(target.ctimer)}
 
//EVASION
 if (evasion == 1){
//aktive
  if (self.state == 12 && (target.frame == 234 || (target.id == 6 && target.ctimer == 250 && target.frame != 247))){J();return basic}
  else if (self.state == 12 && (target.state == 3 || target.state == 301) && timing(target.id,target.frame,self.mp,target.mp,self.hp,target.hp)){J();print(target.frame);return basic}
  else if (self.frame == 215 && (target.state == 3 || target.state == 301)){D();return basic}
}else if (evasion == 2){
//always
  if (self.state == 12){J();return basic}
  else if (self.frame == 215){D();return basic}
 }
 
//DEFENSE
 if (defense == 1 && (target.state == 3 || target.state == 301) && xabs <= 80 && zabs <= 10 && timing(target.id,target.frame,self.mp,target.mp,self.hp,target.hp)){D();print(target.frame)}
//aktive
 else if (defense == 2){D()}
//always
 if (self.frame == 110 && target.facing == self.facing){if (self.facing == 1){right()}else{left()};return basic}
//defend against target
 
//ATTACK
 if (attack == 1 && self.state <= 1 && target.y <= 10 && xdir <= 60 && xdir >= -15 && zabs <= 10){A();return basic}
//aktive
 else if (attack == 2){A();return basic}
//always
 
//CONTROL
 if (basic == 1){
//none
  if (control == 0 && self.state == 2){if (self.facing == 0){left()}else {right()};return basic}
//follow
  if (control == 1){
   if (zabs > 5){if (zdst < 0){down()}else {up()}}
   if (xabs > 60){if (xdst > 0){left()}else {right()};return basic}
   else if (self.state == 2){if (xdst < 0){left()}else {right()};return basic}
//flee
 }else if (control == 2){
   if (zabs < 50){if (zdst > 0 && zbgb > 10){down()}else if(zdst < 0 && zbgu > 10){up()}}
   if (xabs < 300){if (xdir < 0 && self.x > 150){left()}else  if(xdir > 0 && xbgr > 150){right()}}
   if (self.state == 2 && (xabs > 300 || self.x < 150 || xbgr < 150)){if (self.facing == 0){left()}else {right()};return basic}
  }
//FACING
  if (facing == 2 && target.facing != self.facing && (self.state == 0 || self.state == 7)){if (self.facing == 1){right()}else{left()};return basic
//same
 }else if (facing == 1 && target.facing == self.facing && (self.state == 0 || self.state == 7)){if (self.facing == 1){right()}else{left()};return basic}
//against
 }
 
//BASIC
 return basic
}


oh and if my fleeing alg becomes better i can also think of having a function that checks whether the difference of your opponents red-darkred hp is smaller than yours and make the character go into flee mode if he can profit from getting some time to regain health - this should be useful for stage mode

edit: project is replaced by writing a new basic ai since angel script now allows that - i will scavenge everything useful i had already done here as soon as i get to that point
Reply




Users browsing this thread: 1 Guest(s)