Skip to content

Commit

Permalink
Add toggles for immortality and infinite spell charges
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingnesses committed Sep 6, 2022
1 parent 225c0c7 commit 89dfd9d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
47 changes: 47 additions & 0 deletions data/hax/cheatgui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,45 @@ for i = 1, 5 do
end
table.insert(wand_options, {"Haxx", wrap_spawn("data/hax/wand_hax.xml")})

local immortality_on = false
local immortality_component_id
local function toggle_immortality()
immortality_on = not immortality_on
local player = get_player()
if immortality_on then
immortality_component_id = EntityAddComponent2(player, "LuaComponent", {
execute_on_added="1",
remove_after_executed="0",
execute_every_n_frame="1",
script_source_file="mods/cheatgui/data/hax/immortality.lua",
})
-- Player is vulnerable when polymorphed, so prevent it.
EntityAddTag(player, "polymorphable_NOT")
else
EntityRemoveComponent(player, immortality_component_id)
EntityRemoveTag(player, "polymorphable_NOT")
end
GamePrint("Immortality: " .. tostring(immortality_on))
end

local infinite_charges_on = false
local infinite_charges_component_id
local function toggle_infinite_charges()
infinite_charges_on = not infinite_charges_on
local player = get_player()
if infinite_charges_on then
infinite_charges_component_id = EntityAddComponent2(player, "LuaComponent", {
execute_on_added="1",
remove_after_executed="0",
execute_every_n_frame="1",
script_source_file="mods/cheatgui/data/hax/refresh.lua",
})
else
EntityRemoveComponent(player, infinite_charges_component_id)
end
GamePrint("Infinite charges: " .. tostring(infinite_charges_on))
end

local tourist_mode_on = false
local function toggle_tourist_mode()
tourist_mode_on = not tourist_mode_on
Expand Down Expand Up @@ -1054,8 +1093,16 @@ register_cheat_button("[spell refresh]", function()
GameRegenItemActionsInPlayer(get_player())
end)

register_cheat_button(function()
return "[" .. ((infinite_charges_on and "disable") or "enable") .. " infinite charges]"
end, toggle_infinite_charges)

register_cheat_button("[full heal]", function() quick_heal() end)

register_cheat_button(function()
return "[" .. ((immortality_on and "disable") or "enable") .. " immortality]"
end, toggle_immortality)

register_cheat_button("[end fungal trip]", function()
EntityRemoveIngestionStatusEffect(get_player(), "TRIP" )
end)
Expand Down
1 change: 1 addition & 0 deletions data/hax/immortality.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ComponentSetValue2(EntityGetComponent(EntityGetWithTag("player_unit")[1], "DamageModelComponent")[1], "invincibility_frames", 2)
1 change: 1 addition & 0 deletions data/hax/refresh.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GameRegenItemActionsInPlayer(EntityGetWithTag("player_unit")[1])

0 comments on commit 89dfd9d

Please sign in to comment.