Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- this luascript is for analyzing helper kirbys "random transformations" probabilities
- -- go to any room where there is no helper kirby and let this run for hours.
- function text(x, y, text, color, backcolor)
- if backcolor==nil then backcolor=0x00000000 end
- gui.drawText(x, y, text,color,backcolor,10,"Arial")
- end
- local abilityNames= { -- ability, yellow count, red count, green count
- [00] = {"Normal", 0, 0, 0},
- [01] = {"Fire", 0, 0, 0},
- [02] = {"Ice", 0, 0, 0},
- [03] = {"Burning", 0, 0, 0},
- [04] = {"Wheel", 0, 0, 0},
- [05] = {"Parasol", 0, 0, 0},
- [06] = {"Cutter", 0, 0, 0},
- [07] = {"Beam", 0, 0, 0},
- [08] = {"Stone", 0, 0, 0},
- [09] = {"Bomb", 0, 0, 0},
- [10] = {"Throw", 0, 0, 0},
- [11] = {"Sleep", 0, 0, 0},
- [12] = {"Cook", 0, 0, 0},
- [13] = {"Laser", 0, 0, 0},
- [14] = {"UFO", 0, 0, 0},
- [15] = {"Spark", 0, 0, 0},
- [16] = {"Tornado", 0, 0, 0},
- [17] = {"Hammer", 0, 0, 0},
- [18] = {"Sword", 0, 0, 0},
- [19] = {"Cupid", 0, 0, 0},
- [20] = {"Fighter", 0, 0, 0},
- [21] = {"Magic", 0, 0, 0},
- [22] = {"Smash", 0, 0, 0},
- [23] = {"Mini", 0, 0, 0},
- [24] = {"Crash", 0, 0, 0},
- [25] = {"Missile", 0, 0, 0},
- [26] = {"Master", 0, 0, 0}
- }
- local yellow_ability_old = memory.read_u8(0x02118B)
- local red_ability_old = memory.read_u8(0x021333)
- local green_ability_old = memory.read_u8(0x0214DB)
- local yellow_total_count = 0
- local red_total_count = 0
- local green_total_count = 0
- local show_percent = false
- local speed_mode = true
- local left_clicked_frames = 0
- local right_clicked_frames = 0
- local projected_framecount = 0
- local seeking = false
- local seek_step = 300
- local next_screenshot_frame = 5000
- local next_screenshot_step = 500000
- client.SetGameExtraPadding(0,100,240,100)
- memory.usememorydomain("EWRAM")
- event.onexit(function()
- client.SetGameExtraPadding(0,0,0,0)
- console.clear()
- end)
- while true do
- --check new ability
- local yellow_ability = memory.read_u8(0x02118B)
- local red_ability = memory.read_u8(0x021333)
- local green_ability = memory.read_u8(0x0214DB)
- local check_value = memory.read_u8(0x022953) -- zero when resetting and on the menu, nonzero when ingame
- --process new ability
- if check_value > 0 then
- if yellow_ability ~= yellow_ability_old and yellow_ability < 27 then
- if yellow_ability ~= 0 then
- abilityNames[yellow_ability][2] = abilityNames[yellow_ability][2] + 1
- yellow_total_count = yellow_total_count + 1
- end
- end
- if red_ability ~= red_ability_old and red_ability < 27 then
- if red_ability ~= 0 then
- abilityNames[red_ability][3] = abilityNames[red_ability][3] + 1
- red_total_count = red_total_count + 1
- end
- end
- if green_ability ~= green_ability_old and green_ability < 27 then
- if green_ability ~= 0 then
- abilityNames[green_ability][4] = abilityNames[green_ability][4] + 1
- green_total_count = green_total_count + 1
- end
- end
- end
- -- toggle view on click
- if input.getmouse().Left then
- left_clicked_frames = left_clicked_frames + 1
- else
- left_clicked_frames = 0
- end
- if left_clicked_frames == 1 then
- show_percent = not show_percent
- end
- -- toggle speed mode
- if input.getmouse().Middle then
- right_clicked_frames = right_clicked_frames + 1
- else
- right_clicked_frames = 0
- end
- if right_clicked_frames == 1 then
- speed_mode = not speed_mode
- end
- if speed_mode and not seeking then
- projected_framecount = emu.framecount() + seek_step
- client.seekframe(projected_framecount)
- seeking = true
- end
- if speed_mode and seeking then
- if emu.framecount() >= projected_framecount then
- seeking = false
- end
- end
- --screenshot every once in a while in case emu crashes overnight, i want to see the results..
- if emu.framecount() > next_screenshot_frame then
- next_screenshot_frame = next_screenshot_frame + next_screenshot_step
- client.screenshot("HELPER_ANALYSE_ABILITY_GET_" .. emu.framecount() .. ".png")
- print("i did screenshot")
- end
- --text on screen
- local abilities = ""
- local yellow_count = ""
- local red_count = ""
- local green_count = ""
- local yellow_percent = 0
- local red_percent = 0
- local green_percent = 0
- for i=1, #abilityNames do
- abilities = abilities .. abilityNames[i][1] .. "\n"
- if show_percent then
- if yellow_total_count == 0 then
- yellow_percent = 0
- else
- yellow_percent = 100 * (abilityNames[i][2] / yellow_total_count)
- end
- if red_total_count == 0 then
- red_percent = 0
- else
- red_percent = 100 * (abilityNames[i][3] / red_total_count)
- end
- if green_total_count == 0 then
- green_percent = 0
- else
- green_percent = 100 * (abilityNames[i][4] / green_total_count )
- end
- yellow_count = yellow_count .. math.floor(yellow_percent) .. "%\n"
- red_count = red_count .. math.floor(red_percent) .. "%\n"
- green_count = green_count .. math.floor(green_percent) .. "%\n"
- else
- yellow_count = yellow_count .. abilityNames[i][2] .. "\n"
- red_count = red_count .. abilityNames[i][3] .. "\n"
- green_count = green_count .. abilityNames[i][4] .. "\n"
- end
- -- last
- if i == #abilityNames then
- abilities = abilities .. "TOTAL: "
- yellow_count = yellow_count .. yellow_total_count
- red_count = red_count .. red_total_count
- green_count = green_count .. green_total_count
- end
- end
- if show_percent then
- text(20,20,"Left Click to show transformation counts.", 0xFFFFFFFF)
- else
- text(20,20,"Left Click to show percentages.", 0xFFFFFFFF)
- end
- if speed_mode then
- text(20,40,"Middle Click for normal speed.", 0xFFFFFFFF)
- else
- text(20,40,"Middle Click for high speed.", 0xFFFFFFFF)
- end
- text(260,0,abilities, 0xFFFFFFFF)
- text(300,0,yellow_count,0xFFFFFF00)
- text(340,0,red_count, 0xFFFF0000)
- text(380,0,green_count, 0xFF00FF00)
- --update old ability
- yellow_ability_old = yellow_ability
- red_ability_old = red_ability
- green_ability_old = green_ability
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement