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. Weave light to take you to your highest hopes - the 6th Special Effect Contest is here!
    Dismiss Notice
  4. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  5. 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.

[General] Custom Campaign AI

Discussion in 'World Editor Help Zone' started by ABronzeCross, Feb 3, 2019.

  1. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0
    I haven't actually designed an AI yet, but some missions might give the main player 1 or more AI allies. I want to allow the player to control them, but from past experience, AIs tend to constantly disobey player commands and switch mid command, so I want a 10 sec delay before the AI tries to take over their unit again, even on the Ai hero.
     
  2. Shar Dundred

    Shar Dundred

    Map Moderator

    Joined:
    May 6, 2009
    Messages:
    4,160
    Resources:
    10
    Packs:
    1
    Maps:
    8
    Tutorials:
    1
    Resources:
    10
    Just have the AI controlled by neutral instead of computer in player settings and you do not have the problem.
    You only have to set all alliances (ally, enemy, etc) by using the trigger editor.

    This way, the AI not only stops disobeying orders, it also does not just cast spells by itself.
     
  3. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0
    No, no not at all! I don't want a dead AI! I just need the AI to obey when you want to intervene with what it's doing, that's all.
     
  4. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0

    Also this is false, "neutral hostile" creeps can use spells, that is still in their AI. Or maybe just the autocast ones...
     
  5. Shar Dundred

    Shar Dundred

    Map Moderator

    Joined:
    May 6, 2009
    Messages:
    4,160
    Resources:
    10
    Packs:
    1
    Maps:
    8
    Tutorials:
    1
    Resources:
    10
    Neutral in player settings, not neutral as in neutral hostile/passive/victim.
     
  6. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0
    Would the AI still res geros, create armies, attack, build, etc?
     
  7. Nowow

    Nowow

    Joined:
    Jun 15, 2016
    Messages:
    462
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    That's not going to be as easy as you think. My best idea for how to do this goes like this:

    1. Once you send the computer controlled hero a command, store the order id and the target location\unit whatever.
    2. Start a timer for X seconds, during which, if the hero receives an order, send the order you stored again.
    3. Once the timer stops/target has been reached, stop overriding methods received.

    This is the basic outline. BUT, and you might want to allow some orders because some might be essential for normal unit action. And there are a lot of things to consider, like: aggro range and recurring orders, orders following your own walk order (might create something akin to an infinite loop), non immediate build and spell orders (including mana/resource refunding in case of order interrupts), and the effect of a stray unit on general AI behavior (might cause captains to act funky).

    Sounds like an interesting experiment, and something someone probably tried doing already. I really suggest searching the hive for questions about this. If you want to try my way, go here for more info:

    Orders repo

    Missions (see mission 1 - order tracking)
     
  8. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0


    Do you know if AIs ever cancel troop training, cancel building constructions, unsummon already finished buildings, cancel research, or cancel upgrades? These might interfere with the AI or player.
     
  9. Nowow

    Nowow

    Joined:
    Jun 15, 2016
    Messages:
    462
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Didn't see any of those, except unsummoning building, and even that wasn't automatic.
     
  10. 3dris

    3dris

    Joined:
    Jan 9, 2019
    Messages:
    69
    Resources:
    0
    Resources:
    0
    Hmm, maybe you can change the ownership of the unit for 10 second and give back to the original owner after this. Is a posibility...
     
  11. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0
    Maybe... just maybe...
     
  12. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0
    Why did it unsummon? Did the AI not place it perfectly?
     
  13. Nowow

    Nowow

    Joined:
    Jun 15, 2016
    Messages:
    462
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    No, you can make your AI unsummon on purpose with the
    Unsummon
    native command. This isn't something you should worry about, AI is not supposed to unsummon by mistake.
     
  14. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0
    I was wondering because, if the triggers making this "don't redirect your unit and obey the human player" don't work out right they might unsummon a building you tried building for them after 10 sec.
     
  15. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0
    You probably gave the best answer/idea to this.
     
  16. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Per ABronzeCross's other post:

    • Events
      • Unit - A unit is issued an order targeting an object //"object" may not be the correct term
      • Unit - A unit is issued an order targeting a point
      • Unit - A Unit is issued an order with no target
    • Conditions
      • (Owner of (Triggering Unit)) not equal to (Triggering Player) //Triggering Player should work here
    • Actions
      • Custom script: local unit udg_Change_Unit
      • Custom script: local player udg_Change_Player
      • Set Change_Unit = (Triggering Unit)
      • Set Change_Player = (Owner of (Triggering Unit))
      • Unit - Change owner of Change_Unit to (Triggering Player) without changing color
      • Wait 10.00 game-time seconds
      • Unit - Change owner of Change_Unit to Change_Player without changing color
      • -------- might not need these lines, but my suspicion is you will: --------
      • Custom script: set udg_Change_Unit = null
      • Custom script: set udg_Change_Player = null
     
  17. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0
    That is smart, I didn't think of that one.

    I was about to try to say where you went wrong, but I realized I would've been the one who was wrong. Your code might work.

    Actually,
    Can't this just be:
    • Events
      • Unit - A unit is issued an order
    or is that not allowed?
     
  18. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Unless Blizzard added a generic "any order" event with the recent patches there isn't such an event. You have to check all kinds of orders.
     
  19. Nowow

    Nowow

    Joined:
    Jun 15, 2016
    Messages:
    462
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    You can create local variables with udg then refer to them with gui set variable? What sorcery is this?!
    I mean it makes sense, global/local modifiers shouldn't matter when assigning variables but that is a neat trick.
     
  20. ABronzeCross

    ABronzeCross

    Joined:
    Jan 22, 2019
    Messages:
    192
    Resources:
    0
    Resources:
    0
    What about the orders for begin research, begin cast spell, build, drop item, etc? Where can I find all of the built in events?