Warcraft III resources & community, 2003–2006 · archived

Easy triggers for doodad respawn.

12 posts
#1

Easy triggers for doodad respawn.

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?
#2
//======================
//   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

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
#3
hmmm, im not too good at reading triggers like this, but from what i can sett, it picks all the trees within 200 of the death trees? that's about all i figured out.
#4
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.
#5
So this is JASS? People should make a system for this
#6
A system?
#7
Like a small custom script people can copy into their maps for destructible respawn, because it's evil, because I also cannot do this very efficiently
#8
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.
#9
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.
#10
Well, it's not exactly the same, since each tree has a chance to be resurrected every so-and-so seconds, instead of tracking the time independently for each tree.

On the other hand, it's likely to work pretty well.
#11
Well it seems to work pretty well, the only problem i'd have with these triggers is that there is a chance to trap a unit, or for a hero to exploit the trigger. I wish there was a way around that.
#12
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..