Название:Пак наработок для гуи Автор:Maxim Karelov aka Ty3uK Вид наработки:Мапмейкерам Тип исполнения:Jass 2 Тестовая карта:Присутствует Минимальный патч:1.24 Сложность импорта:Очень легко
Итак, в свет вышла еще одна УГ наработка от меня лично. Она позволяет ГУИшникам юзать для перемещения юнитов таймеры, а не периодические триггеры. Все функции очень просто вызываются и не вызывают утечек. В версии 1.0 присутствуют:
Движение дамми на определенное расстояние
Движение дамми до точки каста
Прыжок на определенное расстояние
Прыжок до точки каста
Code
function GetDistanceBetweenCoords takes real x1, real x2, real y1, real y2 returns real return SquareRoot((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) endfunction
function MoveDummy_Timer takes nothing returns nothing local timer t = GetExpiredTimer() local integer hid = GetHandleId(t) local unit dummy = LoadUnitHandle(udg_Hashtable, hid, 0) local real angle = LoadReal(udg_Hashtable, hid, 1) local real distance = LoadReal(udg_Hashtable, hid, 2) local real speed = LoadReal(udg_Hashtable, hid, 3) local real d = LoadReal(udg_Hashtable, hid, 4) local real x = GetWidgetX(dummy) + speed * Cos(angle) local real y = GetWidgetY(dummy) + speed * Sin(angle) if d >= distance then if LoadBoolean(udg_Hashtable, hid, 5) then call RemoveUnit(dummy) else call PauseUnit(dummy, false) endif call FlushChildHashtable(udg_Hashtable, hid) call PauseTimer(t) call DestroyTimer(t) else call SetUnitPosition(dummy, x, y) call SaveReal(udg_Hashtable, hid, 4, d + speed) endif set dummy = null set t = null endfunction
function MoveDummy takes unit dummy, real distance, real speed, boolean remove returns nothing local timer t = CreateTimer() local integer hid = GetHandleId(t) local unit caster = GetTriggerUnit() local real angle = Atan2(GetSpellTargetY() - GetWidgetY(caster), GetSpellTargetX() - GetWidgetX(caster)) call SaveAgentHandle(udg_Hashtable, hid, 0, dummy) call SaveReal(udg_Hashtable, hid, 1, angle) call SaveReal(udg_Hashtable, hid, 2, distance) call SaveReal(udg_Hashtable, hid, 3, speed) call SaveBoolean(udg_Hashtable, hid, 5, remove) call PauseUnit(dummy, true) call TimerStart(t, .04, true, function MoveDummy_Timer) set caster = null set t = null endfunction
function MoveDummyToTarget takes unit dummy, real speed, boolean remove returns nothing local timer t = CreateTimer() local integer hid = GetHandleId(t) local unit caster = GetTriggerUnit() local real angle = Atan2(GetSpellTargetY() - GetWidgetY(caster), GetSpellTargetX() - GetWidgetX(caster)) call SaveAgentHandle(udg_Hashtable, hid, 0, dummy) call SaveReal(udg_Hashtable, hid, 1, angle) call SaveReal(udg_Hashtable, hid, 2, GetDistanceBetweenCoords(GetSpellTargetX(), GetWidgetX(caster), GetSpellTargetY(), GetWidgetY(caster))) call SaveReal(udg_Hashtable, hid, 3, speed) call SaveBoolean(udg_Hashtable, hid, 5, remove) call PauseUnit(dummy, true) call TimerStart(t, .04, true, function MoveDummy_Timer) set caster = null set t = null endfunction
function TossUnit_Timer takes nothing returns nothing local timer t = GetExpiredTimer() local integer hid = GetHandleId(t) local unit u = LoadUnitHandle(udg_Hashtable, hid, 0) local real angle = LoadReal(udg_Hashtable, hid, 1) local real distance = LoadReal(udg_Hashtable, hid, 2) local real d = LoadReal(udg_Hashtable, hid, 3) local real z = LoadReal(udg_Hashtable, hid, 5) local real x = GetWidgetX(u) local real y = GetWidgetY(u) if d <= distance / 2 then set x = x + 10. * Cos(angle) set y = y + 10. * Sin(angle) set z = z + 25. call SetUnitPosition(u, x, y) call SetUnitFlyHeight(u, z, 0.) else set x = x + 10. * Cos(angle) set y = y + 10. * Sin(angle) set z = z - 25. call SetUnitPosition(u, x, y) call SetUnitFlyHeight(u, z, 0.) endif call SaveReal(udg_Hashtable, hid, 3, d + 10.) call SaveReal(udg_Hashtable, hid, 5, z) if z <= 0. then call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", x, y)) call PauseTimer(t) call DestroyTimer(t) call PauseUnit(u, false) call FlushChildHashtable(udg_Hashtable, hid) endif set u = null set t = null endfunction
function TossUnit takes unit u, real distance returns nothing local timer t = CreateTimer() local integer hid = GetHandleId(t) local unit caster = GetTriggerUnit() local real angle = Atan2(GetSpellTargetY() - GetWidgetY(caster), GetSpellTargetX() - GetWidgetX(caster)) call SaveAgentHandle(udg_Hashtable, hid, 0, u) call SaveReal(udg_Hashtable, hid, 1, angle) call SaveReal(udg_Hashtable, hid, 2, distance) call SaveReal(udg_Hashtable, hid, 3, 10.) if UnitAddAbility(u, 'Amrf') then call UnitRemoveAbility(u, 'Amrf') endif call PauseUnit(u, true) call TimerStart(t, .01, true, function TossUnit_Timer) set caster = null set t = null endfunction
function TossUnitToTarget takes unit u returns nothing local timer t = CreateTimer() local integer hid = GetHandleId(t) local unit caster = GetTriggerUnit() local real angle = Atan2(GetSpellTargetY() - GetWidgetY(caster), GetSpellTargetX() - GetWidgetX(caster)) call SaveAgentHandle(udg_Hashtable, hid, 0, u) call SaveReal(udg_Hashtable, hid, 1, angle) call SaveReal(udg_Hashtable, hid, 2, GetDistanceBetweenCoords(GetSpellTargetX(), GetWidgetX(caster), GetSpellTargetY(), GetWidgetY(caster))) call SaveReal(udg_Hashtable, hid, 3, 10.) if UnitAddAbility(u, 'Amrf') then call UnitRemoveAbility(u, 'Amrf') endif call PauseUnit(u, true) call TimerStart(t, .01, true, function TossUnit_Timer) set caster = null set t = null endfunction
GUI Must Die! v1.1 или Наработки для гуишников v1.1
В новой версии:
Даммикаст на юнита
Даммикаст на точку
Даммикаст без цели
Возможность добавление другого эффекта в "Подбрасывание" (или наоборот, его исключение)
[jass]function GetDistanceBetweenCoords takes real x1, real x2, real y1, real y2 returns real return SquareRoot((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) endfunction
function MoveDummy_Timer takes nothing returns nothing local timer t = GetExpiredTimer() local integer hid = GetHandleId(t) local unit dummy = LoadUnitHandle(udg_Hashtable, hid, 0) local real angle = LoadReal(udg_Hashtable, hid, 1) local real distance = LoadReal(udg_Hashtable, hid, 2) local real speed = LoadReal(udg_Hashtable, hid, 3) local real d = LoadReal(udg_Hashtable, hid, 4) local real x = GetWidgetX(dummy) + speed * Cos(angle) local real y = GetWidgetY(dummy) + speed * Sin(angle) if d >= distance then if LoadBoolean(udg_Hashtable, hid, 5) then call RemoveUnit(dummy) else call PauseUnit(dummy, false) endif call FlushChildHashtable(udg_Hashtable, hid) call PauseTimer(t) call DestroyTimer(t) else call SetUnitPosition(dummy, x, y) call SaveReal(udg_Hashtable, hid, 4, d + speed) endif set dummy = null set t = null endfunction
function MoveDummy takes unit dummy, real distance, real speed, boolean remove returns nothing local timer t = CreateTimer() local integer hid = GetHandleId(t) local unit caster = GetTriggerUnit() local real angle = Atan2(GetSpellTargetY() - GetWidgetY(caster), GetSpellTargetX() - GetWidgetX(caster)) call SaveAgentHandle(udg_Hashtable, hid, 0, dummy) call SaveReal(udg_Hashtable, hid, 1, angle) call SaveReal(udg_Hashtable, hid, 2, distance) call SaveReal(udg_Hashtable, hid, 3, speed) call SaveBoolean(udg_Hashtable, hid, 5, remove) call PauseUnit(dummy, true) call TimerStart(t, .04, true, function MoveDummy_Timer) set caster = null set t = null endfunction
function MoveDummyToTarget takes unit dummy, real speed, boolean remove returns nothing local timer t = CreateTimer() local integer hid = GetHandleId(t) local unit caster = GetTriggerUnit() local real angle = Atan2(GetSpellTargetY() - GetWidgetY(caster), GetSpellTargetX() - GetWidgetX(caster)) call SaveAgentHandle(udg_Hashtable, hid, 0, dummy) call SaveReal(udg_Hashtable, hid, 1, angle) call SaveReal(udg_Hashtable, hid, 2, GetDistanceBetweenCoords(GetSpellTargetX(), GetWidgetX(caster), GetSpellTargetY(), GetWidgetY(caster))) call SaveReal(udg_Hashtable, hid, 3, speed) call SaveBoolean(udg_Hashtable, hid, 5, remove) call PauseUnit(dummy, true) call TimerStart(t, .04, true, function MoveDummy_Timer) set caster = null set t = null endfunction
function TossUnit_Timer takes nothing returns nothing local timer t = GetExpiredTimer() local integer hid = GetHandleId(t) local unit u = LoadUnitHandle(udg_Hashtable, hid, 0) local real angle = LoadReal(udg_Hashtable, hid, 1) local real distance = LoadReal(udg_Hashtable, hid, 2) local real d = LoadReal(udg_Hashtable, hid, 3) local real z = LoadReal(udg_Hashtable, hid, 5) local real x = GetWidgetX(u) local real y = GetWidgetY(u) if d <= distance / 2 then set x = x + 10. * Cos(angle) set y = y + 10. * Sin(angle) set z = z + 25. call SetUnitPosition(u, x, y) call SetUnitFlyHeight(u, z, 0.) else set x = x + 10. * Cos(angle) set y = y + 10. * Sin(angle) set z = z - 25. call SetUnitPosition(u, x, y) call SetUnitFlyHeight(u, z, 0.) endif call SaveReal(udg_Hashtable, hid, 3, d + 10.) call SaveReal(udg_Hashtable, hid, 5, z) if z <= 0. then if HaveSavedString(udg_Hashtable, hid, 6) then call DestroyEffect(AddSpecialEffect(LoadStr(udg_Hashtable, hid, 6), x, y)) endif call PauseTimer(t) call DestroyTimer(t) call PauseUnit(u, false) call FlushChildHashtable(udg_Hashtable, hid) endif set u = null set t = null endfunction
function TossUnit takes unit u, real distance, string eff returns nothing local timer t = CreateTimer() local integer hid = GetHandleId(t) local unit caster = GetTriggerUnit() local real angle = Atan2(GetSpellTargetY() - GetWidgetY(caster), GetSpellTargetX() - GetWidgetX(caster)) call SaveAgentHandle(udg_Hashtable, hid, 0, u) call SaveReal(udg_Hashtable, hid, 1, angle) call SaveReal(udg_Hashtable, hid, 2, distance) call SaveReal(udg_Hashtable, hid, 3, 10.) call SaveStr(udg_Hashtable, hid, 6, eff) if UnitAddAbility(u, 'Amrf') then call UnitRemoveAbility(u, 'Amrf') endif call PauseUnit(u, true) call TimerStart(t, .01, true, function TossUnit_Timer) set caster = null set t = null endfunction
function TossUnitToTarget takes unit u, string eff returns nothing local timer t = CreateTimer() local integer hid = GetHandleId(t) local unit caster = GetTriggerUnit() local real angle = Atan2(GetSpellTargetY() - GetWidgetY(caster), GetSpellTargetX() - GetWidgetX(caster)) call SaveAgentHandle(udg_Hashtable, hid, 0, u) call SaveReal(udg_Hashtable, hid, 1, angle) call SaveReal(udg_Hashtable, hid, 2, GetDistanceBetweenCoords(GetSpellTargetX(), GetWidgetX(caster), GetSpellTargetY(), GetWidgetY(caster))) call SaveReal(udg_Hashtable, hid, 3, 10.) call SaveStr(udg_Hashtable, hid, 6, eff) if UnitAddAbility(u, 'Amrf') then call UnitRemoveAbility(u, 'Amrf') endif call PauseUnit(u, true) call TimerStart(t, .01, true, function TossUnit_Timer) set caster = null set t = null endfunction
function DummycastToTarget takes unit caster, integer utype, integer atype, integer lvl, unit target, string order returns nothing local unit dummy = CreateUnit(GetOwningPlayer(caster), utype, GetWidgetX(caster), GetWidgetY(caster), 0.) call UnitAddAbility(dummy, atype) call IssueTargetOrderById(dummy, OrderId(order), target) call UnitApplyTimedLife(dummy, 'BTLF', .76) set dummy = null endfunction
function DummycastNoTarget takes unit caster, integer utype, integer atype, integer lvl, string order returns nothing local unit dummy = CreateUnit(GetOwningPlayer(caster), utype, GetWidgetX(caster), GetWidgetY(caster), 0.) call UnitAddAbility(dummy, atype) call IssueImmediateOrderById(dummy, OrderId(order)) call UnitApplyTimedLife(dummy, 'BTLF', .76) set dummy = null endfunction
function DummycastToPoint takes unit caster, integer utype, integer atype, integer lvl, location loc, string order returns nothing local unit dummy = CreateUnit(GetOwningPlayer(caster), utype, GetWidgetX(caster), GetWidgetY(caster), 0.) call UnitAddAbility(dummy, atype) call IssuePointOrderById(dummy, OrderId(order), GetLocationX(loc), GetLocationY(loc)) call UnitApplyTimedLife(dummy, 'BTLF', .76) set dummy = null endfunction[/jass]