Update phần hướng dẫn Holy Light cho các bạn newbie và những ai cần hướng dẫn
[spoil]Bây giờ mình sẽ giải thích về các trigger trong spell Holy ( chỉ giải thích kĩ những phần khó thôi nhé, còn phần quá đơn giản thì chỉ lướt qua thôi )
Spell thuộc loại MUI,GUI
Đầu tiên là các bạn phải tạo spell, dummy và hero
Các spell cần tạo:
-Holly Light: Spell này chỉ là 1 spell giả, thuộc loại "no target" để thực hiện trigger không quan trọng gì, nhớ add vào effect khi cast spell.
-Light Target: Spell này là spell dành cho dummy, base từ Storm Bolt, khi đường sáng của hero gặp unit địch sẽ cho dummy cast spell này tạo ra các tia sáng khác ( tất nhiên spell này cũng phải MUI ).
-Light: Spell này base từ spell Slow, gây buff lên địch dùng để check các unit đã dính spell để mà tránh trường hợp unit dính spell nhiều lần ( không nhất thiết phải lấy spell slow để tạo buff, spell nào cũng được )
Các dummy cần tạo:
-Dummy Light (Effect): model orb of slow, khi xếp nhiều unit này thành 1 đường thẳng thì sẽ tạo ra 1 đường ánh sáng, nhớ để hp 1 và regen hp -1 để cho unit die thì đường sáng kết thúc.
-Dummy Light (AOE): Dummy này sử dụng để tạo tia sáng đầu tiên từ hero ra, gây damage AOE, về sau dùng để cast Light Target tạo tia sáng khác vào hero, theo hướng nhìn người chơi nghĩa là spell sẽ lan tỏa. Add cho Dummy này Light và cả Light Target.
-Dummy Light (Target): Dummy này sẽ sử dụng spell Light vào unit địch, tạo cho unit địch buff "Holy Light", dùng để check các unit đã bị skill mà không skill tiếp nữa, nếu không sẽ rất "imba". Add cho dummy này spell Light.
Mã:
Holy Light
Events
Unit - A unit Starts the effect of an ability[I][U]//khi 1 unit cast spell[/U][/I]
Conditions
(Ability being cast) Equal to Holy Light[I][U]//spell là Holy Light[/U][/I]
Actions
Set MUI[1] = (MUI[1] + 1)[I][U]//cái này dùng để MUI ở hàm Loop như raivor đã nói ở trên[/U][/I]
Set Caster[MUI[1]] = (Casting unit)[U]//đặt biến Caster[/U]
Set CastPoint = (Position of Caster[MUI[1]])[I]//đặt vị trí của caster, phần này dư sau khi chỉnh sửa không cần thiết, mình quên xóa @@![/I]
Set Integer[MUI[1]] = (200 + ((Level of Holy Light for Caster[MUI[1]]) x 25))[COLOR="royalblue"][U][I]//Đặt thời gian tia sáng di chuyển, lúc đầu theo dự định mình chỉ lặp mỗi 0.04s nên cứ 0.04 x 25 = 1s, phần 200 lúc đầu là khoảng thời gian cho animation của effect xuất hiện[/I][/U][/COLOR]
Countdown Timer - Start TimerHoly as a Repeating timer that will expire in 0.01 seconds[I][U]//Đặt timer lặp mỗi 0.01s[/U], lúc đầu thì mình định là 0.04s nhưng do tia sáng phát ra quá chậm hoặc không liền nhau đành sửa lại[/I]
Custom script: call RemoveLocation(udg_CastPoint)[I]//phần này cũng dư[/I]
Mã:
Holy Light Move
Events
Time - TimerHoly expires[I][U]//Mỗi 0.04s[/U][/I]...
Conditions
Actions
For each (Integer A) from 1 to MUI[1], do (Actions)[U][I]//Hàm Loop sẽ lặp từ 1 đến chỉ số "MUI". Trong hàm này, các biến mà các bạn dùng ở trên thì phần trong ngoặc vuông "[]" sẽ thay bằng "IntegerA", nghĩa là hàm sẽ lặp tất cả các biến từ [1],[2],...,[MUI], điều này sẽ giúp cho spell chúng ta có thể MUI được[/I][/U]
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Integer[(Integer A)] Greater than ((200 + ((Level of Holy Light for Caster[(Integer A)]) x 25)) - 174)[U][I]//Đây là phần time cho animation của effect, sẽ trừ đi 174 chính là số thời gian cần để effect "vung kiếm"[/I][/U]
Then - Actions
Set Integer[(Integer A)] = (Integer[(Integer A)] - 1)[U][I]//Nếu chỉ số vẫn chưa hết 174, tiếp tục trừ đi[/I][/U]
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Integer[(Integer A)] Greater than ((200 + ((Level of Holy Light for Caster[(Integer A)]) x 25)) - 175)[U][I]//Ở đây là 175, nghĩa là 175-174=1, khoảng thời gian này là 0.01s cho chúng ta set vị trí của caster để tạo dummy và xác định hướng nhìn của caster[/I][/U]
Then - Actions
Set Angle[(Integer A)] = (Facing of Caster[(Integer A)])[U][I]//Đặt biến cho hướng nhìn của Caster[/I][/U]
Set Integer[(Integer A)] = (Integer[(Integer A)] - 1)
Set CastPoint = (Position of Caster[(Integer A)])
Unit - Create 1 Dummy Light (AOE) for (Owner of Caster[(Integer A)]) at CastPoint facing Default building facing degrees[I][U]//Tạo dummy và move dummy này từng 0.01s tiến về phía trước, mỗi lần move như thế sẽ tạo effect ở địa điểm của dummy, giúp tạo thành 1 effect mới theo đường thẳng[/U][/I]
Set DummyLightAOE[(Integer A)] = (Last created unit)[U][I]//Đặt biến là dummy vừa created[/I][/U]
Special Effect - Create a special effect at CastPoint using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl[U][I]//Phần này là tạo effect khi tia sáng được bắn ra[/I][/U]
Special Effect - Destroy (Last created special effect)
Custom script: call RemoveLocation(udg_CastPoint)[U][I]//Mỗi lần bạn tạo các biến Point, Group nhớ remove nó[/I][/U]
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Integer[(Integer A)] Greater than 1[U][I]//Nếu Integer lớn hơn 1, ví dụ như 5, 25, 35, 100,... chẳng hạn thì hàm bên dưới vẫn cứ tiếp tục hoạt động cho đến khi nó bằng 1[/I][/U]
Then - Actions
Set PointDLA[(Integer A)] = (Position of DummyLightAOE[(Integer A)])[U][I]//Xác định địa điểm của dumy, điều này quan trọng vì mỗi lần move dummy sẽ thay đổi địa điểm liên tục[/I][/U]
Set PointDLAMove[(Integer A)] = (PointDLA[(Integer A)] offset by 15.00 towards Angle[(Integer A)] degrees)[U]//Đặt PointDLAMove là điểm cách [U]điểm của dummy vừa set trên tức "PointDLA"[/U] một khoảng = 15 range[/U] (hơi ngắn nhưng cứ 0.01s mà đi được như thế thì thử nhân lên xem nào) [U]theo [U]số degrees(độ) góc nhìn của caster tức biến "Angle"[/U][/U]
Unit - Move DummyLightAOE[(Integer A)] instantly to PointDLAMove[(Integer A)][U][I]//Di chuyển dummy đến khoảng vừa set trên, vậy là dummy của chúng ta đã nhích được lên 15 range trong 0.01s rồi đó[/I][/U]
Unit - Create 1 Dummy Light (Effect) for (Owner of Caster[(Integer A)]) at PointDLAMove[(Integer A)] facing Default building facing degrees[U][I]//Đồng thời tạo 1 dummy dạng effect ở điểm đấy để tạo đường sáng[/I][/U]
Set Group = (Units within 100.00 of PointDLAMove[(Integer A)] matching ((((((Matching unit) is alive) Equal to True) and ((Matching unit) Not equal to Caster[(Integer A)])) and (((Matching unit) has buff Holy Light ) Equal to False)) and ((((Matching unit) is Magic Immunne) Equal to False)) and ((Matching unit) has buff Invulnerable ) Equal to False))[U][I]//Đặt Group là các unit trong khoảng 100 range của đường sáng, bao gồm phải đang sống, không phải người cast, chưa buff holy light, chưa buff invunerable và không kháng phép ( không cần phải là unit địch vì skill có thể heal cả allies mà )[/I][/U]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in Group) Greater than 0[I][U]//Nêu số unit lớn hơn 0[/U], nghĩa là có tồn tại hơn 1 unit trong group thì chúng ta mới tiếp tục, không thì cứ pick và loop cẩu thả cũng làm "choáng" bộ nhớ chứ nhỉ[/I]
Then - Actions
Unit Group - Pick every unit in Group and do (Actions)
Loop - Actions
Unit - Order DummyLightAOE[(Integer A)] to Human Mountain King - Storm Bolt (Picked unit)[U][I]//Skill này sẽ tỏa ra 1 tia sáng khác vào đối phương[/I][/U]
Unit - Order DummyLightAOE[(Integer A)] to Human Sorceress - Slow (Picked unit)[U][I]//Skill này sẽ tạo 1 buff vào đối phương để tiện cho việc check[/I][/U]
Else - Actions
Set Integer[(Integer A)] = (Integer[(Integer A)] - 1)[U][I]//Tiếp tục giảm chỉ số này nếu bạn không muốn tia sáng phát ra "mãi mãi" chứ nhỉ?[/I][/U]
Custom script: call RemoveLocation(udg_PointDLA[bj_forLoopAIndex])
Custom script: call RemoveLocation(udg_PointDLAMove[bj_forLoopAIndex])
Custom script: call DestroyGroup(udg_Group)
Else - Actions[I]//Khi chỉ số này không còn lớn hơn 1 nữa (tức = 1)[/I]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Integer[(Integer A)] Greater than 0[U][I]//Và đây là sau 1 khoảng thời gian, khi chỉ số integer của chúng chỉ còn 1 ( lớn hơn 0 mà ), ta thấy rằng chỉ số này đã giảm đi rất nhiều, và lúc này chỉ bằng 1 vài dòng code nữa cộng với việc hạ chỉ số xuống còn "0" thì spell của chúng ta đã hoàn tất[/I][/U]
Then - Actions
Set PointDLA[(Integer A)] = (Position of DummyLightAOE[(Integer A)])[U][I]//Xác định lần cuối vị trí của dummy này trước khi remove nó để deal damage xung quanh nơi ấy[/I][/U]
Set Group = (Units within 400.00 of PointDLA[(Integer A)] matching ((((Matching unit) is alive) Equal to True) and (((((Matching unit) is Magic Immune) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of Caster[(Integer A)])) Equal to True)) and (((Matching unit) has buff Invulnerable ) Equal to False)))[U][I]//Như ở trên, có điều thêm phần unit này là địch vì đây chỉ là deal damage thôi[/I][/U]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in Group) Greater than 0
Then - Actions
Unit Group - Pick every unit in Group and do (Actions)
Loop - Actions
Unit - Cause Caster[(Integer A)] to damage (Picked unit), dealing (100.00 + ((Real((Level of Holy Light for Caster[(Integer A)]))) x 25.00)) damage of attack type Spells and damage type Normal[U][I]//Pick và deal damage theo lvl, chắc ai cũng hiểu[/I][/U]
Else - Actions
Special Effect - Create a special effect at PointDLA[(Integer A)] using war3mapImported\LightNova.mdx
Special Effect - Destroy (Last created special effect)[U][I]//Effect ánh sáng nổ ở cuối đường[/I][/U]
Unit - Remove DummyLightAOE[(Integer A)] from the game
Custom script: call RemoveLocation(udg_PointDLA[bj_forLoopAIndex])
Custom script: call DestroyGroup(udg_Group)
Else - Actions
-Vậy là xong phần spell Holly Light của hero. Nhưng để spell này hoàn chỉnh, chúng ta phải làm cả spell của dummy
Mã:
Light Target Dummy
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Light Target
Actions
Set MUI[2] = (MUI[2] + 1)
Set LightTargetCaster[MUI[2]] = (Casting unit)
Set LightTargetUnit[MUI[2]] = (Target unit of ability being cast)
Set CasPointLightTarget[MUI[2]] = (Position of LightTargetCaster[MUI[2]])
Unit - Create 1 Dummy Light (Target) for (Owner of LightTargetCaster[MUI[2]]) at CasPointLightTarget[MUI[2]] facing Default building facing degrees
Set DummyLightTarget[MUI[2]] = (Last created unit)
Set IntegerDummy[MUI[2]] = 2[U][I]//Đặt chỉ số này = 2 vì spell tia sáng chỉ kết thúc khi đến được điểm của Target[/I][/U]
Countdown Timer - Start TimerLightTarget as a Repeating timer that will expire in 0.01 seconds
-Phần này chắc không có gì để nói, y hệt như Holy Light ngoại trừ thêm phần set Target, có điều bạn phải dùng MUI[2] để không trùng với MUI[1] (có nghĩa nếu để MUI[1] hết thì spell Holy Light có thể lặp nhiều lần và ngược lại --> bug)
Mã:
Light Target Move
Events
Time - TimerLightTarget expires
Conditions
Actions
For each (Integer A) from 1 to MUI[2], do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
IntegerDummy[(Integer A)] Greater than 1[U][I]//Vừa vào đã "greater than 1", hơi khác phải không ? Vì chỉ số này chỉ giảm xuống còn 1 khi dummy đứng gần Target nhất[/I][/U]
Then - Actions
Set PointDLT[(Integer A)] = (Position of DummyLightTarget[(Integer A)])
Set TarPointLightTarget[(Integer A)] = (Position of LightTargetUnit[(Integer A)])
Set PointDLTMove[(Integer A)] = (PointDLT[(Integer A)] offset by 15.00 towards (Angle from PointDLT[(Integer A)] to TarPointLightTarget[(Integer A)]) degrees)
Unit - Move DummyLightTarget[(Integer A)] instantly to PointDLTMove[(Integer A)]
Unit - Create 1 Dummy Light (Effect) for (Owner of LightTargetCaster[(Integer A)]) at PointDLTMove[(Integer A)] facing Default building facing degrees
[U][I]-Phần trên hoạt động y hệt như Holy Light, ngoại trừ phải set thêm point Target[/I][/U]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Integer((Distance between PointDLTMove[(Integer A)] and TarPointLightTarget[(Integer A)]))) Less than or equal to 16[U][I]//Đây là phần quan trọng chuyển sang giai đoạn kế tiếp, deal damage. Nếu khoảng cách giữa dummy và target dưới hoặc bằng 16, trong game có nghĩa là tia sáng đã đến sát nút unit địch, thì việc giảm chì số Integer sẽ hoạt động.[/U] Nên để khoảng cách này = khoảng cách move dummy của bạn +1 nghĩa là 15+1=16, đây là ý kiến riêng của mình thôi.[/I]
Then - Actions
Unit - Order DummyLightTarget[(Integer A)] to Human Sorceress - Slow LightTargetUnit[(Integer A)][U][I]//Tạo buff check[/I][/U]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(LightTargetUnit[(Integer A)] belongs to an enemy of (Owner of LightTargetCaster[(Integer A)])) Equal to True[U][I]//Nếu là địch thì sẽ deal damage = 100, ngược lại allies thì bạn cho deal -100, tức là thêm lượng HP tương đương vơi 100 damage[/I][/U]
Then - Actions
Unit - Cause LightTargetCaster[(Integer A)] to damage LightTargetUnit[(Integer A)], dealing 100.00 damage of attack type Spells and damage type Normal
Else - Actions
Unit - Cause LightTargetCaster[(Integer A)] to damage LightTargetUnit[(Integer A)], dealing -100.00 damage of attack type Spells and damage type Normal
Set IntegerDummy[(Integer A)] = (IntegerDummy[(Integer A)] - 1)[U][I]//Giảm chỉ số Int[/I][/U]
Special Effect - Create a special effect at TarPointLightTarget[(Integer A)] using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl[U][I]//tạo effect tại điểm của target[/I][/U]
Special Effect - Destroy (Last created special effect)
Else - Actions
Custom script: call RemoveLocation(udg_PointDLT[bj_forLoopAIndex])
Custom script: call RemoveLocation(udg_PointDLTMove[bj_forLoopAIndex])
Custom script: call RemoveLocation(udg_TarPointLightTarget[bj_forLoopAIndex])
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
IntegerDummy[(Integer A)] Greater than 0[U][I]//Và sau cùng, kết thúc khi Int chỉ còn 1, nhưng lại mở ra 1 đường đi mới, spell sẽ tỏa ra 2 đường sang 2 địch kế bên, đường thứ nhất sẽ tỏa vào địch trong 600 range, đường thứ 2 sẽ tỏa trong 350 range, và 2 unit này sẽ không trùng nhau, chỉ số range ở đây khác nhau để giảm đi sự "imba" [/U](Theo lý thuyết thì lượng ánh sáng sẽ giảm bớt khi bị tỏa ra, bằng nhau hoặc 1 mạnh 1 yếu)[/I]
Then - Actions
Set PointDLT[(Integer A)] = (Position of DummyLightTarget[(Integer A)])
Set Group = (Units within 600.00 of PointDLT[(Integer A)] matching (((((Matching unit) is alive) Equal to True) and (((Matching unit) has buff Holy Light ) Equal to False)) and ((((Matching unit) is Magic Immune) Equal to False) and (((Matching unit) has buff Invulnerable)[U][I]//Unit trong range 600 thỏa với các điều kiện trên[/I][/U]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in Group) Greater than 0
Then - Actions
Set RandomUnit = (Random unit from Group)[U][I]//Tạo 1 biến RandomUnit dạng unit để việc random unit không bị trùng[/I][/U]
Unit - Create 1 Dummy Light (AOE) for (Owner of LightTargetCaster[(Integer A)]) at PointDLT[(Integer A)] facing Default building facing degrees[I]//Dummy này ta đã gặp trong phần Holy Light, nếu ở spell trên nó đảm nhiệm chức vụ chính thì ở đây nó chỉ có vai trò phụ. [U]Dummy này có skill Light Targer để tiếp tục việc "tỏa" tia sáng ra[/U][/I]
Unit - Add a 1.00 second Generic expiration timer to (Last created unit)[U]//Cho unit này tồn tại trong 1s đủ để cast spell nếu bạn không muốn bị lag do nhiều unit được tạo ra[/U]
Unit - Order (Last created unit) to Human Mountain King - Storm Bolt RandomUnit[U][I]//Light Target base trên Storm Bolt nên..?[/I][/U]
Else - Actions
Custom script: call DestroyGroup(udg_Group)
Set Group = (Units within 350.00 of PointDLT[(Integer A)] matching (((((Matching unit) is alive) Equal to True) and (((Matching unit) has buff Holy Light ) Equal to False)) and (((((Matching unit) is Magic Immune) Equal to False) and ((Matching unit) Not equal to RandomUnit))))[I][U]//Hệt như phần trên có đều thêm 1 điều kiện quan trọng là unit này KHÔNG PHẢI là RandomUnit[/U] (tránh cho việc trùng lặp)[/I]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in Group) Greater than 0
Then - Actions
Unit - Create 1 Dummy Light (AOE) for (Owner of LightTargetCaster[(Integer A)]) at PointDLT[(Integer A)] facing Default building facing degrees
Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Random unit from Group)[U][I]//Lần này không cần set nữa, random unit nào cũng được vì nó không thể trùng unit nữa[/I][/U]
Else - Actions
Custom script: call DestroyGroup(udg_Group)
Set RandomUnit = No unit
Unit - Remove DummyLightTarget[(Integer A)] from the game[I]//Tất nhiên phải remove rồi[/I]
Set IntegerDummy[(Integer A)] = (IntegerDummy[(Integer A)] - 1)[U][I]//Giảm chỉ số Integer, kết thúc spell[/I][/U]
Custom script: call RemoveLocation(udg_PointDLT[bj_forLoopAIndex])
Custom script: call RemoveLocation(udg_CasPointLightTarget[bj_forLoopAIndex])
Else - Actions
Và một lần nữa mình xin nhắc lại, nhớ remove leak sau mối lần set point, group :)[/spoil]
Ps:
Mình cũng hay đùa giỡn ( nói chung là rất nhiều ) nhưng mình lại không thích đùa trong việc xưng hô, giao tiếp. Với lại hôm đó mình cũng đang bực bội nên một phần cũng do mình không đúng, thôi thì giảng hòa, xí xóa mọi việc xem như chẳng có gì xảy ra vậy nhé và quay lại với topic nào.