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!
I'm trying to set a a system that overrides unit exploration, on my map I'm doing it by periodically creating and destroying visibility modifiers that follow the unit around, and so far it works but is kinda buggy since unit sight is a circular area which I cant completely surround using squared regions, so far I cant think of a way to fix that. Any ideas on how to make this system more efficient? . Also is it possible for a visibility modifier to work on "everything but a region" ?
Since it depends on movement I don't think i can explain it good with pictures so I attached an a little example map file thanks in advance for the help
At first I post trigger for others (german editor, but you can use power of imagination)
BlackMask
Ereignisse
Zeit - Every 0.10 seconds of game time
Bedingungen
Aktionen
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
B Gleich 0
'THEN'-Aktionen
Set Position[0] = (X of (Position of Unit))
Set Position[1] = (Y of (Position of Unit))
Sichtbarkeit - Create an initially Aktiviert visibility modifier for Spieler 1 (Rot) emitting Schwarze Maske across (Region centered at (Point(Position[0], (Position[1] + 2050.00))) with size (4600.00, 500.00))
Set VisMod[0] = (Last created visibility modifier)
Sichtbarkeit - Create an initially Aktiviert visibility modifier for Spieler 1 (Rot) emitting Schwarze Maske across (Region centered at (Point((Position[0] + 2050.00), Position[1])) with size (500.00, 3600.00))
Set VisMod[1] = (Last created visibility modifier)
Sichtbarkeit - Create an initially Aktiviert visibility modifier for Spieler 1 (Rot) emitting Schwarze Maske across (Region centered at (Point(Position[0], (Position[1] - 2050.00))) with size (4600.00, 500.00))
Set VisMod[2] = (Last created visibility modifier)
Sichtbarkeit - Create an initially Aktiviert visibility modifier for Spieler 1 (Rot) emitting Schwarze Maske across (Region centered at (Point((Position[0] - 2050.00), Position[1])) with size (500.00, 3600.00))
Set VisMod[3] = (Last created visibility modifier)
Set B = 1
'ELSE'-Aktionen
For each (Integer A) from 0 to 3, do (Actions)
Schleifen - Aktionen
Sichtbarkeit - Destroy VisMod[(Integer A)]
Set Position[0] = (X of (Position of Unit))
Set Position[1] = (Y of (Position of Unit))
Sichtbarkeit - Create an initially Aktiviert visibility modifier for Spieler 1 (Rot) emitting Schwarze Maske across (Region centered at (Point(Position[0], (Position[1] + 2050.00))) with size (4600.00, 500.00))
Set VisMod[0] = (Last created visibility modifier)
Sichtbarkeit - Create an initially Aktiviert visibility modifier for Spieler 1 (Rot) emitting Schwarze Maske across (Region centered at (Point((Position[0] + 2050.00), Position[1])) with size (500.00, 3600.00))
Set VisMod[1] = (Last created visibility modifier)
Sichtbarkeit - Create an initially Aktiviert visibility modifier for Spieler 1 (Rot) emitting Schwarze Maske across (Region centered at (Point(Position[0], (Position[1] - 2050.00))) with size (4600.00, 500.00))
Set VisMod[2] = (Last created visibility modifier)
Sichtbarkeit - Create an initially Aktiviert visibility modifier for Spieler 1 (Rot) emitting Schwarze Maske across (Region centered at (Point((Position[0] - 2050.00), Position[1])) with size (500.00, 3600.00))
Set VisMod[3] = (Last created visibility modifier)
Any ideas on how to make this system more efficient?
If I see this right you only use this "B" integer variable once, to check if trigger runs first time.
You could just run these actions once in an other trigger instead of making a check each 0.1 seconds which is not needed. And this B would also be useless.
And for further situations if you need checks like this, just use a boolean which is TRUE or FALSE. (bools are cooler :d)
Custom script: set udg_Position[0] = GetUnitX(udg_Unit)
Custom script: set udg_Position[1] = GetUnitY(udg_Unit)
And you should create 2 normal real variables and call them x and y instead of "position" and array.
Then you could create these 3 rects once and then only refresh their position to unit instead of re-creating and destroying them.
(I know you seem to be only GUI user but just wanna show you the cool native function, and you could use it in custom script)
Imagine we already have the coordinates of your unit called x,y and rects are r [array].
In case you don't know: Circles are also an option, not only rects.
note:
If you would change it as I said you would not, but currently you leak more than 10~ locations in your periodic event.
Read about MemoryLeaks and how to prevent it. You find a tutorial in my signature under "Links".
I fixed somethings you mentioned.
1. made the first run of the trigger in a different one, which made B not needed anymore.
2. Changed the Position array for two variables instead, X and Y
question: the reason behind this is that I should avoid arrays when possible?
3. used the custom script instead of the = (x of (Position of Unit))
Custom script: set udg_X = GetUnitX(udg_Unit)
Custom script: set udg_Y = GetUnitY(udg_Unit)
4. here is were i got the problem.
For starters xD I am a GUI person since I'm new at this , but I don't reject at all custom scripts I plan on learning JASS eventually.
well the function you gave me makes regions move. Since I didn't work with regions , only with the VisModifiers I had to work around it making 4 starter regions and setting them into an array variable at map Init.
Melee Initialization
Events
Map initialization
Conditions
Actions
-------- Unit creation, Day/Night cycle.. bla bla bla. --------
Set MaskR[0] = Top <gen>
Set MaskR[1] = Right <gen>
Set MaskR[2] = Bot <gen>
Set MaskR[3] = Left <gen>
Now the problem I get resides on Vision modifiers creating on the region position but being unattached of the region. What I mean is that even if I move the regions. the VisMod will not move with it... I even tried Disable /Enable In hopes for them to be refreshed which brings me to needing to destroy and re-create them in the new region position making it just a harder way to do what I initially did. Im doing something wrong?.
Ill attach the 2 triggers the initial(runs one time) and the periodic ones.
BlackMask Init
Events
Time - Elapsed game time is 1.00 seconds
Conditions
Actions
Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Black mask across Top <gen>
Set VisMod[0] = (Last created visibility modifier)
Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Black mask across Right <gen>
Set VisMod[1] = (Last created visibility modifier)
Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Black mask across Bot <gen>
Set VisMod[2] = (Last created visibility modifier)
Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Black mask across Left <gen>
Set VisMod[3] = (Last created visibility modifier)
-------- I know this will not make the regions move as a Square. Since they all are being moved to the same place but ill fix that when the VisionModifiers actualy move. xD --------
Floating Text - Create floating text that reads Region is here but ... at (Center of MaskR[0]) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
-------- Debug --------
For each (Integer A) from 0 to 3, do (Actions)
Loop - Actions
Visibility - Disable VisMod[(Integer A)]
Visibility - Enable VisMod[(Integer A)]
Also Three out of curiosity questions...
1) Custom scripts are compatible with "For each Integer A... do actions" actions?
because this will not pass the syntaxis test
Look at The Things That Leak tutorial.
This leaks. (Center of MaskR[0])
Post your triggers that are the problem please.
Don't use integer A / B. They are slower and less efficient than using your own variable.
Regions always move with the move region action. The reason you are thinking that they do not move is that the trigger events never get updated. So the old location is still being used for the triggers events.
Arrays are almost the same as using non arrayed variables. The differences is that they are an array of one type of variable. The look up is slightly slower but nothing that you would ever notice. Not even when using a few thousand look ups.
Look at my tutorial things a GUIer should know. It is in my sig.
I'm aware of the leaks so far (at least now) ill fix them when the triggers work :c...
I'm sorry if the extra triggers I posted are un-needed I like to fill my questions with all the info I find pertinent so I can get a nice single answer... instead of making a series of post were I try to explain what I really need making people waste time because I failed to explain with my main question that lacked info.
Erm no, I KNOW the regions move, I even made a debug message to make sure of that , the problem is that the Vision modifiers don't move with the region... the problem are them not the regions.
Yes i gave up on moving the Visibility modifier, although would be nice discovering if is even possible to move them.
I Saw your solutions I like it! is similar to my first idea but fixes those ugly rectangular corners on vision and is amazingly much simpler.
Also it reminds me of a early idea I rejected before even making this post. which was pretty much the same thing... creating a global black mask and making a visibility modifier (circular) around the unit but It was buggy ... some how that plain "emitting visibility" did not override the black mask, I was getting a intermittent vision.
Learning GUI is can demotivate you sometime xD knowing that the power tools reside on JASS, but o well I suppose one should start with the basics.
Btw in that script( yes im using JassCraft to help me understand scripts for a time now)
native SetFogStateRadius takes player forWhichPlayer, fogstate whichState, real centerx, real centerY, real radius, boolean useSharedVision returns nothing
Focus on " fogstate whichState "
I saw that you wrote:
...,FOG_OF_WAR_VISIBLE,...
What other options are there to use in that field? just out of curiosity so i can play with it.
by the way thanks for the amazing attention and help I really appreciate it
you too deathismyfriend
From what I know you can't move the modifiers. You have to destroy and create them. You can create multiples though for common areas then you can check if the x and y values is at the common area and hide and show the already created modifier instead of creating and destroying them.
Yes i gave up on moving the Visibility modifier, although would be nice discovering if is even possible to move them.
native SetFogStateRadius takes player forWhichPlayer, fogstate whichState, real centerx, real centerY, real radius, boolean useSharedVision returns nothing
Focus on " fogstate whichState "
I saw that you wrote:
...,FOG_OF_WAR_VISIBLE,...
What other options are there to use in that field? just out of curiosity so i can play with it.
If you use JNGP you can go to the trigger editor then you can click on the function list and click constants. Then type in fog and it will come up with these that you can use.
If you are thinking about switching to JASS you should take a look at my GUI to efficient JASS tutorial. That is the way I learned. I tried to make it as easy as possible and you can post on the tutorial for any questions.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.