"""Guarded Hard attack decisions; native pass/shot execution remains in place."""
ORIGIN=0x2D8800

def install(data,assemble,patch):
    code=assemble('ai_attack',ORIGIN)
    assert len(code)<=0x480,'attack overlaps native keeper season accounting at2D8C80'
    patch(ORIGIN,b'\xff'*len(code),code)
    def jump(addr,old,entry):patch(addr,bytes.fromhex(old),b'\x4e\xf9'+(ORIGIN+entry).to_bytes(4,'big')+b'\x4e\x71')
    jump(0xD1DE,'41fa13b4600031e4',0)
    jump(0xD3BE,'41fa11d460003004',0)
    patch(0xE45E,bytes.fromhex('700661002c24'),b'\x4e\xb9'+(ORIGIN+4).to_bytes(4,'big'))
    patch(0xE292,bytes.fromhex('61d06600004e'),b'\x4e\xf9'+(ORIGIN+8).to_bytes(4,'big'))
