- Joined
- Jun 18, 2007
- Messages
- 214
Hello, there. I'm trying to make a spell that summons novas starting from caster's east all the way to his west side. Now I managed to calculate 180 % degrees divided by the number of novas. It's working except it always summons novas north-west all to way to north-east side.
I'm trying to find out how to make does novas summon in front of the caster like I said from his east to west side, or west to east. I failed 100 times with GetUnitFacing, and math is not really my strongest side
. So, if anyone can help I would be most grateful.
Here's the code.
Thank you!
I'm trying to find out how to make does novas summon in front of the caster like I said from his east to west side, or west to east. I failed 100 times with GetUnitFacing, and math is not really my strongest side
Here's the code.
JASS:
constant function Swing_Slash_Rawcode takes nothing returns integer
return 'A000'
endfunction
constant function Nova_SFX takes nothing returns string
return "Objects\\Spawnmodels\\Undead\\UndeadLargeDeathExplode\\UndeadLargeDeathExplode.mdl"
endfunction
constant function Hit_SFX takes nothing returns string
return "Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl"
endfunction
constant function Slash_Distance takes nothing returns real
return 200.0
endfunction
constant function Damage_Radius takes nothing returns real
return 125.0
endfunction
constant function Slash_Damage takes integer i returns real
return 100.0*i
endfunction
constant function Slash_Number takes nothing returns integer
return 20
endfunction
constant function Nova_Spawn_Speed takes nothing returns real
return 0.1
endfunction
//==========================================================================================================================================================================================================
//Condition trigger.
function Trig_Swing_Slash_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Swing_Slash_Rawcode()
endfunction
//Filter for picking enemies in group.
function Swing_Slash_Filter takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), bj_groupEnumOwningPlayer) and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false and (GetWidgetLife(GetFilterUnit())>0.405)
endfunction
//==========================================================================================================================================================================================================
//===========EXECUTE NOVA===============================================================================
function Slash_Nova takes nothing returns nothing
local timer novatimer = GetExpiredTimer()
local unit damager = LoadUnitHandle(udg_Hash, GetHandleId(novatimer), 1)
local unit ug = null
local integer angle = 180/Slash_Number()
local integer count = LoadInteger(udg_Hash, GetHandleId(novatimer), 2)
local real x = LoadReal(udg_Hash, GetHandleId(novatimer), 3)
local real y = LoadReal(udg_Hash, GetHandleId(novatimer), 4)
local group g = null
local boolexpr b = null
local real newX
local real newY
if count != Slash_Number() then
set newX = x + Slash_Distance() * Cos(I2R(angle*count) * bj_DEGTORAD)
set newY = y + Slash_Distance() * Sin(I2R(angle*count) * bj_DEGTORAD)
call DestroyEffect(AddSpecialEffect(Nova_SFX(), newX, newY))
call SaveInteger (udg_Hash, GetHandleId(novatimer), 2, count + 1)
set g = CreateGroup()
set b = Condition(function Swing_Slash_Filter)
set bj_groupEnumOwningPlayer = GetOwningPlayer(damager)
call GroupEnumUnitsInRange(g, newX, newY, Damage_Radius(), b)
call DestroyBoolExpr(b)
loop
set ug = FirstOfGroup(g)
exitwhen ug == null
call GroupRemoveUnit(g, ug)
call DestroyEffect(AddSpecialEffect(Hit_SFX(), GetUnitX(ug), GetUnitY(ug)))
call UnitDamageTarget(damager, ug, Slash_Damage(GetUnitAbilityLevel(damager, Swing_Slash_Rawcode())), true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
endloop
call DestroyGroup(g)
set g = null
set b = null
set novatimer = null
set damager = null
set ug = null
else
call FlushChildHashtable(udg_Hash, GetHandleId(novatimer))
call PauseTimer(novatimer)
call DestroyTimer(novatimer)
set novatimer = null
set b = null
set g = null
set damager = null
set ug = null
endif
endfunction
//===============SETTINGS FOR 180 % NOVA==============================================================================
function Trig_Swing_Slash_Actions takes nothing returns nothing
local timer novatimer = CreateTimer()
local unit cast = GetTriggerUnit()
local integer count = 1
local real cX = GetUnitX(cast)
local real cY = GetUnitY(cast)
call BJDebugMsg(R2S(GetUnitFacing(cast)))
call SaveUnitHandle (udg_Hash, GetHandleId(novatimer), 1, cast)
call SaveInteger (udg_Hash, GetHandleId(novatimer), 2, count)
call SaveReal (udg_Hash, GetHandleId(novatimer), 3, cX)
call SaveReal (udg_Hash, GetHandleId(novatimer), 4, cY)
call TimerStart(novatimer, Nova_Spawn_Speed(), true, function Slash_Nova)
set novatimer = null
set cast = null
endfunction
//=============INIT TRIGG===================================================================
function InitTrig_Swing_Slash takes nothing returns nothing
local trigger trig = CreateTrigger()
local integer guza
set guza = 0
loop
call TriggerRegisterPlayerUnitEvent(trig, Player(guza), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set guza = guza + 1
exitwhen guza == 16
endloop
call TriggerAddCondition(trig, Condition(function Trig_Swing_Slash_Conditions))
call TriggerAddAction(trig, function Trig_Swing_Slash_Actions)
call Preload(Nova_SFX())
call Preload(Hit_SFX())
call PreloadStart()
set udg_Hash = InitHashtable()
set trig = null
endfunction
Thank you!