Skip to content

fix: remove non-hero units after round ends #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ All other information should be explored by reading the source code!

- [2023/3/21 21:13] fix: remove shop and spawn heros as a circle.([#20](https://github.com/Escapingbug/dotaxctf/pull/20))
- [2023/3/21 22:00] feat: support getting hero's candidate id.([#21](https://github.com/Escapingbug/dotaxctf/pull/21))
- [2023/3/22 13:30] fix: remove non-hero units after round ends.([#23](https://github.com/Escapingbug/dotaxctf/pull/23), reporter: AAA剑圣)
1 change: 0 additions & 1 deletion commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ end
function Commands:FullRestart()
Timers:RemoveTimer("round_periodic_timer")
Timers:RemoveTimer("round_limit_timer")
Rounds:CleanupLivingHeros()
Rounds.restarting = true
Rounds:InitFromServerAndBeginGame()
end
Expand Down
22 changes: 19 additions & 3 deletions rounds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,28 @@ function Rounds:InitFromServerAndBeginGame()
end
end

function Rounds:CleanupLivingHeros()
function Rounds:CleanupLivingHerosAndClearUnits()
for _, hero in pairs(self.heros) do
hero:RemoveSelf()
end

self.heros = {}

for _, team in pairs(AVAILABLE_TEAMS) do
local team_units = FindUnitsInRadius(
team,
Vector(0, 0),
nil, -- cacheUnit
1e6,
DOTA_UNIT_TARGET_TEAM_BOTH,
DOTA_UNIT_TARGET_ALL,
DOTA_UNIT_TARGET_FLAG_NONE,
FIND_ANY_ORDER,
false -- canGrowCache
)
for _, unit in pairs(team_units) do
unit:RemoveSelf()
end
end
end

--[[
Expand Down Expand Up @@ -282,7 +298,7 @@ function Rounds:NextRound(scripts)
table.insert(self.history.scores, last_scores)
end

Rounds:CleanupLivingHeros()
Rounds:CleanupLivingHerosAndClearUnits()
Rounds:ChooseHeros(scripts["chooser_scripts"], scripts["attributes"])
Timers:CreateTimer(
Config.round_begin_delay,
Expand Down