XGM Forum
Сайт - Статьи - Проекты - Ресурсы - Блоги

Форуме в режиме ТОЛЬКО ЧТЕНИЕ. Вы можете задать вопросы в Q/A на сайте, либо создать свой проект или ресурс.
Вернуться   XGM Forum > Warcraft> Академия: форум для вопросов> Jass
Ник
Пароль
Войти через VK в один клик
Сайт использует только имя.

Закрытая тема
 
MpW

offline
Опыт: 49,815
Активность:
У меня не движется молния
Стоит ли задавать вопрос скорее надо в академию чем здесь. Сижу вот, нашел карту в интернете про способность Мystic Snake, в принципе мне нравится как движется та змейка. Я решил сделать ауру паладина. Периодически создаются языки (или целительные волны) и от кастера идут к целям. Была задумка сделать так: Если рядом находятся подходящие юниты типа дружественный юнит, который ранен или является нежитью - пускаем змейку. Короче раненного лечим, а нежити наносим урон. делаю Немного изменил код от дотовского, получилось, но как бы не очень прикольно и красочным

Я искал подходящую модель типа целительная волна (но самого пути к этой модели я так понял нету), а пришлось переделывать на молнию. Я возможно напортачил, но молния не движется. Я не разобрался насчет двойных координат, догадываюсь что эти координаты начало и конец молнии. Но сама молния не движется. Не понимаю почему.

Steal nerves добавил:
вот карта (она слегка отредактирована мною), и пока в ней нет как бы урона и хила, только движение (урон и снятие маны - не мое дело), сейчас волнует только движения
>> код
Steal nerves добавил:
Код:
//Mystic Snake by Zaio - http://www.hiveworkshop.com/forums/spells-569/mystic-snake-v1-5-a-204984/
//================================================================================  ===================================================
//To Import this spell:
//1 - Make sure you have installed TimerUtils (instructions on main page in the hidden tap called IMPORTANT:Requires)
//2 - Copy over the ability and dummy and edit them as you want
//3 - Create a hashtable named hash (if you already one named hash, skip to 4) by opening up variable editor (Ctrl + B)
//4 - Make sure "automatically create unknown variables when pasting trigger data" is enabled in map preferences
//5 - Copy over this trigger to your map
//6 - Edit the 2 configurables below for your map

constant function MSDID takes nothing returns integer
    return 'h000' // The dummy's ID (ctrl + d in object editor)
endfunction

constant function MSAID takes nothing returns integer
    return 'A000' // The ability's ID (ctrl + d in object editor)
endfunction

//7(Optional) - If you want the snake icon and model, export the imports used in this map and save their name along with their path into a word document (or something similar) open up your map and import the models, set their custom paths to the ones you wrote down earlier
//8(Optional) - Change the ability and dummy icons to ReplaceableTextures\CommandButtons\BTNMysticSnakeNew.blp then change the dummy's model file to MysticSnake.mdl
//9(Optional) - Change the tooltips (highly recommended) to your preference, they have been poorly done in the test map because it is all about the map they are running in, almost all maps use different base values for health on heros and units, therefore the tooltip will need to be changed accordingly.
//10(Optional) - Customize the dummy as wanted, reduce/increase its sight radius etc and change the configurables below.
//11 - DONE!
//======================================== CONFIGURABLES ============================================================================
function MSIBN takes nothing returns integer
    return 3 // The base number of jumps + (level of ability * MSABN)
endfunction

function MSABN takes nothing returns integer
    return 1 // The extra number of bounces per level (e.g. if this is set to 1 and MSIBN is set to 3, level 1 will bounce 4 times, level 2 will bounce 5 times etc)
endfunction

function MSIMB takes nothing returns real
    return 70.00 // The mana burn base amount + (level of ability * MSAMB)
endfunction

function MSAMB takes nothing returns real
    return 30.00 // The mana burn increment per level (e.g. if this is set to 30.00 and MSIMB is set to 70.00, level 1 will burn upto 100 base mana, level 2 upto 130 mana etc)
endfunction

function MSPDI takes nothing returns real
    return 120.00 // This is the percentage of mana burn increase (if set to 120.00 = 20% increase per bounce)
endfunction

function MSEOM takes nothing returns string
    return "Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl" // The effect path if the snake returns to the caster
endfunction

function MSEOT takes nothing returns string
    return "Abilities\\Spells\\Human\\Feedback\\ArcaneTowerAttack.mdl" // The effect path if the snake hits an enemy
endfunction

function MSEAM takes nothing returns string
    return "chest" // The attachment point for the effect if the snake returns to the caster
