Level Modifier
Run the script during a (non-spell) attack animation. Start it at the first character of "Enemy is defeated!" Let the script run, unpause, then select the level up. If distance is longer than the # of characters in "nemy is defeated", the script will fail.
[code lua]
target =11365 ;
LEVEL = 0xFF9C9D;
START = savestate.create();
local buttonmap = {[1]='up',[2]='down',[4]='left',[8]='right',[16]='B',[32]='C',[64]='A',[128]='start'}
TURN_COUNT = 0xFF9C07;
TURN_PLACE = 0xFF9C08;
RNG = 0xFF0EC2;
STAT_HEX = {0xFF9C9E, 0xFF9C9F, 0xFF9CA0, 0xFF9CA5, 0xFF9CA8,0xFF9CA2};
MAPPLAYER = 0xFFA1B6;
savestate.save(START);
--Get all RNG values up to location, figure out # of changes.
framecnt = 0;
RNG_Move_Type = {};
RNG_EX = 0;
currchar = memory.readbyte(MAPPLAYER + 16*memory.readbyte(TURN_PLACE + 2*memory.readbyte(TURN_COUNT)));
currlev = memory.readbyte(40*currchar + LEVEL);
ZeroCheck = 27751;
ZeroResult = 12975;
last_RNG = memory.readword(RNG);
start_RNG = memory.readword(RNG);
currstats = {};
for i = 1,6,1 do
currstats = memory.readbyte(STAT_HEX + currchar*40);
memory.writebyte(STAT_HEX + currchar*40,0);
end;
joypad.set(1,{up=true});
gens.emulateframefast();
done = false;
print('Finding Level Up');
while not done do
framecnt = framecnt+1;
memory.writeword(RNG,ZeroCheck);
joypad.set(1,{up=true});
gens.emulateframefast();
if memory.readbyte(40*currchar + LEVEL) == currlev+1 then
done = true;
end;
end
stats = {};
max_stats = {};
min_stats = {};
for i = 1,6,1 do
stats = memory.readbyte(STAT_HEX + currchar*40);
max_stats = math.max(math.min(math.floor(stats/4),5)-1,0) + stats;
min_stats = math.max(-1*math.min(math.floor(stats/4),4) + stats, currstats);
end;
done = false
currcolor = 1;
ccount = 0;
currloc = 1;
plusr = true;
minusr = true;
leftr = true;
rightr = true;
savestate.load(START);
colors = {'white','gray','black'};
while not done do
input_state = input.get();
gens.frameadvance();
gui.text(10,50, ' ATT DEF AGI HP MP CRIT');
gui.text(10,60,string.format('MAX: %02d %02d %02d %02d %02d %02d', max_stats[1], max_stats[2], max_stats[3], max_stats[4], max_stats[5], max_stats[6]));
gui.text(6,70,string.format('CURR: %02d %02d %02d %02d %02d %02d', currstats[1], currstats[2], currstats[3], currstats[4], currstats[5], currstats[6]));
gui.text(10,80,string.format('MIN: %02d %02d %02d %02d %02d %02d', min_stats[1], min_stats[2], min_stats[3], min_stats[4], min_stats[5], min_stats[6]));
gui.text(currloc*24+18,70,'<-');
if input_state.enter then
done = true;
end;
if input_state.numpad8 and plusr then
plusr = false;
currstats[currloc] = math.min((currstats[currloc] + 1), max_stats[currloc]);
end;
if input_state.numpad2 and minusr then
minusr = false;
currstats[currloc] = math.max((currstats[currloc] - 1), min_stats[currloc]);
end;
if input_state.numpad4 and leftr then
leftr = false;
currloc = math.max(currloc-1,1);
end;
if input_state.numpad6 and rightr then
rightr = false;
currloc = math.min(currloc+1,6);
end;
if (not input_state.numpad8) then
plusr = true;
end;
if (not input_state.numpad2) then
minusr = true;
end;
if (not input_state.numpad6) then
rightr = true;
end;
if (not input_state.numpad4) then
leftr = true;
end;
end;
start_RNG = start_RNG - framecnt;
destat = {};
offst = {};
for i = 1,6,1 do
destat = currstats - stats;
offst = max_stats - stats;
end;
i = start_RNG-255;
done = false;
while not done do
x = i;
fail = false
for z=1,6,1 do
x = math.mod((x*13 + 7),65536);
Y1 = math.floor(x*(offst[z]+1)/65536);
x = math.mod((x*13 + 7),65536);
Y2 = math.floor(x*(1+offst[z])/65536);
Y = Y1 - Y2;
if (Y + stats[z]) < math.min(min_stats[z]) then
Y = 0;
end;
if Y ~= destat[z] then
fail = true;
end;
end;
if not fail then
target = i;
done = true;
else
i = i - 1;
if i < 0 then
i = 65536;
end;
end;
end;
print(string.format("Target: %d Distance: %d",target,math.floor((start_RNG-target)/255)));
savestate.load(START);
for i = 1,framecnt-1,1 do
if memory.readword(RNG)-target < (framecnt-i)+255 then
joypad.set(1,{up=true});
end;
gens.emulateframefast();
end;
temp = memory.readword(RNG)-target;
for bit,button in pairs(buttonmap) do
if AND(temp,bit) ~= 0 then
joypad.set({[button]=true})
end
end
gens.emulateframefast();
gens.emulateframefast();
gens.emulateframefast();
test = 1;
for i = 1,6,1 do
if (currstats ~= memory.readbyte(STAT_HEX + currchar*40)) then
test = 0;
end;
end;
if (test == 0)then
print("Normal method failed - Trying secondary");
savestate.load(START);
for i = 1,framecnt-1,1 do
if memory.readword(RNG)-(target-255) < (framecnt-i)+255 then
joypad.set(1,{up=true});
end;
gens.emulateframefast();
end;
temp = memory.readword(RNG)-target;
for bit,button in pairs(buttonmap) do
if AND(temp,bit) ~= 0 then
joypad.set({[button]=true})
end
end;
test = 1;
gens.emulateframefast();
gens.emulateframefast();
gens.emulateframefast();
test = 1;
for i = 1,6,1 do
if (currstats ~= memory.readbyte(STAT_HEX + currchar*40)) then
test = 0;
end;
end;
end
if (test==0) then
print('Level up failed');
end;
gens.pause();
[/code]
Move Character
A fun script that allows you to move characters around the battlefield. The top 2 numbers tell you the X and Y position of a character. The bottom numbers are Character Position in the current battle order, and that characters assigned number in the Battle. Also, [ and ] move a selected character around in the battle order.
[code lua]
CamPosX =0xFF9C48;
CamPosY =0xFF9C49;
Alive = 0xFFA1B6;
LocX = 0xFFA1B7;
LocY = 0xFFA1B8;
OL = 0xFF9C08;
SizeX = 24;
SizeY = 24;
Holding = false;
leftclickrelease = true;
lbrelease = true;
lbrelease = true;
gens.registerbefore(function()
CamX = memory.readbyte(CamPosX);
CamY = memory.readbyte(CamPosY);
OnScreen = {};
PosX = {};
PosY = {};
Ord = {};
for n = 0,31,1 do
Ord[memory.readbyte(OL+n*2)] = n;
end;
i=0;
for c = 0,31,1 do
if memory.readbyte(Alive+c*16) ~= 255 then
X = memory.readbyte(LocX+c*16);
Y = memory.readbyte(LocY+c*16);
if ((X > CamX-1) and (X < CamX+11) and (Y > CamY-1) and (Y < CamY+10)) then
i = i+1;
OnScreen = c;
PosX = (X-CamX)*SizeX-4;
PosY = (Y-CamY)*SizeY+7;
gui.drawbox(PosX,PosY,PosX+SizeX,PosY-SizeY,"clear","white")
gui.text(PosX+3,PosY-8,string.format("%d %d",c,Ord[c]));
gui.text(PosX+3,PosY-21,string.format("%d %d",X,Y));
end;
end;
end;
input_state = input.get();
xmouse = input_state.xmouse+1;
ymouse = input_state.ymouse+1;
Mx = math.floor((xmouse+4)/SizeX)+CamX;
My = math.floor((ymouse-7)/SizeY)+CamY+1;
MDx = (Mx-CamX)*SizeX-4;
MDy = (My-CamY)*SizeY+7;
if ((xmouse > 0) and (xmouse < 320) and (ymouse > 0) and (ymouse < 224)) then
if (not Holding) then
gui.drawbox(MDx,MDy,MDx+SizeX,MDy-SizeY,"opaque","black")
if (input_state.leftclick) and leftclickrelease then
leftclickrelease = false;
for m = 1,i,1 do
if ((xmouse>=PosX[m]) and (xmouse<=PosX[m]+SizeX) and (ymouse<=PosY[m]) and (ymouse>=PosY[m]-SizeY)) then
Holding=true;
CharHold = OnScreen[m];
CharOrd = Ord[CharHold];
end;
end;
end;
elseif (Holding) then
gui.drawbox(MDx,MDy,MDx+SizeX,MDy-SizeY,"opaque","red")
memory.writebyte(LocX+CharHold*16,Mx);
memory.writebyte(LocY+CharHold*16,My);
if (input_state.leftbracket) and (CharOrd > 0) and lbrelease then
lbrelease = false;
temp = memory.readbyte(OL+CharOrd*2-2);
memory.writebyte(OL+CharOrd*2-2,CharHold);
memory.writebyte(OL+CharOrd*2,temp);
CharOrd = CharOrd-1;
end;
if (input_state.rightbracket) and (CharOrd < 31) and rbrelease then
rbrelease = false;
temp = memory.readbyte(OL+CharOrd*2+2);
memory.writebyte(OL+CharOrd*2+2,CharHold);
memory.writebyte(OL+CharOrd*2,temp);
CharOrd = CharOrd+1;
end;
if (input_state.leftclick) and leftclickrelease then
leftclickrelease = false;
Holding = false;
end;
end;
end;
if (not input_state.leftclick) then
leftclickrelease = true;
end;
if (not input_state.leftbracket) then
lbrelease = true;
end;
if (not input_state.rightbracket) then
rbrelease = true;
end;
end);
[/code]
Sage advice from a friend of Jim: So put your tinfoil hat back in the closet, open your eyes to the truth, and realize that the government is in fact causing austismal cancer with it's 9/11 fluoride vaccinations of your water supply.