Cách tạo quỹ đạo cho skill - Sứ dụng MUI và Custom Value Unit

  • Thread starter Thread starter btvinh
  • Ngày gửi Ngày gửi

btvinh

Donkey Kong
Tham gia ngày
15/1/11
Bài viết
343
Reaction score
6
Trước hết là mình xin sorry về bài spam hồi hôm qua.
Hôm nay mình xin giới thiệu "Cách tạo quỹ đạo cho skill - Sứ dụng MUI và Custom Value Unit" qua demo skill Wild Axe.
1/ Trước hết tui sẽ mô tả 2 trigger cần đó là wild axe và wild axe move.
PHP:
Wild Axe
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Wild Axe 
    Actions
        Set MUI = (MUI + 1)
        If (MUI Greater than or equal to 1000) then do (Set MUI = 1) else do (Do nothing)
        Set temp_loc = (Position of (Casting unit))
        Set temp_loc2 = (Target point of ability being cast)
        Unit - Create 1 Wild Axe Dummy for (Owner of (Casting unit)) at temp_loc facing Default building facing degrees
        Unit - Turn collision for (Last created unit) Off
        Unit - Set the custom value of (Last created unit) to MUI
        Unit Group - Add (Last created unit) to wa_g
        Set wa_d[MUI] = (Facing of (Casting unit))
        Set wa_dis[MUI] = (Distance between temp_loc and temp_loc2)
        Set wa_dy[MUI] = (wa_dis[MUI] / 6.00)
        Set wa_p[MUI] = (Position of (Last created unit))
        Set wa_x[MUI] = (-1.00 x (wa_dis[MUI] / 2.00))
        Set wa_s[MUI] = (wa_dis[MUI] / 40.00)
        Set wa_t[MUI] = True
        Set wa_a[MUI] = (wa_dy[MUI] / (wa_x[MUI] x wa_x[MUI]))
        Set wa_di[MUI] = 90.00
        Set wa_lv[MUI] = (Level of Wild Axe  for (Casting unit))
        Trigger - Turn on Wild Axe Move <gen>
        Custom script:   call RemoveLocation(udg_temp_loc)
        Custom script:   call RemoveLocation(udg_temp_loc2)
Đây là trigger wild axe. Trước hết chúng ta sẽ tạo 2 temp_loc để cho xác định các phần cơ bản của quỹ đạo bay của cái búa.
Lưu ý: cái phần đầu tiên
PHP:
Set MUI = (MUI + 1)
        If (MUI Greater than or equal to 1000) then do (Set MUI = 1) else do (Do nothing)
là dùng để tạo giá trị MUI luôn tăng và không tăng quá 1000.
Tiếp theo chúng ta sẽ tạo ra 1 dummy (wildaxe_dummy).
Chúng ta sẽ set customvalue cho unit vừa tạo và add nó vào group wa_g (group lưu trữ các unit sẽ bay theo quỹ đạo)
PHP:
Unit - Create 1 Wild Axe Dummy for (Owner of (Casting unit)) at temp_loc facing Default building facing degrees
        Unit - Turn collision for (Last created unit) Off
        Unit - Set the custom value of (Last created unit) to MUI
        Unit Group - Add (Last created unit) to wa_g
Giá trị custom value sẽ đc gán vào dummy.
Còn kái phần nầy
PHP:
Set wa_d[MUI] = (Facing of (Casting unit)) // Degree của casting unit
        Set wa_dis[MUI] = (Distance between temp_loc and temp_loc2) // khoảng cách từ casting unit đến target của ability.
        Set wa_dy[MUI] = (wa_dis[MUI] / 6.00) // Khoảng cách max y (sr giải thích khó hiểu)
        Set wa_p[MUI] = (Position of (Last created unit)) // Vị trí ban đầu của unit
        Set wa_x[MUI] = (-1.00 x (wa_dis[MUI] / 2.00)) // Giá trị x ban đầu
        Set wa_s[MUI] = (wa_dis[MUI] / 40.00) // Tốc độ bay của dummy
        Set wa_t[MUI] = True // Cái này là biến boolean để biết là dummy đang bay tới hay bay lui
        Set wa_a[MUI] = (wa_dy[MUI] / (wa_x[MUI] x wa_x[MUI])) // Hehe cái giá trị này là dùng để tạo ra quỹ đạo parabol (hệ số a)
        Set wa_di[MUI] = 90.00 (còn giá trị này là giá trị để biết là búa cần lệch sang trái hay sang phải)
        Set wa_lv[MUI] = (Level of Wild Axe  for (Casting unit))
