import { Enemies } from @zelda1:enemies/octorok; import { Link, LinkCombatChecks } from @zelda1:link; import { Stage } from @zelda1:stage; import { Inventory } from @zelda1:inventory; import { WorldFlags } from @zelda1:world; import { Loot } from @zelda1:loot; declare global test_rock: Rock = new Rock(0,0,0,0,0); declare global enemy_check_failures: int = 0; declare global enemy_check_count: int = 0; declare service EnemyCombatChecks { fn check(passed: bool) -> void { enemy_check_count+=1; if !passed { enemy_check_failures+=1; } } fn bounce_case(facing: int, incoming: int, dx: int, dy: int) -> void { Inventory.reset(); LinkCombatChecks.place(120,141,facing); let x=120; let y=141; if incoming==1 { x-=6; } else if incoming==2 { x+=6; } else if incoming==4 { y-=6; } else { y+=6; } test_rock.launch(x,y,incoming); test_rock.update(); EnemyCombatChecks.check(test_rock.direction!=0 && test_rock.bounce==facing && test_rock.distance==0); x=test_rock.x; y=test_rock.y; test_rock.update(); EnemyCombatChecks.check(test_rock.x==x+dx && test_rock.y==y+dy && test_rock.distance==2); for tick: int from 0 until 14 { test_rock.update(); } EnemyCombatChecks.check(test_rock.direction!=0 && test_rock.distance==30); test_rock.update(); EnemyCombatChecks.check(test_rock.direction==0); let partial=Inventory.read_slot(25); EnemyCombatChecks.check(partial==255); } fn run() -> int { Stage.reset(); EnemyCombatChecks.bounce_case(8,4,1,-2); EnemyCombatChecks.bounce_case(4,8,-1,2); EnemyCombatChecks.bounce_case(2,1,-2,-1); EnemyCombatChecks.bounce_case(1,2,2,-1); Inventory.reset(); LinkCombatChecks.place(120,141,8); test_rock.launch(120,147,8); test_rock.update(); let partial=Inventory.read_slot(25); EnemyCombatChecks.check(partial==127 && test_rock.direction==0); test_rock.launch(120,147,8); test_rock.update(); partial=Inventory.read_slot(25); EnemyCombatChecks.check(partial==127 && test_rock.direction!=0); // Visit the northern stage with the player at its actual entrance. Inventory.reset(); WorldFlags.reset(); Enemies.reset(); Loot.reset(); Stage.reset(); Link.start_game(); let command=Stage.advance(120,61,8,0,0,false,true); for tick: int from 0 until 44 { command=Stage.advance(120,61,8,0,0,false,false); } command=Stage.advance(120,221,8,0,0,false,false); LinkCombatChecks.place(120,221,8); Enemies.update(); let alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==4); EnemyCombatChecks.check(e0.x==80 && e0.y==93 && e1.x==80 && e1.y==157); // A completed death advances room/cycle/drop; leaving clears the drop. e0.hp=0; e0.dying=0; Loot.monster_killed(1); Enemies.update(); alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==3 && room_killed==1 && loot0.id==24); WorldFlags.mark_room_item_taken(103); Enemies.leave_room(); EnemyCombatChecks.check(loot0.id<0); let count=WorldFlags.kill_count(103); EnemyCombatChecks.check(count==1); Enemies.update(); alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==3 && e3.hp<0 && e3.dying==0); // Killing the remaining three keeps the room empty on immediate reentry. e0.hp=0; e0.dying=0; e1.hp=0; e1.dying=0; e2.hp=0; e2.dying=0; Enemies.update(); Enemies.leave_room(); count=WorldFlags.kill_count(103); EnemyCombatChecks.check(count==7); Enemies.update(); alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==0); let taken=WorldFlags.room_item_taken(103); EnemyCombatChecks.check(taken); WorldFlags.clear_history(); Enemies.abandon_room(); Enemies.update(); alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==4); // Death abandons this visit; it does not save its in-room kill count. e0.hp=0; e0.dying=0; Enemies.update(); Enemies.abandon_room(); Enemies.update(); alive=Enemies.alive_count(); EnemyCombatChecks.check(alive==4); Enemies.abandon_room(); return enemy_check_failures; } fn count() -> int { return enemy_check_count; } fn draw_bounces(clock: int) -> void { for col: int from 0 until 4 { let facing=if col==0 { 8 } else if col==1 { 4 } else if col==2 { 2 } else { 1 }; test_rock.launch(48+col*48,208,1); test_rock.bounce=facing; for tick: int from 0 until clock%16 { test_rock.update(); } test_rock.draw(); } } }