Tom_Kazansky
<b><font color="RoyalBlue"><font face="Lucida Cons
- 28/12/06
Tom có 1 tutorial về:
- How to Slide: làm thế nào để "trượt" ::)
- How to make chain, bounce spell: tạo spell mà nhảy từ unit này qua unit khác
-------- How to Slide ------
Để cho 1 unit trượt thì chắc chắn ko thể dùng 1 lệnh move unit, vì đó là instant - ngay lập tức, nên phải dùng timer để move nhiều lần, vậy sẽ giống "trượt" hơn.
Cần 4 variable:
SlideUnit, type là unit, dùng cho unit trượt <- ko cần hơi phí
SlideDistance, type là real, khoảng cách mỗi lần move <=> tốc độ slide
SlideAngle, type là real, góc slide
SlideTick, type là integer, tick tak, đây là biến dùng để "đếm" số lần move, nếu = 0 -> dừng slide
Ngoài ra tạo thêm 2 var, TempLoc và TempLoc2, type là point, (temp = temporary) để dùng tạm thời, tức là dùng xong thì bỏ luôn, ko như các var trên.
Chú ý những dòng chữ sau "//" chỉ là giải thích, ko cần thiết.
Áp dụng để tạo skill knockback:
Tạo 1 ability tên là Storm Hammer, có 4 level (thiệt ra là Greater Bash :'> )
add cho hero, sau đó tạo thêm trigger:
cần biến: TempUnit (unit), TempInt( integer)
Thế là xong knockback.
Tương tự cách trên, các bạn có thể tạo các spell slide khác.
Nhưng chú ý là theo cách trên, Slide này sẽ ko MUI (Multi Unit Instanceable), MUI đc hiểu là nhiều unit cast spell 1 lúc cũng ko sao cả. Ko MUI tức là nếu 2 unit trở lên mà cùng Slide thì sẽ gây ra lỗi (unit thứ 2 slide thì unit 1 sẽ ko slide nữa)
Do vậy hãy dùng mảng, array.
Các var cần thiết:
SlideUnit, type là unit, có array
SlideDistance, type là real, có array
SlideAngle, type là real, có array
SlideTick, type là integer, có array
SlideIndex, type là integer, ko array, biến này dùng để đếm số slide đang dùng.
TempLoc, TempLoc2, type point, ko array. dùng tạm thời
trigger như sau:
Đầu tiên có 1 cái loop, vòng lặp từ 1 đến SlideIndex (số slide đang dùng ấy) Nếu SlideIndex = 0 thì ko lặp.
Sau đó kiểm tra SlideTick từ 1 đến SlideIndex, cái nào = 0 thì dừng slide đó, nhg thay vì tắt trigger như trên thì ta giảm SlideIndex.
Loop B này dùng để đẩy index lùi lại. Ví dụ ta có thế này:
Và Slide 4 dừng, thì phải lặp từ slide 4, và đẩy các dữ liệu (unit, distance, angle, tick) lùi lại, tức là 5 -> 4, 6 -> 5, 7 -> 6 và giảm SlideIndex đi 1 đơn vị
còn phía dưới thì cứ move unit bình thường.
Bây giờ Slide đã MUI rồi, 100 unit slide cùng lúc cũng ko sao.
---
Vậy mọi người thử tạo 1 spell: melee cast range, cast vào 1 unit thì deal dam và knock unit đó.
----
------- Chain Spells ----
Tom sẽ hướng dẫn tạo Chain Mana Burn
Tạo 1 spell base từ Mana Burn, hero spell, 4 level, add cho hero
Tạo 1 spell nữa cũng base từ Mana Burn, unit spell, 20 level, đây là spell cho dummy unit.
Tạo 1 dummy unit, model = .mdl, có skill Locust (Aloc)
Vô trigger:
Cần các biến:
TempUnit, TempUnit2, Dummy (unit)
TempInt (integer)
TempGroup (unit group) //unit nào bị trúng rồi thì add vào đây, ko cho trúng 2 lần
TempLoc, TempLoc2 (point)
LoopInteger (integer) //dùng cho vòng lặp thay cho Integer A, dùng biến này để lặp thì có thể thoát khỏi vòng lặp bằng cách đặt biến này lớn hơn giá trị cuối.
(Nhìn khó lắm, có gì xem demo map ok hơn ::) )
Chú ý spell trên ko MUI
----
Bây giờ tạo Chain Frost nhá. (non MUI)
Cần 1 spell Chain Frost để hero cast, base từ skill nào target single, Tom dùng Channel, còn dùng Chain Lightning cũng ko sao, bỏ damage, lightning effect đi là ok, hoặc Cripple (duration = 0.01, 0 = forever đấy)
Thêm Frost Nova cho dummy, damage của chain frost là damage của spell này.
Tạo dummy unit có model = quả cầu băng, đạn của Frost Wyrm ấy. có skill Locust
Các biến:
ChainFrostCaster - unit
ChainFrostBall - unit
ChainFrostTarget - unit
ChainFrostJump - integer
ChainFrostSpeed - real
tốc độ bay của Chain Frost = ChainFrostSpeed * 25, vì timer 0.04 -> 1s move đc 25 lần nên nhân với 25 sẽ ra tốc độ mối giây
TempLoc, TempLoc2 - point
Triggers:
Spell này là tạo 1 dummy unit rồi move dummy unit đó về hướng mục tiêu, đến gần thì cast Frost Nova, sau đó pick 1 mục tiêu mới để nhảy vào, và cứ tiếp tục như thế.
Và tất nhiên là ko MUI
Muốn skill này MUI thì làm theo cách dùng mảng như Slide ấy.
---
Mọi người theo cách này thử tạo spell Paralyzing Cask nhá, chain Firebolt thôi.
---
Mọi người đọc đến đây, chắc chắn chả hiểu gì, lỗi do Tom thôi (vì ko có chuyên môn gì hết, dốt văn)
Vậy mọi người xem demo map Tom attach ở dưới nhá.
- How to Slide: làm thế nào để "trượt" ::)
- How to make chain, bounce spell: tạo spell mà nhảy từ unit này qua unit khác
-------- How to Slide ------
Để cho 1 unit trượt thì chắc chắn ko thể dùng 1 lệnh move unit, vì đó là instant - ngay lập tức, nên phải dùng timer để move nhiều lần, vậy sẽ giống "trượt" hơn.
Cần 4 variable:
SlideUnit, type là unit, dùng cho unit trượt <- ko cần hơi phí
SlideDistance, type là real, khoảng cách mỗi lần move <=> tốc độ slide
SlideAngle, type là real, góc slide
SlideTick, type là integer, tick tak, đây là biến dùng để "đếm" số lần move, nếu = 0 -> dừng slide
Ngoài ra tạo thêm 2 var, TempLoc và TempLoc2, type là point, (temp = temporary) để dùng tạm thời, tức là dùng xong thì bỏ luôn, ko như các var trên.
Mã:
SlideMove //để OFF sẵn
Events
Time - Every 0.04 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SlideTick Equal to 0 //tick = 0, dừng trigger thôi
Then - Actions
Trigger - Turn off (This trigger)
Skip remaining actions
Else - Actions
-------- ---------------- --------
Set SlideTick = (SlideTick - 1) //giảm tick
Set TempLoc = (Position of SlideUnit) //phải cho point vào variable để remove, ko thì sẽ leak
Set TempLoc2 = (TempLoc offset by SlideDistance towards SlideAngle degrees) //phải cho point vào variable để remove, ko thì sẽ leak
Unit - Move SlideUnit instantly to TempLoc2
Special Effect - Create a special effect at TempLoc2 using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl //tạo effect "khói"
Special Effect - Destroy (Last created special effect)
Destructible - Pick every destructible within 200.00 of TempLoc2 and do (Actions)
Loop - Actions
Destructible - Kill (Picked destructible) //phá cây
Custom script: call RemoveLocation( udg_TempLoc ) //cái này để remove leak
Custom script: call RemoveLocation( udg_TempLoc2 ) //cái này để remove leak
Chú ý những dòng chữ sau "//" chỉ là giải thích, ko cần thiết.
Áp dụng để tạo skill knockback:
Tạo 1 ability tên là Storm Hammer, có 4 level (thiệt ra là Greater Bash :'> )
add cho hero, sau đó tạo thêm trigger:
cần biến: TempUnit (unit), TempInt( integer)
Mã:
Storm Hammer
Events
Unit - A unit Is attacked
Conditions
(Level of Storm Hammer for (Attacking unit)) Greater than 0 //phải có ability, tức là phải học rồi ấy
(Random integer number between 1 and 100) Less than or equal to 17 //17% chance
((Triggering unit) is A structure) Equal to False //ko có cái này, knock cả building, 8-}, và nếu cần có thể thêm điều kiện
Actions
Set TempUnit = (Attacking unit)
Set TempInt = (Level of Storm Hammer for TempUnit) //level của skill
Set SlideUnit = (Attacked unit) //knockback unit bị đánh
Set TempLoc = (Position of TempUnit)
Set TempLoc2 = (Position of SlideUnit)
Set SlideAngle = (Angle from TempLoc to TempLoc2)
Set SlideTick = 20 //tick = 20, mỗi tick là 0.04 (xem event của trigger Slide) -> cần 20 * 0.04 = 0.8 giây để move xong, tương đương với 0.8s stun ::)
Set SlideDistance = ((90.00 + (30.00 x (Real(TempInt)))) / (Real(SlideTick))) //khoảng cách slide = khoảng cách knockback / số tick
Custom script: call RemoveLocation( udg_TempLoc )
Custom script: call RemoveLocation( udg_TempLoc2 )
Trigger - Turn on SlideMove <gen> //bật slide lên
-------- -------------------- --------
Animation - Play TempUnit's attack slam animation //slam vào unit bị đánh cho máu :'>
Animation - Queue TempUnit's ready animation //sau khi slam thì unit này sẽ trở về động tác ready (stand ready)
Unit - Cause TempUnit to damage SlideUnit, dealing (25.00 x (Real(TempInt))) damage of attack type Chaos and damage type Universal //deal bonus dam
//thêm tí text ghi số dam bonus, chà, cũng ko cần lắm, nhg cứ thêm vào (visual thôi) :D
Floating Text - Create floating text that reads ((String((25 x TempInt))) + !) above SlideUnit[SlideIndex] with Z offset 0.00, using font size 10.00, color (50.00%, 0.00%, 100.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
Thế là xong knockback.
Tương tự cách trên, các bạn có thể tạo các spell slide khác.
Nhưng chú ý là theo cách trên, Slide này sẽ ko MUI (Multi Unit Instanceable), MUI đc hiểu là nhiều unit cast spell 1 lúc cũng ko sao cả. Ko MUI tức là nếu 2 unit trở lên mà cùng Slide thì sẽ gây ra lỗi (unit thứ 2 slide thì unit 1 sẽ ko slide nữa)
Do vậy hãy dùng mảng, array.
Các var cần thiết:
SlideUnit, type là unit, có array
SlideDistance, type là real, có array
SlideAngle, type là real, có array
SlideTick, type là integer, có array
SlideIndex, type là integer, ko array, biến này dùng để đếm số slide đang dùng.
TempLoc, TempLoc2, type point, ko array. dùng tạm thời
trigger như sau:
Mã:
SlideMove // ko cần OFF sẵn, cứ ON luôn
Events
Time - Every 0.04 seconds of game time
Conditions
Actions
For each (Integer A) from 1 to SlideIndex, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SlideTick[(Integer A)] Equal to 0
Then - Actions
For each (Integer B) from (Integer A) to (SlideIndex - 1), do (Actions)
Loop - Actions
Set SlideAngle[(Integer B)] = SlideAngle[((Integer B) + 1)]
Set SlideDistance[(Integer B)] = SlideDistance[((Integer B) + 1)]
Set SlideTick[(Integer B)] = SlideTick[((Integer B) + 1)]
Set SlideUnit[(Integer B)] = SlideUnit[((Integer B) + 1)]
Set SlideIndex = (SlideIndex - 1)
Else - Actions
-------- ---------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SlideTick[(Integer A)] Greater than 0
Then - Actions
Set SlideTick[(Integer A)] = (SlideTick[(Integer A)] - 1)
Set TempLoc = (Position of SlideUnit[(Integer A)])
Set TempLoc2 = (TempLoc offset by SlideDistance[(Integer A)] towards SlideAngle[(Integer A)] degrees)
Unit - Move SlideUnit[(Integer A)] instantly to TempLoc2
Special Effect - Create a special effect at TempLoc2 using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
Destructible - Pick every destructible within 200.00 of TempLoc2 and do (Actions)
Loop - Actions
Destructible - Kill (Picked destructible)
Custom script: call RemoveLocation( udg_TempLoc )
Custom script: call RemoveLocation( udg_TempLoc2 )
Else - Actions
Đầu tiên có 1 cái loop, vòng lặp từ 1 đến SlideIndex (số slide đang dùng ấy) Nếu SlideIndex = 0 thì ko lặp.
Sau đó kiểm tra SlideTick từ 1 đến SlideIndex, cái nào = 0 thì dừng slide đó, nhg thay vì tắt trigger như trên thì ta giảm SlideIndex.
Mã:
For each (Integer B) from (Integer A) to (SlideIndex - 1), do (Actions)
Loop - Actions
Set SlideAngle[(Integer A)] = SlideAngle[((Integer A) + 1)]
Set SlideDistance[(Integer A)] = SlideDistance[((Integer A) + 1)]
Set SlideTick[(Integer A)] = SlideTick[((Integer A) + 1)]
Set SlideUnit[(Integer A)] = SlideUnit[((Integer A) + 1)]
Set SlideIndex = (SlideIndex - 1)
Loop B này dùng để đẩy index lùi lại. Ví dụ ta có thế này:
Mã:
1 2 3 4 5 6 7
Mã:
1 2 3 4 5 6 7 //cũ: index = 7
1 2 3 5 6 7 //đẩy lùi lại, bây giờ index = 6
còn phía dưới thì cứ move unit bình thường.
Bây giờ Slide đã MUI rồi, 100 unit slide cùng lúc cũng ko sao.
---
Vậy mọi người thử tạo 1 spell: melee cast range, cast vào 1 unit thì deal dam và knock unit đó.
----
------- Chain Spells ----
Tom sẽ hướng dẫn tạo Chain Mana Burn
Tạo 1 spell base từ Mana Burn, hero spell, 4 level, add cho hero
Tạo 1 spell nữa cũng base từ Mana Burn, unit spell, 20 level, đây là spell cho dummy unit.
Tạo 1 dummy unit, model = .mdl, có skill Locust (Aloc)
Vô trigger:
Cần các biến:
TempUnit, TempUnit2, Dummy (unit)
TempInt (integer)
TempGroup (unit group) //unit nào bị trúng rồi thì add vào đây, ko cho trúng 2 lần
TempLoc, TempLoc2 (point)
LoopInteger (integer) //dùng cho vòng lặp thay cho Integer A, dùng biến này để lặp thì có thể thoát khỏi vòng lặp bằng cách đặt biến này lớn hơn giá trị cuối.
Mã:
MindBurn
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Mind Burn
Actions
Set TempUnit = (Triggering unit)
Set TempInt = (Level of Mind Burn for TempUnit)
Set TempUnit2 = (Target unit of ability being cast)
Set TempLoc = (Position of TempUnit2)
Unit Group - Add TempUnit2 to TempGroup //mục tiêu chắc chắn là bị burn rồi nên add vào group luôn
For each (Integer LoopInteger) from 1 to 4, do (Actions) //1 -> 4 -> jump 4 lần
Loop - Actions
Wait 0.10 seconds //đợi 1 tí :)
Custom script: set bj_wantDestroyGroup = true //cái này để group mà sau khi pick random sẽ bị destroy, remove leak thôi
Set TempUnit2 = (Random unit from (Units within 600.00 of TempLoc matching ((((((Matching unit) is alive) Equal to True) and (((Matching unit) is in TempGroup) Equal to False)) and (((Matching unit) is Magic Immune) Equal to False)) and ((((Matching unit) belongs to an enemy
//Chú ý điều kiện nha
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TempUnit2 Equal to No unit
Then - Actions
Set LoopInteger = 10 //ko có unit nào thì thoát khỏi vòng lặp
Custom script: call RemoveLocation( udg_TempLoc )
Else - Actions
//Có unit, pick đc, vậy thì tạo dummy unit ở vị trí unit cũ đã bị burn (TempLoc) và burn unit này
Unit - Create 1 Dummy Unit for (Owner of TempUnit) at TempLoc facing 0.00 degrees // tạo dummy unit
Set Dummy = (Last created unit)
Unit - Add a 1.00 second Generic expiration timer to Dummy
Unit - Add Mana Burn (Dummy) to Dummy
Unit - Set level of Mana Burn (Dummy) for Dummy to (((TempInt - 1) x 5) + LoopInteger)
Unit - Order Dummy to Night Elf Demon Hunter - Mana Burn TempUnit2 //cast mana burn
Custom script: call RemoveLocation( udg_TempLoc )
Unit Group - Add TempUnit2 to TempGroup //bị burn thì add vào group
Set TempLoc = (Position of TempUnit2) //lưu lại vị trí unit vừa bị burn
Unit Group - Remove all units from TempGroup //xóa các unit trong TempGroup
(Nhìn khó lắm, có gì xem demo map ok hơn ::) )
Chú ý spell trên ko MUI
----
Bây giờ tạo Chain Frost nhá. (non MUI)
Cần 1 spell Chain Frost để hero cast, base từ skill nào target single, Tom dùng Channel, còn dùng Chain Lightning cũng ko sao, bỏ damage, lightning effect đi là ok, hoặc Cripple (duration = 0.01, 0 = forever đấy)
Thêm Frost Nova cho dummy, damage của chain frost là damage của spell này.
Tạo dummy unit có model = quả cầu băng, đạn của Frost Wyrm ấy. có skill Locust
Các biến:
ChainFrostCaster - unit
ChainFrostBall - unit
ChainFrostTarget - unit
ChainFrostJump - integer
ChainFrostSpeed - real
tốc độ bay của Chain Frost = ChainFrostSpeed * 25, vì timer 0.04 -> 1s move đc 25 lần nên nhân với 25 sẽ ra tốc độ mối giây
TempLoc, TempLoc2 - point
Triggers:
Mã:
ChainFrost
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Chain Frost
Actions
Set ChainFrostCaster = (Triggering unit)
Set ChainFrostTarget = (Target unit of ability being cast)
Set ChainFrostJump = 7
Set ChainFrostSpeed = 25.00 //tốc độ mỗi giây: 25 * 25 = 625
Set TempInt = (Level of Chain Frost for ChainFrostCaster)
Set TempLoc = (Position of ChainFrostCaster)
Unit - Create 1 Dummy Chain Frost for Player 1 (Red) at TempLoc facing (Facing of ChainFrostCaster) degrees //tạo dummy unit
Set ChainFrostBall = (Last created unit)
Unit - Add Chain Frost Nova (dummy) to ChainFrostBall
Unit - Set level of Chain Frost Nova (dummy) for ChainFrostBall to TempInt
Unit - Add Crow Form to ChainFrostBall //trick, mẹo, để thay đổi fly height của unit
Unit - Remove Crow Form from ChainFrostBall //trick, mẹo, để thay đổi fly height của unit
Animation - Change ChainFrostBall flying height to 60.00 at 0.00
Trigger - Turn on ChainFrostBounce <gen>
Custom script: call RemoveLocation( udg_TempLoc )
Mã:
ChainFrostBounce //để OFF sẵn
Events
Time - Every 0.04 seconds of game time
Conditions
Actions
Set TempLoc = (Position of ChainFrostBall)
Set TempLoc2 = (Position of ChainFrostTarget)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Distance between TempLoc and TempLoc2) Less than or equal to 100.00 //khoảng cách giữa quả cầu và mục tiêu
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions //khoảng cách đủ gần rồi thì kiểm tra thêm điều kiện nữa
(ChainFrostTarget is Magic Immune) Equal to False // ko kháng phép
(ChainFrostTarget is alive) Equal to True //phải còn sống
(ChainFrostTarget is visible to (Owner of ChainFrostCaster)) Equal to True //phải nhìn thấy đc
Then - Actions
Unit - Order ChainFrostBall to Undead Lich - Frost Nova ChainFrostTarget //cast thôi
Else - Actions
Custom script: set bj_wantDestroyGroup = true
//pick 1 mục tiêu mới, chà hơi nhiều điều kiện nhỉ :D
Set ChainFrostTarget = (Random unit from (Units within 600.00 of TempLoc2 matching ((((((Matching unit) is alive) Equal to True) and ((Matching unit) Not equal to ChainFrostTarget)) and (((Matching unit) is Magic Immune) Equal to False)) and ((((Matching unit) belongs to an enemy o
Set ChainFrostJump = (ChainFrostJump - 1) //số lần nhảy
Else - Actions
Custom script: call RemoveLocation( udg_TempLoc2 )
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true //điều kiện hoặc
Conditions
ChainFrostTarget Equal to No unit //ko còn unit nào để nhảy vô nữa
ChainFrostJump Equal to 0 // nhảy đủ rồi
Then - Actions
Custom script: call RemoveLocation( udg_TempLoc )
Trigger - Turn off (This trigger) //tắt trigger
Unit - Kill ChainFrostBall //cho nổ quả cầu
Skip remaining actions
Else - Actions
//phần dười chỉ là move quả cầu về phía mục tiêu thôi
Set TempLoc2 = (Position of ChainFrostTarget)
Set TempReal = (Angle from TempLoc to TempLoc2)
Custom script: call RemoveLocation( udg_TempLoc2 )
Set TempLoc2 = (TempLoc offset by ChainFrostSpeed towards TempReal degrees)
Unit - Move ChainFrostBall instantly to TempLoc2, facing TempReal degrees
Custom script: call RemoveLocation( udg_TempLoc )
Custom script: call RemoveLocation( udg_TempLoc2 )
Spell này là tạo 1 dummy unit rồi move dummy unit đó về hướng mục tiêu, đến gần thì cast Frost Nova, sau đó pick 1 mục tiêu mới để nhảy vào, và cứ tiếp tục như thế.
Và tất nhiên là ko MUI
Muốn skill này MUI thì làm theo cách dùng mảng như Slide ấy.
---
Mọi người theo cách này thử tạo spell Paralyzing Cask nhá, chain Firebolt thôi.
---
Mọi người đọc đến đây, chắc chắn chả hiểu gì, lỗi do Tom thôi (vì ko có chuyên môn gì hết, dốt văn)
Vậy mọi người xem demo map Tom attach ở dưới nhá.

Attachments
Chỉnh sửa cuối:
)


Có chết liền đâu ? 






- nếu ko mấy cái tut sau này của anh cũng bị tụi newbie nó lơ như mấy cái tut trước >"< hôm nay em post bài này phụ anh up cái tut này lên đã
, và nếu cần có thể thêm điều kiện