User File #32172435570358461

Upload All User Files

#32172435570358461 - DW4-ManipMiss

DW4-ManipMiss.lua
1176 downloads
Uploaded 7/10/2016 9:02 PM by adelikat (see all 20)
Similar to the ManipCritical file except it is used to manipulate the enemy to miss
-----------------
-- Settings
-----------------
_wait3 = 0;
_wait2 = 0; --47;
_wait1 = 24; --28;

_odds = 65;
hpAddr = 0x6098;
reportFrequency = 1; -- How many attempts before it logs a result
-------------------------
local c = require("DW4-ManipCore");
c.InitSession();

originalHP = memory.readbyte(hpAddr);
origNexts = memory.readbyte(0x00FD);

while not c.done do
	_maxDelay = math.floor(c.attempts / _odds);
	if (_maxDelay > 18) then _maxDelay = 18 end
	savestate.loadslot(0);
	delay = 0;

	-- Loop
	--------------------------------------
	if (_wait3 > 0) then
		delay = delay + c.DelayUpTo(_maxDelay);	
		c.RndAtLeastOne();
		c.RandomFor(_wait3 - 2)
		c.WaitFor(2);
	end

	if (_wait2 > 0) then
		delay = delay + c.DelayUpTo(_maxDelay);	
		c.RndAtLeastOne();
		c.RandomFor(_wait2 - 2)
		c.WaitFor(2);
	end

	delay = delay + c.DelayUpTo(_maxDelay);	
	c.RndAtLeastOne();	
	c.RandomFor(_wait1 - 2);
	c.WaitFor(2);

	action = memory.readbyte(0x008B);

	c.RndAtLeastOne();	
	c.RandomFor(2);
	c.WaitFor(50); -- Ensure damage is calculated and in memory

	c.attempts = c.attempts + 1;

	-- Eval
	--------------------------------------
	newHP = memory.readbyte(hpAddr);
	nexts = memory.readbyte(0x00FD);
	--turn = memory.readbyte(0x0096);

	if newHP == originalHP
	if newHP == 38
	 then
		c.done = true;
	end
	
	dmg = originalHP - newHP;

	c.LogProgress(c.done, c.attempts, delay, 'newHP: ' .. newHP .. ' action: ' .. action);

	--------------------------------------
end

c.Finish();