• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Large loop trouble

Status
Not open for further replies.

Xan

Xan

Level 1
Joined
May 28, 2008
Messages
5
Background:

There are 3 masts of which each have 7 sails of which each have 4 unclipping points.
The int-array SailStatus gives the status of the sails. Each sail (on each mast) has an element in the array (i.e. 0 is for sail 0 on mast 0, 1 is for sail 1 on mast 0, ..., 7 is for sail 0 on mast 1).
The int-array RiggingSailClip gives the status of an unclipping point. Each unclipping point (for each sail on each mast) has an element in the array (i.e. 0-4 is for unclipping points on sail 0 on mast 0, ...).

I am having trouble with some code for which the event is a unit entering a region (many of these regions are added by another trigger). Then the code checks whether the triggering unit is within the first region in a region array and that some variables are satisfied. If the unit is in the first region and the conditions are satisfied then it is given a skill. The conditions relate to a variables in arrays of which the desired variable's position is determined by which mast/sail/unclipping point has been entered; this is why the loop is split into many different loops of varying lengths.

This trigger works with varying success (in some regions it doesn't work at all, other regions have a better success rate). The loops run many many times and I assume this is the problem but cannot see why.

If I check a region/variable then does this leak? I have tried removing the leaks but to no avail.

Any other input into why this is not working/alternative methods would be much appreciated.

Thanks in advance for your help.

Xan

  • GiveRiggerSkills
    • Events
      • Unit - A unit enters Mainsail1 <gen>
    • Conditions
    • Actions
      • -------- If a fully clipped/partially unclipped sail is ready to be unclipped then a crew member may unclip it --------
      • Game - Display to (All players) the text: Crew entered mast r...
      • -------- Loop: number of unclipping point --------
      • For each (Integer A) from 0 to 4, do (Actions)
        • Loop - Actions
          • -------- Loop: Number of sail --------
          • For each (Integer B) from 0 to 6, do (Actions)
            • Loop - Actions
              • -------- Loop: Number of mast --------
              • For each (Integer IntegerC) from 0 to 2, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (RiggingSailRegion[((IntegerC x 28) + (((Integer B) x 4) + (Integer A)))] contains (Triggering unit)) Equal to True
                      • RiggingSailClip[((IntegerC x 28) + (((Integer B) x 4) + (Integer A)))] Equal to 0
                      • SailStatus[((IntegerC x 7) + (Integer B))] Equal to 6
                    • Then - Actions
                      • Game - Display to (All players) the text: Unfurl Sail given t...
                      • Unit - Add Unfurl Sail to (Triggering unit)
                      • Unit - Add Acid Bomb to (Triggering unit)
                    • Else - Actions
                      • Do nothing
 
Level 11
Joined
Feb 11, 2010
Messages
199
First off, NEVER use "Do Nothing." Just leave that space blank. Do Nothing is bad in every way and good in absolutely no ways.

Second off, don't use "Integer A" or "Integer B," I can't see the rest of your map but if you have any other loops running that use A or B they'll interfere with each other. It's just a general good practice to use variables unique to that loop.

Third, leaks can't cause your trigger to "not work." They just cause lag. Also, I don't think checking to see if a unit is in a region causes a leak.

Fourth, since you're talking about success rate by region, it might help to see the rest of the map where you're setting up these regions... I mean, it looks like everything triggers off of entering one region, yet you're checking all these different regions...
 

Xan

Xan

Level 1
Joined
May 28, 2008
Messages
5
Thanks for the advise. I have implemented what you have said into the map and attached it (although the problem is still occurring). Based on what I can see, it always knows I have entered a region but it gets confused as to which region I have entered (e.g. thinks it is the main mast region rather than the royals region).

Re: your previous question - The other "enter region" events are added by a separate trigger as there are so many of them.

To get an idea of it: a crew member must enter the 'lanyard region' and cast man the ropes, then another must enter the mast circle of power (to be teleported to the mast) then unclip sails - this guy should get 'unfurl sail' ability when entering the 'unclipping regions'. (The acid bomb was just added to check it wasn't a bug with the custom ability).

The variables are pretty well documented in the notes.

It is a tad complicated and there are various bugs I do not understand (e.g. teleporting randomly not working despite working in other maps).

Cheers
 

Attachments

  • Pirate Wars beta v1-1.w3x
    186.7 KB · Views: 63
Level 9
Joined
May 30, 2008
Messages
430
There is no problem in using the loops as much as you like as long as u are careful. Change the loop to start from 1 because 0 don't look good to me. I uninstall my warcraft (a few months ago i get bored from the community) so i can't open the map to say if there are other problems (not sure neither for the mentioned above they may not cause problems but yet)
 

Xan

Xan

Level 1
Joined
May 28, 2008
Messages
5
0 should work just as well as 1 (if not better) as far as I can see.

If the loops start from 1 then there will just be a large gap at the start of the integer arrays which is not used.
 
Status
Not open for further replies.
Top