Nói chung ở phần này chúng ta sẽ tạo ra các biến cần để có 1 quỹ đạo parabol cho dummy.
Tiếp theo sẽ là trigger 2 wild axe move
PHP:
Wild Axe Move
    Events
        Time - Every 0.02 seconds of game time
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in wa_g) Equal to 0
            Then - Actions
                Trigger - Turn off (This trigger)
            Else - Actions
                Unit Group - Pick every unit in wa_g and do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                wa_t[(Custom value of (Picked unit))] Equal to True
                            Then - Actions
                                Set wa_x[(Custom value of (Picked unit))] = (wa_x[(Custom value of (Picked unit))] + wa_s[(Custom value of (Picked unit))])
                                Set wa_y[(Custom value of (Picked unit))] = (wa_a[(Custom value of (Picked unit))] x (wa_x[(Custom value of (Picked unit))] x wa_x[(Custom value of (Picked unit))]))
                                Set wa_y[(Custom value of (Picked unit))] = (-1.00 x wa_y[(Custom value of (Picked unit))])
                                Set wa_y[(Custom value of (Picked unit))] = (wa_y[(Custom value of (Picked unit))] + wa_dy[(Custom value of (Picked unit))])
                                Set temp_loc = (wa_p[(Custom value of (Picked unit))] offset by (wa_x[(Custom value of (Picked unit))] + (wa_dis[(Custom value of (Picked unit))] / 2.00)) towards wa_d[(Custom value of (Picked unit))] degrees)
                                Set temp_loc2 = (temp_loc offset by wa_y[(Custom value of (Picked unit))] towards (wa_d[(Custom value of (Picked unit))] + wa_di[(Custom value of (Picked unit))]) degrees)
                                Unit - Move (Picked unit) instantly to temp_loc2
                                Unit - Create 1 Wild Axe Dummy for (Owner of (Picked unit)) at temp_loc2 facing Default building facing degrees
                                Unit - Set level of Wild Axe Blood  for (Last created unit) to wa_lv[(Custom value of (Picked unit))]
                                Unit - Add a 0.30 second Generic expiration timer to (Last created unit)
                                Animation - Change (Last created unit)'s animation speed to 200.00% of its original speed
                                Animation - Change (Last created unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 50.00% transparency
                                Destructible - Pick every destructible within 200.00 of temp_loc2 and do (Actions)
                                    Loop - Actions
                                        Destructible - Kill (Picked destructible)
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        wa_x[(Custom value of (Picked unit))] Greater than or equal to (wa_dis[(Custom value of (Picked unit))] / 2.00)
                                    Then - Actions
                                        Set wa_t[(Custom value of (Picked unit))] = False
                                        Set wa_di[(Custom value of (Picked unit))] = -90.00
                                        Set wa_s[(Custom value of (Picked unit))] = (-1.00 x wa_s[(Custom value of (Picked unit))])
                                    Else - Actions
                            Else - Actions
                                Set wa_x[(Custom value of (Picked unit))] = (wa_x[(Custom value of (Picked unit))] + wa_s[(Custom value of (Picked unit))])
                                Set wa_y[(Custom value of (Picked unit))] = (wa_a[(Custom value of (Picked unit))] x (wa_x[(Custom value of (Picked unit))] x wa_x[(Custom value of (Picked unit))]))
                                Set wa_y[(Custom value of (Picked unit))] = (-1.00 x wa_y[(Custom value of (Picked unit))])
                                Set wa_y[(Custom value of (Picked unit))] = (wa_y[(Custom value of (Picked unit))] + wa_dy[(Custom value of (Picked unit))])
                                Set temp_loc = (wa_p[(Custom value of (Picked unit))] offset by (wa_x[(Custom value of (Picked unit))] + (wa_dis[(Custom value of (Picked unit))] / 2.00)) towards wa_d[(Custom value of (Picked unit))] degrees)
                                Set temp_loc2 = (temp_loc offset by wa_y[(Custom value of (Picked unit))] towards (wa_d[(Custom value of (Picked unit))] + wa_di[(Custom value of (Picked unit))]) degrees)
                                Unit - Move (Picked unit) instantly to temp_loc2
                                Unit - Create 1 Wild Axe Dummy for (Owner of (Picked unit)) at temp_loc2 facing Default building facing degrees
                                Unit - Set level of Wild Axe Blood  for (Last created unit) to wa_lv[(Custom value of (Picked unit))]
                                Unit - Add a 0.30 second Generic expiration timer to (Last created unit)
                                Animation - Change (Last created unit)'s animation speed to 200.00% of its original speed
                                Animation - Change (Last created unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 50.00% transparency
                                Destructible - Pick every destructible within 200.00 of temp_loc2 and do (Actions)
                                    Loop - Actions
                                        Destructible - Kill (Picked destructible)
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        wa_t[(Custom value of (Picked unit))] Equal to False
                                        wa_x[(Custom value of (Picked unit))] Less than or equal to (-1.00 x (wa_dis[(Custom value of (Picked unit))] / 2.00))
                                    Then - Actions
                                        Unit - Remove (Picked unit) from the game
                                        Unit Group - Remove (Picked unit) from wa_g
                                    Else - Actions
                                Custom script:   call RemoveLocation(udg_temp_loc)
                                Custom script:   call RemoveLocation(udg_temp_loc2)
Trong trigger này chúng ta cần chú ý phần check điều kiện ở đầu actions cái này để cho không lag.
Tiếp theo ta sẽ tìm giá trị y = công thức: y = -a*x*x + dy
Do trong WE cái set point k cho đi theo đường xéo (k phải k mà là khó) nên tui dùng 2 kái temp_loc. temp_loc thứ nhất từ vị trí wa_p đến wa_x trước mặt với wa_d độ.
Temp_loc2 là đi sang ngang từ temp_loc đến vị trí wa_y trước mặt với wa_d + wa_di độ.
Tiếp theo là move unit đến vị trí đó là xong.
Còn kái phần này:
PHP:
 If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        wa_x[(Custom value of (Picked unit))] Greater than or equal to (wa_dis[(Custom value of (Picked unit))] / 2.00)
                                    Then - Actions
                                        Set wa_t[(Custom value of (Picked unit))] = False
                                        Set wa_di[(Custom value of (Picked unit))] = -90.00
                                        Set wa_s[(Custom value of (Picked unit))] = (-1.00 x wa_s[(Custom value of (Picked unit))])
Khi mà dummy bay wa giới hạn thì biến wa_t sẽ false và wa_s,wa_di có giá trị âm
Các giá trị này sẽ làm dummy bay ngược lại.
Tiếp theo là đoạn code cuối
PHP:
 If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        wa_t[(Custom value of (Picked unit))] Equal to False
                                        wa_x[(Custom value of (Picked unit))] Less than or equal to (-1.00 x (wa_dis[(Custom value of (Picked unit))] / 2.00))
                                    Then - Actions
                                        Unit - Remove (Picked unit) from the game
                                        Unit Group - Remove (Picked unit) from wa_g
Khi mà dummy về đến chỗ cũ sẽ bỏ dummy ra khỏi group và remove dummy.

Bài này hơi khó hiểu mong quý vị thông cảm [-X
Map [Demo] Nàk
http://www.2shared.com/file/W_ICx3K1/DemoWild_Axe.html
có chỗ nào hk hiểu pm mình : [email protected]
 
chưa thấy ở đâu là "cách tính quỹ đạo cho skill" cả

và phần "sử dụng MUI và Custom Value Unit" cũng thế

ngoài ra:

(Picked unit) nên cho vào biến
(Custom value of (Picked unit)) cũng nên cho vào biến

tránh việc phải gọi hàm nhiều, quá không cần thiết
 
dạ tại cách diễn đạt của em hơi bèo zí lại là làm lần đầu nên hơi lọng cọng. sr
 
quỹ đạo áp dụng công thức toán học ,gán vào 1 trục tọa độ XoY với gốc tại vị trí cast thì hình j mà chẳng ra.
chưa thấy ở đâu là "cách tính quỹ đạo cho skill" cả

và phần "sử dụng MUI và Custom Value Unit" cũng thế

mà skill wild axe thì cũng có nhiều người hỏi và làm rồi.bạn thử hướng dẫn 1 skill khác đi .nên nêu ra các bước (VD : viết công thức quỹ đạo , tính toán các biến cần dùng , viết trigger )
 
quỹ đạo áp dụng công thức toán học ,gán vào 1 trục tọa độ XoY với gốc tại vị trí cast thì hình j mà chẳng ra.


mà skill wild axe thì cũng có nhiều người hỏi và làm rồi.bạn thử hướng dẫn 1 skill khác đi .nên nêu ra các bước (VD : viết công thức quỹ đạo , tính toán các biến cần dùng , viết trigger )

ukm dạ0 này mìh hơj bận. Vàj pữa nữa mìh sẽ vjết skill pah tưg hìh zjgzag
 
Back
Top