• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Give Vision of two areas -> fix help needed

Status
Not open for further replies.

Ardenian

A

Ardenian

  • Sight Dwarfen goldmine
    • Ereignisse
      • Einheit - A unit enters Dwarfes Gold Mine <gen>
    • Bedingungen
    • Aktionen
      • Set Dwarves_Goldmine_Sight = (Entering unit)
      • Sichtbarkeit - Create an initially Aktiviert visibility modifier for (Owner of Dwarves_Goldmine_Sight) emitting Sichtbarkeit across Dwarfes Gold Mine <gen>
      • Sichtbarkeit - Create an initially Aktiviert visibility modifier for (Owner of Dwarves_Goldmine_Sight) emitting Sichtbarkeit across Dwarfes Gold Mine 2 <gen>
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Bedingungen
          • (Dwarfes Gold Mine <gen> contains Dwarves_Goldmine_Sight) Gleich False
        • 'THEN'-Aktionen
          • Sichtbarkeit - Destroy (Last created visibility modifier)
        • 'ELSE'-Aktionen

This trigger is supposed to give you vision of two areas, called 'dwarfes gold mine' and 'dwarfes gold mine 2', but for ´some reason, it doesn't work.
 

Ardenian

A

Ardenian

Well, you create it and then you destroy it straight away? Does one of them work?

I added requirement that 'entering unit' is not in the area anymore. So I have to write the destroy-function into another trigger -> I cannot write a trigger with create AND destroy function in one trigger ?
So a second trigger would run in case 'entering unit' leaves the region and destroy that visibility ?
 

Ardenian

A

Ardenian

You need a timed difference between the create and destroy.
If you use wait timers, you can do it with one trigger.
If you use timers, you could do it in one with JASS or two with GUI.

hm, okay, guess I will change it into two different triggers then.
Thank you!
 
Level 6
Joined
Oct 31, 2014
Messages
170
Yeah you can simply create another trigger (initialy off) and turn it on at the end of your first trigger.
 

Ardenian

A

Ardenian

Yeah you can simply create another trigger (initialy off) and turn it on at the end of your first trigger.

Hm, I don't think turn off and turn on would be a good idea. I suppose it is better to create to different triggers that run with 'entering' and 'leaving' event. If you limit unit-type to 'hero' ( in case you only have one hero), that should be no problem.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
I cannot write a trigger with create AND destroy function in one trigger ?
Yes because the result is illogical. It might instantly create and destroy it as all non-blocking actions happen instantly with regard to game state.

So a second trigger would run in case 'entering unit' leaves the region and destroy that visibility ?
Generally that is the recommended approach. A trigger for each entry event in your system. You could use a polling approach with blocking actions like TriggerSleepAction and an infinite loop for the destruction event but this is generally less efficient and reliable due to the mechanics of TriggerSleepAction in WC3.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Events:
- generic unit enters (region)
Conditions:
- PlayerHasVision[number of (owner of (triggering unit))] is equal to false
Actions:
- set TempPlayer = owner of (triggering unit)
- set TempInteger = number of TempPlayer
- set PlayerHasVision[TempInteger] = true
- create visibility modifier etc etc etc.
- set VisibilityModifierGoldMine1[TempInteger] = last created visibility modifier
- create visibility modifier etc etc etc.
- set VisibilityModifierGoldMine2[TempInteger] = last created visibility modifier

Events:
- generic unit leaves (region)
Conditions:
- number of units in (region) owned by (owner of (triggering unit)) is equal to 0
- PlayerHasVision[number of (owner of (triggering unit))] is equal to true
Actions:
- set TempPlayer = owner of (triggering unit)
- set TempInteger = number of TempPlayer
- set PlayerHasVision[TempInteger] = false
- destroy VisibilityModifierGoldMine1[TempInteger]
- destroy VisibilityModifierGoldMine2[TempInteger]

This is what DSG said... sort of.
This will keep an eye on any unit that enters or leaves.

The "PlayerHasVision[] is equal to true" in the second one is not necessary I guess.
But it will always avoid crashes.
 

Ardenian

A

Ardenian

Okay, then I will create them this way.

I was just confused because I saw once a trigger that run multiple actions ( it was for item classes based on Item level) and so I thought that one could create multiple conditiond in one trigger. But of course, they were not 'create' and 'destroy', but checking if a certain condition ( Item level) is true. It just confused me because the creator put the following if/then/else in the 'else'-section of the earlier if/then/else-function.
 
Status
Not open for further replies.
Top