Skip to content

fix: remove entities between rounds #36

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 29, 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 @@ -70,3 +70,4 @@ All other information should be explored by reading the source code!
- [2023/3/29 08:46] fix: place history.scores updates to correct loc.([#32](https://github.com/Escapingbug/dotaxctf/pull/32), reporter: AAA剑圣)
- [2023/3/29 11:18] feat: print with `[Sandbox.candidate_name]` banner to support checking specified hero's log.([#33](https://github.com/Escapingbug/dotaxctf/pull/33))
- [2023/3/29 15:26] feat: print with `[Sandbox.candidate_name.script]` banner when script got an error.([#35](https://github.com/Escapingbug/dotaxctf/pull/35))
- [2023/3/29 21:44] feat: remove all nonempty entities after round ends.([#36](https://github.com/Escapingbug/dotaxctf/pull/36))
8 changes: 6 additions & 2 deletions rounds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,13 @@ function Rounds:InitFromServerAndBeginGame()
end

function Rounds:CleanupLivingHerosAndClearUnits()
for _, hero in pairs(self.heros) do
hero:RemoveSelf()
local entities = Entities:FindAllInSphere(Vector(0, 0), 1e6)
for _, entity in ipairs(entities) do
if entity:GetName() ~= "" then
entity:RemoveSelf()
end
end

self.heros = {}

for _, team in pairs(AVAILABLE_TEAMS) do
Expand Down
7 changes: 0 additions & 7 deletions sandbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function Sandbox:Init()
self.public_api = self:SandboxPublicAPI()
self.default_hero = "npc_dota_hero_axe"
self.init = true
self.items = {}
end

function Sandbox:SetupGameInfo(game_info)
Expand Down Expand Up @@ -243,7 +242,6 @@ function Sandbox:SandboxBaseNPC(npc, readonly)
-- we only use unreliable gold
npc:SetGold(gold_left, false)
npc:AddItem(item)
table.insert(Sandbox.items, item)
return true
end

Expand Down Expand Up @@ -335,11 +333,6 @@ function Sandbox:SandboxItem(item)
end

function Sandbox:CleanUpItems()
for _, item in ipairs(self.items) do
item:RemoveSelf()
end
self.items = {}

local total = GameRules:NumDroppedItems()
for _ = 1, total do
GameRules:GetDroppedItem(0):RemoveSelf()
Expand Down