Script running once ?

Sim

Forum Administrator
Staff member
Reaction score
534
Well I've made a short script looking like that :

Code:
function Trig_Barrels_Copy_Actions takes nothing returns nothing
    local destructable d = GetDyingDestructable()
    local location p=GetDestructableLoc(d)
    local integer i=GetRandomInt(1, 8)
    call CreateItemLoc( 'pman', p )
    if i == 1 then
        call CreateItemLoc( 'phea', p )
    else
        if i == 2 then
            call CreateItemLoc( 'pman', p )
        else
        endif
    endif
    call TriggerSleepAction( 20.00 )
    call CreateDestructableLoc( GetDestructableTypeId(d), p, 331.00, 1.00, 0 )
endfunction

//===========================================================================
function InitTrig_Barrels_Copy takes nothing returns nothing
    set gg_trg_Barrels_Copy = CreateTrigger(  )
    call TriggerRegisterDestDeathInRegionEvent( gg_trg_Barrels_Copy, gg_rct_Barrel1 )
    call TriggerRegisterDestDeathInRegionEvent( gg_trg_Barrels_Copy, gg_rct_Barrel2 )
    call TriggerRegisterDestDeathInRegionEvent( gg_trg_Barrels_Copy, gg_rct_Barrel3 )
    call TriggerRegisterDestDeathInRegionEvent( gg_trg_Barrels_Copy, gg_rct_Barrel4 )
    call TriggerRegisterDestDeathInRegionEvent( gg_trg_Barrels_Copy, gg_rct_Barrel5 )
    call TriggerAddAction( gg_trg_Barrels_Copy, function Trig_Barrels_Copy_Actions )
endfunction

What it does is create a mana potion at the dying barrel's position, then if the random integer between 1 and 8 is 1, it creates another potion (but healing one) and if the integer is 2 it creates another mana potion. If it is from 3 to 8 nothing happens.

The trigger runs perfectly ! ... Once

As soon as the barrel is created again (after 20 seconds) it bugs. First the barrel doesn't even drop a mana potion (it is obliged to!) and then never revives again.

I can't seem to understand why :confused:

Any ideas ? ;)
 

Chocobo

White-Flower
Reaction score
409
PHP:
function Trig_Barrels_Copy_Actions takes nothing returns nothing
    local destructable d = GetDyingDestructable()
    local integer id = GetDestructableTypeId(d)
    local location p = GetDestructableLoc(d)
    local integer i = GetRandomInt(1, 8)
    call CreateItemLoc( 'pman', p )
    if i == 1 then
        call CreateItemLoc( 'phea', p )
    else
        if i == 2 then
            call CreateItemLoc( 'pman', p )
        else
        endif
    endif
    call TriggerSleepAction( 20.00 )
    call RemoveDestructable( d )
    call CreateDestructableLoc( id, p, 331.00, 1.00, 0 )
endfunction

//======================================================================  =====
function InitTrig_Barrels_Copy takes nothing returns nothing
    set gg_trg_Barrels_Copy = CreateTrigger(  )
    call TriggerRegisterDestDeathInRegionEvent( gg_trg_Barrels_Copy, gg_rct_Barrel1 )
    call TriggerRegisterDestDeathInRegionEvent( gg_trg_Barrels_Copy, gg_rct_Barrel2 )
    call TriggerRegisterDestDeathInRegionEvent( gg_trg_Barrels_Copy, gg_rct_Barrel3 )
    call TriggerRegisterDestDeathInRegionEvent( gg_trg_Barrels_Copy, gg_rct_Barrel4 )
    call TriggerRegisterDestDeathInRegionEvent( gg_trg_Barrels_Copy, gg_rct_Barrel5 )
    call TriggerAddAction( gg_trg_Barrels_Copy, function Trig_Barrels_Copy_Actions )
endfunction

I don't know if this will work.
Please do not use WE to start War3.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Review the dying destructable instead of creating a new one, the event you are using doesn't do what it says. It fires on death events for all destructables that is in the region when the game starts, but it doesn't fire on death events for new destructables.
 

Rinpun

Ex TH Member
Reaction score
105
Yep. Instead of creating a new destructible, you might be able to revive it instead. That will keep its unit tag in order.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top