if you're not shooting, you're not part of any games, also if afk
This commit is contained in:
parent
ae9e626b0b
commit
02583495f1
42
game.lua
42
game.lua
@ -220,33 +220,39 @@ function snowgame.register_hit(shooter_name, target_name)
|
|||||||
local s_game = games_by_player[shooter_name]
|
local s_game = games_by_player[shooter_name]
|
||||||
local t_game = games_by_player[target_name]
|
local t_game = games_by_player[target_name]
|
||||||
|
|
||||||
if s_game and t_game and (s_game ~= t_game) then
|
|
||||||
-- if both player but different games, merge
|
|
||||||
s_game:merge(t_game)
|
|
||||||
end
|
|
||||||
local game = s_game or t_game
|
|
||||||
if not game then
|
|
||||||
-- none are playing, make a new one
|
|
||||||
game = Game()
|
|
||||||
end
|
|
||||||
if not s_game then
|
if not s_game then
|
||||||
-- add shooter to current
|
-- somehow landed a hit before being in a game
|
||||||
game:add_player(shooter_name)
|
-- probably because left and rejoined?
|
||||||
game:register_shot(shooter_name)
|
s_game = Game()
|
||||||
|
s_game:add_player(shooter_name)
|
||||||
|
s_game:register_shot(shooter_name) -- if was in the game, then shot was registered in on_use
|
||||||
end
|
end
|
||||||
if not t_game then
|
|
||||||
-- add target to current (if played diff game, was merged)
|
if afk_api.is_afk(target_name, yl_snowball.AFK_TIME) then
|
||||||
game:add_player(target_name)
|
-- don't count hits on afk people
|
||||||
|
return
|
||||||
end
|
end
|
||||||
game:register_hit(shooter_name, target_name)
|
|
||||||
|
if s_game and t_game then
|
||||||
|
if (s_game ~= t_game) then
|
||||||
|
-- if both playing, but different games, then merge
|
||||||
|
s_game:merge(t_game)
|
||||||
|
end
|
||||||
|
-- either same game, or was merged into one
|
||||||
|
s_game:register_hit(shooter_name, target_name)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function snowgame.register_shot(shooter_name)
|
function snowgame.register_shot(shooter_name)
|
||||||
local s_game = games_by_player[shooter_name]
|
local s_game = games_by_player[shooter_name]
|
||||||
if s_game then
|
if not s_game then
|
||||||
s_game:register_shot(shooter_name)
|
-- started shooting first time, started a game
|
||||||
|
s_game = Game()
|
||||||
|
s_game:add_player(shooter_name)
|
||||||
end
|
end
|
||||||
|
s_game:register_shot(shooter_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ yl_snowball.COOLDOWN = 0.4 -- TODO make configurable
|
|||||||
|
|
||||||
yl_snowball.SNOWBALL_SPEED = 17 -- 17 was good
|
yl_snowball.SNOWBALL_SPEED = 17 -- 17 was good
|
||||||
yl_snowball.SNOWBALL_GRAVITY = -8 -- -8 was good
|
yl_snowball.SNOWBALL_GRAVITY = -8 -- -8 was good
|
||||||
|
yl_snowball.AFK_TIME = 3*60
|
||||||
|
|
||||||
local player_last_throw_time = {}
|
local player_last_throw_time = {}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user