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

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

Закрытая тема
 
Fakov
Viva la Fa
offline
Опыт: 102,058
Активность:
Двигаться до точки каста
вот триггер полностью:
» кот
scope Bow initializer Init


private struct Bow
    unit u
    real count = 0
    real max
    real damage
    integer level
    real cos
    real sin
    integer array  udg_dist[12]
    real array udg_dmg[12]
    unittype array udg_arrow[12]
endstruct

globals
    //Configuration
    private constant integer ID = 'A000'

    private constant string Stampede = ".mdl"
    private constant real Interval = 0.05//This is the interval of the spell. Try to find a balance between accuracy and efficiency.
    private constant real Speed = 750
    private constant real Distance = Speed * Interval//This is the the distance the Bow moves per interval.
    private constant attacktype AT = ATTACK_TYPE_NORMAL
    private constant damagetype DT = DAMAGE_TYPE_NORMAL
    private constant weapontype WT = WEAPON_TYPE_WHOKNOWS

    //Don't touch this stuff unless you know what you're doing
    private boolexpr filter
    private group Group = CreateGroup()
    private timer Tim = CreateTimer()
    private Bow array queue
    private integer total = 0
    private player BowOwner
endglobals

private function Bow_Timer takes nothing returns nothing
    local integer i = 0
    local Bow data
    local unit f
    local real damage
    local boolean shoot=true
    loop
        exitwhen i >= total
        set data = queue[i]
        set data.count =data.count+1
        call SetUnitX(data.u, GetUnitX(data.u) + data.cos)
        call SetUnitY(data.u, GetUnitY(data.u) + data.sin)
        set BowOwner = GetOwningPlayer(data.u)
        call GroupClear(Group)
        call GroupEnumUnitsInRange(Group, GetUnitX(data.u), GetUnitY(data.u), 100, filter)
        if FirstOfGroup(Group) != null or data.count>=data.max then
            call DestroyEffect(AddSpecialEffect(Stampede, GetUnitX(data.u), GetUnitY(data.u)))
            call KillUnit(data.u)
            set damage = data.damage//Damage(data.level)
            loop
                set f = FirstOfGroup(Group)
                exitwhen shoot==false
                call UnitDamageTarget(data.u, f, damage, true, false, AT, DT, WT)
                call GroupRemoveUnit(Group, f)
                set shoot=false
            endloop
            call data.destroy()
            set total = total - 1
            set queue[i] = queue[total]
            set i = i - 1
        endif
        set i = i + 1
    endloop
    if total == 0 then
        call PauseTimer(Tim)
    endif
    set f = null
endfunction

private function Bow_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ID
endfunction

private function Bow_Filter takes nothing returns boolean
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0. and IsUnitEnemy(GetFilterUnit(), BowOwner) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)//Makes it only work on units (not structures) and living units.
endfunction

private function Bow_Actions takes nothing returns nothing
    local Bow data = Bow.create()
    local real disa = 300.00
    local unit u = GetTriggerUnit()//Stores the caster in a variable.
    local location l = PolarProjectionBJ(GetUnitLoc(u), 1000, GetUnitFacing(u)) //Stores the target location of the spell.
    local real x = GetUnitX(u)//Stores the x of the caster.
    local real y = GetUnitY(u)//Stores the y of the caster.
    local real dx = GetLocationX(l) - x
    local real dy = GetLocationY(l) - y
    local real atan2 = Atan2(dy, dx)
    set data.damage = udg_dmg[GetPlayerId(GetOwningPlayer(u))+1]
    set data.level = GetUnitAbilityLevel(u, ID)//Stores the level of the ability in a struct.
    set data.max = udg_dist[GetPlayerId(GetOwningPlayer(u))+1] /Distance //Calculates the number of executions required by the timer.
    set data.u = CreateUnit(GetOwningPlayer(u), udg_arrow[GetPlayerId(GetOwningPlayer(u))+1], x, y, atan2*bj_RADTODEG)//Stores the Bow in a struct.
    set data.cos = Distance * Cos(atan2)
    set data.sin = Distance * Sin(atan2)
    call SetUnitPathing(data.u, false)//Sets the Bow's pathing to none.
    call PauseUnit(data.u, true)
    call RemoveLocation(l)//Prevents the location from leaking.
    if total == 0 then
         call TimerStart(Tim, Interval, true, function Bow_Timer)
     endif
    set queue[total] = data
    set total = total + 1
    set u = null//local
    set l = null//variables
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()//Creates the trigger.
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_FINISH)//Adds the event.
    call TriggerAddCondition(t, Condition(function Bow_Conditions))//Adds the condition.
    call TriggerAddAction(t, function Bow_Actions)//Adds the action.
    call Preload(Stampede)//Preloads the effect, preventing it from lagging the first time it's cast.
    set filter = Filter(function Bow_Filter)//Stores a global boolexp. Much faster than creating and destroying one all the time.
