• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Get Entangled Mine Builder?

Status
Not open for further replies.
Is there any way to retrieve the Tree of Life that's connected to an Entangled Gold Mine? I've tried using ConstructEvent but it appears Entangled Gold Mines are somewhat special.

Here's my code, currently:
JASS:
function Generate_Extraction_Field_Actions takes nothing returns boolean
    local unit building = GetTriggerUnit()
    local unit worker = GetStructureBuilder(building)
    if GetUnitTypeId(building) == 'e000' then
        call BJDebugMsg("test")
        call AddSpecialEffectLocBJ( GetUnitLoc(worker), "Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl" ) //just a test; this checks if the game is detecting the worker.
        call SetUnitX(worker, GetUnitX(building))
        call SetUnitY(worker, GetUnitY(building))
    endif
    set worker = null
    set building = null
    return false
endfunction

//===========================================================================
function InitTrig_Generate_Extraction_Field takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_CONSTRUCT_START)
    call TriggerAddCondition(t, Condition( function Generate_Extraction_Field_Actions))
    set t = null
endfunction

NB: I'm not particularly good with events in JASS, so if the custom events from ConstructEvent will help, can anyone help me with those?
 
ConstructEvent filters orders <900000 issued inside trigger
JASS:
RegisterAnyUnitEvent(EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, function thistype.onDifferentOrder)

method onDifferentOrder
  if ( orderId > 900000 and target != null ) then
            call create(...

if I may suggest: use EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, then check for "entangleinstant" and "entangle" and write GetOrderTargetUnit() and GetOrderedUnit() to array.
GetOrderTargetUnit() - gold mine has the same handleId as entangled one (I think it is similar to metamorphosis)
 
Last edited:
Not sure I follow. If I check for Target Order, that wouldn't account for when the Tree of Life has been ordered to Entangle from out of range; if you do that, the Tree must uproot and then walk towards the Gold Mine, then root and start the entangling process. I tried to catch it with Starts the Effect of an Ability, but that didn't do anything.
 
I show off incorrect info before, now its corrected.

Entangle Gold mine is a diffrent model then Gold Mine. When "entangling" begins game hides old, original Gold Mine, and creates new Entangle Gold Mine structure at the same location, handleId as well as UnitUserData (with UnitIndexer) are diffrent. Original Gold Mine stays hidden (and alive) until Entangled one is destroyed/depleted.

Tree of Life with Entangled Gold Mine can be paired easy when player uses "entangle" ability. It fires EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER.

Unforetunatelly "auto-entangle" upon finished creation of Tree of Life, or when Tree is rooted near gold mine - these 2 will not fire any "unit issued order" event. Only "unit begins construction" runs, but this one only gives access to new-created entangled gold mine, but not to a Tree.

so I think it is not doable
 
Okay, I figured it out (mostly bu looking at how IcemanBo did it in BuilderTrack). I used GetClosestWidget to pick the worker that is closest to the mine, and then filtered for untit type, owner, and current order (852147 for entangle mine or 852165 for root). This seems to do the trick nicely, whether the entangle is automatic or was specifically ordered.

+rep to both :)
 
Status
Not open for further replies.
Top