• 🏆 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!

Help with tree respawn when area has no units.

Status
Not open for further replies.
Level 9
Joined
Jul 11, 2009
Messages
294
Hey guys,


How can I make a trigger in GUI that initiates tree respawn when the tree dies?
However, I need the tree to respawn only when area has no units to prevent the units from being stucked between the trees.

Thanks!
 
Here you go.
First the doodad that dies needs to be stored into an arrayed variable.
  • Tree Dies
    • Events
      • Destructible - A destructible within (Playable map area) dies
    • Conditions
      • (Destructible-type of (Dying destructible)) Equal to Summer Tree Wall
    • Actions
      • Set TotalDeadDestructables = (TotalDeadDestructables + 1)
      • Set DeadDestructables[TotalDeadDestructables] = (Dying destructible)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TotalDeadDestructables Equal to 1
        • Then - Actions
          • Trigger - Turn on Periodic Check <gen>
        • Else - Actions
Not really necessary how much the periodic timer runs all the time, just own opinion. Although I think that this is the best time for how ofen it is checked that there are no units there.
  • Periodic Check
    • Events
      • Time - Every 0.34 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Index) from 1 to TotalDeadDestructables, do (Actions)
        • Loop - Actions
          • Set DestructableLocation = (Position of DeadDestructables[Index])
          • Set UnitsInRange = (Units within 48.00 of DestructableLocation matching (((Matching unit) is alive) Equal to True))
          • Custom script: call RemoveLocation(udg_DestructableLocation)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in UnitsInRange) Equal to 0
            • Then - Actions
              • Destructible - Resurrect DeadDestructables[Index] with (Max life of DeadDestructables[Index]) life and Show birth animation
              • Set DeadDestructables[Index] = DeadDestructables[TotalDeadDestructables]
              • Set TotalDeadDestructables = (TotalDeadDestructables - 1)
            • Else - Actions
          • Custom script: call DestroyGroup(udg_UnitsInRange)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TotalDeadDestructables Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
This is just the system that you wanted (I guess??). If you have any concerns ask anything. Don't have time atm to go into too much detail. :)

Oh yes and make sure that there is always less than 2,000 destructables within the region that checks when a destructable dies. Tip: you can have multiple events that checks to see if a destructable dies within a region.
 
Last edited:
Level 9
Joined
Jul 11, 2009
Messages
294
Here you go.
First the doodad that dies needs to be stored into an arrayed variable.
  • Tree Dies
    • Events
      • Destructible - A destructible within (Playable map area) dies
    • Conditions
      • (Destructible-type of (Dying destructible)) Equal to Summer Tree Wall
    • Actions
      • Set TotalDeadDestructables = (TotalDeadDestructables + 1)
      • Set DeadDestructables[TotalDeadDestructables] = (Dying destructible)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TotalDeadDestructables Equal to 1
        • Then - Actions
          • Trigger - Turn on Periodic Check <gen>
        • Else - Actions
Not really necessary how much the periodic timer runs all the time, just own opinion. Although I think that this is the best time for how ofen it is checked that there are no units there.
  • Periodic Check
    • Events
      • Time - Every 0.34 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Index) from 1 to TotalDeadDestructables, do (Actions)
        • Loop - Actions
          • Set DestructableLocation = (Position of DeadDestructables[Index])
          • Set UnitsInRange = (Units within 48.00 of DestructableLocation matching (((Matching unit) is alive) Equal to True))
          • Custom script: call RemoveLocation(udg_DestructableLocation())
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in UnitsInRange) Equal to 0
            • Then - Actions
              • Destructible - Resurrect DeadDestructables[Index] with (Max life of DeadDestructables[Index]) life and Show birth animation
              • Set DeadDestructables[Index] = DeadDestructables[TotalDeadDestructables]
              • Set TotalDeadDestructables = (TotalDeadDestructables - 1)
            • Else - Actions
          • Custom script: call DestroyGroup(udg_UnitsInRange())
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TotalDeadDestructables Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
This is just the system that you wanted (I guess??). If you have any concerns ask anything. Don't have time atm to go into too much detail. :)

Oh yes and make sure that there is always less than 2,000 destructables within the region that checks when a destructable dies. Tip: you can have multiple events that checks to see if a destructable dies within a region.

Hi DeathChef,

Thanks for the triggers! Would you be so kind to state the variables that are used? Because I'm slightly confused by the trigger.

Thanks a mil!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
The periodic check rate is far too high. I advise using a duty cycle system which performs one (or a few) checks every 0.5 seconds and slowly cycles through all dead trees. If too many dead trees are near units you could notice map performance degradation otherwise.
 
Level 9
Joined
Jul 11, 2009
Messages
294
The periodic check rate is far too high. I advise using a duty cycle system which performs one (or a few) checks every 0.5 seconds and slowly cycles through all dead trees. If too many dead trees are near units you could notice map performance degradation otherwise.

Hey Dr Super Good,

So how can I get that done? I'm pretty rusty with world editor now.


Thanks!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
So how can I get that done? I'm pretty rusty with world editor now.
You cycle a global integer by increasing it by 1 and mod it with the total number of trees dead. Use that integer as the tree to test for if it should be revived. Repeat this a few times per second as there is no need for fast reviving trees in most cases. When a tree is revived, you inverse cycle the integer back by 1 after swapping the tail of the list for the current.

You may also want to check for visibility unless you want people to be able to see trees being revived.
 
Hi DeathChef,

Thanks for the triggers! Would you be so kind to state the variables that are used? Because I'm slightly confused by the trigger.

Thanks a mil!

Here you go. I've attached a test map containing everything to this post.
Oh yes and I changed the units within range that it checks to a range of 144(working value). 48 is way to little or a radius to check. The tree would just revive basically strait away.

To test the attached map just right click a tree(you would have the peasant being selected automatically).

You may also want to check for visibility unless you want people to be able to see trees being revived.


I don't think that that is completely necessary.

The periodic check rate is far too high. I advise using a duty cycle system which performs one (or a few) checks every 0.5 seconds and slowly cycles through all dead trees. If too many dead trees are near units you could notice map performance degradation otherwise.

I suppose your right.
I might try and to mod my system to counter this issue.

 

Attachments

  • Tree Ressurect.w3x
    18.7 KB · Views: 58
Last edited:
Status
Not open for further replies.
Top