From 3ca6084179f393d7abe1c7b49080464d2da70618 Mon Sep 17 00:00:00 2001 From: Jitnaught Date: Tue, 9 Jul 2019 15:10:57 -0600 Subject: [PATCH] init --- LICENSE | 21 +++++++++++++++++++++ README.md | 3 +++ description.txt | 1 + init.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ mod.conf | 2 ++ 5 files changed, 71 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 description.txt create mode 100644 init.lua create mode 100644 mod.conf diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..497d5ad --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 Jitnaught + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c7c7b78 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +A Minetest mod that adds the Accelerated Back Hopping glitch from Half-Life 2. + +It is not a perfect recreation, due to the differences between the HL2 and Minetest. To do the recreated glitch in Minetest, hold jump (space button) + left, right, and/or down (A/S/D buttons) (e.g. Space + S). You will gain speed on each jump. diff --git a/description.txt b/description.txt new file mode 100644 index 0000000..888551c --- /dev/null +++ b/description.txt @@ -0,0 +1 @@ +Adds Accelerated Back Hopping glitch from Half-Life 2. diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..a512242 --- /dev/null +++ b/init.lua @@ -0,0 +1,44 @@ +function player_moving_abh(player_controls, player_speed) + return ((player_controls.down or player_controls.left or player_controls.right) and player_speed > 3.9 and not player_controls.up) +end + +minetest.register_globalstep(function(dtime) + local player_con, player_speed, node_pos, node + + for _,player in ipairs(minetest.get_connected_players()) do + if player:get_attribute('was_on_ground') == nil then + player:set_attribute('was_on_ground', "1") + player:set_attribute('abh', "0") + end + + local was_on_ground = (player:get_attribute('was_on_ground') == "1") + local abh = (player:get_attribute('abh') == "1") + + player_con = player:get_player_control() + player_speed = vector.length(player:get_player_velocity()) + + node_pos = player:get_pos() + node_pos.y = node_pos.y - 0.3 + + node = minetest.get_node_or_nil(node_pos) + + if node == nil or node.name == "air" then + if was_on_ground and abh and player_moving_abh(player_con, player_speed) then + player:set_physics_override({ speed = player:get_physics_override().speed + 1.0 }) + end + + was_on_ground = false + else + abh = player_con.jump and player_moving_abh(player_con, player_speed) + + if not abh then + player:set_physics_override({ speed = 1.0 }) + end + + was_on_ground = true + end + + player:set_attribute('was_on_ground', was_on_ground and "1" or "0") + player:set_attribute('abh', abh and "1" or "0") + end +end) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..c515f91 --- /dev/null +++ b/mod.conf @@ -0,0 +1,2 @@ +name = abh +