Trigger problems, need help troubleshooting

Nureru

New Member
Reaction score
1
Okay, couple things going on here. I'm making a turn based game, and at the start of the battle it assigns turn order based on agility. That's here:

EDIT: Fixed my first problem.

Next issue is with my enemy AI. I'm using point value to dictate which AI they have. Point value of 1 means they should just run up to whoever's closest and whack at them until someone dies. Point value of 2 means they should run up, attack, and then run away. The issue is enemies with a point value of 1 are doing the routine for enemies with a point value of 2.

Trigger:
  • AI Director
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Point-value of unit_list[1]) Equal to 1
              • (Point-value of unit_list[1]) Equal to 2
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • debug Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: Executing AI routin...
              • Wait 1.00 seconds
            • Else - Actions
          • Trigger - Run Approach to attack Enemy <gen> (checking conditions)
        • Else - Actions


Trigger:
  • Approach to attack Enemy
    • Events
    • Conditions
    • Actions
      • Set temp_point = (Position of unit_list[1])
      • Set temp_real = 2000.00
      • Set temp_group = (Units within temp_real of temp_point matching ((((Matching unit) belongs to an enemy of (Owner of unit_list[1])) Equal to True) and (((Matching unit) is alive) Equal to True)))
      • Unit Group - Pick every unit in temp_group and do (Actions)
        • Loop - Actions
          • Set temp_point_2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between temp_point and temp_point_2) Less than temp_real
            • Then - Actions
              • Set temp_unit = (Picked unit)
              • Set temp_real = (Distance between temp_point and temp_point_2)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Point-value of unit_list[1]) Equal to 2
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • debug Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: Executing AI routin...
            • Else - Actions
          • Trigger - Turn on Flee Enemy <gen>
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in temp_group) Greater than 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • debug Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: (Approaching target: + (Proper name of temp_unit))
            • Else - Actions
          • Unit - Order unit_list[1] to Attack temp_unit
        • Else - Actions
          • Trigger - Run End Turn <gen> (ignoring conditions)
      • Custom script: call DestroyGroup( udg_temp_group )


