offset NPC155
#define
npc.shotcount = [ecx+18]
npc.shotset = [ecx+1C]
sprite_width = 17
sprite_heigth = 17
L_framerect_distance = 0
U_framerect_distance = 2E
SinVar = [EBP-08]
CosVar = [EBP-0C]
Inital_wait_time = 20 //between shots fired
shot_break = 5
shot_break_rapid = 2
Fire_sound = 1
Charge_sound = 23
Cooldown_time = 78
#enddefine
push ebp ;This starts the code
mov ebp, esp
sub esp, C
setpointer
mov eax, npc.scriptstate
jmp [eax*4+:StateTable]
cmp npc.scriptstate, 2
je :rapid_fire
cmp npc.scriptstate, 1
je :state_firing
:State_wait
inc npc.scripttimer
cmp npc.scripttimer, Inital_wait_time
jl :render
xor eax eax
mov npc.scripttimer, eax
mov npc.scriptstate, 1
:state_firing
mov npc.framenum, 1
inc npc.objecttimer
cmp npc.objecttimer, shot_break
jl :render
xor eax eax
mov npc.objecttimer, eax
:proj_create
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 BYTE PTR SS:[EBP-1],AL
MOV DL,BYTE PTR SS:[EBP-1]
PUSH EDX
CALL 004258B0 //sin table
ADD ESP,4
SHL EAX,2 //2
MOV SinVar EAX
MOV AL,BYTE PTR SS:[EBP-1]
PUSH EAX
CALL 004258C0 //Cos table
ADD ESP,4
SHL EAX,2
MOV CosVar,EAX
setpointer
push 100
push 0
push 0
MOV eax SinVar
MOV edx CosVar
push eax //VElsY
push edx //velsX
mov eax, npc.X
mov edx, npc.Y
push edx
push eax
push 9C
call 46efd0 ;create npc function
add esp,20
push 1
push Fire_sound
call playsound
setpointer
cmp npc.scriptstate, 2
je :shot_done_rapid
inc npc.shotcount
cmp npc.shotcount, 4
jl :render
mov npc.shotcount, 0
//shoot_over
xor eax eax
mov npc.scriptstate, eax
mov npc.framenum, eax
inc npc.shotset
cmp npc.shotset, 4
jg :rapid_shot_setup
xor eax eax
mov npc.scriptstate, eax
mov npc.framenum, eax
jmp :render
:rapid_shot_setup
mov npc.scriptstate, 2
mov npc.framenum, 2
push 1
push Charge_sound
call playsound
add esp, 8
setpointer
jmp :render
:rapid_fire
inc npc.directive
cmp npc.directive, 20
jl :render
inc npc.objecttimer
cmp npc.objecttimer, shot_break_rapid
jl :render
xor eax eax
mov npc.objecttimer, eax
jmp :proj_create
:shot_done_rapid
inc npc.shotcount
cmp npc.shotcount, 8
jl :render
mov npc.shotcount, 0
mov npc.scriptstate, 3
jmp :render
:state_cooldown
inc npc.frametimer
cmp npc.frametimer, Cooldown_time
jl :render
xor eax eax
mov npc.scriptstate, eax
mov npc.frametimer, eax
mov npc.shotset, eax
mov npc.directive, eax
:render
xor eax, eax
mov eax,npc.framenum
imul al, al, sprite_width
mov npc.DisplayL,eax
add eax, sprite_width
mov npc.displayR,eax
mov eax, U_framerect_distance
cmp npc.direction, 2
jne :render_left
add eax sprite_heigth
:render_left
mov npc.displayU,eax
add eax,sprite_heigth
mov npc.displayD,eax
:end_of_code
mov esp, ebp
pop ebp
retn
:StateTable
print :State_wait
print :state_firing
print :rapid_fire
print :state_cooldown