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

Help with custom spell

Status
Not open for further replies.
Level 9
Joined
Aug 15, 2007
Messages
261
in gui i need to set units life based on a flame strike ability of all affected units to 50%
something like

Unit Group - Pick every unit in (Units in (Region((Target point of ability being cast), (Target point of issued order)))) and do (Actions)
Loop - Actions
Unit - Set life of (Picked unit) to 50%

but i cant get it to work help pls

i will need to do the same for the frost nova ability cold effected units
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,503
Flame Strike:
  • Flame Strike
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flame Strike
    • Actions
      • Set VariableSet TempPoint = (Target point of ability being cast)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 200.00 of TempPoint.) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is A ground unit) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is invulnerable) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) belongs to an enemy of (Triggering player).) Equal to True
            • Then - Actions
              • Unit - Set life of (Picked unit) to 50.00%
            • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
Frost Nova:
  • Frost Nova
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frost Nova
    • Actions
      • Set VariableSet TempPoint = (Position of (Target unit of ability being cast))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 200.00 of TempPoint.) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is invulnerable) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) belongs to an enemy of (Triggering player).) Equal to True
            • Then - Actions
              • Unit - Set life of (Picked unit) to 50.00%
            • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
If you want to reduce the unit's life by 50% then you'd do:
  • Unit - Set life of (Picked unit) to ((Percentage life of (Picked unit)) - 50.00)%
Change 200.00 to whatever the Area of Effect is for the ability. You can get this value automatically like this:
  • Actions
    • Unit Group - Pick every unit in (Units within (Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field Area of Effect ('aare'), of Level: ((Level of (Ability being cast) for (Triggering unit)) - 1)) of TempPoint.) and do (Actions)
      • Loop - Actions

It's important to understand that Abilities take into consideration Unit Collision Size when finding enemies in their Area of Effect. The Pick Every Unit in range function does NOT do this. This means that their AoE's will be slightly off.

A rather simple solution to this can be found here: Trigger Editor and Object Editor Range
I use the IsUnitInRange function, which does take into consideration Collision Size, to make sure that both the Ability and trigger's AoE is exactly the same.

Unfortunately, IsUnitInRange doesn't exist in GUI, so we have to use Custom script (Jass) to use it. Luckily, it's only 2 lines of Custom script and should work without you having to mess with it.
 

Attachments

  • Pick Every Unit example.w3m
    18.3 KB · Views: 21
Last edited:
Level 9
Joined
Aug 15, 2007
Messages
261
ok thanks i will try that but can it be insted of 200 range - range of ability beeng cast?

edit:
ok that worked fine

Unit Group - Pick every unit in (Units within (Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field Area of Effect ('aare'), of Level: ((Level of (Ability being cast) for (Triggering unit)) - 1)) of TempPoint.) and do (Actions)
Loop - Actions

but sometimes the trigger doesnt respond skips a spell....

Event shud be

Unit - A unit Begins casting an ability

so it works properly
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,503
You would have to use more complex methods for those.

I'd use a Damage Engine -> Damage Engine 5.7.1.2

And use unique Dummy units in order to detect when damage from one of these abilities is dealt.

So the Hero casts a "fake" channeled ability, which creates the Dummy unit, which is then ordered to cast the real ability.

When I say a unique Dummy unit, I mean you create an entirely new Dummy unit and use it ONLY for this specific spell. So if we were doing this for Stampede and Death&Decay, you'd need 2 Dummy units (name them something like Stampede Dummy and Death and Decay Dummy).

You'd then have to link the Dummy unit to the Hero since these abilities are channeling, this way when the Hero stops channeling, the Dummy linked to that Hero stops channeling as well. This can be done using Hashtables or a Unit Indexer -> GUI Unit Indexer 1.4.0.0

So you'll need 2 abilities per spell, the "fake" Channel ability used by the Hero and the real ability that's used by the Dummy unit (Stampede or Death & Decay).

Then when the Dummy deals damage, you can interact with the Damaged unit and do whatever you want like Set it's Life to 50%.

Example, this Event is provided by the Damage Engine and happens whenever "A unit takes damage":
  • Events:
  • DamageEvent becomes Equal to 1.00
  • Conditions:
  • Unit-type of DamageEventSource Equal to Stampede Dummy
  • Actions:
  • Unit - Kill DamageEventTarget
^ When a Stampede lizard hits an enemy and deals damage to it, I kill the damaged unit. You don't have to Kill it, that's just an example, you can do anything you want to it.

The reason this works is because we know for a fact that our Stampede Dummy is used ONLY for this ability, so any damage it deals has to be from Stampede.
 
Last edited:
Status
Not open for further replies.
Top