# Spell Formula (Shockwave)

Status
Not open for further replies.

#### Titanhex

Level 14
I was wanting to make a shockwave spell that only extended out about 250 from the unit casting it. It's damage is boosted based on whether the caster has a certain unit near them, which is why it's gotta be trigger based damage.

So my question is what is the formula for shockwave's radius and extensions from the unit's cast point?

#### Berb

Level 18
What do you mean by "the formula"? Shockwave is one of the most simple spells you can possibly have I don't see where you're finding difficulty.

#### JeffreyQ

Level 9
For me i create a shockwave dummy. That will be the dummy i am moving with shockwave model. I then damage every unit in range and add them to a damaged group. The radius will be just every unit around the shockwave dummy.

For shockwave i did some math to check units infront of a 180 cone degrees so units behind the shockwave won't get damaged.

#### Berb

Level 18
JeffreyQ said:
For shockwave i did some math to check units infront of a 180 cone degrees so units behind the shockwave won't get damaged.

I'm not sure if you were trying to simulate blizzard's or not but the default spell will damage units behind the position of the missile if they haven't been damaged yet.

#### Titanhex

Level 14
Alright check out the picture. I want to do damage to units that'd be in the red. As you can see it's similar to shockwave, only it doesn't go out as far.

However the spell is target point or unit based. It's obviously not a cone by the shape either.

What would be the proper formula to determine the units in that area and allow me to damage them. So far Jeffery is the closest.

#### Attachments

• wave.PNG
384.9 KB · Views: 101

#### JeffreyQ

Level 9
I am not sure how you do it in JASS.
I will give a simple example in GUI [:

I just did it in a simple way. I didn't clear leaks and set the correct position. But just to give you an idea [:

• Short Shockwave
• Events
• Unit - A unit Starts the effect of an ability
• Conditions
• (Ability being cast) Equal to Shockwave
• Actions
• Unit - Create 1 Dummy for (Owner of (Triggering unit)) at (Center of (Playable map area)) facing Default building facing degrees
• Set distance = 250.00
• -------- Save Damage --------
• -------- Save DamagedGroup --------
• -------- Store caster --------
• -------- Store dummy --------
• Shockwave Move
• Events
• Time - Every 0.03 seconds of game time
• Conditions
• Actions
• -------- Get caster --------
• -------- Get dummy --------
• -------- Get damage --------
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• distance Greater than 0.00
• Then - Actions
• Set targetGroup = (Units within 250.00 of (Position of (caster)) matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of (caster))) Equal to True) and (((Matching unit) is in targetGroup) Equal to False))))
• Unit Group - Pick every unit in targetGroup and do (Actions)
• Loop - Actions
• -------- Do Damage --------
• -------- Add them to DamagedGroup --------
• -------- move Dummy --------
• Custom script: call DestroyGroup(udg_targetGroup)
• Else - Actions
• -------- END --------
• -------- Clear DamagedGroup --------
• -------- Kill Dummy --------

I didn't check units infront of the dummy, so it will damage units around him

#### Berb

Level 18
What do you mean the formula? There is no formula necessary for this. What would you say if I asked you for the equation of a stun duration.

There is already a "built-in" native function called `GroupEnumUnitsInRange` (which is also available in GUI) that enumerates units within the radius of a specific, defined point.

JASS:
``native GroupEnumUnitsInRange takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing``

How can you say someone is "the closest" when you don't know what the answer is.

#### Titanhex

Level 14
A radius does not create a cone. Grouping units in range will still get the units behind the caster, which is not where I'm going with this by the picture. When shockwave or carrion swarm is cast, do either of those get all the units in a radius? No, they get the units between the caster and the targeted destination. If I was asking you how to do a breath of fire would you tell me to use a radius to pick all the units? No, because it creates a cone to pick the units, not a radius. What I'm asking for is a vector, not a radius.

If I was asking for how you do a thunderclap you would be correct. I am not asking how to do a thunderclap/stomp/anything like that.

If I was asking you how to determine the direction a knockback'ed unit would go would you tell me to just use a point in a radius? No, you would want that unit to fly away from the one who hit it.

If I was going to ask you how to launch a missile in a straight line away from the unit casting it towards a designated point picked by that user, would you tell me to use GroupEnumUnitsInRange? I would hope not.

But isn't that exactly what I'm asking? How to send something out in a straight line towards a designated point and damage units on that path?

