• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[UNSOLVED] Destrucatables

Status
Not open for further replies.
Level 16
Joined
Jul 21, 2008
Messages
1,121
Destrucatables

I am in the need of some kind of tree transparency system. I could make it with any destructable using Destructable - Pick Every Destrutable function (EnumDestructablesInRect for JASS).

As there is no Destructable Group variable, I am wondering if there is any way to bypass leaks created by it and still keep the performance when executing that function for large number of units (I do not need ordinary RPG destructable transparency systems).

Be advised that I do not need any custom tree models or anything else. The solution must be fully compatible with standard WE or JNGP without any imports.

Thank you in advance!
 
Sorry if that sounds to idiot or too obvious, but sometimes we get stuck with easy things, but since i am not still sure of what your goal is:

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set T_G = (Units owned by Player 1 (Red))
      • Unit Group - Pick every unit in T_G and do (Actions)
        • Loop - Actions
          • Set T_Unit = (Picked unit)
      • Custom script: call DestroyGroup (udg_T_G)
  • Detector
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Set PointU = (Position of T_Unit)
      • Set RegionU = (Region centered at PointU with size (300.00, 500.00))
      • Destructible - Pick every destructible in RegionU and do (Actions)
        • Loop - Actions
        • ----
      • Custom script: call RemoveLocation (udg_PointU)
I don't know if you seeked for such thing, you seem to know of that stuff already.
 
Level 15
Joined
Jul 19, 2007
Messages
618
there is no way to not use Pick Every Destructable... action, and yes i can make a new type destructables group... but that would not help u, the best way is to do as you already was told by other people here! Use timer maybe every 0.1 seconds would be fine and do not use pick destructables in rect but in range... so u dont leak regions.

ofc u only need to pick every destructable in range of maybe 256!

as well i thing this is the best way to do it without any picking and such!
  • Trees Trans
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Cinematic - Enable occlusion for (All players)
thats all there is chose which one u like more!

Greets!
~Dark Dragon
 
Level 15
Joined
Jul 19, 2007
Messages
618
Sorry, could you explain what that is? I've never seen the action before. It's a native with very little description, there seems to be no way of picking the transparency or area..?


JASS:
function EnableOcclusionBJ takes boolean enable, force f returns nothing
    if (IsPlayerInForce(GetLocalPlayer(), f)) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call EnableOcclusion(enable)
    endif
endfunction

it gives trees transparency!
duno what else to say, enable it and test the map u will see that trees get more invisuable...
 
Level 15
Joined
Jul 19, 2007
Messages
618
Is there any major FPS dent? If not I might just enable it for everyone all the time.

just enable it (by default it was enabled in RoC 1.0) and duno when it got disabled! fps will be fine!
ohh no if for everyone the simple use native with no GetLocalPlayer

JASS:
native EnableOcclusion              takes boolean flag returns nothing

give it a true and there u go!
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
JASS:
globals
    unit TreeFilterUnit
    destructable array TreeArray
    integer TreeCountInt
endglobals 
function TreeFilter takes nothing returns boolean
        local destructable d = GetFilterDestructable()
        local boolean b = IsDestructableInvulnerable(d)
        local boolean result = false
        if b then
            call SetDestructableInvulnerable(d,false)
        endif
        call PauseUnit(TreeFilterUnit, false)
        set result = IssueTargetOrder(TreeFilterUnit, "harvest", d)
        call PauseUnit(TreeFilterUnit, true)
        if b then
            call SetDestructableInvulnerable(d,true)
        endif
        set d = null
        return result
    endfunction
 
function TreeCount takes nothing returns nothing
    set TreeArray[TreeCountInt] = GetEnumDestructable()
    set TreeCountInt = TreeCountInt + 1
endfunction
 
function PickAllTrees takes nothing returns nothing
    local integer i = 0
    local destructable d = null
    call EnumDestructablesInRect(<rect>, Filter(function TreeFilter), function TreeCount)
    loop
       exitwhen i >= TreeCountInt
       set d = TreeArray[i]
        // YourAction
        set i = i + 1
    endloop
    // Hope this works,,
endfunction
 
function Init takes nothing returns nothing
    set TreeFilterUnit = CreateUnit(...... // Initialize the unit here
endfunction
 
Level 21
Joined
Aug 9, 2006
Messages
2,384
You know what enum destructables does? it does not create a group, it is just like a loop which picks all destructibles in that area, it wont leak, but you cannot bypass it... beside.... well, you could use a destructible array where you save it, but you will need more than 1 array, so.... its going to be alot of work.

My first try would be:

A indexing system for like 4 or 5 array variables of the type destructibles, store all trees in your area in the array, reset the array after 3 or 5 seconds and start once again storing the destructibles, reset the arrays every 5 seconds or 3, dunno what would look good, then pick again all the closer tree destructibles, then again 5 or 3 seconds till reset, the array is empty, fill a new load of destructibles in a area around you in, reset the array again and so on.

So you will have a constantly changing area of invisible destructibles, or better said half invisible.

But my version could maybe lag for multiple players... but I am not sure.
 
Status
Not open for further replies.
Top