[ Hướng dẫn ] Làm skills Time Lapse

langthangbairac

T.E.T.Я.I.S
Tham gia ngày
19/5/12
Bài viết
594
Reaction score
767
Chắc mọi người biết until con kiến trong dota rồi chứ ? Sau đây mình sin giới thiệu qua về skills này :

Khi cast skill, hero sẽ trở về trạng thái 5s trước đó ( MP, HP trở về và EXP, gold vẫn bình thường )

Mình dốt văn nên ko thể miêu tả được cho các bạn :(( nên chỉ nói sơ sơ thôi, ai ko hiểu down về copy sang map mình cũng được.

Khi cast skill, nó sẽ hồi phục MP, HP 5s trước ( nhờ trigger thứ 3 )
Mã:
Time Lapse cast
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Time Lapse 
    Actions
        Set CasterPos = (Position of (Triggering unit))
        Special Effect - Create a special effect at CasterPos using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
        Special Effect - Destroy (Last created special effect)
        Custom script:   call RemoveLocation (udg_CasterPos)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                HPInteger Less than or equal to 6
            Then - Actions
                Unit - Set life of (Triggering unit) to HP[1]
                Unit - Set mana of (Triggering unit) to MP[1]
                Unit - Move (Triggering unit) instantly to POS[1]
                Custom script:   call RemoveLocation (udg_POS[1])
            Else - Actions
                Unit - Set life of (Triggering unit) to HP[(HPInteger - 5)]
                Unit - Set mana of (Triggering unit) to MP[(MPInteger - 5)]
                Unit - Move (Triggering unit) instantly to POS[(POSInteger - 5)]
                Custom script:   call RemoveLocation (udg_POS[udg_POSInteger - 5])
        Set CasterPos = (Position of (Triggering unit))
        Special Effect - Create a special effect at CasterPos using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
        Special Effect - Destroy (Last created special effect)
        Custom script:   call RemoveLocation (udg_CasterPos)
        Unit - Order (Triggering unit) to Stop
Khi học skill thì sẽ bắt dầu mở trigger 3 đẻ đặt thời gian bảo lưu
Mã:
Time Lapse cast
    Events
        Unit - A unit Learns a skill
    Conditions
        (Level of Time Lapse  for (Triggering unit)) Greater than 0
    Actions
        Set Caste = (Triggering unit)
        Trigger - Turn off (This trigger)
        Trigger - Turn on Time Lapse creat restore2 <gen>
Đặt số máu, vị trí trước đó 5s, sau 5s sẽ đặt lại vị trí ( kể từ khi mỏ trigger này )
Mã:
Time Lapse creat restore2
    Events
        Time - Every 1.00 seconds of game time
    Conditions
        (Caste is alive) Equal to True
    Actions
        Set HPInteger = (HPInteger + 1)
        Set HP[HPInteger] = (Life of Caste)
        Set MPInteger = (MPInteger + 1)
        Set MP[MPInteger] = (Mana of Caste)
        Set POSInteger = (POSInteger + 1)
        Set POS[POSInteger] = (Position of Caste)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                HPInteger Greater than 6
            Then - Actions
                Custom script:   call RemoveLocation (udg_POS[udg_POSInteger - 6])
            Else - Actions
Lưu 5 giây kể từ khi bị chết
Mã:
Time Lapse save dies
    Events
        Unit - A unit Dies
    Conditions
        (Dying unit) Equal to Caste
    Actions
        Wait until ((Caste is alive) Equal to True), checking every 0.10 seconds
        For each (Integer A) from 1 to 5, do (Actions)
            Loop - Actions
                Set HP[(HPInteger - (Integer A))] = (Life of Caste)
                Set MP[(MPInteger - (Integer A))] = (Mana of Caste)
                Set POS[(POSInteger - (Integer A))] = (Position of Caste)

Chắc khó hiểu :( nhưng đảm bảo ko có leak :2onion2:

Cũng tại vì WE bị lỗi nên đã Enabled trigger nên các bạn phải tick vào enabled trigger rồi test
 

Attachments

Chỉnh sửa cuối:
Edit: nhìn nhầm code 8-|

P/s: được thì nghiên cứu làm MUI luôn đi.
 
Wtf? Mui là gì vậy ? Trước giờ chỉ ngiên cứu gui vs jass thôi
 
èo, ko biết làm MUI sao bjk code jass hay vậy ?
 
Ulti chứ không phải Unti

MUI = Multi Unit Instanciable (nhiều unit cùng cast 1 triggered spell mà không gây ra lỗi).
 
hè. cũng hay đấy chứ :D thử rồi sẽ biết ngay :)
èo, ko biết làm MUI sao bjk code jass hay vậy ?

ko nhất thiết đâu :D mà cũng mới biết mấy cái rìa thôi chẳng dám đông sâu :(
 
Chỉnh sửa cuối:
sao giống code trên thehelper.net vậy? =.=
 
chủ topic set trigger nhớ HP,MP,vị trí thành mỗi 0,1 s đi làm vậy chính xác hơn.
 
sao giống code trên thehelper.net vậy? =.=


thực ra nó là đoạn
code jass tôi kiếm trên epic và viết bằng gui đấy.

Mã:
function Trig_Time_Lapse_Creat_restore_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Time_Lapse_Creat_restore_Func005C takes nothing returns boolean
    if ( not ( udg_HPInteger <= 6 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Time_Lapse_Creat_restore_Actions takes nothing returns nothing
    set udg_CasterPos = GetUnitLoc(GetTriggerUnit())
    call AddSpecialEffectLocBJ( udg_CasterPos, "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call RemoveLocation (udg_CasterPos)
    if ( Trig_Time_Lapse_Creat_restore_Func005C() ) then
        call SetUnitLifeBJ( GetTriggerUnit(), udg_HP[1] )
        call SetUnitManaBJ( GetTriggerUnit(), udg_MP[1] )
        call SetUnitPositionLoc( GetTriggerUnit(), udg_POS[1] )
        call RemoveLocation (udg_POS[1])
    else
        call SetUnitLifeBJ( GetTriggerUnit(), udg_HP[( udg_HPInteger - 5 )] )
        call SetUnitManaBJ( GetTriggerUnit(), udg_MP[( udg_MPInteger - 5 )] )
        call SetUnitPositionLoc( GetTriggerUnit(), udg_POS[( udg_POSInteger - 5 )] )
        call RemoveLocation (udg_POS[udg_POSInteger - 5])
    endif
    set udg_CasterPos = GetUnitLoc(GetTriggerUnit())
    call AddSpecialEffectLocBJ( udg_CasterPos, "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call RemoveLocation (udg_CasterPos)
    call IssueImmediateOrderBJ( GetTriggerUnit(), "stop" )
endfunction

//===========================================================================
function InitTrig_Time_Lapse_Creat_restore takes nothing returns nothing
    set gg_trg_Time_Lapse_Creat_restore = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Time_Lapse_Creat_restore, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Time_Lapse_Creat_restore, Condition( function Trig_Time_Lapse_Creat_restore_Conditions ) )
    call TriggerAddAction( gg_trg_Time_Lapse_Creat_restore, function Trig_Time_Lapse_Creat_restore_Actions )
endfunction
Mã:
function Trig_Time_Lapse_cast_Conditions takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A000', GetTriggerUnit()) > 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Time_Lapse_cast_Actions takes nothing returns nothing
    set udg_Caste = GetTriggerUnit()
    call DisableTrigger( GetTriggeringTrigger() )
    call EnableTrigger( gg_trg_Time_Lapse_creat_restore2 )
endfunction

//===========================================================================
function InitTrig_Time_Lapse_cast takes nothing returns nothing
    set gg_trg_Time_Lapse_cast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Time_Lapse_cast, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_Time_Lapse_cast, Condition( function Trig_Time_Lapse_cast_Conditions ) )
    call TriggerAddAction( gg_trg_Time_Lapse_cast, function Trig_Time_Lapse_cast_Actions )
endfunction
Mã:
function Trig_Time_Lapse_creat_restore2_Conditions takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(udg_Caste) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Time_Lapse_creat_restore2_Func007C takes nothing returns boolean
    if ( not ( udg_HPInteger > 6 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Time_Lapse_creat_restore2_Actions takes nothing returns nothing
    set udg_HPInteger = ( udg_HPInteger + 1 )
    set udg_HP[udg_HPInteger] = GetUnitStateSwap(UNIT_STATE_LIFE, udg_Caste)
    set udg_MPInteger = ( udg_MPInteger + 1 )
    set udg_MP[udg_MPInteger] = GetUnitStateSwap(UNIT_STATE_MANA, udg_Caste)
    set udg_POSInteger = ( udg_POSInteger + 1 )
    set udg_POS[udg_POSInteger] = GetUnitLoc(udg_Caste)
    if ( Trig_Time_Lapse_creat_restore2_Func007C() ) then
        call RemoveLocation (udg_POS[udg_POSInteger - 6])
    else
    endif
endfunction

//===========================================================================
function InitTrig_Time_Lapse_creat_restore2 takes nothing returns nothing
    set gg_trg_Time_Lapse_creat_restore2 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Time_Lapse_creat_restore2, 1.00 )
    call TriggerAddCondition( gg_trg_Time_Lapse_creat_restore2, Condition( function Trig_Time_Lapse_creat_restore2_Conditions ) )
    call TriggerAddAction( gg_trg_Time_Lapse_creat_restore2, function Trig_Time_Lapse_creat_restore2_Actions )
endfunction
Mã:
function Trig_Time_Lapse_save_dies_Conditions takes nothing returns boolean
    if ( not ( GetDyingUnit() == udg_Caste ) ) then
        return false
    endif
    return true
endfunction

function Trig_Time_Lapse_save_dies_Func001001 takes nothing returns boolean
    return ( IsUnitAliveBJ(udg_Caste) == true )
endfunction

function Trig_Time_Lapse_save_dies_Actions takes nothing returns nothing
    loop
        exitwhen ( Trig_Time_Lapse_save_dies_Func001001() )
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.10))
    endloop
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 5
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set udg_HP[( udg_HPInteger - GetForLoopIndexA() )] = GetUnitStateSwap(UNIT_STATE_LIFE, udg_Caste)
        set udg_MP[( udg_MPInteger - GetForLoopIndexA() )] = GetUnitStateSwap(UNIT_STATE_MANA, udg_Caste)
        set udg_POS[( udg_POSInteger - GetForLoopIndexA() )] = GetUnitLoc(udg_Caste)
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Time_Lapse_save_dies takes nothing returns nothing
    set gg_trg_Time_Lapse_save_dies = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Time_Lapse_save_dies, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Time_Lapse_save_dies, Condition( function Trig_Time_Lapse_save_dies_Conditions ) )
    call TriggerAddAction( gg_trg_Time_Lapse_save_dies, function Trig_Time_Lapse_save_dies_Actions )
endfunction

zzz nhìn hoa cả mắt. ko biết có sai chỗ nào ko
 
Chỉnh sửa cuối:
nhưng đám (code jass) kia nó hoàn toàn là từ GUI to jass( Converter Custom Text) cũng là jass nhưng không được tối ưu.

nói chung:

Jass không tối ưu hóa = Vô ích.
GUI (Converter Custom Text) chẳng khác gì là GUI mặc dù ghi = jass

nếu bấm nút (Converter Custom Text) thì lấy đâu ra mà sai =))

P/S: có thể ai đó khá rảnh rỗi up một map demo. spell Time Lapse by cr4xzZz được chuyển hết GUI = jass lên epicwar chăng :-?
 
Chỉnh sửa cuối:
gui chuyển sang jass được hả. giờ em mới nghe đấy
 
gui chuyển sang jass được hả. giờ em mới nghe đấy

4da53a7fa84168822cb44535d800763e_45900967.untitl3ed2.png

thì vào phần Edit bấm Converter Custom Text là đươc...
 
thế jass -> gui có làm đc ko vậy ?
 
Mình có một số câu hỏi sau, ai giúp nha :
1. Có thể add player group sang player group khác được ko
2. Nếu có ai đã từng làm skill black hole thì cho hỏi phần di chuyển unit trong phạm vi ảnh hưởng của skill thì làm sao để nó như đứng 1 chỗ giật giật, cái em làm sao nó cứ giật rồi đi về tâm
3. Skill torrent, cái effect bọt nước đấy làm sao để ẩn với kẻ địch

Chỉ giùm vài cái thắc mắc nhỏ này cái :D chắc bạn biết nhỉ ??
 
Sẵn topic cho mình hỏi GUI, MUI và JASS là gì vậy
 
Sẵn topic cho mình hỏi GUI, MUI và JASS là gì vậy

GUI: Tức là những trigger bình thường có ba dòng event, conditions, actions mà bạn có thể đưa các lệnh thực thi có sẵn bằng cách chuột phải-> add event, condition,action trong trigger đó.

MUI: MUI Là một thuật ngữ để chỉ về việc trigger đó có thể thực hiện cùng một lúc (hay chênh lệch ở một phạm vi thời gian) hoặc nhiều bản thân khác sử dụng mà không bị lỗi.
Lấy ví dụ đơn giản về một chiêu thức, thường thì bạn làm chiêu sử dụng lên một đối thủ, muốn gây ra dam sau 5s mà sử dụng hàm Wait 5.00s trong trigger , rồi sau đó sử dụng hàm deal dam và gán mục tiêu là một giá trị định sẵn (ex:set TargetUnit = GetSpellTargetUnit()) trước đó thì sẽ bị lỗi khi một đơn vị khác sử dụng chiêu thức đó trong phạm vi 5 giây.

JASS: Là trigger và cũng có event, conditions, actions nhưng được hiển thị dưới hình thức text, nó phải nhờ người viết phân định ra đâu là event, đâu là conditions, đâu là actions qua các bộ hàm gọi là function. Tiện lợi của JASS hơn GUI ở chỗ là dễ dàng giúp người viết thực hiện MUI spell nếu biết cách sử dụng hợp lý.
JASS được anh Tom-sama khuyên các bạn rành thạo nên học và viết các spell bằng JASS. :7onion68:
Bạn đọc thêm về JASS ở đây nhé:http://forums.gamevn.com/showthread.php?485055-Tutorial-GUI-to-JASS

p.s: Trả lời thui Tom-sama chém nhẹ em thui nhé :9cool_too_sad:
 
Chỉnh sửa cuối:
GUI là viết tắt của graphical user interface, hiểu nôm na là lập trình bằng giao diện.
MUI = Multi Unit Instanciable (nhiều unit cùng cast 1 triggered spell mà không gây ra lỗi).
Jass là ngôn ngữ lập trình của World Editor.
 
Back
Top