A strange bug

Joccaren

You can change this now in User CP.
Reaction score
54
Ok, so recently a number of my triggers have been mysteriously not working. After a lot of trouble shooting the problem seems to come from the map itself, with a strange bug or something that I haven't seen before.

Now, my map presently has 3 "Players" activated. Used to be 2, but for debugging this I enabled the third. Player 1 is the user, 2 is an AI called ErrorCheck, and 12 is a Computer called People.

I have enabled the "Spawn starting units" melee trigger, but none of the others. I am using the Jass NewGen pack. I have only done this with the "Test map" function, I will soon try to do a test launching straight from Warcraft and see if it persists.

First evidence of this popped up when I realised that Player 12's colour was blue, and was named "Computer", as opposed to being brown and named "People". Even when spawning in units. Curious as to whether this was at all being a problem, I added in player 2 blue and named it ErrorCheck. Now the weird stuff really starts. Originally, none of the units controlled by this AI were obeying trigger orders. I could place a build order, and it would just stand there. Done with default units and buildings to error check, its not the object editor doing things.
Presently, however, only 1 AI spawns. The player spawns, and the blue, "Computer" named player spawns, however the third AI that should be spawning does not. All have their spawn points defined, and are enabled in the map settings.

Presently, this is acting as a bit of a blocker to doing... Anything that doesn't involve the player directly. There are workarounds I guess, however they are far less than optimal. Does anyone have any idea as to why only one AI spawns, and that AI seems to behave... Randomly to say the least?
 

Joccaren

You can change this now in User CP.
Reaction score
54
Ok, after some more toying around the players themselves are now spawning properly, however no unit at all is obeying any order given to it by a trigger.

Here is an example of one such trigger. The trigger posts out all the debugs [Dependent on which If/Then/Else ends up being selected] except for the "People be moving yo" message, and spawns the builder. The only thing it fails to do is either order the units in the unit group to do anything, or order the peasant to build: [This is the Actions segment. The trigger is when a Unit enters playable map area, the condition checks the type of unit to ensure it is the correct unit] :
Code:
 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        ((Entering unit) is in NationAir) Equal to (==) True
    Then - Actions
         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                BuildAirOrder[(Custom value of (Entering unit))] Equal to (==) Temple
            Then - Actions
                 Do Multiple ActionsFor each (Integer TrueFalseInt) from 1 to 5, do (Actions)
                    Loop - Actions
                        Set VarRandInt = (Random integer number between 1 and 1)
                         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                BuildSiteTakenAir[VarRandInt] Equal to (==) True
                            Then - Actions
                                -------- Debug --------
                                Game - Display to (All players) the text: (Build site  + ((String(VarRandInt)) +  is taken))
                            Else - Actions
                                Set AirVillageSite[(Custom value of (Entering unit))] = BuildSiteAir[VarRandInt]
                                Set BuildSiteTakenAir[VarRandInt] = True
                                Set SiteFound = True
                                -------- Debug --------
                                Game - Display to (All players) the text: (Build site  + ((String(VarRandInt)) +  is selected))
                                Set TrueFalseInt = 5
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        SiteFound Equal to (==) True
                    Then - Actions
                        -------- Debug --------
                        Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: Post for loop
                        Unit - Create 1 Peasant for Player 12 (Brown) at (Center of AirVillageSite[(Custom value of (Entering unit))]) facing Default building facing (270.0) degrees
                        Unit - Order (Last created unit) to build a Air Temple at (Position of (Last created unit))
                        Unit Group - Pick every unit in FactAirVillage[(Custom value of (Entering unit))] and do (Actions)
                            Loop - Actions
                                Unit - Order (Picked unit) to Move To (Random point in AirVillageSite[(Custom value of (Entering unit))])
                                Set UnitJob[(Custom value of (Picked unit))] = Move
                                -------- Debug --------
                                Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: People be moving yo
                        Set AIAirVillageGoal[(Custom value of (Triggering unit))] = Build
                    Else - Actions
                        -------- Debug --------
                        Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: No site found
            Else - Actions
    Else - Actions
 

vypur85

Hibernate
Reaction score
803
What is the array size of your unit group (FactAirVillage)?
Try setting the array size to a relatively larger value, like 20.

I haven't check through the trigger though. It's too lengthy.
 

Joccaren

You can change this now in User CP.
Reaction score
54
From memory the array size didn't matter, unless you were setting default values for the variables, whilst I declare what is in this group in another variable. Is this different for Unit Groups?
Either way, I'll give it a go and see how it works.
 

Joccaren

You can change this now in User CP.
Reaction score
54
Ok, so I've got the unit to build and all finally. The group still isn't moving, which is a bit annoying, but its less essential than the rest at this point.

Another issue has arisen though. I duplicated a Town Hall, gave it the animation tags Upgrade and Second to have it look like a castle, and removed all its abilities and descriptions, called it Air Temple. This has, however, resulted in another strange thing. The game presently counts it as a Hero for some reason. It has levels, it has stats, and it has a name string - but only in game. In the editor it is treated as a normal building, but the game itself shows it as a unit. Again, any clue on what's going on here?
 

