• 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.

Repairing destructible gates

Status
Not open for further replies.
Level 2
Joined
Nov 16, 2011
Messages
13
so i havent been tampering with the map editor for a long time and thought id play around with it. has there ever been a way to repair a destructible gate say in a castle defense map? ive looked online everywhere and im at a lost here. given i have limited skill in editing etc.

i was trying to get peasants to either repair the gate or have a spot where they can harvest and drop off wood in front of the gate and that would trigger a increase in current hp. any help would be much appreciated.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
Gates can be "repaired" by closing them. More specifically this sequence repairs a dead gate.

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
    endif
endfunction
So calling DestructableRestoreLife on a dead gate and playing the stand animation should fix it. How fixed it is can be specified by DestructableRestoreLife, in the case of GUI open gate it uses full life.

If you can make this into the sort of system you want I do not know. Maybe a periodic loop that fixes the gate a tiny bit in exchange for some wood from the player's resources? Maybe a dummy "gate control" unit could be used which triggers try to sync life with the gate and peasants can repair it to reheal the gate.
 
Level 12
Joined
Nov 3, 2013
Messages
989
Scrap the destructible gates and make it into a unit with morph or something instead.

It will make things much easier for you, especially if you want it to be repaired and units to drop off lumber at it.

I mean you could even add the town hall classification and peasants would literally return lumber to it...

Not to mention that normal destructible gates "open" by being destroyed, this means that even if you keep track of how much health the gate is supposed to have it can't be killed while it's already open (since it's already dead). That can lead to people spamming open and close to basically abuse that the enemy units can't land their attacks in time to deal damage and they also don't have time enough to walk through, in effect this basically turns the gate invulnerable.

However the open/close can get a bit iffy if you have a single unit that transform between two units, sometimes if there's a unit in the middle of the gate while it's closing it can be moved out of the way due to pathing.

Ways to get around it is to have separate units or pathing blockers.

In some games like that GoT ice and fire and maps like it the gate is still a destructible (I think) but the unit which open and close it is a separate one, it's like a decent compromise between the two.

It's not my personal favorite, but you can try a couple of things and see what works best for you.
 
Status
Not open for further replies.
Top