Death Trigger

Sevion

The DIY Ninja
Reaction score
413
Ahh, thanks for the explanation AceHart.

You always know everything. :rolleyes:

I beg to differ! AceHart, what's the meaning of life? >=D

Anyways, Native > BJ. Just don't use BJ's whenever possible :p I think there's a tutorial on writing efficient code somewhere on here that talks about Natives and BJ's.
 

Cheesy

some fucker
Reaction score
95
[del]Erm, how exactly do I use a native, just like a normal function, right?[/del]

EDIT: Figured that out, but have another question: I don't see the problem with ExplodeUnitBJ because it's calling two separate functions with one line, so wouldn't it be faster?

ExplodeUnitBJ:
JASS:
function ExplodeUnitBJ takes unit whichUnit returns nothing
    call SetUnitExploded(whichUnit, true)
    call KillUnit(whichUnit)
endfunction


Rather than calling both of those separately, so which is faster?
 

Sevion

The DIY Ninja
Reaction score
413
BJ = Call the BJ which calls the 2 Natives

Total Calls: 3

Native = Call the 2 functions.

Total Calls: 2
 

Cheesy

some fucker
Reaction score
95
Ahh, ok. I cleared up the ONLY BJ in the Death Trigger. :thup:

I also removed the rest in my other triggers.
 

Cheesy

some fucker
Reaction score
95
Erm, you just edited your post. :p

As you said before you edited your post: "You need to go a long way to optimize that code". Is there something in particular that is inefficient about my code? Could you please point it out?

Here is my current code:

JASS:
function Trig_Death_Conditions1 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'hfoo' )
endfunction

function Trig_Death_Actions takes nothing returns nothing
    local unit Unit
    local group UnitGroup = GetUnitsOfPlayerMatching( Player(1), Condition( function Trig_Death_Conditions1 ))
    local integer TempInteger = GetRandomInt( 4, 7 )
    local integer LoopStart = 1
    local integer UnitsKilled = 0
    loop
        exitwhen LoopStart > TempInteger
        set Unit = GroupPickRandomUnit(UnitGroup)
        call GroupRemoveUnitSimple( Unit, UnitGroup )
        //call ExplodeUnitBJ( Unit )
        call SetUnitExploded( Unit, true )
        call KillUnit( Unit )
        set UnitsKilled = ( UnitsKilled + 1 )
        set LoopStart = ( LoopStart + 1 )
    endloop
    call DisplayTextToForce( GetPlayersAll(), ( I2S(UnitsKilled) + " Units exploded!" ) )
    set LoopStart = 1
    set UnitsKilled = 0
    call DestroyGroup( UnitGroup )
    call RemoveUnit( Unit )
endfunction

//===========================================================================
function InitTrig_Death takes nothing returns nothing
    set gg_trg_Death = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Death, 8.00 )
    call TriggerAddAction( gg_trg_Death, function Trig_Death_Actions )
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top