Dateien nach "/" hochladen

This commit is contained in:
2026-03-07 12:16:36 +00:00
parent c9d5922ef6
commit 4ab1cb87e3
2 changed files with 16 additions and 18 deletions

View File

@@ -45,13 +45,11 @@ local function remove_mech_scope(player)
end
end
-- ── Spider Ammo HUD ──────────────────────────────────────────────────────────
-- ── Spider Ammo HUD ──────────────────────────────────────────────────────────
-- Text-only bar, no external textures required.
-- Renders as: [||||||....] 60% (green when enough ammo, red when empty)
-- ── Ammo HUD (text-only, keine externen Texturen noetig) ─────────────────────
-- Wir bauen den Balken aus ASCII-Zeichen: [|||||||| ] + Prozentzahl
-- Das funktioniert in jeder Minetest/Luanti-Version zuverlaessig.
local AMMO_BAR_WIDTH = 10 -- Anzahl Segmente im Balken
local AMMO_BAR_WIDTH = 10 -- number of segments in the bar
local function ammo_bar_string(ammo_pct)
local filled = math.floor((ammo_pct / 100) * AMMO_BAR_WIDTH + 0.5)
@@ -64,7 +62,7 @@ local function add_ammo_hud(player)
if not player then return end
local meta = player:get_meta()
-- Label "PLASMA"
-- Label
local label_id = player:hud_add({
type = "text",
position = {x = 0.5, y = 0.88},
@@ -76,7 +74,7 @@ local function add_ammo_hud(player)
})
meta:set_int("ammo_hud_label", label_id)
-- Balken + Prozentzahl als Text
-- Bar + percentage as text
local bar_id = player:hud_add({
type = "text",
position = {x = 0.5, y = 0.88},
@@ -290,7 +288,7 @@ local function register_mech(mech)
self._mech_stand_anim = mech.stand_animation
self._mech_head_name = mech.head_name
self._mech_name = mech.name
-- Spider-Ammo initialisieren (gilt fuer alle Mechs mit head_spider)
-- Initialize spider ammo (applies to all mechs using head_spider)
if mech.head_name == "assorted_mecha:head_spider" then
self._spider_ammo = self._spider_ammo or SPIDER_AMMO_MAX
end
@@ -346,7 +344,7 @@ local vel = self.object:get_velocity() or {x=0, y=0, z=0}
vel.y = vel.y - (dtime * 9.8)
self.object:set_velocity(vel)
-- Spider-Ammo: passiver Regen (alle Mechs mit head_spider)
-- Spider ammo: passive regen (all mechs using head_spider)
if mech.head_name == "assorted_mecha:head_spider" then
if (self._spider_ammo or SPIDER_AMMO_MAX) < SPIDER_AMMO_MAX then
self._spider_ammo = math.min(
@@ -354,7 +352,7 @@ self.object:set_velocity(vel)
(self._spider_ammo or 0) + SPIDER_AMMO_REGEN * dtime
)
end
-- HUD beim Fahrer aktualisieren
-- Update HUD for the current driver
if self.driver then
update_ammo_hud(self.driver, self._spider_ammo or SPIDER_AMMO_MAX)
end
@@ -507,7 +505,7 @@ clicker:set_properties({visual_size = {x=1, y=1, z=1}})
clicker:hud_set_flags({crosshair = true, wielditem = true})
clicker:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
clicker:get_meta():set_int("mech_third_person", 0)
-- Ammo-HUD entfernen (nur Spider)
-- Remove ammo HUD on dismount (spider only)
if mech.head_name == "assorted_mecha:head_spider" then
remove_ammo_hud(clicker)
end
@@ -542,7 +540,7 @@ clicker:set_properties({visual_size = {x=1, y=1, z=1}})
-- Scope overlay replaces crosshair; hide ingame crosshair & wielditem
clicker:hud_set_flags({crosshair = false, wielditem = false})
clicker:get_meta():set_int("mech_third_person", 0)
-- Ammo-HUD anzeigen (nur Spider)
-- Show ammo HUD on mount (spider only)
if mech.head_name == "assorted_mecha:head_spider" then
add_ammo_hud(clicker)
update_ammo_hud(clicker, self._spider_ammo or SPIDER_AMMO_MAX)
@@ -854,7 +852,7 @@ on_step = function(self, dtime)
local control = target_player:get_player_control()
if control.aux1 and not self.is_firing then
-- Ammo-Check: zugehoerigen mech1-Body in der Naehe suchen
-- Ammo check: find the mech1 body near the head (head_offset.y = 4.75)
local mech_ent = nil
local hp = self.object:get_pos()
for _, obj in ipairs(minetest.get_objects_inside_radius(hp, 6)) do
@@ -869,13 +867,13 @@ on_step = function(self, dtime)
local ammo = mech_ent and (mech_ent._spider_ammo or SPIDER_AMMO_MAX) or SPIDER_AMMO_MAX
if ammo < SPIDER_AMMO_MIN_TO_FIRE then
-- Leer: kein Schuss, kurzer Click-Sound als Feedback
-- Empty: no shot, play a dry-fire click as feedback
minetest.sound_play("bullet", {pos = self.object:get_pos(), gain = 0.3, max_hear_distance = 8})
return
end
self.is_firing = true
-- Ammo verbrauchen und HUD aktualisieren
-- Consume ammo and update HUD
if mech_ent then
mech_ent._spider_ammo = math.max(0, ammo - SPIDER_AMMO_COST)
update_ammo_hud(target_player, mech_ent._spider_ammo)