Jan 9, 2016 at 4:58 PM
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1640
Age: 27
Pronouns: he/him
@Thomas Xin
NPC's treat slopes kinda weird because how their collision is different from the player, but here you go:
it works on, but doesn't like slopes very well.
E: well apparently I only read half of your post; welp
NPC's treat slopes kinda weird because how their collision is different from the player, but here you go:
Code:
offset NPC---
#define
L_framerect_distance = 0
U_framerect_distance = 10
sprite_width = 10
sprite_heigth = 10
#enddefine
push ebp
mov ebp, esp
sub esp, 10
mov dword [EBP-10],0
mov dword [EBP-C],0
mov dword [EBP-8],0
mov dword [EBP-4],0
setpointer
;----------------------------------------
cmp npc.scriptstate, 1
je :velXset
mov eax npc.EntityID
imul eax eax 10
mov npc.moveX, eax
mov npc.scriptstate, 1
:velXset
add npc.moveY, 3FF
mov edx, npc.collision
and edx, 5
je :no_hit_wall
inc npc.scripttimer
cmp npc.scripttimer, 3
jl :not_yet
neg npc.moveX
mov npc.scripttimer, 0
jmp :no_hit_wall
:not_yet
add npc.Y -F00
mov npc.moveY, 0
:no_hit_wall
;----------------------------------------
:add_vels
mov eax, npc.moveX
mov edx, npc.moveY
add npc.X eax
add npc.Y edx
inc npc.frametimer
cmp npc.frametimer, A
jl :render
mov npc.frametimer, 0
cmp npc.framenum, 1
je :2_0
inc npc.framenum
jmp :render
:2_0
mov npc.framenum, 0
: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
mov npc.displayU,eax
add eax,sprite_heigth
mov npc.displayD,eax
:end_of_code
mov esp, ebp
pop ebp
retn
it works on, but doesn't like slopes very well.
E: well apparently I only read half of your post; welp