change death method, add invincible particle
parent
e943f6d826
commit
d6f695d60a
|
@ -155,7 +155,49 @@ arena_lib.on_time_tick('sumo', function(arena)
|
|||
|
||||
end)
|
||||
|
||||
function sumo.kill_player(arena,pl_name)
|
||||
sumo.invincible[pl_name] = true
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
local inv = player:get_inventory()
|
||||
local taken = inv:remove_item("main", ItemStack("sumo:pushstick"))
|
||||
|
||||
arena.players[pl_name].lives = arena.players[pl_name].lives - 1
|
||||
if arena.players[pl_name].lives == 0 then
|
||||
if player then
|
||||
arena_lib.remove_player_from_arena(pl_name, 1)
|
||||
arena_lib.HUD_hide('hotbar', pl_name)
|
||||
end
|
||||
else
|
||||
arena_lib.HUD_send_msg("title", pl_name,'You Died! Lives: '.. arena.players[pl_name].lives , 2,nil,0xFF1100)
|
||||
minetest.after(2,function(pl_name)
|
||||
--sumo.invincible[pl_name] = false
|
||||
if arena_lib.is_player_in_arena(pl_name, 'sumo') then
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
if arena.in_game == true then
|
||||
arena_lib.HUD_send_msg("title", pl_name,'Fight!', 2,nil,0x00FF00)
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
local sp_pos = arena_lib.get_random_spawner(arena)
|
||||
if player then
|
||||
player:move_to(sp_pos, false)
|
||||
player:get_inventory():set_stack("main", 1, ItemStack("sumo:pushstick"))
|
||||
minetest.after(3,function(pl_name)
|
||||
sumo.invincible[pl_name] = false
|
||||
|
||||
end,pl_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,pl_name)
|
||||
minetest.sound_play('sumo_elim', {
|
||||
to_player = pl_name,
|
||||
gain = 2.0,
|
||||
})
|
||||
player:move_to(arena.jail_pos, false)
|
||||
|
||||
end
|
||||
player:set_hp(20)
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
minetest.register_on_player_hpchange(function(player, hp_change,reason)
|
||||
|
@ -172,55 +214,7 @@ minetest.register_on_player_hpchange(function(player, hp_change,reason)
|
|||
if sumo.invincible[pl_name] then return 0 end --protects players from dying twice in a row
|
||||
if hp + hp_change <= 0 then --dont ever kill players, but if a damage *would* kill them, then eliminate them, and set their health back to normal
|
||||
|
||||
sumo.invincible[pl_name] = true
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
local inv = player:get_inventory()
|
||||
local taken = inv:remove_item("main", ItemStack("sumo:pushstick"))
|
||||
|
||||
arena.players[pl_name].lives = arena.players[pl_name].lives - 1
|
||||
if arena.players[pl_name].lives == 0 then
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
if player then
|
||||
arena_lib.remove_player_from_arena(pl_name, 1)
|
||||
|
||||
arena_lib.HUD_hide('hotbar', pl_name)
|
||||
end
|
||||
else
|
||||
arena_lib.HUD_send_msg("title", pl_name,'You Died! Lives: '.. arena.players[pl_name].lives , 2,nil,0xFF1100)
|
||||
|
||||
minetest.after(2,function(pl_name)
|
||||
--sumo.invincible[pl_name] = false
|
||||
if arena_lib.is_player_in_arena(pl_name, 'sumo') then
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
if arena.in_game == true then
|
||||
arena_lib.HUD_send_msg("title", pl_name,'Fight!', 2,nil,0x00FF00)
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
local sp_pos = arena_lib.get_random_spawner(arena)
|
||||
|
||||
if player then
|
||||
player:move_to(sp_pos, false)
|
||||
player:get_inventory():set_stack("main", 1, ItemStack("sumo:pushstick"))
|
||||
minetest.after(3,function(pl_name)
|
||||
sumo.invincible[pl_name] = false
|
||||
|
||||
end,pl_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,pl_name)
|
||||
|
||||
minetest.sound_play('sumo_elim', {
|
||||
to_player = pl_name,
|
||||
gain = 2.0,
|
||||
})
|
||||
|
||||
player:move_to(arena.jail_pos, false)
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
player:set_hp(20)
|
||||
sumo.kill_player(arena,pl_name)
|
||||
return 0
|
||||
else
|
||||
return hp_change --if it would not kill players then apply damage as normal
|
||||
|
@ -324,3 +318,48 @@ minetest.register_on_joinplayer(function(player)
|
|||
local taken = inv:remove_item("main", stack)
|
||||
|
||||
end)
|
||||
|
||||
|
||||
|
||||
|
||||
-- kill players who are in water on the globalstep instead of in the on_tick
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local pl_name = player:get_player_name()
|
||||
if arena_lib.is_player_in_arena(pl_name, "sumo") and not(arena_lib.is_player_spectating(pl_name)) then
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
if not(arena.in_queue == true) and not (arena.in_loading == true) and not(arena.in_celebration == true) and arena.enabled == true then
|
||||
local stats = arena.players[pl_name]
|
||||
|
||||
local pos = player:get_pos()
|
||||
local node = minetest.get_node(pos).name
|
||||
-- kill players found in the killer water or air
|
||||
if node == "sumo:player_killer_air" or
|
||||
node == "sumo:player_killer_water_source" or
|
||||
node == "sumo:player_killer_water_flowing" or
|
||||
node == "sumo:fullclip" then
|
||||
|
||||
sumo.kill_player(arena,pl_name)
|
||||
end
|
||||
|
||||
if sumo.invincible[pl_name] then
|
||||
minetest.add_particle({
|
||||
pos = vector.add(player:get_pos(), vector.new(math.random(-.3,.3),math.random(1,2),math.random(-.3,.3))),
|
||||
velocity = {x=0, y=1, z=0},
|
||||
acceleration = {x=0, y=5, z=0},
|
||||
expirationtime = 1,
|
||||
size = 1,
|
||||
collisiondetection = true,
|
||||
collision_removal = true,
|
||||
object_collision = false,
|
||||
vertical = false,
|
||||
texture = "invincible.png",
|
||||
glow = 3,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -9,7 +9,6 @@ minetest.register_node("sumo:player_killer_air", {
|
|||
diggable = true,
|
||||
buildable_to = false,
|
||||
drop = "",
|
||||
damage_per_second = 40,
|
||||
groups = {oddly_breakable_by_hand = 1},
|
||||
})
|
||||
|
||||
|
@ -25,7 +24,6 @@ minetest.register_node("sumo:fullclip", {
|
|||
diggable = false,
|
||||
buildable_to = false,
|
||||
drop = "",
|
||||
damage_per_second = 40,
|
||||
groups = {},
|
||||
})
|
||||
|
||||
|
@ -57,7 +55,6 @@ minetest.register_node("sumo:player_killer_water_source", {
|
|||
},
|
||||
},
|
||||
},
|
||||
damage_per_second = 40,
|
||||
alpha = 191,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
|
@ -105,7 +102,6 @@ minetest.register_node("sumo:player_killer_water_flowing", {
|
|||
},
|
||||
},
|
||||
},
|
||||
damage_per_second = 200,
|
||||
alpha = 191,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 132 B |
Loading…
Reference in New Issue