Tom_Kazansky
<b><font color="RoyalBlue"><font face="Lucida Cons
- 28/12/06
- 3,454
- 462
Có thể hướng dẫn cụ thể hơn không?
Spell này khá đơn giản. Cần 3 biến array: UFCaster(unit), UFTarget(unit), UFDamage(real) (trong 3 biến này thì Caster ko cần lắm, nhg cứ cho vào) và biến integer UFIndex.
UFCaster: caster của Unholy Frenzy
UFTarget: target của Unholy Frenzy
UFDamage: damage của Unholy Frenzy
UFIndex: được dùng làm "biến đếm", đếm số unit đang "bị buff" và "bị mất máu". Ta gọi mỗi (caster, target, damage) ở mỗi index là 1 "instance" //từ này ko cần hiểu sâu, tôi ko dịch đc nên để nguyên thôi
--- Trigger thứ 1 ---
Mã:
Unholy Frenzy
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Unholy Frenzy
Actions
Set TempUnit = (Target unit of ability being cast)
-------- kiem tra xem unit nay da~ co buff tu` trc hay chua --------
For each (Integer A) from 1 to UFIndex, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TempUnit Equal to UFTarget[(Integer A)]
Then - Actions
Skip remaining actions
Else - Actions
-------- them 1 unit thi index tang 1 --------
Set UFIndex = (UFIndex + 1)
Set UFCaster[UFIndex] = (Triggering unit)
Set TempInt = (Level of Unholy Frenzy for UFCaster[UFIndex])
Set UFTarget[UFIndex] = TempUnit
-------- unit dc buff se mat 1 x level % max life moi giay --------
Set UFDamage[UFIndex] = (0.01 x (Real(TempInt)))
Nếu điều vừa nói trên chưa xảy ra, thì UFIndex phải tăng thêm 1, và index của UFCaster, UFTarget, UFDamage bây giờ là UFIndex.
Ví dụ:
UFIndex: 1 2 3 4 5
Bây giờ tăng lên
UFIndex: 1 2 3 4 5 6
Tại trigger đó, caster, target, damage của UF là "instance" thứ 6
--- Trigger thứ 2 ---
Mã:
UF Damage
Events
Time - Every 1.00 seconds of game time
Conditions
Actions
For each (Integer A) from 1 to UFIndex, do (Actions)
Loop - Actions
Set TempInt = (Integer A)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(UFTarget[TempInt] has buff Unholy Frenzy ) Equal to False
Then - Actions
-------- 1 unit het buff, vay index giam 1 sau do tien hanh "da^y?" index --------
Set UFIndex = (UFIndex - 1)
For each (Integer B) from TempInt to UFIndex, do (Actions)
Loop - Actions
Set TempInt2 = (Integer B)
Set UFCaster[TempInt2] = UFCaster[(TempInt2 + 1)]
Set UFTarget[TempInt2] = UFTarget[(TempInt2 + 1)]
Set UFDamage[TempInt2] = UFDamage[(TempInt2 + 1)]
Else - Actions
-------- ---------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Percentage life of UFTarget[TempInt]) Greater than 5.00
Then - Actions
Set TempUnit = UFTarget[TempInt]
Unit - Set life of TempUnit to ((Life of TempUnit) - ((Max life of TempUnit) x UFDamage[TempInt]))
Else - Actions
Nhg trước khi deal damage, phải kiểm tra xem UFTarget ở "instance" hiện tại (tại index = Integer A) có buff hay ko, ko thì "đẩy" index.
Tức là: Như ví dụ trên: UFIndex: 1 2 3 4 5 6
Giả sử instance 3 bị mất buff (dispel, out of duration,... whatever) thì instance 4 sẽ thành instance 3, 5 sẽ thành 4 và 6 sẽ thành 5 và UFIndex đương nhiên sẽ giảm 1 còn 5.
Dưới đó thì check buff và deal damage bình thường.
Chú ý: tôi dùng biến unit TempUnit để "tạm thời" nhận giá trị của UFTarget[TempInt], điều này ko có ý nghĩa gì đặc biệt, chỉ là viết cho "nhanh" thôi. Tức là các lệnh về sau, dùng TempUnit chắc chắn sẽ nhanh hơn dùng UFTarget[TempInt], đúng ko ?
Và dùng TempInt thay cho (Integer A) hay TempInt2 thay cho (Integer B), biến là thứ có thể thay đổi, nếu bạn ko muốn dùng loop với Integer A hay B mà muốn dùng với biến integer nào khác chẳng hạn, thì chỉ việc set TempInt = <biến integer loop> là xong, ko phải đổi ở các lệnh trong loop nữa.
=> các bạn chăm dùng biến một tí.
@Espeon - cool, cái Leap của bạn tôi thấy ở đầu trigger, đã "lưu" caster vào biến rồi, thế mà ở cuối vẫn dùng Trigger Unit với Casting Unit -> ???
, nếu là do bug thì tại sao mình thay buff 3, 4 lần rồi vẫn thế? Tom kiểm tra lại các giá trị xem có đúng chưa? Nó có hoạt động trong map của ông không?


