mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Merge pull request #407 from Abi79/master
Small optimizations to metroid AIprocess()
This commit is contained in:
@@ -211,6 +211,7 @@
|
|||||||
var/Tempstun = 0 // temporary temperature stuns
|
var/Tempstun = 0 // temporary temperature stuns
|
||||||
var/Discipline = 0 // if a metroid has been hit with a freeze gun, or wrestled/attacked off a human, they become disciplined and don't attack anymore for a while
|
var/Discipline = 0 // if a metroid has been hit with a freeze gun, or wrestled/attacked off a human, they become disciplined and don't attack anymore for a while
|
||||||
var/SStun = 0 // stun variable
|
var/SStun = 0 // stun variable
|
||||||
|
var/Obstacle = 1 // determines whether the turf the metroid will head to has an obstacle
|
||||||
proc
|
proc
|
||||||
|
|
||||||
AIprocess() // the master AI process
|
AIprocess() // the master AI process
|
||||||
@@ -228,7 +229,9 @@
|
|||||||
switch(nutrition)
|
switch(nutrition)
|
||||||
if(150 to 800) hungry = 1
|
if(150 to 800) hungry = 1
|
||||||
if(0 to 149) starving = 1
|
if(0 to 149) starving = 1
|
||||||
|
|
||||||
AIproc = 1
|
AIproc = 1
|
||||||
|
|
||||||
while(AIproc && stat != 2 && (attacked > 0 || starving || hungry || rabid || Victim))
|
while(AIproc && stat != 2 && (attacked > 0 || starving || hungry || rabid || Victim))
|
||||||
if(Victim) // can't eat AND have this little process at the same time
|
if(Victim) // can't eat AND have this little process at the same time
|
||||||
break
|
break
|
||||||
@@ -242,63 +245,63 @@
|
|||||||
AIproc = 0
|
AIproc = 0
|
||||||
break
|
break
|
||||||
|
|
||||||
if(Target)
|
for(var/mob/living/carbon/metroid/M in view(1,Target))
|
||||||
for(var/mob/living/carbon/metroid/M in view(1,Target))
|
if(M.Victim == Target)
|
||||||
if(M.Victim == Target)
|
Target = null
|
||||||
Target = null
|
AIproc = 0
|
||||||
AIproc = 0
|
|
||||||
break
|
|
||||||
if(!AIproc)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if(Target in view(1,src))
|
if(!AIproc)
|
||||||
|
break
|
||||||
|
|
||||||
if(istype(Target, /mob/living/silicon))
|
if(get_obstacle_ok(Target))
|
||||||
if(!Atkcool)
|
Obstacle = 0
|
||||||
spawn()
|
else Obstacle = 1
|
||||||
Atkcool = 1
|
|
||||||
sleep(15)
|
|
||||||
Atkcool = 0
|
|
||||||
|
|
||||||
if(get_obstacle_ok(Target))
|
if(Target in view(1,src))
|
||||||
Target.attack_metroid(src)
|
|
||||||
return
|
|
||||||
if(prob(80) && !Target.lying)
|
|
||||||
|
|
||||||
if(Target.client && Target.health >= rand(10,30))
|
if(istype(Target, /mob/living/silicon))
|
||||||
if(!Atkcool)
|
if(!Atkcool)
|
||||||
spawn()
|
spawn()
|
||||||
Atkcool = 1
|
Atkcool = 1
|
||||||
sleep(25)
|
sleep(15)
|
||||||
Atkcool = 0
|
Atkcool = 0
|
||||||
|
|
||||||
if(get_obstacle_ok(Target))
|
if(!Obstacle)
|
||||||
Target.attack_metroid(src)
|
Target.attack_metroid(src)
|
||||||
|
return
|
||||||
|
|
||||||
|
if(prob(80) && !Target.lying && Target.client && Target.health >= rand(10,30))
|
||||||
|
|
||||||
|
if(!Atkcool)
|
||||||
|
spawn()
|
||||||
|
Atkcool = 1
|
||||||
|
sleep(25)
|
||||||
|
Atkcool = 0
|
||||||
|
|
||||||
|
if(!Obstacle)
|
||||||
|
Target.attack_metroid(src)
|
||||||
|
|
||||||
|
|
||||||
if(prob(30))
|
if(prob(30))
|
||||||
step_to(src, Target)
|
step_to(src, Target)
|
||||||
|
|
||||||
else
|
|
||||||
if(!Atkcool && get_obstacle_ok(Target))
|
|
||||||
Feedon(Target)
|
|
||||||
|
|
||||||
else
|
|
||||||
if(!Atkcool && get_obstacle_ok(Target))
|
|
||||||
Feedon(Target)
|
|
||||||
|
|
||||||
else
|
else
|
||||||
if(Target in view(30, src))
|
if(!Atkcool && !Obstacle)
|
||||||
if(get_obstacle_ok(Target))
|
Feedon(Target)
|
||||||
step_to(src, Target)
|
|
||||||
|
|
||||||
else
|
else
|
||||||
Target = null
|
if(Target in view(30, src))
|
||||||
AIproc = 0
|
if(!Obstacle)
|
||||||
break
|
step_to(src, Target)
|
||||||
|
|
||||||
|
else
|
||||||
|
Target = null
|
||||||
|
AIproc = 0
|
||||||
|
break
|
||||||
|
|
||||||
var/sleeptime = movement_delay()
|
var/sleeptime = movement_delay()
|
||||||
if(sleeptime <= 0) sleeptime = 1
|
if(sleeptime < 1) sleeptime = 1
|
||||||
|
|
||||||
sleep(sleeptime + 2) // this is about as fast as a player Metroid can go
|
sleep(sleeptime + 2) // this is about as fast as a player Metroid can go
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user