vypur85

Hibernate
Reaction score
803
> any clue on what's going on here?
Sounds like an odd bug here. I guess you'd better back up some stuff before it gets worse.
Normal units/structures won't become hero all of a sudden.

> group still isn't moving
What do you mean? The units are not moving or the unit group is not looping?
Unit groups are initialised during the game load. So you'd have to set the array size to a value.
 

Joccaren

You can change this now in User CP.
Reaction score
54
>Sounds like an odd bug here.
Yeah, I'll delete its data entry, and start making it up in the object editor again from scratch. ATM I don't have any terrain, or much object data done, its mostly the background system triggers I'm working on ATM, so if I have to start a new map to get rid of it it won't be the end of the world.

>The units are not moving or the unit group is not looping?
Both, near as I can tell. I never get the message saying that they are moving, which I have added on its own inside the loop. I've done as suggested, and bumped up the Array size to 80, but it still does this. I'll do some more debugging and see if I can find exactly where the problem lies.
 

vypur85

Hibernate
Reaction score
803
> debugging and see if I can find exactly where the problem lies
Yeah. You'll probably wanna check out if the unit group is actually containing anything.
Also, check out what is the current count for the unit group array. Ie. what's the unit custom value.
And see if the unit group[custom value] has been created correctly in the first place.

This may/may not help, try placing the debug message at the beginning of the unit group loop (before the unit order action). See if there is any message created ingame.
 

jonas

You can change this now in User CP.
Reaction score
64
Ok, so I've got the unit to build and all finally. The group still isn't moving, which is a bit annoying, but its less essential than the rest at this point.

Another issue has arisen though. I duplicated a Town Hall, gave it the animation tags Upgrade and Second to have it look like a castle, and removed all its abilities and descriptions, called it Air Temple. This has, however, resulted in another strange thing. The game presently counts it as a Hero for some reason. It has levels, it has stats, and it has a name string - but only in game. In the editor it is treated as a normal building, but the game itself shows it as a unit. Again, any clue on what's going on here?

What is the object code of the Air Temple?

Ok, after some more toying around the players themselves are now spawning properly, however no unit at all is obeying any order given to it by a trigger.

Here is an example of one such trigger. The trigger posts out all the debugs [Dependent on which If/Then/Else ends up being selected] except for the "People be moving yo" message, and spawns the builder. The only thing it fails to do is either order the units in the unit group to do anything, or order the peasant to build: [This is the Actions segment. The trigger is when a Unit enters playable map area, the condition checks the type of unit to ensure it is the correct unit] :

Show us the code where you set
FactAirVillage[(Custom value of (Entering unit))]
and every place where you modify it (e.g., adding units).
 

Joccaren

You can change this now in User CP.
Reaction score
54
Alright, so after a bit of RL stuff, finally got around to some debugging.

The core of the issue is that the custom value of the unit seems to be set to 2, rather than 1, and hence it references an empty unit group rather than the one with units in it. The unit group should be working and all, I just realised, as it is used in other triggers and works.

I've also deleted and recreated the Air Temple, and now it behaves as expected. Presently its unit code is at01, previously I believe it was at00.

Code where the custom value of the unit is set. Its a long one as it also goes through a bunch of other things:

Code:
 Do Multiple ActionsFor each (Integer A) from 1 to FactVillageNumber[1], do (Actions)
    Loop - Actions
        Unit Group - Pick every unit in FactAirVillage[(Integer A)] and do (Actions)
            Loop - Actions
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked unit) is in FactAirMasters) Equal to (==) True
                    Then - Actions
                        Unit Group - Add (Picked unit) to VotingSession[VoteSessionCount]
                    Else - Actions
        Unit Group - Pick every unit in VotingSession[VoteSessionCount] and do (Actions)
            Loop - Actions
                Set VotingIssue[(Custom value of (Picked unit))] = BuildT
        Unit Group - Pick every unit in VotingSession[VoteSessionCount] and do (Actions)
            Loop - Actions
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                         Multiple ConditionsAnd - All (Conditions) are true
                            Conditions
                                FactVillageNumber[1] Less than (<) 4
                                ((Number of units in FactAirVillage[(Integer A)]) + ((StatWillpower[(Custom value of (Picked unit))] / 2) + ((StatWisdom[(Custom value of (Picked unit))] / 3) + ((Custom value of (Picked unit)) / 2)))) Greater than (>) 35
                    Then - Actions
                        Set Vote[(Custom value of (Picked unit))] = True
                    Else - Actions
                        Set Vote[(Custom value of (Picked unit))] = False
        Unit Group - Pick every unit in VotingSession[VoteSessionCount] and do (Actions)
            Loop - Actions
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Vote[(Custom value of (Picked unit))] Equal to (==) True
                    Then - Actions
                        Set VoteFor[VoteSessionCount] = (VoteFor[VoteSessionCount] + 1)
                        -------- Debug --------
                        Game - Display to (All players) the text: ((Proper name of (Picked unit)) +  Has Voted Yes)
                    Else - Actions
                        -------- Debug --------
                        Game - Display to (All players) the text: ((Proper name of (Picked unit)) +  Has Voted No)
         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                 Multiple ConditionsOr - Any (Conditions) are true
                    Conditions
                        VoteFor[VoteSessionCount] Greater than (>) ((Number of units in VotingSession[VoteSessionCount]) / 2)
                        DebugVoteRig Equal to (==) True
            Then - Actions
                Unit - Create 1 Dummy Build for Player 12 (Brown) at (Center of (Playable map area)) facing Default building facing (270.0) degrees
                Unit - Set the custom value of (Last created unit) to (Integer A)
                Unit Group - Add (Last created unit) to NationAir
                Set BuildAirOrder[FactVillageNumber[(Integer A)]] = Temple
            Else - Actions
                -------- Debug --------
                Game - Display to (All players) the text: Vote Failed
        Set VoteSessionCount = (VoteSessionCount + 1)

