;ANP 0001 = start attacking player
;ANP 0007 = dead
offset NPC276
#define
npc.jump=[ecx+1C]
npc.directionhandler = [ecx+18]
localvar1 = [EBP-14]
localvar2 = [EBP-18]
localvar3 = [EBP-1C]
TPcool = edit these to your likings
jumpheight = 500
jumplength = 300
L_framerect_distance = 0
U_framerect_distance = 40
#enddefine
push ebp ;This starts the code
mov ebp, esp
sub esp,14
mov dword [EBP-10],0
mov dword [EBP-C],0
mov dword [EBP-8],0
mov dword [EBP-4],0
setpointer
cmp npc.health, 0
je :statedead
;direction check
mov eax, PlayerXpos
cmp npc.X, eax
jl :face_right
mov npc.direction, 0
jmp :end_direction
:face_right
mov npc.direction, 2
:end_direction
mov eax, npc.scriptstate
jmp [eax*4+:StateTable]
;-----FIRE (ground)-----
:statefire
add npc.y 5FF
mov npc.framenum, 0
inc npc.objecttimer
cmp npc.objecttimer, 15
jge :fireproj
mov npc.framenum, 3
jmp :render
:fireproj
mov npc.framenum, 4
cmp npc.objecttimer, 21
je :create_object
:Fired_proj_ground
cmp npc.objecttimer, 30
jl :render
mov npc.objecttimer, 0
inc npc.scripttimer
push 0
push 7
call RANDOM
add esp, C
setpointer
cmp npc.scripttimer, eax
jge :jump_prep
jmp :render
:create_object
setpointer
push 0
mov edx, npc.y
sub edx, playerypos
push edx
mov edx, npc.x
sub edx,playerxpos
push edx
call 004258e0 ;detects player collision
add esp,8
mov localvar3,eax
mov edx,localvar3
push edx
call 004258b0 ;sin table
add esp,4
shl eax,2
mov localvar2,eax
mov eax, localvar3
push eax
call 004258c0 ;cos table
add esp,4
shl eax,2
mov localvar1,eax
push 100
push 0
push 0
mov ecx, localvar2
push ecx
mov edx, localvar1
push edx
setpointer
mov eax, npc.y
push eax
mov edx, npc.x
push edx
push 115
call 0046efd0
add esp,20
cmp npc.scriptstate, 1
je :Fired_proj_ground
jmp :jump_vel_handler_Y
:jump_prep
mov npc.scriptstate, 3
mov npc.objecttimer, 0
jmp :render
;-----JUMP-----
:statejump1 ;squat before jump
inc npc.objecttimer
cmp npc.objecttimer, 10
jg :statejump2
mov npc.framenum, 2
jmp :render
:Statejump2 ;prep for jump (one frame)
mov npc.framenum 7
mov npc.scriptstate, 5
mov npc.objecttimer, 0
cmp npc.direction, 2
je :right_jump_prep
mov npc.jump, 0
jmp :left_jump_prep
:right_jump_prep
mov npc.jump, 2
:left_jump_prep
jmp :render
;objecttimer = open/close arms timer
;scripttimer = jumping timer
:Statejump3
cmp npc.jump, 2
je :right_jump
add npc.X -jumplength
jmp :left_jump
:right_jump
add npc.X jumplength
:left_jump
inc npc.objecttimer
cmp npc.objecttimer, 10 ;before arms closed
jge :Statejump4
jmp :jump_vel_handler_Y
:Statejump4
mov npc.framenum, 5 ;closed arms
cmp npc.objecttimer, 15
jg :jumpfire
jmp :jump_vel_handler_Y
:jumpfire
mov npc.framenum, 6
cmp npc.objecttimer, 20 ;time between firing
je :create_object
cmp npc.objecttimer, 28
jl :jump_vel_handler_Y
mov npc.scriptstate, 5
mov npc.objecttimer, 0
jmp :jump_vel_handler_Y
:jump_vel_handler_Y
cmp npc.scriptstate, 2
je :render
add npc.scripttimer, 15 ;script timer holds velocitys?
cmp npc.scripttimer, A00
jg :vel_to_high
mov eax, npc.scripttimer
add eax, -jumpheight
add npc.Y, eax
jmp :render
:vel_to_high
cmp npc.collision, 0 ;colliding with something? (need to test values)
jge :done_jump
cmp npc.collision, 20
jg :done_jump
mov eax, A00
add eax, -jumpheight
add npc.Y, eax
jmp :render
:done_jump
mov npc.scriptstate, 2 ;go to state lightning
mov npc.scripttimer, 0
mov npc.objecttimer, 0
jmp :render
:StateLightning
add npc.Y 5ff ;gravity
mov npc.framenum, 3
inc npc.objecttimer
cmp npc.objecttimer 30
je :lightning
jl :render
mov npc.framenum, 4
cmp npc.objecttimer, 60
jl :render
mov npc.scriptstate, 3
jmp :render
:lightning
push 140
push 0
push 0
push 0
push 0
setpointer
mov eax PlayerYPos
push eax
mov eax PlayerXPos
push eax
push 14D
call 46efd0
add esp,20
setpointer
mov npc.scriptstate, 1
jmp :render
:stateDead
;inc npc.scriptstate
;push 0
;push 36
;call PlaySound
;add esp, 8
:statedead2
;gravity
mov npc.framenum, 8
mov npc.flags, 200
mov npc.hitrectL, 0
mov npc.hitrectU, 0
mov npc.hitrectR, -8000
mov npc.hitrectD, -8000
jmp :render
;---------------------
:stateIdle
add npc.y 5FF ;gravity
mov npc.objecttimer, 0
mov npc.framenum, 0
inc npc.frametimer
cmp npc.frametimer, 30 ;breathe check
jl :render
mov npc.framenum, 1
cmp npc.frametimer, 60
jl :render
mov npc.frametimer,0
:render
cmp npc.direction, 2 ;trasfer directon to our variable
je :direction_transfer
mov npc.directionhandler, 0
:direction_transfer
jmp :end_direction_transfer
mov npc.directionhandler, 1
:end_direction_transfer
xor eax, eax ;mov eax L_framerect_distance
mov eax,npc.framenum
imul al, al, 20
mov npc.DisplayL,eax
add eax,20
mov npc.displayR,eax
mov eax, U_framerect_distance
cmp npc.direction, 2
jne :render_left
add eax 28
:render_left
mov npc.displayU,eax
add eax,28
mov npc.displayD,eax
:end_of_code
mov esp, ebp
pop ebp
retn
:StateTable
print :StateIdle ;<ANP0000
print :StateFire
print :StateLightning
print :Statejump1
print :Statejump2
print :Statejump3 ;<ANP0005
print :Statejump4
print :statedead
print :statedead2