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

[Solved] Nearby Building Damage

Status
Not open for further replies.
Level 10
Joined
Jun 20, 2017
Messages
329
Which ability allows you to damage to the structure with the present?! like "Building Damage Aura"
for example when my hero destroying a building, there is a chance that nearby weak buildings with less than 500 total hit points will get destroyed as well.
- hero lvl 5 10% chance to damage the structure
- hero lvl 10 20%
- hero lvl 15 30%
- hero lvl 20 40%
- hero lvl 25 50%
- hero lvl 30 60%
- hero lvl 35 70%
- hero lvl 40 80%
- hero lvl 45 90%
- hero lvl 50 100%
 
Last edited:
Level 5
Joined
Dec 25, 2014
Messages
111
What you need is not 'Building Damage Aura' ability at all. What you need is a trigger using 'A unit dies' event.
It is something like, check if a unit is a structure, level of your ability of killing unit greater than 0, bla bla.
Then in the action, do if-then-else, set the chances, then pick unit group of structure that has hp less than 500 around the destroyed unit. There you go.
 
Level 39
Joined
Feb 27, 2007
Messages
4,989
Yes mostly but 4 things:
  • No need to check if it's a hero; the ability level check is good enough.
  • You want to only look for structures hostile to the killer, probably, so add a (Matching Unit) belongs to an enemy of (Owner of (Killing Unit)) in there.

  • You don't need 3 separate if blocks, you just need one. And an array to hold different chance values and then look up based on the ability level. Store ShatteringChance[1] = 10, ShatteringChance[2] = 20, ShatteringChance[3] = 30... up through 10. Then you check if Integer_RandomChance less than or equal to ShatteringChance[(Level of ABILITY for (Killing Unit)) / 5)].

  • Do you want the killer to gain gold from killing the extra structures with this ability? Probably use Unit - Damage Target with a large damage amount instead of Unit - Kill here.
 
Level 39
Joined
Feb 27, 2007
Messages
4,989
  • You can remove the "killing unit is a hero" and "kill (dying unit)" lines.
  • You want to damage Picked Unit not Dying Unit.
  • Set all of the integer variables once in a Map Initialization trigger, not in this trigger. This one just checks them.
 
Level 39
Joined
Feb 27, 2007
Messages
4,989
They should both say "enabled" and "initially on"; one doesn't need to turn on or run the other. Remove the Set Integer_RandomChance2[] lines from "Nearby Building Damage" trigger. Also in that trigger you have an extra (((Matching unit) is A Hero) Equal to (==) True)) that shouldn't be there at all. Remove it.
 
Level 39
Joined
Feb 27, 2007
Messages
4,989
Remove the 10 variable setting lines in the death trigger. Leave them in the init trigger.

At some point you deleted the if statement that checked if RandomChance was less than the right one of the saved integer variables. Add that back in and put the unit damage line inside the Then actions.
 
Level 39
Joined
Feb 27, 2007
Messages
4,989
You deleted stuff and have now gotten rid of some important lines. You never set the Point_Building variable (neither do you clean it up): Set Point_Building = (Position of (Triggering Unit)) and put at the end: Custom script: call RemoveLocation(udg_Point_Building)

Move the integer randomchance setting inside the Loop - Actions of the unit group pick so it picks a new random integer for every unit.
 
Level 10
Joined
Jun 20, 2017
Messages
329
Is working now ty:thumbs_up:
  • Nearby Building Damage
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A structure) Equal to (==) True
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero level of (Killing unit)) Greater than (>) 0
        • Then - Actions
          • Set Point_Building = (Position of (Triggering unit))
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 512.00 of Point_Building matching ((((Matching unit) is A structure) Equal to (==) True) and (((Matching unit) belongs to an enemy of (Owner of (Killing unit))) Equal to (==) True))) and do (Actions)
            • Loop - Actions
              • Set Integer_RandomChance = (Random integer number between 1 and 100)
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Integer_RandomChance Less than or equal to (<=) Integer_RandomChance2[((Hero level of (Killing unit)) / 5)]
                  • Then - Actions
                    • Unit - Cause (Killing unit) to damage (Picked unit), dealing 1000000000.00 damage of attack type Spells and damage type Fire
                  • Else - Actions
          • Custom script: call RemoveLocation(udg_Point_Building)
        • Else - Actions
 
