Кто подскажет как раскрыть эту функции. можно ли в ней углы как то плюсовать.
local unit Unit = CreateUnitAtLoc(GetOwningPlayer(caster),UnitId, GetOwningPlayer(GetSpellAbilityUnit()), PolarProjectionBJ(PolarProjectionBJ(GetSpellTargetLoc(), 150.00, ( AngleBetweenPoints(GetSpellTargetLoc(), GetUnitLoc(GetSpellAbilityUnit())) + 90.00 )), 150.00, ( AngleBetweenPoints(GetUnitLoc(GetLastCreatedUnit()), GetSpellTargetLoc()) + 90.00 )), bj_UNIT_FACING )
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Целевая точка создания способности = T
Применяющий юнит = U
1 Созданная точка = D
Конечная точка создания юнита = V
Создать юнита в X смещением 150 поворот на угол между T-U + 90 + смещение на 150 поворот между на угол между Е и D + 90
scope landingTroops initializer Init
private constant integer SpellId = 'A09D'
private constant integer Spell2Id = 'A005'
private constant integer UnitId = 'h01M'
private constant integer Unit2Id = 'h023'
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SpellId
endfunction
private function Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local location cas = GetUnitLoc(caster)
local location tar = GetSpellTargetLoc()
Создание 1 Вертолёта
local real angle = bj_RADTODEG * Atan2(GetLocationY(tar) - GetLocationY(cas),GetLocationX(tar) - GetLocationX(cas) - 0)
local real x = GetLocationX(tar) + 0 * Cos(angle * bj_DEGTORAD - 0)
local real y = GetLocationY(tar) + 0 * Sin(angle * bj_DEGTORAD - 0)
local unit Unit = CreateUnitAtLoc(GetOwningPlayer(caster),UnitId, Location(x, y), angle - 0)
call SetUnitFlyHeight(Unit, 1000, 0)
call SetUnitFlyHeight(Unit, 200, 500)
call TriggerSleepAction(1.60)
Создание 1 Юнита
local real angle2 = bj_RADTODEG * Atan2(GetLocationY(tar) - GetLocationY(cas),GetLocationX(tar) - GetLocationX(cas) - 0)
local real x2 = GetLocationX(tar) + 175 * Cos(angle * bj_DEGTORAD - 150)
local real y2 = GetLocationY(tar) + 175 * Sin(angle * bj_DEGTORAD - 150)
local unit Unit2 = CreateUnitAtLoc(GetOwningPlayer(caster),Unit2Id, Location(x2, y2), angle2 + 45)
UnitAddAbility(Unit2, Spell2Id)
call SetUnitFlyHeight(Unit2, 150, 0)
call SetUnitFlyHeight(Unit2, 0, 300)
UnitRemoveAbility(Unit2, Spell2Id)
Создание 2 Юнита
local real angle3 = bj_RADTODEG * Atan2(GetLocationY(tar) - GetLocationY(cas),GetLocationX(tar) - GetLocationX(cas) - 0)
local real x3 = GetLocationX(tar) + 150 * Cos(angle * bj_DEGTORAD + 150)
local real y3 = GetLocationY(tar) + 150 * Sin(angle * bj_DEGTORAD + 150)
local unit Unit3 = CreateUnitAtLoc(GetOwningPlayer(caster),Unit2Id, Location(x3, y3), angle3 -45)
UnitAddAbility(Unit3, Spell2Id)
call SetUnitFlyHeight(Unit3, 150, 0)
call SetUnitFlyHeight(Unit3, 0, 300)
UnitRemoveAbility(Unit3, Spell2Id)
call TriggerSleepAction(0.50)
Создание 3 Юнита
local real angle4 = bj_RADTODEG * Atan2(GetLocationY(tar) - GetLocationY(cas),GetLocationX(tar) - GetLocationX(cas) - 0)
local real x4 = GetLocationX(tar) + 175 * Cos(angle * bj_DEGTORAD - 30)
local real y4 = GetLocationY(tar) + 175 * Sin(angle * bj_DEGTORAD - 30)
local unit Unit4 = CreateUnitAtLoc(GetOwningPlayer(caster),Unit2Id, Location(x4, y4), angle4 + 90)
UnitAddAbility(Unit4, Spell2Id)
call SetUnitFlyHeight(Unit4, 150, 0)
call SetUnitFlyHeight(Unit4, 0, 300)
UnitRemoveAbility(Unit4, Spell2Id)
Создание 4 Юнита
local real angle5 = bj_RADTODEG * Atan2(GetLocationY(tar) - GetLocationY(cas),GetLocationX(tar) - GetLocationX(cas) + 0)
local real x5 = GetLocationX(tar) + 175 * Cos(angle * bj_DEGTORAD + 30)
local real y5 = GetLocationY(tar) + 175 * Sin(angle * bj_DEGTORAD + 30)
local unit Unit5 = CreateUnitAtLoc(GetOwningPlayer(caster),Unit2Id, Location(x5, y5), angle5 - 90)
UnitAddAbility(Unit5, Spell2Id)
call SetUnitFlyHeight(Unit5, 150, 0)
call SetUnitFlyHeight(Unit5, 0, 300)
UnitRemoveAbility(Unit5, Spell2Id)
call TriggerSleepAction(0.50)
Создание 5 Юнита
local real angle6 = bj_RADTODEG * Atan2(GetLocationY(tar) - GetLocationY(cas),GetLocationX(tar) - GetLocationX(cas) + 0)
local real x6 = GetLocationX(tar) + 150 * Cos(angle * bj_DEGTORAD - 90)
local real y6 = GetLocationY(tar) + 150 * Sin(angle * bj_DEGTORAD - 90)
local unit Unit6 = CreateUnitAtLoc(GetOwningPlayer(caster),Unit2Id, Location(x6, y6), angle6 - 115)
UnitAddAbility(Unit6, Spell2Id)
call SetUnitFlyHeight(Unit6, 150, 0)
call SetUnitFlyHeight(Unit6, 0, 300)
UnitRemoveAbility(Unit6, Spell2Id)
Создание 6 Юнита
local real angle7 = bj_RADTODEG * Atan2(GetLocationY(tar) - GetLocationY(cas),GetLocationX(tar) - GetLocationX(cas) + 0)
local real x7 = GetLocationX(tar) + 175 * Cos(angle * bj_DEGTORAD + 90)
local real y7 = GetLocationY(tar) + 175 * Sin(angle * bj_DEGTORAD + 90)
local unit Unit7 = CreateUnitAtLoc(GetOwningPlayer(caster),Unit2Id, Location(x7, y7), angle7 + 115)
UnitAddAbility(Unit7, Spell2Id)
call SetUnitFlyHeight(Unit7, 150, 0)
call SetUnitFlyHeight(Unit7, 0, 300)
UnitRemoveAbility(Unit7, Spell2Id)
call TriggerSleepAction(0.75)
call SetUnitFlyHeight(Unit, 1200, 500)
call TriggerSleepAction(2.4)
RemoveUnit(Unit)
Обнуление Переменных
set caster = null
set Unit = null
set Unit2 = null
set Unit3 = null
set Unit4 = null
set Unit5 = null
set Unit6 = null
set Unit7 = null
set angle = 0
set angle2 = 0
set angle3 = 0
set angle4 = 0
set angle5 = 0
set angle6 = 0
set angle7 = 0
set x = 0
set y = 0
set x2 = 0
set y2 = 0
set x3 = 0
set y3 = 0
set x4 = 0
set y4 = 0
set x5 = 0
set y5 = 0
set x6 = 0
set y6 = 0
set x7 = 0
set y7 = 0
call RemoveLocation (cas)
call RemoveLocation (tar)
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer index
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( t, Condition( function Conditions ) )
call TriggerAddAction( t, function Actions )
set t = null
endfunction
Отредактирован MadDemon
local unit caster = GetSpellAbilityUnit()
local location cas = GetUnitLoc(caster)
local location tar = GetSpellTargetLoc()
local real d = bj_RADTODEG * (Atan2(GetLocationY(cas) - GetLocationY(tar),GetLocationX(cas) - GetLocationX(tar)))
Точка создания Юнита1
local real x = (GetLocationX(tar) + 150 * Cos((d+90) * bj_DEGTORAD)) - 300 * Cos((d+180) * bj_DEGTORAD)
local real y = (GetLocationY(tar) + 150 * Sin((d+90) * bj_DEGTORAD)) - 300 * Sin((d+180) * bj_DEGTORAD)
Точка создания Юнита2
local real x2 = (GetLocationX(tar) + 150 * Cos((d-90) * bj_DEGTORAD)) - 300 * Cos((d-180) * bj_DEGTORAD)
local real y2 = (GetLocationY(tar) + 150 * Sin((d-90) * bj_DEGTORAD)) - 300 * Sin((d-180) * bj_DEGTORAD)
Появление 1 юнита
local unit Unit = CreateUnitAtLoc(GetOwningPlayer(caster),Unit2Id, Location(x, y), d + 90)
Появление 2 юнита
local unit Unit2 = CreateUnitAtLoc(GetOwningPlayer(caster),Unit2Id, Location(x2, y2), d - 90)
Обнуление переменных
set caster = null
set Unit = null
set Unit2 = null
set d = 0
set x = 0
set y = 0
set x2 = 0
set y2 = 0
call RemoveLocation (cas)
call RemoveLocation (tar)
endfunction
Отредактирован nazarpunk
Отредактирован Nevermourne
Почему не написать все то же самое в одну строку?
Да, может строка выйдет длинновата, но ты же сам знаешь что это просто точка со смещением, и менять в ней всего 2 значения...
Лично я бы сократил так:
Отредактирован nazarpunk
Я просто спросил почему ты считаешь такой вариант более комфортным.