ReplaceDoodad function

jackall

You can change this now in User CP.
Reaction score
37
Hello again, i've made the below function that is supposed to replace doodads which it really does but i want to know what YOU think of it:
Does it have leaks?
Is it useful for anything? and so on
JASS:
function ReplaceDoodad takes destructable toRe, integer newID, real scale, integer var, boolean oldHP returns nothing
  local destructable newOne
  if oldHP == true then
    if GetDestructableLife(toRe) > 0 then
      set newOne = CreateDestructable(newID,GetDestructableX(toRe),GetDestructableY(toRe),GetRandomDirectionDeg(),scale,var)
      call RemoveDestructable(toRe)
      return
    endif
    set newOne = CreateDeadDestructable(newID,GetDestructableX(toRe),GetDestructableY(toRe),GetRandomDirectionDeg(),scale,var)
    call RemoveDestructable(toRe)
  endif
endfunction

So? Watch'a think?
 

BlackRose

Forum User
Reaction score
239
Doodads and destructables are different things. You can't modify doodads in game [aside from hiding / showing them]. The only thing you can possibly do with this is probably just replacing trees, rocks, to match terrain or something.

:O
 

Bribe

vJass errors are legion
Reaction score
67

Executor

I see you
Reaction score
57
This is better:

JASS:
function ReplaceDoodad takes destructable toRe, integer newID, real scale, integer var, boolean oldHP returns nothing
    local real x = GetWidgetX(toRe)
    local real y = GetWidgetY(toRe)
    if (oldHP) then
        call RemoveDestructable(toRe)
        if GetWidgetLife(toRe) > 0 then
            call CreateDestructable(newID,x,y,GetRandomReal(0.,360.),scale,var)
        else
            call CreateDeadDestructable(newID,x,y,GetRandomReal(0.,360.),scale,var)
        endif
    endif
endfunction

Shouldnt it be sth. like this:
JASS:
function ReplaceDoodad takes destructable toRe, integer newID, real scale, integer var, boolean oldHP returns nothing
    local real x    = GetWidgetX(toRe)
    local real y    = GetWidgetY(toRe)
    local real hp   = 0
    if oldHP then
        set hp = GetWidgetLife(toRe)
        call RemoveDestructable(toRe)
        if hp > 0 then
            set toRe = CreateDestructable(newID,x,y,GetRandomReal(0.,360.),scale,var)
            call SetDestructableLife(toRe,hp)
        else
            call CreateDeadDestructable(newID,x,y,GetRandomReal(0.,360.),scale,var)
        endif
    else
        call RemoveDestructable(toRe)
        call CreateDestructable(newID,x,y,GetRandomReal(0.,360.),scale,var)
    endif
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top