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

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

Ответ
 
Vampirrr
O_o
offline
Опыт: 19,286
Активность:
Нужен код перемещения снаряда
Народ, на другие темки посылать ненадо, т.к. перерыл я их уже немало. А прошу помочь потому что нужен код, на простом джассе или в крайнем случае ВДжассе, но БЕЗ всяких библиотек и прочих извращений (к сожалению нет времени разбирать все те огромные и запутанные коды). Максимум - структуры. Заранее спасибо.
Старый 05.08.2009, 01:31
Ranger21
I love beatiul days XD
offline
Опыт: 13,274
Активность:
» Код

scope Bow initializer Init


private struct Bow
    unit u
    real count = 0
    real max
    integer level
    real cos
    real sin
endstruct

globals
    //Configuration
    private constant integer ID = 'A000'
    private constant integer DummyID = 'h000'
    private constant string Stampede = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.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 = 700
    private constant real EnumRange = 100
    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_FIRE
    private constant weapontype WT = WEAPON_TYPE_WHOKNOWS
    private constant real TravelDistance=2000
    //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 constant function Damage takes integer level returns real
    return level * 60. + 100.
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), EnumRange, 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 = 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 unit u = GetTriggerUnit()//Stores the caster in a variable.
    local location l = GetSpellTargetLoc()//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.level = GetUnitAbilityLevel(u, ID)//Stores the level of the ability in a struct.
    set data.max = TravelDistance/Distance//Calculates the number of executions required by the timer.
    set data.u = CreateUnit(GetOwningPlayer(u), DummyID, 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
Довольно простой код.
Старый 05.08.2009, 01:45
Vampirrr
O_o
offline
Опыт: 19,286
Активность:
кому как..я вообще нихрена не понимаю как оно устроено, несмотря на подсказки..неуже ли нет ничего действительно простого? меня вообще больше всего интересует использование таймера для данных действий..
Старый 05.08.2009, 02:01
Ranger21
I love beatiul days XD
offline
Опыт: 13,274
Активность:
Vampirrr, Проще некуда =0
Даже я разобрался после этого.
Если ты Jass не знаешь, то с этим не разберёшься тем более.
Старый 05.08.2009, 02:06
Vampirrr
O_o
offline
Опыт: 19,286
Активность:
джасс я знаю..правда уже подзабыл маленько, больше чем пол года ничего не делал..я даже вроде VJass туториал понял..ну а с этой хренотенью разбираться(
Старый 05.08.2009, 02:09
ZeToX2007

offline
Опыт: 7,009
Активность:
Vampirrr,
Код:
call SetUnitX (u,GetUnitX(u) + (r*Cos(0.01745*ugol)))
call SetUnitY (u,GetUnitY(u) + (r*Sin(0.01745*ugol)))


Мб это ? О_о... и перемещай каждые 0.05сек (или 0.04, 0.03, и тд)

u - Юнит которого перемещаешь
r - растрояние
u - угол.
все (""")(о_О)(""")
Старый 06.08.2009, 16:59
Ответ

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

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

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

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



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