endfunction

function MSEAT takes nothing returns string
    return "overhead" // The attachment point for the effect if the snake hits an enemy
endfunction

function MSDPS takes nothing returns real
    return 300.00 // This is the distance the snake will travel per second
endfunction

function MSRAOE takes nothing returns real
    return 100.00 // This is the max distance the snake must be to return to the caster to restore mana
endfunction

function MSAAOE takes nothing returns real
    return 50.00 // This is the max distance the snake must be to attack a unit and steal mana
endfunction

function MSSR takes nothing returns real
    return 400.00 // This is the search radius the snake will check units in after it has mana burned a different unit
endfunction

//============================================ END CONFIGURABLES ==========================================================
//============================= DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING! =================================

function MSFilter takes nothing returns boolean
    local unit u = GetFilterUnit()
    local boolean b = not IsUnitInGroup(u, udg_Temp_Group) and IsUnitEnemy(u, GetOwningPlayer(udg_Temp_Unit)) and not IsUnitType(u, UNIT_TYPE_DEAD) and not IsUnitType(u, UNIT_TYPE_STRUCTURE) and not IsUnitType(u, UNIT_TYPE_MECHANICAL) and not (GetUnitAbilityLevel(u, 'Bams') > 0) and not (GetUnitAbilityLevel(u, 'BHds') > 0)
    set u = null
    return b
endfunction

function Loop takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local integer bn = LoadInteger(udg_hash, id, 3)
    local lightning s = LoadLightningHandle(udg_hash, id, 1)
    local unit u
    local unit u2
    local unit u3
    local unit u4 = LoadUnitHandle(udg_hash, id, 2)
    local real x
    local real x2
    local real x3
    local real y
    local real y2
    local real y3
    local real a
    local real d
    local real m
    local real m2
    local real dx
    local real dy
    local group g
    local real dmg
    if 0 >= bn or u4 == null then //проверяем кол-во прыжков и не обнулен ли юнит
      set u2 = LoadUnitHandle(udg_hash, id, 0)
      if IsUnitType(u2, UNIT_TYPE_DEAD) then //если кастер мертв останавливаем
        set g = LoadGroupHandle(udg_hash, id, 4)
        call DestroyGroup(g)
        set g = null
        call ReleaseTimer(t)
        call DestroyLightning(s)
        call FlushChildHashtable(udg_hash, id)
      else //иначе двигаем
        set x3 = GetUnitX(u2) //координаты кастера
        set y3 = GetUnitY(u2)
        set x2 = LoadInteger(udg_hash, id, 6) //координаты молнии
        set y2 = LoadInteger(udg_hash, id, 7)
        //вычисляем пройденное расстояние
        set dx = x3 - x2
        set dy = y3 - y2
        set d = SquareRoot(dx * dx + dy * dy)
        if d <= MSRAOE() then
          set m = LoadReal(udg_hash, id, 6)
          call SetUnitState(u2, UNIT_STATE_MANA, (GetUnitState(u2, UNIT_STATE_MANA) + m))
          //call DestroyEffect(AddSpecialEffectTarget(MSEOM(), u2, MSEAM()))
          set g = LoadGroupHandle(udg_hash, id, 4)
          call DestroyGroup(g)
          set g = null
          call ReleaseTimer(t)
          call DestroyLightning(s)
          call FlushChildHashtable(udg_hash, id)
        else
          set a = Atan2(y3 - y2, x3 - x2)
          set x = x2 + MSDPS() / 33. * Cos(a)
          set y = y2 + MSDPS() / 33. * Sin(a)
          call MoveLightning(s,true,x,y,x+30,y+30)
          call RemoveSavedReal( udg_hash, id, 6)
          call RemoveSavedReal( udg_hash, id, 7)
          call SaveReal(udg_hash, id, 6, x)
          call SaveReal(udg_hash, id, 7, y)
          //call SetUnitX(s, x)
          //call SetUnitY(s, y)
          //call SetUnitFacing(s, (bj_RADTODEG * a))
        endif
      endif
      set u2 = null
    else
      set x = LoadInteger(udg_hash, id, 6)
      set y = LoadInteger(udg_hash, id, 7)
      set u = LoadUnitHandle(udg_hash, id, 2)
      set x2 = GetUnitX(u)
      set y2 = GetUnitY(u)
      set dx = x2 - x
      set dy = y2 - y
      set d = SquareRoot(dx * dx + dy * dy)
      if d <= MSAAOE() then
        if not IsUnitType(u, UNIT_TYPE_DEAD) then
          set u3 = LoadUnitHandle(udg_hash, id, 0)
          set dmg = LoadReal(udg_hash, id, 5)
          set m2 = GetUnitState(u, UNIT_STATE_MANA)
          set m = LoadReal(udg_hash, id, 6)
          if dmg > m2 then
            set m = (m + m2)
            call SetUnitState(u, UNIT_STATE_MANA, 0.)
          else
            set m = (m + dmg)
            call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) - dmg))
          endif
          call UnitDamageTarget(u3, u, 1, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
          //call DestroyEffect(AddSpecialEffectTarget(MSEOT(), u, MSEAT()))
          call SaveReal(udg_hash, id, 6, m)
          set dmg = (dmg * (MSPDI() / 100))
          call SaveReal(udg_hash, id, 5, dmg)
          set u3 = null
        endif
        set udg_Temp_Group = LoadGroupHandle(udg_hash, id, 4)
        call GroupAddUnit(udg_Temp_Group, u)
        //set udg_Temp_Unit = s
        call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, MSSR(), Filter(function MSFilter))
        set u2 = FirstOfGroup(bj_lastCreatedGroup)
        if u2 != null then
            call SaveUnitHandle(udg_hash, id, 2, u2)
            set bn = (bn - 1)
            call SaveInteger(udg_hash, id, 3, bn)
            set u2 = null
        else
            call RemoveSavedHandle(udg_hash, id, 2)
        endif
      else
        set a = Atan2(y2 - y, x2 - x)
        set x3 = x + MSDPS() / 33. * Cos(a)
        set y3 = y + MSDPS() / 33. * Sin(a)
        call MoveLightning(s,true,x3+30,y3+30,x3,y3)
        call SaveReal(udg_hash, id, 6, x3)
        call SaveReal(udg_hash, id, 7, y3)
        //call SetUnitX(s, x3)
        //call SetUnitY(s, y3)
        //call SetUnitFacing(s, (bj_RADTODEG * a))
      endif
      set u = null
    endif
    set t = null
    set s = null
    set u4 = null