Level 5
Joined
Dec 25, 2014
Messages
111
but how to change channel ability to passive?!
Impossible. Then why should if there is a lot of passive spell that do nothing to customized? Use them.
Is working now ty
  • Nearby Building Damage
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A structure) Equal to (==) True
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero level of (Killing unit)) Greater than (>) 0
        • Then - Actions
          • Set Point_Building = (Position of (Triggering unit))
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 512.00 of Point_Building matching ((((Matching unit) is A structure) Equal to (==) True) and (((Matching unit) belongs to an enemy of (Owner of (Killing unit))) Equal to (==) True))) and do (Actions)
            • Loop - Actions
              • Set Integer_RandomChance = (Random integer number between 1 and 100)
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Integer_RandomChance Less than or equal to (<=) Integer_RandomChance2[((Hero level of (Killing unit)) / 5)]
                  • Then - Actions
                    • Unit - Cause (Killing unit) to damage (Picked unit), dealing 1000000000.00 damage of attack type Spells and damage type Fire
                  • Else - Actions
          • Custom script: call RemoveLocation(udg_Point_Building)
        • Else - Actions
And i'm still not sure about that trigger. But whatever, it is up to you.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
Still destroying buildings without ability, the ability is passive and level 1, and needs an upgrade to use.
Just because an ability requires an upgrade does not mean it is not level 1. An ability can be any level and still disabled due to requirements.

You want to change the conditional test to make sure that the owner of killing unit has the required upgrade and that the level of the ability is greater than 0.

To kill the unit you will likely want to set its health to 1 (possibly not required, just here to make sure) and deal the structures previous current life as damage. This is to prevent potentially buggy interactions with systems that process taking damage since feeding a stupidly large amount of damage into them could cause unexpected results.
 
Level 10
Joined
Jun 20, 2017
Messages
329
is it correct? and has leakage?
  • Nearby Building Damage
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A structure) Equal to (==) True
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero level of (Killing unit)) Greater than (>) 0
          • (Current research level of Vampiric-Shattering for (Owner of (Killing unit))) Greater than (>) 0
        • Then - Actions
          • Set Point_Building = (Position of (Triggering unit))
          • Set UnitGroup = (Units within 256.00 of Point_Building matching ((((Matching unit) is A structure) Equal to (==) True) and (((Matching unit) belongs to an enemy of (Owner of (Killing unit))) Equal to (==) True)))
          • Unit Group - Pick every unit in UnitGroup and do (Actions)
            • Loop - Actions
              • Set Integer_RandomChance = (Random integer number between 1 and 100)
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Integer_RandomChance Less than or equal to (<=) Integer_RandomChance2[((Hero level of (Killing unit)) / 5)]
                    • (Current research level of Vampiric-Shattering for (Owner of (Killing unit))) Less than or equal to (<=) 1
                  • Then - Actions
                    • Unit - Cause (Killing unit) to damage (Picked unit), dealing 1000000000.00 damage of attack type Hero and damage type Fire
                  • Else - Actions
          • Custom script: call RemoveLocation(udg_Point_Building)
          • Custom script: call DestroyGroup(udg_UnitGroup)
        • Else - Actions
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
(Current research level of Vampiric-Shattering for (Owner of (Killing unit))) Less than or equal to (<=) 1
This condition is not needed? It is already explicitly true in order for execution to reach that stage.

If you plan to map multiple different effects based on the level of the research, consider using an array instead of a conditional tree.
Set UnitGroup = (Units within 256.00 of Point_Building matching ((((Matching unit) is A structure) Equal to (==) True) and (((Matching unit) belongs to an enemy of (Owner of (Killing unit))) Equal to (==) True)))
Technically this leaks a handle value due to a game engine bug. However to fix it one has to write JASS.

Reason...
JASS:
function GetUnitsInRangeOfLocMatching takes real radius,location whichLocation,boolexpr filter returns group
    local group g = CreateGroup()
    call GroupEnumUnitsInRangeOfLoc(g, whichLocation, radius, filter)
    call DestroyBoolExpr(filter)
    return g // g is not null here, hence a handle value reference count is leaked
endfunction
Most people ignore it and it should be fine in the case of on death as that is at most a few thousand indices lost during a game. It may also be fixed in a future Warcraft III update.
 
Status
Not open for further replies.
Top