MNoya / BuildingHelper

Library for RTS & TD Dota Custom Games
GNU General Public License v3.0
37 stars 14 forks source link

ability_building is not always applied #8

Closed Septica closed 8 years ago

Septica commented 8 years ago

I build a building. Click on the building. Press Z to cancel the building. The building is destroyed but the collision and the pedestal linger. The item to cancel building cannot be clicked but can be used by pressing Z

MNoya commented 8 years ago

The item and scripts to cancel building are just an example, Z is just your hotkey, the reason you see no icon is because I didn't bundle one with the code. Changing this line or adding a 'cancel' image should get rid of that problem.

That said, the collision/pedestal not being removed when a building is killed is totally not intended, will look into that.

MNoya commented 8 years ago

@Septica have you managed to resolve this? I can't reproduce it and don't see why it would not remove it unless you are running into a script error. building:ForceKill(true) calls BuildingHelper:RemoveBuilding which will do UTIL_Remove(building.prop) and remove the pedestal, and BuildingHelper:FreeGridSquares removes the grid blockers.

Septica commented 8 years ago

Not sure why you can't reproduce it. I've replaced all the buildinghelper files in case i changed something but still the same. I think the GridSquares is removed because the ghost placement shows green squares, but the collision and pedestal is not

Edit: Add this to BuildingHelper:StartBuilding. It works now.

if not building:HasAbility("ability_building") then
    building:AddAbility("ability_building")
end
MNoya commented 8 years ago

Ah that makes sense, thank you! Currently a building will only be detected as IsCustomBuilding if it has the ability_building or ability_tower, but I only force to add the ability in PlaceBuilding...

At first I didn't want to force ability_building on every building because it has MODIFIER_STATE_MAGIC_IMMUNE amongst other modifier states which people might not want to apply to all their buildings. I think the best is if I make it a lua modifier and leave each of the states as a building_setings.kv option.

MNoya commented 8 years ago

Fixed in 69675a4e0c722b732409626a9ac26191200ddf35