• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] an efficient way to damage a line

Status
Not open for further replies.
Level 10
Joined
Oct 2, 2005
Messages
398
I wonder if there is a better and simpler way to damage a line as it it was a lightning effect damage. Yes, shockwave can damage a line, but it doesnt have a flexible distance changing, and creating multiple area damages isn't more efficient/easier. +rep.
Thanks in advance
 
Last edited:
Level 5
Joined
Oct 3, 2008
Messages
104
if u want a variable distance, and also instant damage, then u must instantly create dummy units in the damage area for referencing for the 'unit within range' function. it wont be hard to do, it will just take a while to get it right.

basically say u create like 5 dummies in your line of damage, then pick every one of those dummy units and add all units within range to a unit group variable, and then damage those units. use some simple maths to place those dummies correctly, and remember to remove leaks, you should be fine
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Can't you base it on Chain Lightning, and make it an ability targetting a point instead of a unit. You can check every x (e.g. 100) distance (let's call these checking distances 'DistanceCheck') between TempPoint1 (position of caster) and TempPoint2 (position of point the ability was casted) to see if there are any units in the same distance of the distance you check until they reach TempPoint2.
If you want units in a bigger or smaller range to be effected, you increase/decrease both the distance around the DistanceChecks as the radius around the DistanceChecks. This to avoid overlapping of 2 DistanceChecks, which can cause units to be damaged twice if they're in range of a DistanceCheck.

If you don't completely get me, I'll make a little drawing on paint when I get home. It'll give you a good view of what I mean, and how to increase/decrease the effective area.
 
Level 10
Joined
Aug 15, 2008
Messages
448
Try creating an area ability (like Healing Ward with no summoned unit) and a dummy unit with the immolation ability, then make a trigger like this:
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to (your ability)
  • Actions
    • Set AbilityTempLoc=Target point of ability being cast
    • Set CasterTempLoc=Position of (casting unit)
    • Unit - Create 1 (ImmolationDummyUnit) for (Owner of (casting unit)) at (CasterTempLoc) facing (AbilityTempLoc)
    • Set DummyUnitVar=Last created unit
    • Unit - Add a ((Distance between (AbilityTempLoc) and (CasterTempLoc))/(Current movement speed of (Dummy Unit)) second (generic) expiration timer to DummyUnitVar
    • Unit - Order DummyUnitVar to Move to (AbilityTempLoc)
    • Custom script: Call RemoveLocation(udg_AbilityTempLoc)
    • Custom script: Call RemoveLocation(udg_CasterTempLoc)
That's it. I don't know if the expiration timer will function, but it should set the "life" of the projectile to end once it reaches its target... if you want a lighting effect then add it with the AbilityTempLoc and CasterTempLoc points :wink:.

[EDIT]
By the way, by doing a unit-based projectile you will not be able to set its speed over 560 or so... you may add a trigger that instantly moves it to the designated location every 0.3 seconds by... let's say 10. That would include points with polar offset and other variables though. You may also create another dummy unit on the other side and make it to move to the caster unit or periodically create dummy units with immolation each (number) for filling the distance between the caster and the target point.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Wtf?
Why do you need dummy units???
Just for fun?
That approach is good(not really, but works), but there is absolutely no need for dummy units.
Just pick up the units around the location where you would have placed the dummy ...
But heck, what do I know, may be easier to place the dummy on a known location and pick up the units within some range of the location of the dummy(the location where you placed it) ;)
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
  • Actions
    • Set temppoint1 = (Position of (Triggering Unit))
    • For each integer A from 1 to 7 do:
      • Set temppoint2 = temppoint1 offset by x towards (Facing of (Triggering unit)) degrees
      • Set temprect = Region centered at temppoint 2 with size 200, 200
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in temprect matching (Matching Unit) belongs to an enemy of (Owner of (Triggering Unit)) equal to true and do:
        • Unit Group - Add (Picked Unit) to dmg_group
      • Set x = x + 100
      • Custom script: call RemoveLocation(udg_temppoint2)
      • Custom script: call RemoveRect(udg_temprect)
    • Unit Group - Pick every unit in dmg_group and do Unit - Cause (Triggering Unit) to damage (Picked Unit) for...
    • Custom script: call RemoveLocation(udg_temppoint1)
