forked from JailDoctor/cacaus
- WIP EL_ALIEN AI
This commit is contained in:
31
elalien.lua
31
elalien.lua
@@ -1,4 +1,4 @@
|
||||
elalien={hab=59,x=24,y=24,flip=true,goup=true,frame=8,stairscooldown=0,wait=0,step=0,anim={8,9,8,10},bb={x=4,y=0,w=8,h=16},scene_intro=false,scene_object=false}
|
||||
elalien={hab=38,x=24,y=24,flip=true,goup=true,frame=8,stairscooldown=0,wait=0,step=0,anim={8,9,8,10},bb={x=4,y=0,w=8,h=16},scene_intro=false,scene_object=false}
|
||||
|
||||
function elalien.init()
|
||||
elalien.hit=elalien.hit
|
||||
@@ -20,7 +20,7 @@ end
|
||||
function elalien.update_normal()
|
||||
elalien.wait=elalien.wait+1
|
||||
|
||||
if elalien.wait==6 then
|
||||
if elalien.wait>=6 then
|
||||
elalien.wait=0
|
||||
if elalien.stairscooldown>0 then elalien.stairscooldown=elalien.stairscooldown-1 end
|
||||
elalien.step=(elalien.step+1)%4
|
||||
@@ -30,6 +30,13 @@ function elalien.update_normal()
|
||||
if not elalien.flip and elalien.x==84 then
|
||||
elalien.hab=elalien.hab+1
|
||||
elalien.x=-4
|
||||
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)==tiletype.nonpc then
|
||||
if rnd(10)<8 then
|
||||
elalien.update=elalien.update_jumping
|
||||
elalien.step=0
|
||||
else
|
||||
elalien.flip=not elalien.flip
|
||||
end
|
||||
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)<tiletype.half then
|
||||
if elalien.flip then
|
||||
elalien.x=elalien.x-2
|
||||
@@ -41,7 +48,9 @@ function elalien.update_normal()
|
||||
elalien.x=84
|
||||
end
|
||||
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+6)<tiletype.half then
|
||||
if rnd(2)==0 then
|
||||
local r=rnd(2)
|
||||
if check_tile(elalien.hab,elalien.x+inc,elalien.y+14)==tiletype.block then r=0 end
|
||||
if r==0 then
|
||||
elalien.update=elalien.update_jumping
|
||||
elalien.step=0
|
||||
else
|
||||
@@ -63,8 +72,10 @@ function elalien.update_normal()
|
||||
--end
|
||||
end
|
||||
|
||||
if check_tile(elalien.hab,elalien.x+6,elalien.y+8)==tiletype.stair and elalien.stairscooldown==0 then
|
||||
if rnd(10)<3 then
|
||||
if elalien.stairscooldown==0 and
|
||||
check_tile(elalien.hab,elalien.x+6,elalien.y+8)==tiletype.stair and
|
||||
check_tile(elalien.hab,elalien.x+14,elalien.y+8)==tiletype.stair then
|
||||
if rnd(10)<6 then
|
||||
elalien.update=elalien.update_stairs
|
||||
if check_tile(elalien.hab,elalien.x+4,elalien.y+16)==tiletype.block then
|
||||
elalien.goup=true
|
||||
@@ -83,11 +94,13 @@ function elalien.update_normal()
|
||||
|
||||
if check_tile(elalien.hab,elalien.x+4,elalien.y+16)==tiletype.void and ((elalien.x+4)&7==0 or check_tile(elalien.hab,elalien.x+12,elalien.y+16)==tiletype.void) then
|
||||
local option=rnd(10)
|
||||
if elalien.stairscooldown>0 then option=0 end
|
||||
if option<5 then
|
||||
elalien.update=elalien.update_falling
|
||||
elseif option<8 then
|
||||
elalien.update=elalien.update_jumping
|
||||
elalien.step=0
|
||||
elalien.wait=0
|
||||
else
|
||||
elalien.flip=not elalien.flip
|
||||
end
|
||||
@@ -112,14 +125,14 @@ function elalien.update_jumping()
|
||||
elalien.frame=9
|
||||
elalien.wait=elalien.wait+1
|
||||
|
||||
if elalien.wait==6 then
|
||||
if elalien.wait>=6 then
|
||||
elalien.wait=0
|
||||
|
||||
local inc=12 if elalien.flip then inc=2 end
|
||||
if not elalien.flip and elalien.x==84 then
|
||||
elalien.hab=elalien.hab+1
|
||||
elalien.x=-4
|
||||
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)<tiletype.half and check_tile(elalien.hab,elalien.x+inc,elalien.y+16)~=tiletype.void then
|
||||
elseif check_tile(elalien.hab,elalien.x+inc,elalien.y+14)<tiletype.half then
|
||||
if elalien.flip then
|
||||
elalien.x=elalien.x-2
|
||||
else
|
||||
@@ -154,7 +167,7 @@ function elalien.update_falling()
|
||||
elalien.frame=9
|
||||
elalien.wait=elalien.wait+1
|
||||
|
||||
if elalien.wait==6 then
|
||||
if elalien.wait>=6 then
|
||||
elalien.wait=0
|
||||
|
||||
local inc=12 if elalien.flip then inc=2 end
|
||||
@@ -193,7 +206,7 @@ function elalien.update_stairs()
|
||||
elalien.frame=11
|
||||
elalien.wait=elalien.wait+1
|
||||
|
||||
if elalien.wait==6 then
|
||||
if elalien.wait>=6 then
|
||||
elalien.wait=0
|
||||
|
||||
--if btn(KEY_RIGHT) then
|
||||
|
||||
Reference in New Issue
Block a user