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:
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:
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.
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:
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 039;A00J039;
endfunction
constant function Multi_Shockwave_Dummy_Ability_ID takes nothing returns integer
return 039;A00K039;
endfunction
constant function Multi_Shockwave_Temp_Dummy_ID takes nothing returns integer
return 039;h008039;
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.