• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

GUI and JASS IsDestTree v1.3

IsDestTree
Originally by Almia - GUI Version by Daffa the Mage

REMAKING PURPOSE
Honestly, the main purpose I'm remaking Almia's vJass IsDestTree is that I found it unusable to normal WE users.
Noticing this, I decide to learn Jass a bit, using Almia's original script, I modify them to fit Plain Jass (it was in GUI, but using custom scripts, later turned into full Plain Jass) and also later Almia recommend me to remake them to whole GUI.

WARNING
Do not use both IsDestTree! It screws the code.

TRIGGERS AND CODES

JASS:
function IsDestTree takes destructable d returns boolean
    return IssueTargetOrderById(udg_DestChecker,852018,d) and IssueImmediateOrderById(udg_DestChecker,851972)
endfunction
function DestroyTree takes destructable d returns nothing
    if IsDestTree(d) and GetWidgetLife(d) > 0.405 then
        call KillDestructable(d)
    endif
endfunction

function InitTrig_IsDestTree takes nothing returns nothing
    set udg_DestChecker = CreateUnit(Player(15), 'hpea', 0, 0, 0)
    call UnitAddAbility(udg_DestChecker, 'Aloc')
    call UnitAddAbility(udg_DestChecker, 'Ahrl')
    call ShowUnit(udg_DestChecker, false)
endfunction

  • TreeKiller GUI Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Dest = No destructible
      • Custom script: set udg_DestChecker = CreateUnit(Player(15), 'hpea', 0, 0, 0)
      • Custom script: call UnitAddAbility(udg_DestChecker, 'Aloc')
      • Custom script: call UnitAddAbility(udg_DestChecker, 'Ahrl')
      • Unit - Hide DestChecker
  • TreeKiller GUI
    • Events
    • Conditions
    • Actions
      • Set IsDestTree = False
      • Unit - Order DestChecker to Harvest Dest
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current order of DestChecker) Equal to (Order(harvest))
        • Then - Actions
          • Set IsDestTree = True
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TreeKill Equal to True
            • Then - Actions
              • Destructible - Kill Dest
              • Set TreeKill = False
            • Else - Actions
        • Else - Actions
      • Unit - Order DestChecker to Stop
GUIDE

JASS Version

Read the tutorial linked below before Installing the JASS Version.
This Tutorial By Almia

How to Import :
1. Create a Variable named DestChecker with type Unit
2. Import the IsDestTree JASS Folder
3. Ready to use, read the Tutorial above in case of errors

GUI Version

use the Dest variable to set the Tree you want to check.
Look at the Example carefully!

How to Import :
1. Make Sure "Create Unknown Variables When Pasting Trigger Data" is Enabled
2. Copy the IsDestTree GUI Folder
3. Use this action to run the IsDestTree :
  • Trigger - TreeKiller GUI gen (ignoring conditions)
to Destroy Trees while checking, use this before you run the function (can be in an Init or right before use) :
  • Set TreeKill = True
How to use GUI IsDestTree [aka TreeKiller] :
A little Guide for those who uses this IsDestTree [aka TreeKiller] along with it's TreeKill for Configurable Spells :
1. Use TreeKill_Init for True and False for killing trees!
2. Use the
  • Set TreeKill = TreeKill_Init
to connect the Init with the actual tree kill (remember, if you use pick destructables, put the
  • Set TreeKill = TreeKill_Init
inside the loop, also use the action before the Run IsDestTree, else it will cause bugs)
3. Done!
If you still don't know how to do it, check the Ex Init and Example GUI

Why this needs to be done? This is because the system automatically RESET TreeKill to False and make it easier for other users to configure your spell (nobody want to see a pile of trigger to find a minor thing right?)

CHANGELOGS
V1.3 : Minor Patch by BPower
V1.2 : Just a couple of minor changes, change GUI IsDestTree name to TreeKiller to make it less vague.
V1.1 : Opt Jass Version, thanks to Magtheridon96
Fixes GUI Version Bug for TreeKill, thanks to PurgeandFire
V1.0 Minor Update : Fixes Jass Version Issue, thanks to Almia
V1.0 : First Upload


CREDITS
Special Thanks to Almia for Giving me Permission to Upload this IsDestTree, Fixing the Jass Version, and Improving the GUI Version.
Magtheridon96 : Optimizing Jass Version and Giving Suggestions
PurgeandFire : Discovering GUI Bugs
BPower : Mention issues with this IsDestTree


AUTHOR NOTES
This System is marked as NO RATING like Mag's GUI AutoFly and Almia's IsDestTree

I hope this is useful, useful feedbacks are VERY APPRECIATED

~Daffa the Mage

Keywords:
Magtheridon96, Almia, IsDestTree, Daffa, Mage, Daffa the Mage, System
Contents

IsDestTree (Map)

Reviews
19:32, 25th Sep 2013 PurgeandFire: Approved!
Level 33
Joined
Apr 24, 2012
Messages
5,113
Uhh, The InitTrig function I suggested must be the init function. Rename the trigger to IsDestTree or rename the init function to the init function you use in the code. I told you it is the most optimized script yet you added a "fail" function, a useless function XD

Other than that, good job

Btw, make sure to notify them that they must only implement one of the systems(GUI and JASS), because the unit's handler may be lost due to the fact that One of them replaces the older harvester :D
 
You should set TreeKill back to "False" after killing the destructible. Otherwise it can cause issues if you leave it up to the user.

E.g. Let's say you have some knockback trigger that kills trees. You set TreeKill = true in that trigger. Meanwhile, some other trigger fires that groups destructables and checks if any of them are trees. Since TreeKill is still set to True, it will kill those destructables even if the user didn't set TreeKill to true right then.
 
Delete this entirely:

JASS:
//===========================================================================
function InitTrig_IsDestTree_JASS takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerAddAction( t, function InitTrig_IsDestTree )
    set t = null
endfunction

It does absolutely nothing.
 
Any function that starts with InitTrig will be called inside of one of the initialization functions that runs inside function main.

Currently, your InitTrig_IsDestTree function is running on map initialization and initializing the library just fine, then you have this other useless function:

JASS:
//===========================================================================
function InitTrig_IsDestTree_JASS takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerAddAction( t, function InitTrig_IsDestTree )
    set t = null
endfunction

That just creates a trigger, adds an action to it and does nothing after that. All it's doing is leaking memory :p
 
Top