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

How to make shockwave or spell like shockwave that hit only 1 enemy?

Status
Not open for further replies.
Level 6
Joined
Aug 31, 2018
Messages
157
I need ability that reques aiming and its not target ability (like shockwave) but the problem is that shockwave continiue forward even after hiting an enemy,i want the ability to dissapear after hiting the first enemy.

(The idea is to make Fireball ability with no cooldown and i want it to reques aiming, not to target people, any ideas how to do it? It don't have to be based on shockwave if there is another way to do it.

P.S it gonna be cool if there is a way to show ability range when you click on it (but its not necessary)
 
Level 5
Joined
Jun 12, 2018
Messages
148
You could use the Carrion Swarm as base ability as it doesn't requires a unit target.

For the spell you want to achieve, you will need a "dummy" unit that represents the projectile model of your custom shockwave. The dummy unit is created when the spell is cast and will move/deal damage in another trigger.
There is a good tutorial about dummy units there : Tutorial - What are dummy units and how they work?

I've written two triggers to show you the idea of what I'm talking about, I didn't test it though.

This is the trigger which is called when the shockwave ability is casted :
  • My Custom Shockwave Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Custom Shockwave
    • Actions
      • -------- Initializes your variables --------
      • Set dummyLocation = (Position of (Casting unit))
      • Set spellTarget = (Target point of ability being cast)
      • -------- Creates the dummy unit that has the shockwave model --------
      • Unit - Create 1 DummyShockwave for (Owner of (Triggering unit)) at dummyLocation facing Default building facing degrees
      • Set dummyUnit = (Last created unit)
      • -------- Turn on the trigger loop to get your shockwave working --------
      • Trigger - Turn on My Custom Shockwave Loop <gen>
The loop trigger would go like this :
  • My Custom Shockwave Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • -------- Set the next location for the shockwave dummy according to the original spell target --------
      • Set dummyLocation = (dummyLocation offset by 30.00 towards (Angle from dummyLocation to spellTarget) degrees)
      • Unit - Move (Triggering unit) instantly to dummyLocation, facing (Angle from dummyLocation to spellTarget) degrees
      • -------- Gets the potential targets which are close to the shockwave --------
      • Set shockwaveTargets = (Units within 90.00 of dummyLocation matching ((((Matching unit) is dead) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of dummyUnit)) Equal to True)))
      • -------- If one unit or more has been found close to the shockwave, we got our target --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in shockwaveTargets) Greater than 0
        • Then - Actions
          • -------- Deals damage to the target and removes the shockwave dummy --------
          • Unit - Cause dummyUnit to damage (Random unit from shockwaveTargets), dealing 200.00 damage of attack type Spells and damage type Normal
          • Unit - Remove dummyUnit from the game
          • Custom script: call RemoveLocation(udg_dummyLocation)
          • -------- Turns off the loop because we don't need it any longer --------
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • -------- If the distance between the dummy and the spell target is too close, it seems we have found no target --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between dummyLocation and spellTarget) Less than or equal to 70.00
        • Then - Actions
          • Unit - Remove dummyUnit from the game
          • Custom script: call RemoveLocation(udg_dummyLocation)
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • -------- Removes memory leaks by cleaning the variables --------
      • Unit Group - Remove all units from shockwaveTargets
 
Level 39
Joined
Feb 27, 2007
Messages
5,015
Spell range indicators are nigh-impossible if not entirely impossible in wc3. There’s no way to know when a player enters the targeting phase of a spellcast except perhaps something where you can query UI elements since the command card goes black.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
@Swatosj
That's certainly a perfectly viable method of doing this but I just wanted to show a slightly alternate approach that you can apply to your trigger. This way requires no Unit Group variable and makes it easier to filter units:
  • Example
    • Events
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroy = true
      • Unit Group - Pick every unit in (Units within 100.00 of Point) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Dummy Not equal to No unit
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is A flying unit) Equal to False
              • ((Picked unit) is Mechanical) Equal to False
            • Then - Actions
              • -------- Deal the damage --------
              • Unit - Cause Dummy to damage (Picked unit), dealing 500.00 damage of attack type Spells and damage type Normal
              • Unit - Remove Dummy from the game
              • Set Dummy = No unit
              • Trigger - Turn off (This trigger)
            • Else - Actions
So instead of using shockwaveTargets you can simply use that custom script and Pick every unit. This makes filtering units a lot easier instead of having to deal with "Matching unit".

Once a valid target is found the Loop will basically "break" because Dummy will be set to No Unit and one of the conditions checks to see if Dummy ISN'T No Unit.

Some other notes:
For a smooth looking projectile you definitely want to reduce the Interval to something like 0.03.

Use an Integer to track when the Missile (Dummy) should expire instead of calculating the Distance between the Dummy and the Cast Point. For example:
  • Example
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set counter = (counter + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • counter Equal to 50
        • Then - Actions
          • Unit - Remove dummy from the game
        • Else - Actions
The Dummy will expire after 1.50 seconds (0.03*50 = 1.50). Or you can use a Real that is equal to the desired Duration and reduce it by 0.03 every Interval. Then check when that Real is Less than or Equal to 0 and Remove the dummy. Reals can lose precision so you shouldn't check for exact values like "Equal to 0". I like using Integers because they're always precise.
 
Last edited:
Status
Not open for further replies.
Top