endfunction

endscope
Проблема следующая: юнит-снаряд летит только на расстояние udg_dist (оно равно 1000). Как сделать так, чтобы юнит-снаярд летел в точку спеллкаста? То есть если указал перед собой - снаряд пролетел метр и исчез, а если указал другой конец карты - он полетел в этот другой конец карты.
код как видите не мой, мои только исправления(под рук-вом Doc'a). Если не трудно - разжуйте как для конченного, ибо я с джассом дальше локалок не дружу =((((
Старый 30.01.2011, 14:11
Doc

offline
Опыт: 63,163
Активность:
scope Bow initializer Init


private struct Bow
    unit u
    real count = 0
    real max
    real damage
    integer level
    real cos
    real sin
    integer array  udg_dist[12]
    real array udg_dmg[12]
    unittype array udg_arrow[12]
endstruct

globals
    //Configuration
    private constant integer ID = 'A000'

    private constant string Stampede = ".mdl"
    private constant real Interval = 0.05//This is the interval of the spell. Try to find a balance between accuracy and efficiency.
    private constant real Speed = 750
    private constant real Distance = Speed * Interval//This is the the distance the Bow moves per interval.
    private constant attacktype AT = ATTACK_TYPE_NORMAL
    private constant damagetype DT = DAMAGE_TYPE_NORMAL
    private constant weapontype WT = WEAPON_TYPE_WHOKNOWS

    //Don't touch this stuff unless you know what you're doing
    private boolexpr filter
    private group Group = CreateGroup()
    private timer Tim = CreateTimer()
    private Bow array queue
    private integer total = 0
    private player BowOwner
endglobals

private function Bow_Timer takes nothing returns nothing
    local integer i = 0
    local Bow data
    local unit f
    local real damage
    local boolean shoot=true
    loop
        exitwhen i >= total
        set data = queue[i]
        set data.count =data.count+1
        call SetUnitX(data.u, GetUnitX(data.u) + data.cos)
        call SetUnitY(data.u, GetUnitY(data.u) + data.sin)
        set BowOwner = GetOwningPlayer(data.u)
        call GroupClear(Group)
        call GroupEnumUnitsInRange(Group, GetUnitX(data.u), GetUnitY(data.u), 100, filter)
        if FirstOfGroup(Group) != null or data.count>=data.max then
            call DestroyEffect(AddSpecialEffect(Stampede, GetUnitX(data.u), GetUnitY(data.u)))
            call KillUnit(data.u)
            set damage = data.damage//Damage(data.level)
            loop
                set f = FirstOfGroup(Group)
                exitwhen shoot==false
                call UnitDamageTarget(data.u, f, damage, true, false, AT, DT, WT)
                call GroupRemoveUnit(Group, f)
                set shoot=false
            endloop
            call data.destroy()
            set total = total - 1
            set queue[i] = queue[total]
            set i = i - 1
        endif
        set i = i + 1
    endloop
    if total == 0 then
        call PauseTimer(Tim)
    endif
    set f = null
endfunction

private function Bow_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ID
endfunction

private function Bow_Filter takes nothing returns boolean
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0. and IsUnitEnemy(GetFilterUnit(), BowOwner) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)//Makes it only work on units (not structures) and living units.
endfunction

