Admin has super weapons

This commit is contained in:
HybridDog 2015-01-24 14:27:23 +01:00 committed by stujones11
parent a6f3caeaf5
commit 26beddca61
2 changed files with 38 additions and 1 deletions

View file

@ -2,6 +2,10 @@
-- Global Constants (defaults)
-- Enable admin super weapons
-- This lets admins shoot guns automatically after 2 seconds without munition.
SHOOTER_ADMIN_WEAPONS = false
-- Enable node destruction with explosives
SHOOTER_ENABLE_BLASTING = true

View file

@ -7,6 +7,7 @@ shooter = {
reload_time = 0,
}
SHOOTER_ADMIN_WEAPONS = false
SHOOTER_ENABLE_BLASTING = false
SHOOTER_ENABLE_CROSSBOW = true
SHOOTER_ENABLE_GUNS = true
@ -38,7 +39,8 @@ SHOOTER_ENTITIES = {
"mobs:dungeon_master",
}
if minetest.is_singleplayer() == true then
local singleplayer = minetest.is_singleplayer()
if singleplayer then
SHOOTER_ENABLE_BLASTING = true
SHOOTER_ALLOW_ENTITIES = true
SHOOTER_ALLOW_PLAYERS = false
@ -203,7 +205,9 @@ function shooter:process_round(round)
end
end
shooter.registered_weapons = shooter.registered_weapons or {}
function shooter:register_weapon(name, def)
shooter.registered_weapons[name] = def
local shots = def.shots or 1
local wear = math.ceil(65534 / def.rounds)
local max_wear = (def.rounds - 1) * wear
@ -427,3 +431,32 @@ function shooter:blast(pos, radius, fleshy, distance, user)
end
end
if not singleplayer and SHOOTER_ADMIN_WEAPONS then
local timer = 0
local shooting = false
minetest.register_globalstep(function(dtime)
if not shooting then
timer = timer+dtime
if timer < 2 then
return
end
timer = 0
end
shooting = false
for _,player in pairs(minetest.get_connected_players()) do
if player:get_player_control().LMB then
local name = player:get_player_name()
if minetest.check_player_privs(name, {server=true}) then
local spec = shooter.registered_weapons[player:get_wielded_item():get_name()]
if spec then
spec = spec.spec
shooter.shots[name] = false
spec.name = name
shooter:fire_weapon(player, {}, spec)
shooting = true
end
end
end
end
end)
end