• 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.

Easy triggers for doodad respawn.

Status
Not open for further replies.
Level 10
Joined
Apr 9, 2004
Messages
502
In the map i;m working on with some other people, i'm trying to find an effective way to respawn the trees a X seconds (we'll say 20) after they are destroyed. Why, because i have abilities that not only require the use of destructables, but also destroy the destructables like it's no ones business.

The problem is that eventually, all the destructables which had created paths will be opned and the map won't work properlyas an AOS.

Can anyone show an easy trigger i can use to help with this dilema?
 
Level 8
Joined
Apr 3, 2004
Messages
507
Code:
//======================
//   Functi0ns
//======================
function Trig_Trees_regrow_Actions takes nothing returns nothing
//== Loc4ls ============
    local destructable destTree = GetDyingDestructable()
    local group groupInRange = CreateGroup()
    local location locTree = GetDestructableLoc(destTree)
    local integer intInRange = 0
    local unit unitPicker

//== Ac7ions ===========
    loop
        call PolledWait(30.00 + GetRandomReal(0, 60.00))
        call GroupEnumUnitsInRangeOfLoc(groupInRange, locTree, 200.00, null)
        loop
            set unitPicker = FirstOfGroup(groupInRange)
            exitwhen unitPicker == null
            if (GetWidgetLife(unitPicker) > 0) then
                set intInRange = intInRange + 1
            endif
            call GroupRemoveUnit(groupInRange, unitPicker)
        endloop
        if (intInRange == 0) then
            call DestructableRestoreLife(destTree, GetDestructableMaxLife(destTree), true)
        endif
        set intInRange = 0
        exitwhen GetWidgetLife(destTree) > 0
    endloop

//== Cl3anup ===========
    set destTree = null
    call DestroyGroup(groupInRange)
    set groupInRange = null
    call RemoveLocation(locTree)
    set locTree = null
    set unitPicker = null
endfunction

//======================
//  Event5
//======================
function InitTrig_Trees_regrow takes nothing returns nothing
    set gg_trg_Trees_regrow = CreateTrigger()
    call TriggerAddAction(gg_trg_Trees_regrow, function Trig_Trees_regrow_Actions)
endfunction
Code:
function Trig_Time_elapsed_zero_Tree_events takes nothing returns nothing
    if (GetDestructableTypeId(GetEnumDestructable()) == 'LTlt') then
        call TriggerRegisterDeathEvent(gg_trg_Trees_regrow, GetEnumDestructable())
    endif
endfunction

//======================
//   Functi0ns
//======================
function Trig_Time_elapsed_zero_Actions takes nothing returns nothing
    call EnumDestructablesInRectAll(GetPlayableMapRect(), function Trig_Time_elapsed_zero_Tree_events)
endfunction

//======================
//  Event5
//======================
function InitTrig_Time_elapsed_zero takes nothing returns nothing
    set gg_trg_Time_elapsed_zero = CreateTrigger()
    call TriggerRegisterTimerEventSingle(gg_trg_Time_elapsed_zero, 0.00)
    call TriggerAddAction(gg_trg_Time_elapsed_zero, function Trig_Time_elapsed_zero_Actions)
endfunction
 
Level 8
Joined
Apr 3, 2004
Messages
507
The first part is a trigger with no events that takes the Dying Destructible, waits for a random time between 30 and 90 seconds, and then checks to see if there are any living units co-habiting its space. If there are none, it revives the tree. If there is one or more, it waits again and re-checks.

The second part is a trigger that runs at Time Elapsed 0.00 and adds each tree destructible dying as an event to the first trigger.

The advantages of this system are hard to argue with. It's efficient, small, and it works.
 
Level 8
Joined
Apr 3, 2004
Messages
507
Huh. Well, this can be copied over into a new map, if you change the destructible-type that it looks for to your tree type (where it says GetEnumDestructable()) == 'LTlt', replace LTlt with the raw id for your tree object). It basically does everything over an entire map, and doesn't have any references to anything specific to the map that I wrote it in, I don't think.

It does look big, but it's a pretty straightforward trigger. To make important functional changes, a knowledge of jass functions would be required, but just to use it, that's not really necessary.
 
Level 10
Joined
Apr 9, 2004
Messages
502
Well your JASS gave me some ideas so i could make this

Respawn trees
Events
Time - Every (Random real number between 15.00 and 20.00) seconds of game time
Conditions
Actions
Destructible - Pick every destructible in (Playable map area) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked destructible) is dead) Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in (Units within 200.00 of (Position of (Picked destructible)))) Greater than 0
Then - Actions
Do nothing
Else - Actions
Destructible - Resurrect (Picked destructible) with (Max life of (Picked destructible)) life and Show birth animation
Else - Actions
Do nothing

This is pretty simple i think and it works just the same as what you said yours did. I haven't had any problems while testing, so Eusira, you asked for a simple trigger, here it is.
 
Level 9
Joined
Nov 27, 2004
Messages
465
Hmm may be i'll make 1 more tutorial , because you may also make the same trigger as Panto's JASS script . it will consist of 2-3 triggers

1 trigger :
event:
TIME ELAPSED 0.5 sec.
Action:
pick every destructible entire world
_loop
__if
__picked destructeble = what you need
___then
___Add event to trigger (trigger2) :(picked destructible die)
___else
___nothing.

2 trigger:
Event
Condition
Action:
wait (random or static time or i don't know...)
create 1 of unit type at place of died destructeble

and the 3rd one may be some kind of a fixer..
 
Status
Not open for further replies.
Top