FactAirVillageNumber[1] is set in another trigger here, as is the addition of units to the group:

Code:
Actions
    Set FactVillageNumber[1] = 1
    Unit Group - Pick every unit in (Units in Rect 000 <gen>) and do (Actions)
        Loop - Actions
            Unit Group - Add (Picked unit) to NationAir
            Unit Group - Add (Picked unit) to FactAirVillage[FactVillageNumber[1]]
            -------- Debug --------
            Game - Display to (All players) the text: ((Proper name of (Picked unit)) + ( is part of village  + (String(FactVillageNumber[1]))))
    Set FactVillageNumber[1] = (FactVillageNumber[1] + 1)

The only thing that I can think of is that IntegerA is reaching 2 midway through, without getting to assigning the custom value of the unit. The whole voting system works properly, though I normally skip it by setting DebugVoteRig to true, and it references the units in FactAirVillage[1], where the 1 is selected as Integer A, as shown in the code. Any idea as to why this is?
 

jonas

You can change this now in User CP.
Reaction score
64
I am not really sure what your code is supposed to do, but maybe you meant to have the following line:
Code:
Set FactVillageNumber[1] = (FactVillageNumber[1] + 1)

Inside of the loop?

E.g., like this:
Code:
Actions
    Set FactVillageNumber[1] = 0
    Unit Group - Pick every unit in (Units in Rect 000 <gen>) and do (Actions)
        Loop - Actions
            Set FactVillageNumber[1] = (FactVillageNumber[1] + 1)
            Unit Group - Add (Picked unit) to NationAir
            Unit Group - Add (Picked unit) to FactAirVillage[FactVillageNumber[1]]
            -------- Debug --------
            Game - Display to (All players) the text: ((Proper name of (Picked unit)) + ( is part of village + (String(FactVillageNumber[1]))))
 

Joccaren

You can change this now in User CP.
Reaction score
54
At the moment its just a placeholder in the most part. Its meant to assign units to a specific village group dynamically as needed in game. As I haven't built the systems for that yet though, I simply use all the units inside a given region as my test village set, and they are all added to the same 1 village. So, ATM that is as intended. All the units in the group should be in the same village group, but later I'll be expanding the trigger, and then changing the village group based on
 

jonas

You can change this now in User CP.
Reaction score
64
Apparently I am not clear enough, so let me say this: are you aware that your for integer A ... loop is run for A = 1 and for A = 2, therefore creating a builder with custom value 2?
The reason for this is the line I mentioned before:

Code:
Set FactVillageNumber[1] = (FactVillageNumber[1] + 1)
 

Joccaren

You can change this now in User CP.
Reaction score
54
Well, yes. Eventually there will be multiple Air Village Faction groups that will be run through with this voting trigger.
The trigger first gets every unit in the air village group, checks if they are a Master, and if they are, adds them to a voting session group.
It then runs through the voting session group, and sets the voting topic [ATM there is only one, later I will add more].
Next it runs through the voting session group again, and gets the group's votes on the issue.
After tallying up the votes, and seeing if the vote passes or not [I have a rigging mechanism I enable to ensure it always passes], it will create a builder, and set its custom value to the value of the air village group that was voting, as well as setting which building is to be built.
It then follows into another trigger, the original one, where the location for the build is decided, and a builder is spawned there and builds the building [Or places it, more accurately], whilst ordering the village group to move to the approximate location of the building.

The weird thing that happens is that Integer A seems to change what it is midway through the trigger. It creates the voting session for village group 1, votes with the units from village group 1, delivers a verdict for village group one, and then creates a build trigger unit for village group 2.
Whilst I could make sure Integer A only runs for the number of villages there are, rather than one more [Which shouldn't have an effect as there are no units in that unit group], that would seemingly not solve the problem of village group 1 not getting a builder, and would introduce problems when more village groups are added, which I am trying to solve now.

All actions seem to be a part of the for Integer A loop, so I am confused as to why Integer A seemingly changes partway through this loop.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top