Formula(s) Needed

Tinki3

Special Member
Reaction score
418
I am attempting to make a spell called "Multi Shockwave".

It is meant to send shockwaves casted by dummy units out from the caster's origin,
towards different angles, in a formation something like this:

untitledpv5.jpg


At level 1, it launches 2, so to be logical and to make the spell look "good",
the shockwaves should be the East-South-South, and the West-South-South.
(The one's closest to the South apart from the middle one).

Level 2 launches 3, so its formation should be the 3 closest to South.

Level 3 launches 4, the formation would be too hard to explain in words.

Level 4 launches 5, the formation would/should look exactly like the diagram.

Basically I need to have the formation of shockwaves more or less "centered",
and evenly-spread about the angle from the caster to the target location.

In saying this, if the angle between the caster and the target location was 90 dgrs,
I wouldn't want one shockwave shooting out towards 20 dgrs, and another shooting out 160 dgrs.

Here is my current JASS code for the spell:
JASS:
constant function Multi_Shockwave_Offset takes nothing returns real
    return 50.0
endfunction

constant function Multi_Shockwave_Amount takes integer lvl returns integer
    return 1 + lvl
endfunction

constant function Multi_Shockwave_Ability_ID takes nothing returns integer
    return 'A00J'
endfunction

constant function Multi_Shockwave_Dummy_Ability_ID takes nothing returns integer
    return 'A00K'
endfunction

constant function Multi_Shockwave_Temp_Dummy_ID takes nothing returns integer
    return 'h008'
endfunction

function Multi_Shockwave_Actions takes nothing returns nothing
    local unit u      = GetTriggerUnit()
    local location l  = GetSpellTargetLoc()
    local integer lvl = GetUnitAbilityLevel(u, Multi_Shockwave_Ability_ID())
    local integer amt = Multi_Shockwave_Amount(lvl)
    local integer c   = 1
    local real X1     = GetUnitX(u)
    local real Y1     = GetUnitY(u)
    local real X2     = GetLocationX(l)  
    local real Y2     = GetLocationY(l)  
    local real ang    = Atan2(Y2-Y1, X2-X1)/(amt + 1)
    local real X3
    local real Y3
    local unit d

    loop
        exitwhen c > amt
        set X3 = X1 + Multi_Shockwave_Offset() * Cos(ang * (c * 2))
        set Y3 = Y1 + Multi_Shockwave_Offset() * Sin(ang * (c * 2))     
        set d  = CreateUnit(GetOwningPlayer(u), Multi_Shockwave_Temp_Dummy_ID(), X1, Y1, bj_RADTODEG * (ang * (c * 2)))
        call UnitAddAbility(d, Multi_Shockwave_Dummy_Ability_ID())
        call IssuePointOrder(d, "shockwave", X3, Y3)
        set c  = c + 1   
    endloop

    call RemoveLocation(l)

    set u = null
    set l = null
    set d = null
endfunction

function Multi_Shockwave_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Multi_Shockwave_Ability_ID() 
endfunction

function InitTrig_Multi_Shockwave takes nothing returns nothing
    set gg_trg_Multi_Shockwave = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Multi_Shockwave, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Multi_Shockwave, Condition( function Multi_Shockwave_Conditions ) )
    call TriggerAddAction( gg_trg_Multi_Shockwave, function Multi_Shockwave_Actions )
endfunction

Want to know if it works?
Well, it does!

But not the way I desire it to.
As is, it evenly spreads the shockwaves from the angle given, but the formation of them
isn't the same if I cast at say 50 dgrs and 150 dgrs, or any angle to be exact.

For example, if I cast at roughly 180 dgrs, the shockwaves are widely spread. If I cast at roughly 0 dgrs, the shockwaves aren't spread at all.

This is because the angle between the points is used for the formula;
the closer its value is to 0, the smaller the space between each shockwave.

I could use an If-then-else statement to do this whole thing,
but that would be messy, and I am determined to get a formula working here.

If anyone would like to help me solve this problem, I'd be glad to hear from you.
 

Choppa

www.warcraft-gamers.po.gs
Reaction score
59
I don't know jass but from looking at it I can guess what it does but how does this return the angle?
Code:
local real ang    = Atan2(Y2-Y1, X2-X1)/(amt + 1)
That's if ang equals the angle the unit is facing... Is it?
 

Choppa

www.warcraft-gamers.po.gs
Reaction score
59
I just don't see why you'd need the level of the unit to get it position :confused:
Am I missing something?

