• 🏆 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!

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
 
Level 12
Joined
Jun 15, 2016
Messages
472
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.
 
Level 5
Joined
Jun 15, 2016
Messages
111
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.
 
Level 12
Joined
Jun 15, 2016
Messages
472
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.
 
Level 8
Joined
Jan 28, 2016
Messages
486
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.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
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.
Top