Trigger:
  • Flee Enemy
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Owner of (Attacking unit)) controller) Not equal to User
      • (Issued order) Not equal to (Order(move))
      • (Ability being cast) Not equal to End Turn
    • Actions
      • Wait 1.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • debug Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: Executing AI routin...
        • Else - Actions
      • Set temp_point = (Position of (Attacked unit))
      • Set temp_point_2 = (Position of (Attacking unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Facing of (Attacking unit)) Greater than or equal to 180.00
        • Then - Actions
          • Set temp_point_3 = (temp_point_2 offset by 800.00 towards (((Facing of (Attacking unit)) - 180.00) + (Random real number between -10.00 and 10.00)) degrees)
        • Else - Actions
          • Set temp_point_3 = (temp_point_2 offset by 800.00 towards (((Facing of (Attacking unit)) + 180.00) + (Random real number between -10.00 and 10.00)) degrees)
      • Unit - Order (Attacking unit) to Move To temp_point_3
      • Custom script: call RemoveLocation( udg_temp_point )
      • Custom script: call RemoveLocation( udg_temp_point_2 )
      • Custom script: call RemoveLocation( udg_temp_point_3 )
      • Trigger - Turn off (This trigger)


I realize I'm asking a lot, but I have no idea what to do anymore. I can't find anything wrong. Any help would be absolutely wonderful.
 

Moridin

Snow Leopard
Reaction score
144
OK. I'll try and help, but you're going to have to explain a few things to me.
Firstly, for the "3 units not getting turns":

Trigger:
  • For each (Integer A) from 1 to (Number of units in temp_group), do (Actions)
    • Loop - Actions
      • Set temp_count = 0
      • 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
              • (Agility of (Picked unit) (Include bonuses)) Greater than temp_count
            • Then - Actions
              • Unit Group - Remove (Picked unit) from temp_group
              • Set unit_list[(Integer A)] = (Picked unit)
              • Set temp_count = (Agility of (Picked unit) (Include bonuses))
              • Unit - Pause unit_list[(Integer A)]
            • Else - Actions


In the first trigger. I simply don't understand the logic behind this bloc (more specifically the loop).

----
* You copied AI Director twice

Secondly, for the different AI's not working:

- Does the text "Executing AI routine" show? (referring to Flee Enemy trigger)
-
Trigger:
  • # If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Facing of (Attacking unit)) Greater than or equal to 180.00
    • Then - Actions
      • Set temp_point_3 = (temp_point_2 offset by 800.00 towards (((Facing of (Attacking unit)) - 180.00) (Random real number between -10.00 and 10.00)) degrees)
    • Else - Actions
      • Set temp_point_3 = (temp_point_2 offset by 800.00 towards (((Facing of (Attacking unit)) + 180.00) (Random real number between -10.00 and 10.00)) degrees)

I don't understand the logic behind the condition of this if.
 

Nureru

New Member
Reaction score
1
Hrm. Looking at that first loop you mentioned, I'm not sure what it's doing. What I had wanted it to do was cycle through each slot, figure out which unit had the highest agility, and then put them in that slot, remove them from the group so in the next slot it wouldn't put them in again, and go that way until all the slots were filled. I think I screwed up and put some of those things in the loop that shouldn't have been in the loop.

That if statement was because they weren't running away properly. They were running at me half the time. That fixed it. I figured WC3 just didn't like angles greater than 360 or less than 0, and this seemed easier than looping it manually. If there's a better way, by all means.

And whoops, didn't mean to copy AI Director twice. Lemme fix that.

Yes, the text Executing AI Routine shows whenever it causes a unit to run away. My issue is when the unit's point value is 1, why is it still running the Flee trigger?

EDIT: Okay, that fixed my first problem. Thanks for pointing that out to me. I scooted the removing from the group and the pausing in that loop just beneath the loop and lo and behold those units suddenly started moving. Don't I feel silly.
 

Moridin

Snow Leopard
Reaction score
144
Ok, try adding this condition to your Flee Enemy trigger:

(Point value of (Attacking unit)) Equal to 2

Note: Freehand.

Will take a closer look at the first trigger for the other problem.
 

Moridin

Snow Leopard
Reaction score
144
Alter your loop in the first trigger to the following. I think that it might go wrong in the wrong circumstances....so I fixed it. Try it out and tell me, as I haven't tested it.

Trigger:
  • For each (Integer A) from 1 to (Number of units in temp_group), do (Actions)
    • Loop - Actions
      • Set temp_count = 0
      • 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
              • (Agility of (Picked unit) (Include bonuses)) Greater than temp_count
            • Then - Actions
              • Set unit_list[(Integer A)] = (Picked unit)
              • Set temp_count = (Agility of (Picked unit) (Include bonuses))
            • Else - Actions
      • Unit Group - Remove unit_list[(Integer A)] from temp_group
      • Unit - Pause unit_list[(Integer A)]


Edit: edited the positioning of the last two lines twice...as they didn't appear in the right place the first two times with wc3 tags.
 

Nureru

New Member
Reaction score
1
Yeah, that fixed it. Don't know why that didn't occur to me. I'm still curious as to why it was running in the first place, but at least the issue is gone. Thanks for your help. +rep
 

Moridin

Snow Leopard
Reaction score
144
I can explain it to you if you want. (explaining in an edit right now)

I now understand that the loop is there to make an initiative roll, somewhat like in DnD. Basically a list of who starts first, who gets the next turn and so on.

I also realised that you had made a simple mistake. I can better explain it with an example, so:

Let's say there are 5 units: A, B, C, D, E and let's say their agility is A>B>C>D>E for simplicity's sake.

if the unit group picked B first and then A and went through the actions, it would find B to be the current highest (which would actually be wrong as A is the highest). It would then proceed to remove B from the group ALONG with remove A from the group right after that and completely erase B's place in the list as A overrides it.

What it actually has to do (which it does now) is find the highest out of all, and then put the highest in it's rightful place in the list. Simply put, it's placement has to be outside the loop where it finds the highest.

If you didn't get that, I can explain it a little more :).
Np for the help btw. Thanks for the rep.
 

Nureru

New Member
Reaction score
1
Oh, sorry, I wasn't clear. I figured out the first issue shortly after you pointed it out to me and I sat down to try to explain what was going on. The one I still don't get but works now is the flee trigger. Do you know why that one was executing when the point value was 1?
 

Moridin

Snow Leopard
Reaction score
144
Oh. Simply because there was no condition to ensure that the point value was 2 :). The event was "A unit is attacked" which would have happened for both point value units.
 

Joccaren

You can change this now in User CP.
Reaction score
54
Also, is your AI controlled by a AI player? If so, this could be part f your problem. Even when no AI script is running for them, AI players tend to take control of the units under their control (Had this Problem With my AI). Say you had a Paladin, and you told it to just walk up and attack an enemy, then run when he reaches low hp and, whilst running, cast 'Divine Sheild'. The Computer Player, with no AI script running, will order the unit to cast Divine sheild when entering combat, not whilst leaving it (Just an example).
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1

      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