1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  4. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  5. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[AI] Player leaves- Run custom AI script for player

Discussion in 'Triggers & Scripts' started by PsycoMarauder, May 12, 2009.

  1. PsycoMarauder

    PsycoMarauder

    Joined:
    Sep 19, 2005
    Messages:
    173
    Resources:
    3
    Maps:
    3
    Resources:
    3
    Hi, posting from iphone here, so hopefully text doesnt appear weirdly. Ive made my own custom or "campaign" AI for my Risk mapsnthat works quite well. But Ive been trying to make the ai script run for players that leave, so far it hasnt worked. Is this even possiblenl to do? If so, then how?
     
  2. Dr. Boom

    Dr. Boom

    Joined:
    May 1, 2008
    Messages:
    1,550
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Seas =)

    Hmm so you got your own script allrdy and you want it to run?

    The create a trigger with no event and condition. The action is your script.

    Then create a trigger:

    • Check
      • Events:
        • Player - Player 1 leaves
      • Conditions:
      • Actions:
        • Trigger - Run <Trigger with script> ignore conditions.


    Read me
    1) But ofc make sure, that your script is only running for the leaving Player then.

    2) Maybe you need to create so many trigger with the script egual to the Players in your map - and a trigger for "Player 1 leaving > Run Script 1" "Player 2 leaving > Run Script 2" ...
     
  3. PsycoMarauder

    PsycoMarauder

    Joined:
    Sep 19, 2005
    Messages:
    173
    Resources:
    3
    Maps:
    3
    Resources:
    3
    Seas? Ive tried this, doesnt seem to be working. When the game begins, I have the script run for all players of computer control. This works fine. But it hasnt been working when trying to run for the leaving player. The trigger I used was similar to what you posted. I'm not at the computer now, but I know when creating a run ai gui trigger, theres a descriptiom saying something to the effect run script only for computer players and make set forces disabled, if my memory serves me correct. Is this just not possible with GUI then?

    EDIT: The trig i used was something like : Player Leaves. Run (aiscript) for triggering player)
     
  4. Lord_BoNes

    Lord_BoNes

    Joined:
    Sep 5, 2007
    Messages:
    264
    Resources:
    0
    Resources:
    0
    I think that the reason that the AI script isn't running is:
    1) When Wc3 is told to run AI, it checks the "player slot controller" and only runs if the computer is in control of a given slot. When a game is hosted, the game sets the slot to "player" not "computer" so the AI can't run on that slot.
    2) The leaving player is declared defeated when they leave, so the AI just continues with this assumption, and doesn't do anything (or stops running).

    Either way, I don't know of ways to get around this, other than not using an AI script... use complex triggers to simulate AI. That's my only answer.
     
  5. PsycoMarauder

    PsycoMarauder

    Joined:
    Sep 19, 2005
    Messages:
    173
    Resources:
    3
    Maps:
    3
    Resources:
    3
    Well, at first I used complex triggers. I've found that "complex triggers" or at least what I was doing-- (with my GUI knowledge -.-) was lagging up the game. Besides, my AI does much better than what I could hope to trigger. (Although it is still trigger-assisted.) So since I couldn't come up with a working solution, here's what I've done. When a player leaves, all of the players units are set to a variable. Another variable grabs a random AI player that is still alive, and then the leaving player's units are given to the random player. Not QUITE the same, but still better than to have units just sitting after a player leaves, better to have an AI player take over the units. (Might be hard to understand if not familiar with risk games)