Lower or increase the maximum integer (7 here) as 1 goes for 100 range and 7 for 700 range and on and on..

//There might be slight differences as this trigger is handwritten ;)
 
Level 5
Joined
Oct 3, 2008
Messages
104
damn im stupid, i just thought of a better way.

first i must say that damaging in circles across the line will double damage some of the units, which is BAD

make several carrion swarm abilities with different ranges. The more you are willing to make the more accurate your range will be. Use a dummy ability for this spell u wanna make. In your trigger, reference the dummy ability, detect the range of the target point of ability being cast, and use maths to compute which carrion swarm (in other words, which range) to use
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
I just thought that you might solve double hitting by adding the hit targets to a unit group. So whenever the first part hits a unit, you add the unit to the unit group, when the second part hits a unit that is in the unit group, it'll do nothing, if it's not in the unit group, it simply does the effect it should. Very easy and efficient way to prevent double hits.
Do keep in mind that you'll have to clear the unit group when the spell has done it's full effect.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
I've asked that in another topic a while ago before. The answer: No, only 1 of a unit can only be in a Unit Group. If you add the unit toi the unit group again, it'll won't have any effect.

I was saying that he can make if/then/else commands.

  • If (All conditions are true) then do (Then actions), else do (Else actions)
    • If - Conditions
      • Unit in <REGION> is NOT in <UNIT GROUP>
    • Then - Actions
      • DO SPELL EFFECT
      • Add <UNIT> to <UNIT GROUP>
    • Else - Actions
That way the spell only takes effect if the unit is not in the group yet. After the spell is complete, you clear the unit group.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Yes and that's exactly how you should do it since, sadly, we can use only vertical and horizontal rects.

Picking units with, say, a 100 radius and then a 100 radius after that can damage twice a unit that was exactly in the middle, so if you do that, pick 101 after the first one.
But still, it's a circle, not a square and thus you won't damage a line.

So, you have to pick at very small ranges (the smaller the accurate but more memory consuming) and check if they're in your damage group.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Or you can use jass. Pick all units in an big circle that match a condition( they are in your very own custom rect(search for the programming method if you do not know how). Or you can simply go to wc3campaigns.net and find the system, code or whatever they classified it, that takes a set of coordinates and returns all units in the rect(like this one, but I recall others too).
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Well, you can make new shapes by making like a hundred small square regions in the shape of the shape you want xD

That's just going to take too long, isn't very smoothly and probably also not worth the trouble.


About the distance between the center of the radius': I suggest you take about 1/4th-1/2th of the distance between the centers of 2 radius' if the ends of the radius' would touch. That means 1/4th-1/2nd of:

. . . |<------>|. . . . (<--- Distance between 2 radius' touching)
---==-------==-----
-=----=---=----=---
=--<>--==--<>--==
-=----=---=----=---
---==-------==-----
 
Level 6
Joined
Sep 5, 2007
Messages
264
To speed up unit picking around the current-point along the line, what you can do is:

When the spell initiates, find the distance/angle between start & end of line (this is obvious)... Then find the half-way point, do a "pick all units in range" using the total distance*0.55(extra 10% to be sure to catch all units) as the radius. Remember this group, by whatever means, and scan through it when looking for possible targets. 20x this way is much faster than 20x "pick all units in range".

As for the actual detection, Avator seems to have a good approach. But, I'd allow the circles to overlap, just filter out already effected units (add them to a group, and scan that group).

I've have used this sort of approach myself. I did it a while back using H2I, and it was still pretty quick, even though structs are a hell of alot faster.
 
Status
Not open for further replies.
Top