bugfixes and gameplay changes

This commit is contained in:
chmodsayshello 2022-10-09 21:19:33 +02:00
parent c83d7a1720
commit 0ee9582cd1
4 changed files with 50 additions and 22 deletions

View File

@ -30,8 +30,8 @@ end
function update_huds(arena, player)
local playername = player:get_player_name()
player:hud_change(arena.huds[playername].blue, "text", tostring(arena.teams[team_id_blue].goals))
player:hud_change(arena.huds[playername].red, "text", tostring(arena.teams[team_id_red].goals))
player:hud_change(arena.huds[playername].blue, "text", tostring(arena.teams[arena.team_id_blue].goals))
player:hud_change(arena.huds[playername].red, "text", tostring(arena.teams[arena.team_id_red].goals))
end
function remove_all_huds(arena)

View File

@ -2,8 +2,8 @@
local S = minetest.get_translator("the_bridge")
team_id_red = 1
team_id_blue = 2
--team_id_red = 1
--team_id_blue = 2
@ -11,6 +11,15 @@ local modpath = minetest.get_modpath("the_bridge")
minetest.register_privilege("the_bridge_admin", S("Is required in order to manage the bride games!"))
function get_team_id_by_name(modref,p_name)
for ID, name in pairs(modref.teams) do
if name == p_name then
return ID
end
end
return nil
end
arena_lib.register_minigame("the_bridge", {
name = "The Bridge",
--icon = "magiccompass_the_bridge.png",
@ -26,9 +35,14 @@ arena_lib.register_minigame("the_bridge", {
the_bridge_area_pos_1 = {x = 0, y = 0, z = 0},
the_bridge_area_pos_2 = {x = 0, y = 0, z = 0},
mapdata = nil,
finished = false,
huds = {}
huds = {},
team_id_red=nil,
team_id_blue=nil
},
temp_properties = {
finished = false,
},
in_game_physics = {
speed = player_speed,
jump = player_jump,

View File

@ -39,6 +39,8 @@ arena_lib.on_load("the_bridge", function(arena)
arena_lib.force_arena_ending("the_bridge", arena)
minetest.log("warning","The Bridge is not supposed to run without any teams!")
end --this game is not supposed to be used without teams!
arena.team_id_red = get_team_id_by_name(arena_lib.mods["the_bridge"],"red")
arena.team_id_blue = get_team_id_by_name(arena_lib.mods["the_bridge"],"blue")
create_huds(arena)
after_goal(arena) --gives all players their items and teleports them to spawners

View File

@ -13,14 +13,14 @@ end
function after_goal(arena) --global because its called once outside of this file
restore_map(arena)
local players_team_red = arena_lib.get_players_in_team(arena, team_id_red, true)
local players_team_blue = arena_lib.get_players_in_team(arena, team_id_blue, true)
local players_team_red = arena_lib.get_players_in_team(arena, arena.team_id_red, true)
local players_team_blue = arena_lib.get_players_in_team(arena, arena.team_id_blue, true)
for player_index in ipairs(players_team_red) do
local player = players_team_red[player_index]
set_player_inventory(player)
player:set_hp(20)
player:set_pos(arena_lib.get_random_spawner(arena, team_id_red))
player:set_pos(arena_lib.get_random_spawner(arena, arena.team_id_red))
update_huds(arena,player)
minetest.sound_play("ding", {
to_player = player:get_player_name(),
@ -32,7 +32,7 @@ function after_goal(arena) --global because its called once outside of this file
local player = players_team_blue[player_index]
set_player_inventory(player)
player:set_hp(20)
player:set_pos(arena_lib.get_random_spawner(arena, team_id_blue))
player:set_pos(arena_lib.get_random_spawner(arena, arena.team_id_blue))
update_huds(arena,player)
minetest.sound_play("ding", {
to_player = player:get_player_name(),
@ -48,21 +48,23 @@ local goalfunc = function(pos, node, player)
nodename = node.name
if nodename == "the_bridge:goal_area_red" then
arena.teams[team_id_red].goals = arena.teams[team_id_red].goals +1
if arena.teams[team_id_red].goals >= 5 and arena.in_game then
local temp = arena.teams[arena.team_id_red].goals +1
arena.teams[arena.team_id_red].goals = temp
if temp > 4 and arena.in_game then
if arena.finished then return end
arena_lib.load_celebration("the_bridge", arena, arena.team_id_red)
arena.finished = true
arena_lib.load_celebration("the_bridge", arena, team_id_red)
return
end
after_goal(arena)
elseif nodename == "the_bridge:goal_area_blue" then
arena.teams[team_id_blue].goals = arena.teams[team_id_blue].goals +1
if arena.teams[team_id_blue].goals >= 5 and arena.in_game then
local temp = arena.teams[arena.team_id_blue].goals +1
arena.teams[arena.team_id_blue].goals = temp
if temp > 4 and arena.in_game then
if arena.finished then return end
arena_lib.load_celebration("the_bridge", arena, arena.team_id_blue)
arena.finished = true
arena_lib.load_celebration("the_bridge", arena, team_id_blue)
return
end
after_goal(arena)
@ -70,18 +72,18 @@ local goalfunc = function(pos, node, player)
end
arena_lib.on_death("the_bridge", function(arena, p_name, reason)
local players_team_red = arena_lib.get_players_in_team(arena, team_id_red, false)
local players_team_blue = arena_lib.get_players_in_team(arena, team_id_blue, false)
local players_team_red = arena_lib.get_players_in_team(arena, arena.team_id_red, false)
local players_team_blue = arena_lib.get_players_in_team(arena, arena.team_id_blue, false)
for player_index in ipairs(players_team_red) do
if players_team_red[player_index] == p_name then
minetest.get_player_by_name(p_name):set_pos(arena_lib.get_random_spawner(arena, team_id_red))
minetest.get_player_by_name(p_name):set_pos(arena_lib.get_random_spawner(arena, arena.team_id_red))
end
end
for player_index in ipairs(players_team_blue) do
if players_team_blue[player_index] == p_name then
minetest.get_player_by_name(p_name):set_pos(arena_lib.get_random_spawner(arena, team_id_blue))
minetest.get_player_by_name(p_name):set_pos(arena_lib.get_random_spawner(arena, arena.team_id_blue))
end
end
@ -182,13 +184,13 @@ minetest.register_tool("the_bridge:diapick", {
full_punch_interval = 0.9,
max_drop_level=3,
groupcaps={
cracky = {times={[1]=2.0, [2]=1.0, [3]=0.50}, uses=0, maxlevel=3},
cracky = {times={[1]=2.0, [2]=1.0, [3]=1.0}, uses=0, maxlevel=3},
},
},
})
local gappleeat = minetest.item_eat(8,"")
local gappleeat = minetest.item_eat(6,"")
minetest.register_craftitem("the_bridge:gapple",{
on_place = gappleeat,
on_secondary_use = gappleeat,
@ -196,3 +198,13 @@ minetest.register_craftitem("the_bridge:gapple",{
description = S("Golden Apple"),
inventory_image = "default_apple.png^[colorize:#ead535",
})
minetest.register_craftitem("the_bridge:knockback_stick",{
inventory_image = "default_stick.png",
on_use = function(itemstack, user, pointed_thing) --parts of the code inside of this function are from https://gitlab.com/zughy-friends-minetest/sumo/-/blob/master/items.lua
if not pointed_thing then return end
if not minetest.is_player(pointed_thing.ref) then return end
dir = user:get_look_dir()
pointed_thing.ref:add_player_velocity(vector.multiply(dir,8))
end,
})