OK this is a melee map. Whenever a player leaves, I want to put an AI in his place to keep playing. However the AI doesn't do anything. Here's what I've done so far:
I have created this trigger:
And I have imported a custom Blizzard.j, where I have modified the MeleeTriggerActionPlayerLeft function to this:

JASS:
function MeleeTriggerActionPlayerLeft takes nothing returns nothing
local player thePlayer=GetTriggerPlayer()
if(IsPlayerObserver(thePlayer))then
call RemovePlayerPreserveUnitsBJ(thePlayer,PLAYER_GAME_RESULT_NEUTRAL,false)
return
endif
call CachePlayerHeroData(thePlayer)
if(MeleeGetAllyCount(thePlayer)>0)then
call ShareEverythingWithTeam(thePlayer)
endif
call MeleeCheckForLosersAndVictors()
endfunction
(before, this had a lot of "call MeleeDoLeave(thePlayer)" in it)
Now when a player leaves, the AI will just stand there and do nothing. Also the player slot state is no longer "Is Playing".
I'm using AMAI, but I don't think that has anything to do with this.
Is there any way to fix this?