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

removing unit

Status
Not open for further replies.
Level 18
Joined
May 11, 2012
Messages
2,103
how do I properly remove picked unit after it's damaged? I want every picked unit to be damaged once... I tried to do some things, but i failed.

  • Demon Slash Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set TempPoint = (Position of DemonSlash_TrigUnit)
      • Set DemonSlash_UnitGroup = (Units within 75.00 of TempPoint)
      • Unit Group - Pick every unit in DemonSlash_UnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (((Picked unit) belongs to an enemy of (Owner of DemonSlash_TrigUnit)) Equal to True) and (((Picked unit) is alive) Equal to True)
            • Then - Actions
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Human\Banish\BanishTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Cause DemonSlash_TrigUnit to damage (Picked unit), dealing Damage[Damage_Integer] damage of attack type Spells and damage type Normal
            • Else - Actions
      • Custom script: call DestroyGroup(udg_DemonSlash_UnitGroup)
      • Custom script: call RemoveLocation(udg_TempPoint)
WRONG SECTION... sry
 
Level 8
Joined
Oct 26, 2008
Messages
387
Its on the right section, you have to set to different unit groups, i will tell you details in a short while.

Edit: Ok so from what i understand your problem is, the units are susposed to be only damaged 1 time, from your dash, but they are damaged every 0,03 seconds. Had the same problem, and came up with a neat way to do this. So you will have 2 Unit Groups, you have the one, you are missing the other. Your triggers,



  • Demon Slash Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set TempPoint = (Position of DemonSlash_TrigUnit)
      • Set DemonSlash_UnitGroup = (Units within 75.00 of TempPoint)
      • Unit Group - Pick every unit in DemonSlash_UnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (((Picked unit) belongs to an enemy of (Owner of DemonSlash_TrigUnit)) Equal to True) and (((Picked unit) is alive) Equal to True) and (Picked unit) is in (UnitGroup2) Equal to False
            • Then - Actions
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Human\Banish\BanishTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Cause DemonSlash_TrigUnit to damage (Picked unit), dealing Damage[Damage_Integer] damage of attack type Spells and damage type Normal
              • Unit - Add (Picked Unit) to (UnitGroup2)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_DemonSlash_UnitGroup)
      • Custom script: call RemoveLocation(udg_TempPoint)
So whats done here, is that when the picked unit is damaged, it is added in a unit group, but before the your caster damages, he checks if the units arround him belong to the unit group. So when they are damaged, they are added in that "safe" group, and they are not damaged again.


Sorry if there are any mistakes done here i did thing handwriting, if you do what i said and you still have issues, i search my map and post triggers.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Use a Damage Detection System (Search "Damage Detection System" in the Spell Section on web header) Follow instructions to detect damage, and Select the unit you want to remove in the condition, and remove it.

"Damage Event Happens"
-> Unit is YourUnit
Action - Remove unit.
 
Level 8
Joined
Oct 26, 2008
Messages
387
Use a Damage Detection System (Search "Damage Detection System" in the Spell Section on web header) Follow instructions to detect damage, and Select the unit you want to remove in the condition, and remove it.

"Damage Event Happens"
-> Unit is YourUnit
Action - Remove unit.

What do you think of my sollution? I believe its easier than importing a Damage Detection System.

~Regards
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Creating a Group and a Point, and removing both, 33 times per second it sick.

You just need to detect damage dealt, and the unit that received the damage, then remove it, right? Use a damage detection system. Everyone does nowdays.

<< EDIT >>

OOOHHH!! I've seen the light! You want to Pick units around and damage them once! Lol... add Immolation to the unit, make it have a 75 AoE, and make the Target Attachment buff the one you're creating there. Make it deal 0 damage. It will do the special effect, You just need to trigger the damage (because you want it triggered)

The use "A unit is damaged" and "Distance between Damaged Unit and DemonSlashUnit is less than or equal to 75 AND Unit is in NoDamageGrou p= false" and do the damage. Then, add the unit to NoDamageGroup
 
Level 8
Joined
Oct 26, 2008
Messages
387
Creating a Group and a Point, and removing both, 33 times per second it sick.

You just need to detect damage dealt, and the unit that received the damage, then remove it, right? Use a damage detection system. Everyone does nowdays.

<< EDIT >>

OOOHHH!! I've seen the light! You want to Pick units around and damage them once! Lol... add Immolation to the unit, make it have a 75 AoE, and make the Target Attachment buff the one you're creating there. Make it deal 0 damage. It will do the special effect, You just need to trigger the damage (because you want it triggered)

The use "A unit is damaged" and "Distance between Damaged Unit and DemonSlashUnit is less than or equal to 75 AND Unit is in NoDamageGrou p= false" and do the damage. Then, add the unit to NoDamageGroup

No dont believe you do xD
I think he wants this to be a looping damage, BUT units that he has damaged, not being damaged again. Understand me? He wants to damage each unit 1 time not more, but he wants to be able new units arround him be damaged... otherwise he wouldnt have the loop...
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Well... the damage detection system will run this only when the damage of that unit happens, and not 33 times per second.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Then, you would need to have 400 units within 75 AoE distance from this unit (The one that deals damage), wich is virtually impossible. And, yes, this would run 400 times and damage each one of those 400 units once. The other system would run too, even if there are 0 or 400 units around, which is way worse :D
 
Level 8
Joined
Oct 26, 2008
Messages
387
Then, you would need to have 400 units within 75 AoE distance from this unit (The one that deals damage), wich is virtually impossible. And, yes, this would run 400 times and damage each one of those 400 units once. The other system would run too, even if there are 0 or 400 units around, which is way worse :D