private function Bow_Actions takes nothing returns nothing
    local Bow data = Bow.create()
    local real disa = 300.00
    local unit u = GetTriggerUnit()//Stores the caster in a variable.
    //local location l = PolarProjectionBJ(GetUnitLoc(u), 1000, GetUnitFacing(u)) //Stores the target location of the spell.
    local real tx = GetSpellTargetX()
    local real tx = GetSpellTargetY()
    local real x = GetUnitX(u)//Stores the x of the caster.
    local real y = GetUnitY(u)//Stores the y of the caster.
    local real dx = tx - x
    local real dy = ty - y
    local real atan2 = Atan2(dy, dx)
    local real dist = SquareRoot(dx * dx + dy * dy)
    set data.damage = udg_dmg[GetPlayerId(GetOwningPlayer(u))+1]
    set data.level = GetUnitAbilityLevel(u, ID)//Stores the level of the ability in a struct.
    set data.max = dist /Distance //Calculates the number of executions required by the timer.
    set data.u = CreateUnit(GetOwningPlayer(u), udg_arrow[GetPlayerId(GetOwningPlayer(u))+1], x, y, atan2*bj_RADTODEG)//Stores the Bow in a struct.
    set data.cos = Distance * Cos(atan2)
    set data.sin = Distance * Sin(atan2)
    call SetUnitPathing(data.u, false)//Sets the Bow's pathing to none.
    call PauseUnit(data.u, true)
    //call RemoveLocation(l)//Prevents the location from leaking.
    if total == 0 then
         call TimerStart(Tim, Interval, true, function Bow_Timer)
     endif
    set queue[total] = data
    set total = total + 1
    set u = null//local
    //set l = null//variables
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()//Creates the trigger.
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_FINISH)//Adds the event.
    call TriggerAddCondition(t, Condition(function Bow_Conditions))//Adds the condition.
    call TriggerAddAction(t, function Bow_Actions)//Adds the action.
    call Preload(Stampede)//Preloads the effect, preventing it from lagging the first time it's cast.
    set filter = Filter(function Bow_Filter)//Stores a global boolexp. Much faster than creating and destroying one all the time.
endfunction

