• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Ordering AI to do Reserch

Status
Not open for further replies.
Level 7
Joined
Oct 8, 2007
Messages
154
Hi !
I want AI to make a research from the time to time when it has money, do you have idea why does this trigger doesn't really work :/ ?


  • bot upgrades units
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to Computer
      • ((Owner of (Triggering unit)) Current gold) Greater than or equal to 110
    • Actions
      • Unit - Order Upgrade Center 0176 <gen> to research Iron Forged Weapons
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
Triggering Unit is null when you make the conditions, so the trigger never actually fires
because Time Event does not use units mainly

you can do this though:
  • Events -
    • Time - Every 5 seconds of game time
  • Conditions -
  • Actions -
    • Loop temp_int from 1 to 12
      • If (Conditions), Then (actions), Else (Actions)
        • If -
          • (Player(temp_int)) controller equal to Computer
          • (Player(temp_int) Current gold) Greater than or equal to 110
        • Then -
          • Unit - Order Upgrade_Center[temp_int] to research Iron Forged Weapons
        • Else -

You will just need to set an array unit variable to the upgrade centers referring to each player, like this:
  • Events -
    • Time - Elapsed Game Time becomes 0 s
  • Conditions -
  • Actions -
    • Set Upgrade_Center[1] = Upgrade Center of player 1
    • Set Upgrade_Center[2] = Upgrade Center of player 2
    • Set Upgrade_Center[3] = Upgrade Center of player 3
    • Set Upgrade_Center[4] = Upgrade Center of player 4
    • Set Upgrade_Center[5] = Upgrade Center of player 5
    • ------And you continue like that------
 
You use 'Owner of TriggeringUnit' as refrerence but you dont have any unti who triggers this, because it gets fired just each 30 seconds.

If you want check it for one specific player:


  • Events
    • Time - Every 30.00 seconds of game time
  • Conditions
    • YourPlayer Current Gold >= 110
    • YourPlayer controller Equal to Computer
  • Actions
    • Unit - Order YourUnit to research YourResearch


If you want check for all players you can loop them:


  • Events
    • Time - Every 30.00 seconds of game time
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 12, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Conditions
            • ((Player((Integer A))) Current Gold) >= 110
            • ((Player((Integer A))) controller) Equals to Computer
          • 'THEN'-Actions
            • Unit - Order Unit[Integer A] to research YourResearch
          • 'ELSE'-Actions
Unit[Integer A] is a variable. This would require that you set them for each player in an Init-trigger:

Set Unit[1] = Red's Unit
Set Unit[2] = Blue's Unit
...
Set Unit[12] = Brown's Unit


Edit: Sorry Jad, when I started to trigger it was empty :p
 
Level 7
Joined
Oct 8, 2007
Messages
154
I have a problem


How shall I use Loop Integer?
Only way is like this :

integeraJ_nqnnpqn.JPG


But later in trigger it doesnt look like in yours ;)

I can get result like for ex

  • ((Load (Integer A) of (Integer A) in (Last created hashtable)) Current gold) Equal to 0
simply how to put loop integer a into argument of Player() ?
Sorry for such a n00b questions but I havent been doing triggers since a long time and work in c++ on everyday nowadays.

by the way how to make the same thing but when I want to upgrade building from Building a to B is ? I think i will handle it when i will understand researchbut ask just in case :p
 
Last edited:
Status
Not open for further replies.
Top