• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Disarming a group of units then removing

Status
Not open for further replies.
Level 5
Joined
Jun 15, 2016
Messages
111
How to disarm units by
a. picking nearby units then only accepting Heroes in conditions
b. disarm them thru Orc Cargo Hold
c. the picked enemy heroes get the cargo hold removed after like, 5 seconds.

Do i use array as well? ty
 
I think using a unit group would be better (not considering MUI issues).
So you take X units according to your parameters and make another condition (with if\then\else). There's a boolean comparison condition that check if X unit is a structure\hero\whatever you choose. if it's a hero you add it to the group and give it cargo hold, and if not you do nothing. At the end of that trigger start a timer that will end after 5 seconds, which will start the second trigger that removes the cargo hold ability.
 
I think using a unit group would be better (not considering MUI issues).
So you take X units according to your parameters and make another condition (with if\then\else). There's a boolean comparison condition that check if X unit is a structure\hero\whatever you choose. if it's a hero you add it to the group and give it cargo hold, and if not you do nothing. At the end of that trigger start a timer that will end after 5 seconds, which will start the second trigger that removes the cargo hold ability.
I think I understand. So I check for units nearby 300 units, then I check if they are heroes? Then, if they are, add that Picked Unit to <insert Unit Group here>. At the end of that, I start a timer ending in 5 seconds. The next trigger will remove cargo hold from???? I cant find All Units in Unit Group. Only Random N units in Unit Group.
 
That is correct, but remember to give them the cargo hold ability before starting the timer.

There isn't an "all units in group" function per se, but if you go to unit group actions the first action in the list is "for all units in group do X", which is what you need.
 
You could use Silence and set it to only affect heroes and then set its data to disable both melee and ranged attacks instead of spells.

Just an idea if you're after a trigger-less alternative.
 
Code:
def int unit.disarm = 0;

def unit.disarmSub() {
    unit.disarm--;

    if (unit.disarm == 0) {
        UnitRemoveAbility(unit, cargo);
    }
}

def unit.disarmAdd() {
    unit.disarm++;

    if (unit.disarm == 1) {
        UnitAddAbility(unit, cargo);
    }
}

def spellInstance.durationTimer;
def spellInstance.targetGroup;

def spellInstance.destroy() {
    ForGroup(spellInstance.targetGroup, () -> {
        GetEnumUnit().disarmSub();
    })

    DestroyTimer(spellinstance.durationTimer);
    DestroyGroup(spellinstance.targetGroup);
}

def spellInstance.onExpire() {
    spellInstance.destroy();
}

def spellInstance.start() {
    GroupEnumUnitsInRange(spellInstance.targetGroup, range, filter);

    ForGroup(spellInstance.targetGroup, () -> {
        GetEnumUnit().disarmAdd();
    })

    TimerStart(spellinstance.durationTimer(), 5., false, function spellinstance.onExpire);
}

def spellinstance.create() {
    spellinstance.durationTimer = CreateTimer();
    spellinstance.targetGroup = CreateGroup();

    spellInstance.start();
}
 
Status
Not open for further replies.
Back
Top