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

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

Закрытая тема
 
Fakov
Viva la Fa
offline
Опыт: 102,058
Активность:
Снаряд в точку
суть следующая: сейчас этот код отправляет снаряд в указанную кастером точку. Надо, чтобы снаряд отпарвлялся в точку на удалении 1000 АОЕ по направлению взгляда кастера, без указания цели. То есть кастер смотрит вперед, кастует, и снаряд летит на 1000 АОЕ вперед.
что тут нужно подправить, хелп.
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 = 'A002'

    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 = 1000
    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
Старый 16.06.2011, 03:00
Rewenger
The culprit will not die
offline
Опыт: 35,873
Активность:
    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 x = GetUnitX(u)//Stores the x of the caster.
	local real y = GetUnitY(u)//Stores the y of the caster.
	local real tx = x + 1000.0*Cos(GetUnitFacing(u)*0.01745)
	local real ty = x + 1000.0*Sin(GetUnitFacing(u)*0.01745)
Это если не разбираться в коде и не пытаться его улучшить. Что, несомненно, лень.
Rewenger добавил:
А код тут хреновый, если верить беглому взгляду.
Старый 16.06.2011, 13:02
Fakov
Viva la Fa
offline
Опыт: 102,058
Активность:
А код тут хреновый, если верить беглому взгляду.
^^ в нем раньше копался если не ошибаюсь Док.
Да и вообще я заметил - каждый кодер кодит в своей тарелке своей ложкой.
спасибо, буду пробовать)
Старый 16.06.2011, 13:09
Rewenger
The culprit will not die
offline
Опыт: 35,873
Активность:
^^ в нем раньше копался если не ошибаюсь Док.
Беглый взгляд может и ошибаться. =О
Rewenger добавил:
local location l = PolarProjectionBJ(GetUnitLoc(u), 1000, GetUnitFacing(u)) Stores the target location of the spell.
Вообще на вид для создания прожектайла на расстояние 1000 предназначалась эта строка. И остальные закомментаренные. Но впоследствии были "выпилены", видимо.
Старый 16.06.2011, 13:18
Fakov
Viva la Fa
offline
Опыт: 102,058
Активность:
камрады хелп
local real x = GetUnitX(u)//Stores the x of the caster.
	local real y = GetUnitY(u)//Stores the y of the caster.
	local real tx = x + 1000.0*Cos(GetUnitFacing(u)*0.01745)
	local real ty = x + 1000.0*Sin(GetUnitFacing(u)*0.01745)
отправляет снаряд совсем не вперед, в чем беда?
Fakov добавил:
отбой тревоги, х на у надо было поменять, сам разобралсо))
Старый 16.06.2011, 14:52
Закрытая тема

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

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

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

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



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