Move flag-bearer slowdown to a separate speed modifier (#601)

Improves separation; less prone to error
This commit is contained in:
ANAND 2020-05-01 11:42:16 +05:30 committed by GitHub
parent bc46f56852
commit c44827f2f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View file

@ -111,13 +111,8 @@ function ctf_classes.update(player)
set_max_hp(player, class.properties.max_hp) set_max_hp(player, class.properties.max_hp)
ctf_classes.set_skin(player, color, class) ctf_classes.set_skin(player, color, class)
local speed = class.properties.speed
if ctf_flag.has_flag(name) and speed > 0.9 then
speed = 0.9
end
physics.set(player:get_player_name(), "ctf_classes:speed", { physics.set(player:get_player_name(), "ctf_classes:speed", {
speed = speed, speed = class.properties.speed,
}) })
crafting.lock_all(player:get_player_name()) crafting.lock_all(player:get_player_name())

View file

@ -80,11 +80,21 @@ function ctf_match.create_teams()
error("Error! Unimplemented") error("Error! Unimplemented")
end end
ctf_flag.register_on_pick_up(function(name)
physics.set(name, "ctf_match:flag_mult", { speed = 0.9 })
end)
ctf_flag.register_on_drop(function(name)
physics.remove(name, "ctf_match:flag_mult")
end)
ctf_flag.register_on_capture(function(attname, flag) ctf_flag.register_on_capture(function(attname, flag)
if not ctf.setting("match.destroy_team") then if not ctf.setting("match.destroy_team") then
return return
end end
physics.remove(attname, "ctf_match:flag_mult")
local fl_team = ctf.team(flag.team) local fl_team = ctf.team(flag.team)
if fl_team and #fl_team.flags == 0 then if fl_team and #fl_team.flags == 0 then
ctf.action("match", flag.team .. " was defeated.") ctf.action("match", flag.team .. " was defeated.")