endfunction

function Trigs takes nothing returns boolean
    return( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(gg_unit_N000_0010)))and( not IsUnitDeadBJ(GetFilterUnit()))
endfunction

function Start takes nothing returns boolean
    local unit u = gg_unit_N000_0010
    local timer t
    local unit u2
    local real x
    local real y
    local integer id
    local lightning a
    local group g = CreateGroup()
    local boolexpr f = Condition(function Trigs)
    set x = GetUnitX(u)
    set y = GetUnitY(u)
    call GroupEnumUnitsInRange(g, x, y, 900, f)
    loop
        set u2=FirstOfGroup(g)
        exitwhen u2 == null
        set t = NewTimer()
        set id = GetHandleId(t)
        set a = AddLightning("HWSB", true, x, y, x+30, y+30)
        call TimerStart(t, 0.02025, true, function Loop)
        call SaveUnitHandle(udg_hash, id, 0, u)
        call SaveLightningHandle(udg_hash, id, 1, a)
        call SaveUnitHandle(udg_hash, id, 2, u2)
        call SaveInteger(udg_hash, id, 3, 1) //колличество прыжков с цели на цель
        call SaveGroupHandle(udg_hash, id, 4, CreateGroup())
        call SaveReal(udg_hash, id, 5, (MSIMB() + (MSAMB() * GetUnitAbilityLevel(u, MSAID()))))
        call SaveReal(udg_hash, id, 6, x)
        call SaveReal(udg_hash, id, 7, y)
        call GroupRemoveUnit(g,u2)
        set u2 = null
    endloop
    call DestroyGroup(g)
    call DestroyBoolExpr(f)
    set u = null
    set u2 = null
    set t = null
    set g = null
    set f = null
    set a = null
    return false
endfunction

function InitTrig_Mystic_Snake takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEventPeriodic( t, 1 )
    call TriggerAddCondition( t, Condition( function Start ) )
    if udg_hash == null then
      set udg_hash = InitHashtable()
    endif
    set t = null
endfunction

<<
Прикрепленные файлы
Тип файла: w3x Mystic Snake v1.5.w3x (45.9 Кбайт, 9 просмотров )
Старый 03.08.2013, 09:10
DioD

offline
Опыт: 45,134
Активность:
делаем отладку сами, перед тем как постить тему.
Старый 03.08.2013, 11:28
Закрытая тема

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы можете скачивать файлы

BB-коды Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход



Часовой пояс GMT +3, время: 02:22.