diff --git a/README.md b/README.md index fa1e792..6360670 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Minetest can be found online at . ## Important notices and short game guide +* Press Aux1 key to change your jump strength * Be sure the `minetest.conf` file in the main Minetest directory doesn't have any parameters who are in conflict with the `minetest.conf` file from the `hades_revisited` directory. Especially mapgen parameters or stuff like `give_initial_stuff = false` * There only 1 biome, with the focus on terraforming and landscaping * Not everyone will like this game. But maybe there are some freaks out there ;-) diff --git a/mods/hades_movement/init.lua b/mods/hades_movement/init.lua new file mode 100644 index 0000000..c98ffd5 --- /dev/null +++ b/mods/hades_movement/init.lua @@ -0,0 +1,84 @@ +local HIDE_JUMP_HUD_AFTER = 5 -- seconds after which to hide jump HUD +local JUMP_FACTOR_HIGH = 1 +local JUMP_FACTOR_MED = 0.85 +local JUMP_FACTOR_LOW = 0.65 + +local ctrls = {} -- cache player controls +local jump_modes = {} -- current jump modes of each player + -- mode 0: high jump + -- mode 1: med jump + -- mode 2: low jump +local jump_huds = {} -- current HUD IDs of each player +local remove_time = {} -- countdown timer to hide the jump HUD icon again + +minetest.register_globalstep(function(dtime) + for _, player in pairs(minetest.get_connected_players()) do + local name = player:get_player_name() + local ctrl = player:get_player_control() + if not ctrls[name] then + ctrls[name] = {} + end + if not jump_modes[name] then + jump_modes[name] = 0 + end + -- Aux1 key: Cycle jump mode (high, medium, low jump strength) + if ctrl.aux1 == true then + if not ctrls[name].aux1 then + local mode = jump_modes[name] + mode = (mode - 1) % 3 + jump_modes[name] = mode + local jump_height = JUMP_FACTOR_HIGH + local img = "hades_movement_jump_high.png" + if (mode == 1) then + jump_height = JUMP_FACTOR_MED + img = "hades_movement_jump_med.png" + elseif (mode == 2) then + jump_height = JUMP_FACTOR_LOW + img = "hades_movement_jump_low.png" + end + playerphysics.add_physics_factor(player, "jump", "jump_mode", jump_height) + if jump_huds[name] then + player:hud_change(jump_huds[name], "text", img) + end + minetest.sound_play({name="hades_movement_change_jump_mode", gain=0.4}, {pitch=1-mode*0.1}, true) + remove_time[name] = HIDE_JUMP_HUD_AFTER + end + ctrls[name].aux1 = true + else + if remove_time[name] and remove_time[name] > 0 then + remove_time[name] = remove_time[name] - dtime + if remove_time[name] <= 0 then + player:hud_change(jump_huds[name], "text", "blank.png") + remove_time[name] = nil + end + end + ctrls[name].aux1 = false + end + end +end) + +minetest.register_on_joinplayer(function(player) + local name = player:get_player_name() + ctrls[name] = {} + jump_modes[name] = 0 + -- Show icon that displays the current jump mode + jump_huds[name] = player:hud_add({ + hud_elem_type = "image", + position = { x=1, y=1 }, + alignment = { x=-1, y=-1 }, + size = { x=100, y=100 }, + scale = { x=3, y=3}, + offset = { x=-4, y=-4}, + text = "blank.png", + z_index = 0, + }) + remove_time[name] = HIDE_JUMP_HUD_AFTER +end) + +minetest.register_on_leaveplayer(function(player) + local name = player:get_player_name() + ctrls[name] = nil + jump_modes[name] = nil + jump_huds[name] = nil + remove_time[name] = nil +end) diff --git a/mods/hades_movement/mod.conf b/mods/hades_movement/mod.conf new file mode 100644 index 0000000..d834929 --- /dev/null +++ b/mods/hades_movement/mod.conf @@ -0,0 +1,3 @@ +name = hades_movement +description = Press Aux1 to change jump strength. +depends = playerphysics diff --git a/mods/hades_movement/sounds/hades_movement_change_jump_mode.ogg b/mods/hades_movement/sounds/hades_movement_change_jump_mode.ogg new file mode 100644 index 0000000..be9de90 Binary files /dev/null and b/mods/hades_movement/sounds/hades_movement_change_jump_mode.ogg differ diff --git a/mods/hades_movement/sounds/snd.wav b/mods/hades_movement/sounds/snd.wav new file mode 100644 index 0000000..f255502 Binary files /dev/null and b/mods/hades_movement/sounds/snd.wav differ diff --git a/mods/hades_movement/textures/hades_movement_jump_high.png b/mods/hades_movement/textures/hades_movement_jump_high.png new file mode 100644 index 0000000..a0d27e7 Binary files /dev/null and b/mods/hades_movement/textures/hades_movement_jump_high.png differ diff --git a/mods/hades_movement/textures/hades_movement_jump_low.png b/mods/hades_movement/textures/hades_movement_jump_low.png new file mode 100644 index 0000000..7649a3a Binary files /dev/null and b/mods/hades_movement/textures/hades_movement_jump_low.png differ diff --git a/mods/hades_movement/textures/hades_movement_jump_med.png b/mods/hades_movement/textures/hades_movement_jump_med.png new file mode 100644 index 0000000..22a796f Binary files /dev/null and b/mods/hades_movement/textures/hades_movement_jump_med.png differ