diff --git a/examples/death_warp.lua b/examples/death_warp.lua new file mode 100644 index 000000000..d27432202 --- /dev/null +++ b/examples/death_warp.lua @@ -0,0 +1,19 @@ +meta.name = 'Death warp' +meta.version = 'WIP' +meta.description = 'Automatic instant restart on death.' +meta.author = 'Dregu' + +-- actually instant restart on death +set_callback(function() + if state.screen ~= 12 then + return + end + local hp = 0 + for i, player in ipairs(players) do + hp = hp + player.health + end + if hp == 0 then + state.quest_flags = set_flag(state.quest_flags, 1) + warp(state.world_start, state.level_start, state.theme_start) + end +end, ON.FRAME) diff --git a/src/injected/ui.cpp b/src/injected/ui.cpp index 0e04531f6..b32436424 100644 --- a/src/injected/ui.cpp +++ b/src/injected/ui.cpp @@ -1748,6 +1748,11 @@ void render_narnia() if (ImGui::DragScalar("Level##WarpLevel", ImGuiDataType_U8, &g_level, 0.1f, &u8_one, &u8_four)) {} render_themes(); ImGui::PopItemWidth(); + if (ImGui::Button("Instant warp##InstantWarp")) + { + warp(g_world, g_level, g_to + 1); + } + ImGui::SameLine(); if (ImGui::Button("Warp door##SpawnWarpDoor")) { int spawned = spawn_door(g_x, g_y, g_world, g_level, g_to + 1); @@ -1759,11 +1764,6 @@ void render_narnia() { spawn_backdoor(g_x, g_y); } - ImGui::SameLine(); - if (ImGui::Button("Warp##InstantWarp")) - { - warp(g_world, g_level, g_to + 1); - } ImGui::Text("Instant warp to level:"); std::vector doortypes; doortypes.push_back(to_id("ENT_TYPE_FLOOR_DOOR_EXIT"));