Cannot Use Gold-Cost Ability on any Unit-Summoned Unit
The title may be confusing, so let me clarify:
Player uses an item to summon a Giant Wolf. The Giant wolf has an ability that costs 200gp, which summons an Alpha Wolf. This works fine. However, when the Alpha Wolf tries to use his 900gp ability to summon a Lycan Shapeshift Wolf, the Player gets the error "Not Enough Gold." Alpha Wolf will otherwise move/attack just fine. I suspect that Dota has decided the Alpha Wolf belongs to the Giant Wolf, and not to the Player.
How do I fix that?
Summons are accomplished via "SpawnUnit" in custom abilities "summon_AlphaWolf" and "summon_AcnientWolf" in the npc_custom_abilities.txt file.
The code that I haphazardly tried was this:
function ResetOwner ( event ) local player = PlayerResource:GetPlayer(0) local unit = CreateUnitByName("base", Vector(0,0,0), false, nil, nil, DOTA_TEAM_GOODGUYS) unit:SetOwner(hero) unit:SetControllableByPlayer(0,false) end
But this obviously won't work. I understand that "RunScript" inside of "OnSpellStart" probably doesn't automatically know stuff like "unit = the unit I just summoned." So how do I tell the script what unit to adjust ownership on? And how do I tell the script the correct Player to give the ownership of that unit to, especially if there are multiple people on the Player's team?
I am currently trying to learn Lua, so I'm sorry if it feels like I'm asking you to spoon-feed me. It's just tough to get into stuff like this without a teacher/class, and this particular problem leaves me feeling very lost.
Any Help is Greatly Appreciated,