endscope
Лениво переписал, должно работать.
Старый 30.01.2011, 15:39
Fakov
Viva la Fa
offline
Опыт: 102,058
Активность:
в центр карты все летит((((((
Старый 30.01.2011, 15:54
megasniper

offline
Опыт: 3,656
Активность:
мой неизвестно почему не работающий код)
scope Bow initializer Init


private struct Bow
    unit u
    real count = 0
    real max
    real damage
    integer level
    real cos
    real sin
    integer array  udg_dist[12]
    real array udg_dmg[12]
    unittype array udg_arrow[12]
endstruct

globals
    //Configuration
    private constant integer ID = 'A000'

    private constant string Stampede = ".mdl"
    private constant real Interval = 0.05//This is the interval of the spell. Try to find a balance between accuracy and efficiency.
    private constant real Speed = 750
    private constant real Distance = Speed * Interval//This is the the distance the Bow moves per interval.
    private constant attacktype AT = ATTACK_TYPE_NORMAL
    private constant damagetype DT = DAMAGE_TYPE_NORMAL
    private constant weapontype WT = WEAPON_TYPE_WHOKNOWS

    //Don't touch this stuff unless you know what you're doing
    private boolexpr filter
    private group Group = CreateGroup()
    private timer Tim = CreateTimer()
    private Bow array queue
    private integer total = 0
    private player BowOwner
endglobals

private function Bow_Touch_Act takes nothing returns nothing
    local Bow data
    call RemoveUnit(data.u)
endfunction

private function Bow_Touch takes nothing returns nothing
    local Bow data
    local trigger t = CreateTrigger()
    call TriggerRegisterUnitInRangeSimple(t, 10, data.u)
    call TriggerAddAction(t, function Bow_Touch_Act)
endfunction

private function Bow_Timer takes nothing returns nothing
    local integer i = 0
    local Bow data
    local unit f
    local real damage
    local boolean shoot=true
    loop
        exitwhen i >= total
        set data = queue[i]
        set data.count =data.count+1
        call SetUnitX(data.u, GetUnitX(data.u) + data.cos)
        call SetUnitY(data.u, GetUnitY(data.u) + data.sin)
        set BowOwner = GetOwningPlayer(data.u)
        call GroupClear(Group)
        call GroupEnumUnitsInRange(Group, GetUnitX(data.u), GetUnitY(data.u), 100, filter)
        if FirstOfGroup(Group) != null or data.count>=data.max then
            call DestroyEffect(AddSpecialEffect(Stampede, GetUnitX(data.u), GetUnitY(data.u)))
            call KillUnit(data.u)
            set damage = data.damage//Damage(data.level)
            loop
                set f = FirstOfGroup(Group)
                exitwhen shoot==false
                call UnitDamageTarget(data.u, f, damage, true, false, AT, DT, WT)
                call GroupRemoveUnit(Group, f)
                set shoot=false
            endloop
            call data.destroy()
            set total = total - 1
            set queue[i] = queue[total]
            set i = i - 1
        endif
        set i = i + 1
    endloop
    if total == 0 then
        call PauseTimer(Tim)
    endif
    set f = null
endfunction

private function Bow_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ID
endfunction

private function Bow_Filter takes nothing returns boolean
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0. and IsUnitEnemy(GetFilterUnit(), BowOwner) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)//Makes it only work on units (not structures) and living units.
endfunction

private function Bow_Actions takes nothing returns nothing
    local Bow data = Bow.create()
    local real disa = 300.00
    local unit u = GetTriggerUnit()//Stores the caster in a variable.
    local location l = PolarProjectionBJ(GetUnitLoc(u), 1000, GetUnitFacing(u)) //Stores the target location of the spell.
    local real x = GetUnitX(u)//Stores the x of the caster.
    local real y = GetUnitY(u)//Stores the y of the caster.
    local real dx = GetLocationX(l) - x
    local real dy = GetLocationY(l) - y
    local real atan2 = Atan2(dy, dx)
    set data.damage = udg_dmg[GetPlayerId(GetOwningPlayer(u))+1]
    set data.level = GetUnitAbilityLevel(u, ID)//Stores the level of the ability in a struct.
    set data.max = udg_dist[GetPlayerId(GetOwningPlayer(u))+1] /Distance //Calculates the number of executions required by the timer.
    set data.u = CreateUnit(GetOwningPlayer(u), udg_arrow[GetPlayerId(GetOwningPlayer(u))+1], x, y, atan2*bj_RADTODEG)//Stores the Bow in a struct.
    set data.cos = Distance * Cos(atan2)
    set data.sin = Distance * Sin(atan2)
    call SetUnitPathing(data.u, false)//Sets the Bow's pathing to none.
    call PauseUnit(data.u, true)
    call RemoveLocation(l)//Prevents the location from leaking.
    if total == 0 then
         call TimerStart(Tim, Interval, true, function Bow_Timer)
     endif
    set queue[total] = data
    set total = total + 1
    set u = null//local
    set l = null//variables
    call Bow_Touch ()
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()//Creates the trigger.
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_FINISH)//Adds the event.
    call TriggerAddCondition(t, Condition(function Bow_Conditions))//Adds the condition.
    call TriggerAddAction(t, function Bow_Actions)//Adds the action.
    call Preload(Stampede)//Preloads the effect, preventing it from lagging the first time it's cast.
    set filter = Filter(function Bow_Filter)//Stores a global boolexp. Much faster than creating and destroying one all the time.
endfunction

endscope
Старый 30.01.2011, 15:59
Doc

offline
Опыт: 63,163
Активность:
Fakov, абила то с точкой каста?
Старый 30.01.2011, 16:02
Fakov
Viva la Fa
offline
Опыт: 102,058
Активность:
да, абила с точкой каста.
Старый 30.01.2011, 16:04
spellwerk

offline
Опыт: 4,869
Активность:
это ужас какой-то, по-моему проще с нуля все написать, чем искать ошибки или менять этот код =(
Старый 30.01.2011, 16:30
Fakov
Viva la Fa
offline
Опыт: 102,058
Активность:
Spy_, кому как. Мне например не проще((
да и разницы в этих двух способах решения проблемы я все равно не вижу. Никто не хочет помогать все равно =\
Старый 30.01.2011, 16:31
Doc

offline
Опыт: 63,163
Активность:
scope Bow initializer Init


private struct Bow
    unit u
    real count = 0
    real max
    real damage
    integer level
    real cos
    real sin
    integer array  udg_dist[12]
    real array udg_dmg[12]
    unittype array udg_arrow[12]
endstruct

globals
    //Configuration
    private constant integer ID = 'A000'

    private constant string Stampede = ".mdl"
    private constant real Interval = 0.05//This is the interval of the spell. Try to find a balance between accuracy and efficiency.
    private constant real Speed = 750
    private constant real Distance = Speed * Interval//This is the the distance the Bow moves per interval.
    private constant attacktype AT = ATTACK_TYPE_NORMAL
    private constant damagetype DT = DAMAGE_TYPE_NORMAL
    private constant weapontype WT = WEAPON_TYPE_WHOKNOWS

    //Don't touch this stuff unless you know what you're doing
    private boolexpr filter
    private group Group = CreateGroup()
    private timer Tim = CreateTimer()
    private Bow array queue
    private integer total = 0
    private player BowOwner
endglobals

private function Bow_Timer takes nothing returns nothing
    local integer i = 0
    local Bow data
    local unit f
    local real damage
    local boolean shoot=true
    loop
        exitwhen i >= total
        set data = queue[i]
        set data.count =data.count+1
        call SetUnitX(data.u, GetUnitX(data.u) + data.cos)
        call SetUnitY(data.u, GetUnitY(data.u) + data.sin)
        set BowOwner = GetOwningPlayer(data.u)
        call GroupClear(Group)
        call GroupEnumUnitsInRange(Group, GetUnitX(data.u), GetUnitY(data.u), 100, filter)
        if FirstOfGroup(Group) != null or data.count>=data.max then
            call DestroyEffect(AddSpecialEffect(Stampede, GetUnitX(data.u), GetUnitY(data.u)))
            call KillUnit(data.u)
            set damage = data.damage//Damage(data.level)
            loop
                set f = FirstOfGroup(Group)
                exitwhen shoot==false
                call UnitDamageTarget(data.u, f, damage, true, false, AT, DT, WT)
                call GroupRemoveUnit(Group, f)
                set shoot=false
            endloop
            call data.destroy()
            set total = total - 1
            set queue[i] = queue[total]
            set i = i - 1
        endif
        set i = i + 1
    endloop
    if total == 0 then
        call PauseTimer(Tim)
    endif
    set f = null
endfunction

private function Bow_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ID
endfunction

private function Bow_Filter takes nothing returns boolean
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0. and IsUnitEnemy(GetFilterUnit(), BowOwner) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)//Makes it only work on units (not structures) and living units.
endfunction

private function Bow_Actions takes nothing returns nothing
    local Bow data = Bow.create()
    local real disa = 300.00
    local unit u = GetTriggerUnit()//Stores the caster in a variable.
    //local location l = PolarProjectionBJ(GetUnitLoc(u), 1000, GetUnitFacing(u)) //Stores the target location of the spell.
    local real tx = GetSpellTargetX()
    local real ty = GetSpellTargetY()
    local real x = GetUnitX(u)//Stores the x of the caster.
    local real y = GetUnitY(u)//Stores the y of the caster.
    local real dx = tx - x
    local real dy = ty - y
    local real atan2 = Atan2(dy, dx)
    local real dist = SquareRoot(dx * dx + dy * dy)
    set data.damage = udg_dmg[GetPlayerId(GetOwningPlayer(u))+1]
    set data.level = GetUnitAbilityLevel(u, ID)//Stores the level of the ability in a struct.
    set data.max = dist /Distance //Calculates the number of executions required by the timer.
    set data.u = CreateUnit(GetOwningPlayer(u), udg_arrow[GetPlayerId(GetOwningPlayer(u))+1], x, y, atan2*bj_RADTODEG)//Stores the Bow in a struct.
    set data.cos = Distance * Cos(atan2)
    set data.sin = Distance * Sin(atan2)
    call SetUnitPathing(data.u, false)//Sets the Bow's pathing to none.
    call PauseUnit(data.u, true)
    //call RemoveLocation(l)//Prevents the location from leaking.
    if total == 0 then
         call TimerStart(Tim, Interval, true, function Bow_Timer)
     endif
    set queue[total] = data
    set total = total + 1
    set u = null//local
    //set l = null//variables
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()//Creates the trigger.
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_FINISH)//Adds the event.
    call TriggerAddCondition(t, Condition(function Bow_Conditions))//Adds the condition.
    call TriggerAddAction(t, function Bow_Actions)//Adds the action.
    call Preload(Stampede)//Preloads the effect, preventing it from lagging the first time it's cast.
    set filter = Filter(function Bow_Filter)//Stores a global boolexp. Much faster than creating and destroying one all the time.
endfunction

endscope
Если так не будет работать давай карту.
Старый 30.01.2011, 16:38
Fakov
Viva la Fa
offline
Опыт: 102,058
Активность:
док, не работает(в центр все равно летит), смотри личку
=(
Старый 30.01.2011, 16:41
Doc

offline
Опыт: 63,163
Активность:
scope Bow initializer Init


private struct Bow
    unit u
    real count = 0
    real max
    real damage
    integer level
    real cos
    real sin
    integer array  udg_dist[12]
    real array udg_dmg[12]
    unittype array udg_arrow[12]
endstruct

globals
    //Configuration
    private constant integer ID = 'A000'

    private constant string Stampede = ".mdl"
    private constant real Interval = 0.05//This is the interval of the spell. Try to find a balance between accuracy and efficiency.
    private constant real Speed = 750
    private constant real Distance = Speed * Interval//This is the the distance the Bow moves per interval.
    private constant attacktype AT = ATTACK_TYPE_NORMAL
    private constant damagetype DT = DAMAGE_TYPE_NORMAL
    private constant weapontype WT = WEAPON_TYPE_WHOKNOWS

    //Don't touch this stuff unless you know what you're doing
    private boolexpr filter
    private group Group = CreateGroup()
    private timer Tim = CreateTimer()
    private Bow array queue
    private integer total = 0
    private player BowOwner
endglobals

private function Bow_Timer takes nothing returns nothing
    local integer i = 0
    local Bow data
    local unit f
    local real damage
    local boolean shoot=true
    loop
        exitwhen i >= total
        set data = queue[i]
        set data.count =data.count+1
        call SetUnitX(data.u, GetUnitX(data.u) + data.cos)
        call SetUnitY(data.u, GetUnitY(data.u) + data.sin)
        set BowOwner = GetOwningPlayer(data.u)
        call GroupClear(Group)
        call GroupEnumUnitsInRange(Group, GetUnitX(data.u), GetUnitY(data.u), 100, filter)
        if FirstOfGroup(Group) != null or data.count>=data.max then
            call DestroyEffect(AddSpecialEffect(Stampede, GetUnitX(data.u), GetUnitY(data.u)))
            call KillUnit(data.u)
            set damage = data.damage//Damage(data.level)
            loop
                set f = FirstOfGroup(Group)
                exitwhen shoot==false
                call UnitDamageTarget(data.u, f, damage, true, false, AT, DT, WT)
                call GroupRemoveUnit(Group, f)
                set shoot=false
            endloop
            call data.destroy()
            set total = total - 1
            set queue[i] = queue[total]
            set i = i - 1
        endif
        set i = i + 1
    endloop
    if total == 0 then
        call PauseTimer(Tim)
    endif
    set f = null
endfunction

private function Bow_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ID
endfunction

private function Bow_Filter takes nothing returns boolean
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0. and IsUnitEnemy(GetFilterUnit(), BowOwner) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)//Makes it only work on units (not structures) and living units.
endfunction

private function Bow_Actions takes nothing returns nothing
    local Bow data = Bow.create()
    local real disa = 300.00
    local unit u = GetTriggerUnit()//Stores the caster in a variable.
    //local location l = PolarProjectionBJ(GetUnitLoc(u), 1000, GetUnitFacing(u)) //Stores the target location of the spell.
    local real tx = GetSpellTargetX()
    local real ty = GetSpellTargetY()
    local real x = GetUnitX(u)//Stores the x of the caster.
    local real y = GetUnitY(u)//Stores the y of the caster.
    local real dx = tx - x
    local real dy = ty - y
    local real atan2 = Atan2(dy, dx)
    local real dist = SquareRoot(dx * dx + dy * dy)
    set data.damage = udg_dmg[GetPlayerId(GetOwningPlayer(u))+1]
    set data.level = GetUnitAbilityLevel(u, ID)//Stores the level of the ability in a struct.
    set data.max = dist /Distance //Calculates the number of executions required by the timer.
    set data.u = CreateUnit(GetOwningPlayer(u), udg_arrow[GetPlayerId(GetOwningPlayer(u))+1], x, y, atan2*bj_RADTODEG)//Stores the Bow in a struct.
    set data.cos = Distance * Cos(atan2)
    set data.sin = Distance * Sin(atan2)
    call SetUnitPathing(data.u, false)//Sets the Bow's pathing to none.
    call PauseUnit(data.u, true)
    //call RemoveLocation(l)//Prevents the location from leaking.
    if total == 0 then
         call TimerStart(Tim, Interval, true, function Bow_Timer)
     endif
    set queue[total] = data
    set total = total + 1
    set u = null//local
    //set l = null//variables
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()//Creates the trigger.
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)//Adds the event.
    call TriggerAddCondition(t, Condition(function Bow_Conditions))//Adds the condition.
    call TriggerAddAction(t, function Bow_Actions)//Adds the action.
    call Preload(Stampede)//Preloads the effect, preventing it from lagging the first time it's cast.
    set filter = Filter(function Bow_Filter)//Stores a global boolexp. Much faster than creating and destroying one all the time.
endfunction

endscope
Вполне можешь передать автору спелла мои искренние пожелания насчет его дальнейшей судьбы в кодинге.
Старый 30.01.2011, 16:52
Fakov
Viva la Fa
offline
Опыт: 102,058
Активность:
*восторженный мат*
РАБОТАЕТ! Спасибо!)
автору не знаю - вряд ли передам, но при возможности - сразу же))
Закрывайте
Старый 30.01.2011, 16:58
Закрытая тема

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

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

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

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



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