• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How Can I detect if a gate is open

Status
Not open for further replies.
Level 18
Joined
Jan 21, 2006
Messages
2,552
This is the blizzard function that opens/closes gates (and is used in the World Editor's GUI);

JASS:
function ModifyGateBJ takes integer gateOperation, destructable d returns nothing
    if (gateOperation == bj_GATEOPERATION_CLOSE) then
        if (GetDestructableLife(d) <= 0) then
            call DestructableRestoreLife(d, GetDestructableMaxLife(d), true)
        endif
        call SetDestructableAnimation(d, "stand")
    elseif (gateOperation == bj_GATEOPERATION_OPEN) then
        if (GetDestructableLife(d) > 0) then
            call KillDestructable(d)
        endif
        call SetDestructableAnimation(d, "death alternate")
    elseif (gateOperation == bj_GATEOPERATION_DESTROY) then
        if (GetDestructableLife(d) > 0) then
            call KillDestructable(d)
        endif
        call SetDestructableAnimation(d, "death")
    else
        // Unrecognized gate state - ignore the request.
    endif
endfunction

So there are three situations setup here:
  • Open
  • Close
  • Destroy

Open
The gate destructable's life is restored and it plays its "stand" animation, as if it were perfectly okay.

Close
The gate destructable is killed and it plays its "death alternate" animation, which looks like the gate is being opened.

Destroy
This kills the gate destructable and plays its typical death animation.

If your gate is capable of dying then you'll need to use a more complicated way of determining whether a gate is open or not, but if gates are not meant to die then in order to check if it is open you can simply check whether or not it is dead or alive, dead meaning that the gate is open and alive meaning that the gate is closed.
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,551
When opening, the gate dies and plays an alternate death animation. I don't think there's any function to check what animation is a unit playing, so you'll have to use either a global boolean-type variable or a hashtable (the first option is probably easier).
By the way, «how to» questions go on the World Editor Help Zone.
~Thread moved
 
Status
Not open for further replies.
Top