Seeing as how you can't seem to grasp that even after I've shown you a picture of the targeted area I want covered by this spell in order to pick units and do damage, perhaps someone could assist me with what number.

I'm sure it'd be good enough just to pick units in a radius some 125 outward from the current facing of the unit casting.

I'll try Jeffery's method to see if it gets the desired results.

#### Maker

Level 37
Use this as a condition to pick units inside a cone:
• (Cos((Temp_Real_1 - (Angle from Temp_Loc_1 to Temp_Loc_2)))) Greater than (Cos(30))
If that returns true, the unit is inside the cone.

Temp_Real_1 = Facing of casting unit
Temp_Loc_1 = Position of casting unit
Temp_Loc_2 = Position of unit you want to check

The total angle is 2*30° since it checks angles between facing - 30° and facing + 30°.

If you want it to be exactly like in the pic you posted, I can help you do that if needed.

#### Titanhex

Level 14
This is pretty close to what I was asking for. I'll tweak it and toy with it to see if I can't get it pretty exact. I'm not too worried if it's closer to a cone than what my picture has stated, as I doubt that'll make too big of a difference.

How do I determine where this cone ends though? My geometry and algebra skills aren't up to par.

#### Maker

Level 37
• Events
• Unit - A unit Starts the effect of an ability
• Conditions
• (Ability being cast) Equal to ...
• Actions
• Set Temp_Unit_1 = (Triggering unit)
• Set Temp_Loc_1 = (Position of Temp_Unit_1)
• Set Temp_Real_1 = (Facing of Temp_Unit_1)
• Set Temp_Real_2 = 800.00
• ...
• Set Temp_Group = (Units within Temp_Real_2 of Temp_Loc_1 matching ...
• Unit Group - Pick every unit in Temp_Group and do (Actions)
• Loop - Actions
• Set Temp_Loc_2 = (Position of (Picked unit))
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Cos((Temp_Real_1 - (Angle from Temp_Loc_1 to Temp_Loc_2)))) Greater than (Cos(30.00))
• Then - Actions
• *is inside the cone, withing 800 range*
Something like that.

#### Berb

Level 18
Titanhex said:
A radius does not create a cone. Grouping units in range will still get the units behind the caster, which is not where I'm going with this by the picture.

Titanhex said:
It's obviously not a cone by the shape either.

Man you need to get your story straight before asking for help.

Also, if you were to want units enumerated in a "cone" shape you will still have to use the `GroupEnumUnitsInRange` function. It sounds like you don't even know what you want you've said several different things now.

And by the way, the spell Shockwave, as I said before, deals damage to units behind the caster if the area of effect is big enough.

#### Titanhex

Level 14
I've decided to send you a PM Berbanog as it is far more polite and mature to discuss these matters away from the public board.

I should start work on this current spell in the next day or two, and will reply if I need more exact equations to land this spell's asthetics. I wish I had some trig or calculus teachings under my belt, but unfortunately I don't and have to rely on the mathmatics of others to assist me :\ Thanks though.

#### Berb

Level 18
I've received your message. To be honest (after re-reading the thread) you really aren't very clear in describing what you want, and if you wanted a "cone" shaped missile then it wouldn't have been very hard to clarify so. Anyways, good luck.

#### Titanhex

Level 14
That actual, perfect area I assume I need is not a cone but rather what is described exactly by that picture. Every unit that'd be enclosed within the red. I can however use a cone just as well, since I don't see too big of an issue between using a cone and a "House" shape in that small of an area.

Also, how could a picture not be more clear on the area I am looking for?

On top of that how and why and for what reason would you find any remote sense in responding to this thread when the one you should directly be responding to is me via PM as the issue you have is with me and me alone.

On top of that I did not say I wanted a missile but merely referenced one as an example of why you wouldn't tell me to use a radius. Please stop trolling the thread. Thank you.

#### Berb

Level 18
I did PM you. My reply to this thread was me giving you my re-evaluated opinion. Even after re-reading the thread it seemed you were unclear with exactly what you wanted, you seemed open to suggestion. I was trying to evaluate what it was you specifically wanted so I could give you as best an answer as I could. Apologies.

#### Titanhex

Level 14
Apology accepted. PM sent to clarify things.

Status
Not open for further replies.

Replies
1
Views
774
Replies
1
Views
629
Replies
6
Views
826
Replies
7
Views
681
Replies
21
Views
1K