KAZIK/tools/tests/npc_life_test.inc
Artvasil09 881a0061dc Add native NPC visitors with contracts, Clover slots, Pyramid, and party table scenes
Implement 32x32 BFS visitor navigation and daily contracts system with companion .npc journals; add native assembly scenes for Clover slots, Pyramid cards, Blackjack Party and Russian Party; package animation and sprite packs; add comprehensive offline test suites and rebuild shipping binaries.
2026-10-13 09:47:33 +03:00

227 lines
5.9 KiB
PHP

.data
npcTestBase1 db "build\arrival\fixtures\npc-one.dat",0
npcTestBase2 db "build\arrival\fixtures\npc-two.dat",0
npcTestJournal1 db "build\arrival\fixtures\npc-one.dat.npc",0
npcTestJournal2 db "build\arrival\fixtures\npc-two.dat.npc",0
npcTestOpenShot db "build\actions\npc-dialog-open.bmp",0
npcTestReadyShot db "build\actions\npc-dialog-ready.bmp",0
npcTestDoneShot db "build\actions\npc-dialog-done.bmp",0
.code
RunNpcLifeTest3D PROC uses ebx esi edi
local oldBank:DWORD,steps:DWORD,identity:DWORD,firstX:DWORD,firstY:DWORD,claimBank:DWORD
mov eax,bankroll
mov oldBank,eax
mov hallTestStage3D,7901
call InitHall3D
xor esi,esi
npc_test_destinations:
invoke NpcPlanPath3D,0,esi
cmp eax,1
jne npc_test_fail
inc esi
cmp esi,NPC_DEST_COUNT
jb npc_test_destinations
mov esi,20
npc_test_rate:
call InitNpcLife3D
mov playerX,30*FP_1+FP_HALF
mov playerY,30*FP_1+FP_HALF
mov edi,1
npc_test_rate_clear_crowd:
imul ebx,edi,SIZEOF NpcLife3D
mov npcLife3D[ebx].state,NPC_AWAY
inc edi
cmp edi,NPC_LIFE_COUNT
jb npc_test_rate_clear_crowd
invoke NpcPlanPath3D,0,5
cmp eax,1
jne npc_test_fail
mov eax,2000
xor edx,edx
div esi
mov steps,eax
npc_test_rate_step:
invoke NpcMove3D,0,esi
dec steps
jnz npc_test_rate_step
mov eax,casinoNpcs3D.posX
mov edx,casinoNpcs3D.posY
cmp esi,20
jne npc_test_rate_compare
mov firstX,eax
mov firstY,edx
mov esi,50
jmp npc_test_rate
npc_test_rate_compare:
cmp eax,firstX
jne npc_test_fail
cmp edx,firstY
jne npc_test_fail
cmp esi,100
je npc_test_routes
mov esi,100
jmp npc_test_rate
npc_test_routes:
mov hallTestStage3D,7902
call InitNpcLife3D
mov deltaTime3D,50
mov steps,2400
npc_test_simulate:
call UpdateNpcLife3D
xor esi,esi
npc_test_person_bounds:
imul ebx,esi,SIZEOF NpcMindEntity
invoke CanWalk3D,casinoNpcs3D[ebx].posX,casinoNpcs3D[ebx].posY
cmp eax,1
jne npc_test_fail
imul edi,esi,SIZEOF NpcLife3D
cmp npcLife3D[edi].state,NPC_AWAY
ja npc_test_fail
cmp npcLife3D[edi].identity,NPC_IDENTITY_COUNT
jae npc_test_fail
cmp npcLife3D[edi].pathCount,NPC_PATH_CAP
ja npc_test_fail
inc esi
cmp esi,NPC_LIFE_COUNT
jb npc_test_person_bounds
dec steps
jnz npc_test_simulate
cmp npcLifeClock3D,120000
jne npc_test_fail
mov hallTestStage3D,7903
invoke DeleteFileA,OFFSET npcTestJournal1
invoke DeleteFileA,OFFSET npcTestJournal2
mov npcJournalBasePtr3D,OFFSET npcTestBase1
mov npcDateOverride3D,20261012
mov npcJournalLoaded3D,0
call NpcEnsureJournal3D
cmp eax,1
jne npc_test_fail
xor esi,esi
npc_test_find_any:
invoke NpcContractType3D,esi
test eax,eax
jz npc_test_accept
inc esi
cmp esi,NPC_IDENTITY_COUNT
jb npc_test_find_any
jmp npc_test_fail
npc_test_accept:
mov identity,esi
invoke NpcRecordRound3D,0,1
cmp npcProgress3D[esi*4],0
jne npc_test_fail
invoke NpcAcceptContract3D,esi
cmp eax,1
jne npc_test_fail
invoke NpcClaimContract3D,esi
test eax,eax
jnz npc_test_fail
; A real legacy graphical settlement contributes once, including repeat protection.
mov skulls3d_state,3
mov skulls3d_choice,0
mov skulls3d_ballPos,0
mov skulls3d_bet,50
call FinalizeSkullsGuess
cmp npcProgress3D[esi*4],1
jne npc_test_fail
mov eax,bankroll
mov claimBank,eax
call FinalizeSkullsGuess
mov eax,claimBank
cmp bankroll,eax
jne npc_test_fail
cmp npcProgress3D[esi*4],1
jne npc_test_fail
invoke NpcRecordRound3D,1,1
invoke NpcRecordRound3D,2,0
invoke NpcRecordRound3D,3,1
cmp npcProgress3D[esi*4],3
jne npc_test_fail
invoke NpcClaimContract3D,esi
cmp eax,1
jne npc_test_fail
mov eax,claimBank
add eax,150
cmp bankroll,eax
jne npc_test_fail
mov npcJournalLoaded3D,0
call NpcEnsureJournal3D
invoke NpcClaimContract3D,identity
test eax,eax
jnz npc_test_fail
mov hallTestStage3D,7904
mov npcJournalBasePtr3D,OFFSET npcTestBase2
call NpcEnsureJournal3D
cmp npcAccepted3D,0
jne npc_test_fail
cmp npcClaimed3D,0
jne npc_test_fail
call InitNpcLife3D
mov playerX,16*FP_1+FP_HALF
mov playerY,18*FP_1+FP_HALF
mov playerAngle,384
call UpdateCamera3D
mov interactTargetId,0
call CheckNpcInteractions3D
cmp interactTargetId,INTERACT_NPC
jne npc_test_fail
cmp npcSelected3D,0
jne npc_test_fail
call TriggerHallInteraction3D
cmp engineMode,MODE_NPC_DIALOG
jne npc_test_fail
call RenderNpcDialog3D
invoke WriteActionSnapshot3D,OFFSET npcTestOpenShot
mov mouseClick3D,1
mov mouseX3D,60
mov mouseY3D,175
call HandleNpcDialog3D
bt npcAccepted3D,0
jnc npc_test_fail
mov ebx,3
npc_test_finish_dialog:
xor esi,esi
npc_test_finish_games:
invoke NpcRecordRound3D,esi,1
inc esi
cmp esi,6
jb npc_test_finish_games
dec ebx
jnz npc_test_finish_dialog
call RenderNpcDialog3D
invoke WriteActionSnapshot3D,OFFSET npcTestReadyShot
mov mouseClick3D,1
mov mouseX3D,145
mov mouseY3D,175
call HandleNpcDialog3D
bt npcClaimed3D,0
jnc npc_test_fail
call RenderNpcDialog3D
invoke WriteActionSnapshot3D,OFFSET npcTestDoneShot
call CardTableEscape3D
cmp eax,1
jne npc_test_fail
cmp engineMode,MODE_WALK
jne npc_test_fail
mov npcDateOverride3D,20261013
call NpcEnsureJournal3D
cmp npcAccepted3D,0
jne npc_test_fail
cmp npcClaimed3D,0
jne npc_test_fail
mov npcAccepted3D,0
mov npcClaimed3D,0
mov npcJournalLoaded3D,0
mov npcDateOverride3D,0
mov npcJournalBasePtr3D,OFFSET npcJournalTestBase3D
mov deltaTime3D,16
mov eax,oldBank
mov bankroll,eax
call ClearKeys3D
xor eax,eax
ret
npc_test_fail:
mov eax,hallTestStage3D
ret
RunNpcLifeTest3D ENDP