You said damage detection system i assumed it was affecting all units, i dont in which you are refering since i rarely use other peoples systems in my maps/spells. But i still believe that the 0,03 check is better than importing a whole system in your map..
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
  • Demon Slash Loop
  • Events
  • Time - Every 0.03 seconds of game time
  • Conditions
  • Actions
  • Set TempPoint = (Position of DemonSlash_TrigUnit)
  • Set DemonSlash_UnitGroup = (Units within 75.00 of TempPoint)
  • Unit Group - Pick every unit in DemonSlash_UnitGroup and do (Actions)
  • Loop - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
  • (((Picked unit) belongs to an enemy of (Owner of DemonSlash_TrigUnit)) Equal to True) and (((Picked unit) is alive) Equal to True) and (Picked unit) is in (UnitGroup2) Equal to False
    • Then - Actions
  • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Human\Banish\BanishTarget.mdl
  • Special Effect - Destroy (Last created special effect)
  • Unit - Cause DemonSlash_TrigUnit to damage (Picked unit), dealing Damage[Damage_Integer] damage of attack type Spells and damage type Normal
  • Unit - Add (Picked Unit) to (UnitGroup2)
    • Else - Actions
  • Custom script: call DestroyGroup(udg_DemonSlash_UnitGroup)
  • Custom script: call RemoveLocation(udg_TempPoint)
Some issues:
1st: You use (Picked Unit) Many, many times. Use a Variable = (Picked Unit) and use the variable instead. Is faster, and matters if you have a 0.03 loop.
2nd: When does this trigger turns on?
3rd: When does this trigger turns off?
4th: Why 2 unit groups, if you don't really need them? These takes important memory space.
5th: Ussually attached special effects doesn't work if destroyed inmediatly.

So far, we have a constantly on periodic trigger (even if it isn't needed) creating/destroying groups, points and effects every 0.03 seconds just to detect if there's a unit near and do damage once.

I would rather use a Damage Detection System to detect 0 damage with inmolation (wich resembles the constant pick every unit around), check for the Unit Type of the damage source to match this Unit Type, if true, then check if the unit is in NoDamageGroup = false, then check the distance, if less than 75, do the triggered damage and add to NoDamageGroup

I could also avoid the Unit Group with Bribe's Unit Indexer and a NoDamageBoolean array wich is way faster than Unit Group Loops. Alternatively, I could also use a Hashtable instead of a NoDamageGroup and save a boolean in the UnitID to know if it has already been damage once for being near.

SO FAR, most maps will need a Hashtable/UnitIndexer and a Damage Detection System. Both systems are pretty safe and efficient, and are used to improve efficiency of all these things. I would also jass it all, use locals, avoid locations, and creating/destroying the effect, but just destroy it. Could also avoid One group to pick units, and another to Nodamage, and use call GroupEnumUnitsInRange wich already enums units around into a default group as bj_lastCreatedGroup and add these picked units to the NoDamageGroup

If the whole map consist on just this ability (which I doubt), then it's fine, but if it's going to have more things that requires damage being detected, then DDS is the way.

BTW, what damage detection does is creating in an efficient way specific unit events "A unit takes damage" and adds to a variable the DamageSource and DamagedUnit, so the trigger destroys itselfs and recreates itselfs to clean the event leaks (like units that already died, and there's no need to detect if those units are damaged, that would be an Event Leak). And bribe's indexer is, precisely, to avoid using unit groups and/or hashtables, since arrays are faster.
 
Level 8
Joined
Oct 26, 2008
Messages
387
First things first! I didnt try to fix his trigger in total, because i dont know in details what he wants to achieve, and its not my job to take requests.
What i did here, was to give a solution, on a specific problem, in a specific trigger.
If he uses this trigger, in a map, with 3000 more triggers, that is not in my power to know or to intefiere.

What i do, is give the simpler, and most efficient solution ( i can see ) to specific problems. So i am targeting specific, to the problem he has in this specific trigger. Suggesting a system is a generic solution, which will not help the person asking the question to learn more about GUI. Instead it will give him a generic and *easy* sollution, based on other peoples work!

I am sure, that if used in a map, where damage detections is a constant need, then ofc importing a system is usefull.
But importing a whole system, for the needs of 1 spell, is pointless.

Also keep in mind, that many people who come here, are new to triggers, thus they come here for help. They come because they dont know every function in GUI, and they require help finding the proper one! Instructing them to use a customized system, will confuse them because in 99% of the cases they will not be able to read the system and understand it better.

That is my point here, i repeat that ofc if you have a whole map, then it would be more efficient and more proffesional to use a system, but in a signle spell? When you can avoid it with a single line? Nah..
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I agree with you, but I can't sleep knowing that I helped someone who's new on Triggering and that doesn't know all the resources GUI/Jass provides, and he/she is ignoring.

I remember when, several times, I created 12 triggers instead of using "Player number of Player". I remember LONG if/then/else chains before knowing Hashtables. I remember using Points when I didn't knew X/Y. I remember using 10 concatenated strings instead of jass s1 + s2 + s3 + s4, etc...

People come here with an Idea, and searching for help, but the best help we can give is knowledge.
Boy says: "Hey, dad, i'm trying to take this tree down with the scissors, but I won't fall"
Dad says: "Use an axe"
Boy says: "Oh, I never tough about that. I didn't know we had an axe".
That's what happens with people new to Wc3. They have an idea, and tough of a way to achieve it, but ussually, that's not the best idea, either the best way to achieve it.
 
Status
Not open for further replies.
Top