HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Player leaves -> Replace him with an AI

04-18-2007, 12:06 PM#1
Sagan
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:

Trigger:
Player leaves
Collapse Events
Player - Player 1 (Red) leaves the game
Player - Player 2 (Blue) leaves the game
Player - Player 3 (Teal) leaves the game
Player - Player 4 (Purple) leaves the game
Player - Player 5 (Yellow) leaves the game
Player - Player 6 (Orange) leaves the game
Player - Player 7 (Green) leaves the game
Player - Player 8 (Pink) leaves the game
Player - Player 9 (Gray) leaves the game
Player - Player 10 (Light Blue) leaves the game
Player - Player 11 (Dark Green) leaves the game
Player - Player 12 (Brown) leaves the game
Collapse Conditions
((Triggering player) controller) Equal to User
Collapse Actions
Custom script: call SetPlayerController(GetTriggerPlayer(), MAP_CONTROL_COMPUTER)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Race of (Triggering player)) Equal to Human
Collapse Then - Actions
AI - Start melee AI script for (Triggering player): scripts\human.ai
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Race of (Triggering player)) Equal to Orc
Collapse Then - Actions
AI - Start melee AI script for (Triggering player): scripts\orc.ai
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Race of (Triggering player)) Equal to Undead
Collapse Then - Actions
AI - Start melee AI script for (Triggering player): scripts\undead.ai
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Race of (Triggering player)) Equal to Night Elf
Collapse Then - Actions
AI - Start melee AI script for (Triggering player): scripts\elf.ai
Else - Actions
Player - Set name of (Triggering player) to (Computer ( + ((Name of (Triggering player)) + )))

And I have imported a custom Blizzard.j, where I have modified the MeleeTriggerActionPlayerLeft function to this:
Collapse 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?
04-18-2007, 12:15 PM#2
Rising_Dusk
I'm fairly sure that you can't make players into AI at runtime.
I believe there was a topic about that sometime back.