I understand that "Atan2(Y2-Y1, X2-X1)" will return the angle between, hmm... if you minus the values (Y2-Y1) then that might give a totaly different value...

Let's say
Y2:70,
X2:60,
Y1:50,
X1:40,

Then "Atan2(Y2-Y1, X2-X1)" will be "Atan2(70-50, 60-40)" which will return the angle between (20, 20) which will equal 0 right? Unless that's not how Atan2 works... Tell me if i'm wrong.
 

Tinki3

Special Member
Reaction score
418
>I just don't see why you'd need the level of the unit to get it position

That has nothing to do with the actual angle between the 2 points.
Like I said, it's part of my inaccurate forumala which is used in the loop.

>Unless that's not how Atan2 works... Tell me if i'm wrong

Yep, you are (partly) :p

The Atan2 function returns the angle in radians.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> ang * (c * 2)

Whatever you think this is doing, it's probably not... :p


Point with polar offset: ... towards Casting direction
For i from 1 to Level - 1
- Point with polar offset: ... towards Casting direction + 15 * i
- Point with polar offset: ... towards Casting direction - 15 * i
 

Tinki3

Special Member
Reaction score
418
>In "nearly english"

Your right about that :p

Could you make it a little clearer?
I'm not sure what means what, or what goes with what.

Are those POs where I create the dummies at?
Or are they where I order them to cast shockwaves at?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Set PositionCaster = Position of Caster
Set Angle = Angle from PositionCasting to Target point of ability being cast

Unit - Create Dummy at PositionCaster
Set Point = PositionCaster offset by whatever towards Angle
Unit - Order Dummy to ...

For each Integer A from 1 to (Level of Ability being cast - 1)
- Unit - Create Dummy at PositionCaster
- Set Point = PositionCaster offset by whatever towards Angle + 15 * Integer A
- Unit - Order Dummy to ...
- Unit - Create Dummy at PositionCaster
- Set Point = PositionCaster offset by whatever towards Angle - 15 * Integer A
- Unit - Order Dummy to ...


Something like that I would guess.
Cleaned up for leaks, MUI and similar of course. Though I trust you don't need help with that part.
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
Would using an angle comparision between caster facing and target location be helpful here?

Your spell is always going to be centered on the angle of origin to target correct? (unless unit facing comes into it?) So would having (spell level variable number) of dummy points being set off the angle be a workable idea?

I don't know if that was clear. I'll try to explain what I'm thinking in this part. To do so I'll talk about something your not doing in your spell. Lets take it back a step. And lets use straight down cause it's easier to see. Lets assume straight down is 0 and you only have one target, just like a normal spell. Then move on from there. I'll also use points, but you can think in terms of coordinates. What I'm focusing on here is the thinking. You can convert later or as you read - suit yourself. See image below.

angles.jpg


Each of your dummy target points are going to be one of 9 points. The middle is always centered on the Angle of origin to spell target location. The two extremes are 45° and -45° (or whatever you set). The angle between the respective even and odd lines are always going to be 22.5°.

So, in words, this is what you'd do for your formula.

1 dummy target point. TDummyLoc=spell target
2 dummy target points. TDummy1Loc=spell target + 11.25. TDummy2Loc= - 11.25. (because half of 22.5 = 11.25)

3 dummy target point. TDummyLoc1=spell target. TDummyLoc2=spell target + 22.5°. TDummyLoc3=spell target - 22.5°.
etc and add another plus and negative onto the last angle.
etc and add another plus and negative onto the last angle.

Does that help any? Edit: lol beaten to the post by about er... 40 minutes lol.
 

emjlr3

Change can be a good thing
Reaction score
395
perhaps you have your answer, perhaps not

is the idea to have them more spread the farther away you cast? or a constant angle?

for the latter

id get anglebetweenpoints, where point 1 is the caster, and point 2 is the spelltargetloc

this is stored as a real, lets called it "ang"

now say we want 1 straight ahead down this angle, and 2 on either side....15 degrees away

id do something like
JASS:
integer i = 0
real ang = our angle gotten
real new_ang
real const_start = -30.
real cosnt_change = 15

loop
  exitwhen i>4
  set new_ang = ang-cons_start+(i*const_change)
  set i = i + 1
endloop


you can than pick a distance away you want to cast your ability, use your angle, and the polarprojection functions to grab a location out at that distance, at the correct angle
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top