SetOverrideSelectionEntity crashes the game

edited December 2015 in Questions

An issue that has been bugging me since the 01.12 update (before that everything worked fine):

If I use PlayerResource:SetOverrideSelectionEntity(playerID, entity) and soon after that entity dies, the game just freezes and never comes back. If I take the empty template and use

if GameMode == nil then
    GameMode = class({})

function GameMode:InitGameMode()
    GameMode = self

    ListenToGameEvent('dota_player_pick_hero', Dynamic_Wrap(GameMode, 'OnPlayerPickHero'), self)

function GameMode:OnPlayerPickHero(keys)
    local player = EntIndexToHScript(keys.player)
    local playerID = player:GetPlayerID()
    local entity = EntIndexToHScript(keys.heroindex)

    PlayerResource:SetOverrideSelectionEntity(playerID, entity)


as gamemode file, the game crashes right after picking the hero. If I don't use ForceKill it works, but then crashes as soon as the hero dies. However for some reason the rpg example, which makes use of that function, doesn't crash.

Any ideas what the issue is here?


  • edited December 2015 Posts: 413

    I had issues with this method too. But my case was simplier, the hero received MODIFIER_STATE_UNSELECTABLE at some point, causing game to freeze. Check your code for that kind of stuff.

    I think I also had that issue yesterday, where I used SetCustomTeamAssignment for a player after ingame game state, and that worked very weird, in such a way, that I couldn't control my hero (my selection didn't drop when I gave orders, like it does when you don't use SetControllableByPlayer, but no orders were executed). In that case SetOverrideSelectionEntity crashed me at hero death. When I fixed SetCustomTeamAssignment it went away.

  • I don't use anything special like the unselectable modifier. And I don't need it to reproduce the issue.

    The following codeblock makes the game hang for me at any point:

    local crash_dummy = CreateUnitByName("npc_dota_creep_badguys_ranged", Vector(0,0,0), false, player, player, player:GetTeam())
    PlayerResource:SetOverrideSelectionEntity(playerID, crash_dummy)
    crash_dummy:ForceKill(true) -- or kill the dummy in any other way

    Either it is a client-side issue just on my end or it is a major bug.