Trigger's help :)

soider8

New Member
Reaction score
0
This is my trigger:

Trigger:
  • AI
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Set Building[1] = Dryad Spawner
      • Set Building[2] = Druid Secreter
      • Set Building[3] = Treant Harvester
      • Set Building[4] = Light Archer Base
      • Set Building[5] = Light Infantry Base
      • Set Building[6] = Light Cavalry Base
      • Set Building[7] = Ultimate Golem
      • Set Temp_Group = (Units in Red Zone <gen> matching ((((Owner of (Matching unit)) is an ally of Player 1 (Red)) Equal to True) and (((Owner of (Matching unit)) controller) Equal to Computer)))
      • Unit Group - Pick every unit in Temp_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current order of (Picked unit)) Equal to (Order(<Empty String>))
            • Then - Actions
              • Set Temp_Point = (Random point in Red Zone <gen>)
              • Unit - Order (Picked unit) to build a Building[(Random integer number between 1 and 7)] at Temp_Point
              • Custom script: call RemoveLocation (udg_Temp_Point)
            • Else - Actions
      • Custom script: call DestroyGroup (udg_Temp_Group)


I want the AI to build the desired building, only when it has enough money, not to random every 10 seconds. So I want the AI to choose a type of building and wait for enough money to build it, and carry out the order.

I would like it if someone could edit the trigger as how it should be, I will be able to replicate it then.

Thanks :)
 

TomTTT

New Member
Reaction score
44
Maybe try something like this:
Trigger:
  • Building
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching ((((Matching player) slot status) Equal to Is playing) and (((Matching player) controller) Equal to Computer))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) Current gold) Greater than or equal to MONEY NEEDED
            • Then - Actions
              • Set Buildings[1] = Dryad Spawner
              • Set Buildings[2] = ...
              • Set Buildings[3] = ...
              • Set Buildings[7] = Ultimate Golem
              • Set TempPoint = POSITION
              • Set TempGroup = (Units in Red Zone <gen> matching ((((Owner of (Matching unit)) is an ally of Player 1 (Red)) and (((Owner of (Matching unit)) controller) Equal to Computer)))
                • Unit Group - Pick every unit in TempGroup and do (Actions)
                  • Loop - Actions
                    • If (All conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (Current order of (Picked unit equal to (Order(stop))
                      • Then - Actions
                        • Unit - Order UNIT to build a Buildings[(Random integer number between 1 and 7) ]at TempPoint
                        • Custom script: call RemoveLocation(udg_TempPoint)
                      • Else - Actions

Now just destroy rest of the leaks (TempGroup).
Some of it was handwritten, so it may seem clumsy.
 

AoW_Hun7312

I'm a magic man, I've got magic hands.
Reaction score
76
You set the same variable values over and over (Buildings array). You're better off setting that during map initialization or game time 0.00 to save function calls.
 

HydraRancher

Truth begins in lies
Reaction score
197
Also Tom,t hat doesn't look right. You put the custom script inside the if/then/else, so if it runs once, it will only work once, the rest of the times it will do it in the Center of Playable Map Area.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top