Topic hỏi đáp về cách làm map | version 15

Thêm điều kiện các UNIT TYPE trong cái Region đó vào ,là creep trong region thì trigger ko hoat động ,chỉ thằng ngoại đạo đi vào mới check lv của nó
 
Làm thế nào để remove 1 Point mà ko cần set biến? Ví dụ mình set point = position of triggering unit, thì code là call RemoveLocation(udg_Point), thế nếu ko set biến thì nó sẽ thành gì? call RemoveLocation (?????? .... ). À cái leak check của mình nó ra cái lỗi này thì làm ntn: System Error &h80004005 (-2147467259). Unspecified error
 
Ko set biến thì sẽ ko có cái tham chiếu đến để RemoveLocation => sẽ thành leak
Cậu tốt nhất là tự check leak đi. Check nhiều rồi sẽ có kinh nghiệm thì làm sẽ ko bị leak nữa.
Các phần mềm như thế ko đáng tin cho lắm. Lúc đầu cứ post trigger lên đây ae check leak hộ cho cũng được!
 
Bác nào giải thích hộ tại sao code này ko hoạt động với
Mã:
Damage Return Aura Copy
    Events
        Unit - A unit enters (Playable map area)
    Conditions
        ((Triggering unit) is A Hero) Equal to True
        ((Triggering unit) has buff Damage Return Aura ) Equal to True
    Actions
        Set UnitGroupExplosion = (Units within 600.00 of (Position of (Triggering unit)) matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))
        Unit Group - Pick every unit in UnitGroupExplosion and do (Actions)
            Loop - Actions
                Unit - Cause (Triggering unit) to damage (Picked unit), dealing 1000.00 damage of attack type Chaos and damage type Normal
        Custom script:   call DestroyGroup( udg_UnitGroupExplosion )
 
- Event của cậu khiến trigger chỉ chạy lúc con heo của cậu mới vào map mà thôi. Nếu cậu đặt sẵn con heo đó ở WE thì lúc bắt đầu map chính là lần duy nhất mà trigger đó chạy
- Cậu có đảm bảo các điều kiện cậu cho trong Condition thỏa mãn ?

Theo như mình thấy thì cậu định làm aura phản dam cố định? Vậy thì phải dùng trigger liên quan đến dam. Mà cái này thì ............. mình chỉ biết dùng library mà thôi
 
Thực ra cái trên là edit lại của một cái phản damage, mình định làm 1 cái kiểu như Passive Immolation mà có thể tính damage theo LV hay máu gì đấy...Chả biết ghép Event nào cho phù hợp :(

Tranh thủ hỏi cái phản damage này luôn
Mã:
Damage Return Aura Copy 2
    Events
        Unit - A unit Is attacked
    Conditions
        ((Attacked unit) is A Hero) Equal to True
        ((Attacked unit) has buff Hell Flame <Buff> ) Equal to True
    Actions
        Set UnitGroupExplosion = (Units within 600.00 of (Position of (Attacked unit)) matching (((Matching unit) belongs to an enemy of (Owner of (Attacked unit))) Equal to True))
        Unit Group - Pick every unit in UnitGroupExplosion and do (Actions)
            Loop - Actions
                Unit - Cause (Attacked unit) to damage (Picked unit), dealing ((0.02 x (Real((Level of Hell Flame  for (Attacked unit))))) x (Life of (Attacked unit))) damage of attack type Chaos and damage type Normal
                Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Demon\DemonBoltImpact\DemonBoltImpact.mdl
                Special Effect - Destroy (Last created special effect)
        Custom script:   call DestroyGroup( udg_UnitGroupExplosion )
Code trên chạy bình thường. Damage gây ra đúng theo code. Skill và Buff sử dụng đều của Passive Immolation. Vấn đề là máu của Hero mất rất nhanh. Khi ko sử dụng trigger này thì Hero khá trâu. Mình ngờ là cả Hero của mình cũng dính phản damage. Bác nào giúp cái :D
 
Thực ra cái trên là edit lại của một cái phản damage, mình định làm 1 cái kiểu như Passive Immolation mà có thể tính damage theo LV hay máu gì đấy...Chả biết ghép Event nào cho phù hợp :(

Tranh thủ hỏi cái phản damage này luôn
Mã:
Damage Return Aura Copy 2
    Events
        Unit - A unit Is attacked
    Conditions
        ((Attacked unit) is A Hero) Equal to True
        ((Attacked unit) has buff Hell Flame <Buff> ) Equal to True
    Actions
        Set UnitGroupExplosion = (Units within 600.00 of (Position of (Attacked unit)) matching (((Matching unit) belongs to an enemy of (Owner of (Attacked unit))) Equal to True))
        Unit Group - Pick every unit in UnitGroupExplosion and do (Actions)
            Loop - Actions
                Unit - Cause (Attacked unit) to damage (Picked unit), dealing ((0.02 x (Real((Level of Hell Flame  for (Attacked unit))))) x (Life of (Attacked unit))) damage of attack type Chaos and damage type Normal
                Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Demon\DemonBoltImpact\DemonBoltImpact.mdl
                Special Effect - Destroy (Last created special effect)
        Custom script:   call DestroyGroup( udg_UnitGroupExplosion )
Code trên chạy bình thường. Damage gây ra đúng theo code. Skill và Buff sử dụng đều của Passive Immolation. Vấn đề là máu của Hero mất rất nhanh. Khi ko sử dụng trigger này thì Hero khá trâu. Mình ngờ là cả Hero của mình cũng dính phản damage. Bác nào giúp cái :D

Bạn pick unit như thế thì ko chỉ có con tấn công bị phản damage mà tất cả các con trong vùng AoE cũng mất máu theo luôn. Tức là ví dụ có 10 con đứng trong AoE thì nó sẽ phản damage lên tận 10 lần. Tốt nhất là xóa cái unitgroup đi, và để là cause attacked unit to damage triggering unit thôi cho đơn giản, vs làm thế thì con tướng chưa bị đánh thì con kia đã mất máu rồi, muốn phản damage kiểu spectre, blade mail .... thì dùng take damage vs 1 số trigger khác chứ phản damage thế này 1 con unit chưa đánh nó đã mất máu thì có lẽ hơi ớn.
 
Stork[gm];22420662 nói:
Bạn pick unit như thế thì ko chỉ có con tấn công bị phản damage mà tất cả các con trong vùng AoE cũng mất máu theo luôn. Tức là ví dụ có 10 con đứng trong AoE thì nó sẽ phản damage lên tận 10 lần. Tốt nhất là xóa cái unitgroup đi, và để là cause attacked unit to damage triggering unit thôi cho đơn giản, vs làm thế thì con tướng chưa bị đánh thì con kia đã mất máu rồi, muốn phản damage kiểu spectre, blade mail .... thì dùng take damage vs 1 số trigger khác chứ phản damage thế này 1 con unit chưa đánh nó đã mất máu thì có lẽ hơi ớn.
Công nhận bá đạo thật :">
Nhưng mình đang thắc mắc tại sao Hero của mình lại ăn damage đau thế ? Với 1 đám unit damage to mất máu nhanh kinh.
Trong khi chưa thêm trigger vào thì vẫn với đám unit đó trụ cả phút ko sao.
Bác có map tutorial về phản damage nào ko ? Đừng chơi Jass nhé :(
Cái bác bảo là "cause attacked unit to damage triggering unit" thì triggering unit là attacking unit à ?
 
cho m` hỏi, câu lệnh trong jass có BJ với k có BJ khác nhau chỗ nào, và sử dụng cía nào thì có lợi hơn
 
cho m` hỏi, câu lệnh trong jass có BJ với k có BJ khác nhau chỗ nào, và sử dụng cía nào thì có lợi hơn

BJ có thể nói là "gián tiếp" để thực hiện lệnh đó qua các lệnh khác mà đa phần đều thực hiện bằng một hoặc nhiều lệnh không có hoặc ít BJ
còn không BJ thì làm "trực tiếp" luôn nên nó sẽ tốn ít dữ liệu hơn.
BJ ở đây là các lệnh màu đỏ,không BJ là các lệnh màu tím ^^


Công nhận bá đạo thật :">
Nhưng mình đang thắc mắc tại sao Hero của mình lại ăn damage đau thế ? Với 1 đám unit damage to mất máu nhanh kinh.
Trong khi chưa thêm trigger vào thì vẫn với đám unit đó trụ cả phút ko sao.
Bác có map tutorial về phản damage nào ko ? Đừng chơi Jass nhé :(
Cái bác bảo là "cause attacked unit to damage triggering unit" thì triggering unit là attacking unit à ?

Đầu tiên copy system này của anh Tom về map,trong Trigger UnitTakeDamage cho Triggering Unit gây damage vào Damage source một lượng sát thương = Damage taken (lượng sát thương Unit đó phải chịu) ít hoặc nhiều hơn tùy bạn

http://forum.gamevn.com/showthread.php?t=474447
 
Chỉnh sửa cuối:
Ai check giùm code sao xem đã ok chưa (lag, leak, code...) với lại hướng dẫn mình cách remove BJ

PHP:
globals
    integer StunBuff = 'BPSE'
    string StunOrder = "thunderbolt"
    integer StunAbi = 'A000'
    integer StunDummy = 'h000'
endglobals
struct StunData
    unit whichUnit
    timer xtimer
endstruct

library Stun
function GetStunTime takes unit u returns real
    local StunData data = GetCSData ( u )
    local real r = TimerGetRemaining( data.xtimer)
    return r
endfunction

function StunEnd takes nothing returns nothing
    local timer ti = GetExpiredTimer()
    local StunData data = GetCSData ( ti )
    if GetStunTime( data.whichUnit ) == 0 then
    call UnitRemoveBuffBJ( StunBuff , data.whichUnit )
    endif
endfunction

function StunUnit takes unit u, real r returns nothing
    local StunData data = StunData.create()
    local StunData xdata = GetCSData(u)
    local location p = GetUnitLoc(u)
    local timer ti = CreateTimer()
    set data.whichUnit = u
    set data.xtimer = ti
    if (UnitHasBuffBJ(u, StunBuff) == FALSE) then
        call CreateNUnitsAtLoc( 1 , StunDummy , GetOwningPlayer(u), p , GetUnitFacing(u) )
        call UnitAddAbility( GetLastCreatedUnit() , StunAbi )
        call IssueTargetOrderBJ( GetLastCreatedUnit() , StunOrder , u )
        call UnitApplyTimedLife( GetLastCreatedUnit() , 'BTLF' , 0.5)
    endif
    if (r > TimerGetRemaining( xdata.xtimer)) then
        call SetCSData (ti , data )
        call SetCSData (u , data )
        call TimerStart( ti , r , false , function StunEnd)
    endif
    call RemoveLocation(p)
    set p = null
endfunction
endlibrary
 
Ai check giùm code sao xem đã ok chưa (lag, leak, code...) với lại hướng dẫn mình cách remove BJ

PHP:
globals
    integer StunBuff = 'BPSE'
    string StunOrder = "thunderbolt"
    integer StunAbi = 'A000'
    integer StunDummy = 'h000'
endglobals
struct StunData
    unit whichUnit
    timer xtimer
endstruct

library Stun
function GetStunTime takes unit u returns real
    local StunData data = GetCSData ( u )
    local real r = TimerGetRemaining( data.xtimer)
    return r
endfunction

function StunEnd takes nothing returns nothing
    local timer ti = GetExpiredTimer()
    local StunData data = GetCSData ( ti )
    if GetStunTime( data.whichUnit ) == 0 then
    call UnitRemoveBuffBJ( StunBuff , data.whichUnit )
    endif
endfunction

function StunUnit takes unit u, real r returns nothing
    local StunData data = StunData.create()
    local StunData xdata = GetCSData(u)
    local location p = GetUnitLoc(u)
    local timer ti = CreateTimer()
    set data.whichUnit = u
    set data.xtimer = ti
    if (UnitHasBuffBJ(u, StunBuff) == FALSE) then
        call CreateNUnitsAtLoc( 1 , StunDummy , GetOwningPlayer(u), p , GetUnitFacing(u) )
        call UnitAddAbility( GetLastCreatedUnit() , StunAbi )
        call IssueTargetOrderBJ( GetLastCreatedUnit() , StunOrder , u )
        call UnitApplyTimedLife( GetLastCreatedUnit() , 'BTLF' , 0.5)
    endif
    if (r > TimerGetRemaining( xdata.xtimer)) then
        call SetCSData (ti , data )
        call SetCSData (u , data )
        call TimerStart( ti , r , false , function StunEnd)
    endif
    call RemoveLocation(p)
    set p = null
endfunction
endlibrary

Dùng JassCraft nhé,hoặc trong JNG click vào FunctionList,nếu là các lệnh BJ thì tra xem lệnh BJ đó được thực hiện bằng lệnh nào khác nào thì thay để bằng các lệnh đó,nếu các lệnh đó vẫn là BJ thì lại tiếp tục cho đến khi nó hết là BJ (màu đỏ) nhé,cái này với cinematic mà ko dùng BJ thì cực lắm lắm :(

Ví dụ UnitHasBuffBJ thay bằng GetUnitAbilityLevel

Thay vì dùng location thì dùng GetUnitX,GetUnitY

Trên cậu còn chưa set timer thành null nữa kìa
 
Chỉnh sửa cuối:
Hôm qua cái Win của em bị lỗi nên em cài lại, nhưng sau khi cài bật JNG thì nó cứ báo thế này:

Untitled.png

Em đã lên mạng tải lại JNG mới rồi nhưng vẫn bị thế. Bật WE thì vẫn ổn. Có ai biết là lỗi gì không?
 
BJ có thể nói là "gián tiếp" để thực hiện lệnh đó qua các lệnh khác mà đa phần đều thực hiện bằng một hoặc nhiều lệnh không có hoặc ít BJ
còn không BJ thì làm "trực tiếp" luôn nên nó sẽ tốn ít dữ liệu hơn.
BJ ở đây là các lệnh màu đỏ,không BJ là các lệnh màu tím ^^




Đầu tiên copy system này của anh Tom về map,trong Trigger UnitTakeDamage cho Triggering Unit gây damage vào Damage source một lượng sát thương = Damage taken (lượng sát thương Unit đó phải chịu) ít hoặc nhiều hơn tùy bạn

http://forum.gamevn.com/showthread.php?t=474447
Thanks bạn, nhìn có vẻ phức tạp phết :))
Cái lỗi ăn damage đau hơn của mình là do bọn quái có Thorn Aura, nên damage phản lại kinh hồn luôn :))
Mà cũng lạ. Cách tạo damage giống y các skill khác, trong khi các skill kia 1 hit kill hết, Hero mình chả sao. Skill này cắn máu dần dần, Hero mình lại dính phản damage. Chả hiểu.
 
Chỉnh sửa cuối:
@LeoNguyen112:

tớ nghĩ cậu tập xài system repeat sẽ ngon hơn nhiều nó rất là đơn giản và tiện dụng hơn :-? và sys đó có 1 ưu thế là hok lag hơn so với sys chạy hashtable
cái này thì mình hok cần dọn "rác" cả gì tất cả đa được dọn dùm :-"

PHP:
library CustomStun//ten thu vien

    globals
        private constant integer StunBuff = 'BPSE' //id buff
        private constant string StunOrder = "thunderbolt" //id order cua skill stun
        private constant integer StunAbi = 'A000' //stun ability id
        private constant integer StunDummy = 'h000' //stun dummy unit
        private constant real StunLoop = 0.05 //thoi gian cho system loop
    endglobals
    
    private struct repeat extends RepeatData
        unit target
        integer tik
        integer endtik
        method onStart takes nothing returns nothing
        endmethod
        
        method onLoop takes nothing returns nothing
            set this.tik = this.tik + 1
            if this.tik >= this.endtik then// khi du? tik se stop system coi nhu da done! 
                call this.stop()
            endif
        endmethod

        method onEnd takes nothing returns nothing
            call UnitRemoveAbility(this.target, StunBuff)
            set this.target = null
        endmethod
    endstruct
    
    function StunUnit takes unit u, real r returns nothing
        local repeat this = repeat.create(StunLoop, 0)
        set this.target = u
        set this.tik = 0
        set this.endtik = R2I(r / StunLoop) //lay thoi gian R chia cho loop vi du. 15 giay thi` 15 / 0.03 tuc 300tik!
        if not (GetUnitAbilityLevel(this.target, StunBuff) > 0) then// khong co buff
            set u = CreateUnit(GetOwningPlayer(this.target), StunDummy, GetUnitX(this.target), GetUnitY(this.target), 0)
            call UnitAddAbility(u, StunAbi)
            call IssueTargetOrder(u, StunOrder, this.target)
            call UnitApplyTimedLife(u, 'BTLF', 0.5)
        endif
        set u = null
    endfunction
endlibrary

đây là sys yêu cầu :"> à quên Made in Dore.mun ức Daric Nguyen :">
PHP:
library RepeatData initializer RepeatInit
/* 
----------------------------------------------------------------------------------------------------------------------------------------------------------- 
*/
/*
 ____                       _   ____        _        
|  _ \ ___ _ __   ___  __ _| |_|  _ \  __ _| |_ __ _ 
| |_) / _ \ '_ \ / _ \/ _` | __| | | |/ _` | __/ _` |
|  _ <  __/ |_) |  __/ (_| | |_| |_| | (_| | || (_| |
|_| \_\___| .__/ \___|\__,_|\__|____/ \__,_|\__\__,_|
          |_|                         
          
                        ---- version 0.1 ----
                            
Write by Daric Nguyen
    => Easy to use
    => Store data by Struct
    => MUI for spell

  * HOW TO USE?
      + Method:
         - method isStart takes nothing returns nothing
         - method isLoop takes nothing returns nothing
         - method isEnd takes nothing returns nothing
      + Example
         "
         library example initializer init requires RepeatData
         private struct repeat extends RepeatData
              // some variables
              method onLoop takes nothing returns nothing
                  // some actions when loop
              endmethod
              method onStart takes nothing returns nothing
                  // some actions when start
              endmethod
              method onEnd takes nothing returns nothing
                  // some actions when end
              endmethod
         endstruct

         function init takes nothing returns nothing
              local repeat t=repeat.create(0.05,0)    // (real timeloop, real maxtimeloop) if real maxtimeloop equal to 0, struct will repeat until you use call this.stop() command in method Loop
         endfunction
         endlibrary
         "
*/

/* 
----------------------------------------------------------------------------------------------------------------------------------------------------------- 
*/
private interface RepeatFace
    method onLoop takes nothing returns nothing defaults nothing
    method onStart takes nothing returns nothing defaults nothing
    method onEnd takes nothing returns nothing defaults nothing
endinterface

globals
    private integer cn
    private timer rTime
endglobals
/* Version 0.1  */


struct RepeatData extends RepeatFace
    public real rL
    public real nrL
    public real mrL
    public boolean rSt
    public real rnL
    
    private static thistype array rData
    static method create takes real Loop, real maxLoop returns thistype
        local thistype this=thistype.allocate()
            set this.rL=Loop
            set this.mrL=maxLoop
            set this.rSt=true
            set this.nrL=0
            set this.rnL=0
            set cn=cn+1
            set .rData[cn]=this
            if cn==1 then
                call TimerStart(rTime,0.03,true,function RepeatData.rpLoop)
            endif
        return this
    endmethod
    
    
    method stop takes nothing returns nothing
        set this.mrL=0.03
    endmethod
    
    static method rpLoop takes nothing returns nothing
        local thistype this
        local integer i=1
        loop
            exitwhen i>cn
            set this=.rData[i]
            if this.rL==0 then
                call this.stop()
            endif
            if this.rSt==true then
                set this.rSt=false
                call this.onStart()
            endif
            if this.mrL==0 then
                set this.nrL=this.nrL+0.03
                set this.rnL=this.rnL+0.03
                if this.rnL>=this.rL then
                    call this.onLoop()
                    set this.rnL=0
                endif
            else
                if this.nrL>=this.mrL then
                    call this.onEnd()
                    call this.destroy()
                    set .rData[i]=.rData[cn]
                    set i=i-1
                    set cn=cn-1
                else
                    set this.nrL=this.nrL+0.03
                    set this.rnL=this.rnL+0.03
                    if this.rnL>=this.rL then
                        call this.onLoop()
                        set this.rnL=0
                    endif
                endif
            endif
            set i=i+1
        endloop
        if cn<=0 then
            set cn=0
            call PauseTimer(rTime)
        endif
    endmethod
endstruct

private function RepeatInit takes nothing returns nothing
    set cn=0
    set rTime=CreateTimer()
endfunction
endlibrary

@Ngoc LeO: cậu vào thẳng Trigger Editor bấm Ctrl vào các fun BJ là dc mà :| đâu cần phải JC :-<
 
Chỉnh sửa cuối:
Ai check giùm code sao xem đã ok chưa (lag, leak, code...) với lại hướng dẫn mình cách remove BJ
Code về logic thì thế là OK rồi trừ chỗ StunEnd: Code đó chỉ chạy khi timer đã hết tức là time remain đương nhiên = 0 rùi còn check chi nữa @@
Mà struct mà đã create thì cần có destroy cũng như code với location hay group thôi
Cơ mà có create timer mà chưa có destroy kìa .....
location p = null rồi sao timer ti ko nốt luôn đi @@
Còn về tối ưu code thì ngoài loại trừ BJ thì nên tạo sẵn 1 con dummy với stun luôn đi. Mỗi lần stun thì gọi con đó ra stun là được và dùng global var sẽ nhanh hơn local (1 ít, ko rõ có đủ nhận thấy ko :-??)

tớ nghĩ cậu tập xài system repeat sẽ ngon hơn nhiều nó rất là đơn giản và tiện dụng hơn
@Ngoc LeO: cậu vào thẳng Trigger Editor bấm Ctrl vào các fun BJ là dc mà :| đâu cần phải JC :-<

Tốt nhất ko biết về điện thì đừng đái vô cầu chì @@
Tùy xem cách xử lý chứ. Nếu để chính xác thời gian stun thì dùng cách của LeoNguyen là ko thể tránh khỏi. Mỗi con 1 timer.
Mà cách repeat kia mà có nhiều timer thì sẽ đảm bảo lag đến từng giây luôn
Còn cách cậu LeoNguyen khi đó chỉ lag khi cast stun thôi :-"
 
Có hàm nào trong trigger làm cho unit ko hiển thị trên minimap ko nhi?
 
Có hàm nào trong trigger làm cho unit ko hiển thị trên minimap ko nhi?

Chèn một file texture vô hình cho icon Neutral buiding minimap trong game interface rồi trong trigger đặt lệnh Neutral Building - Turn special minimap icon On/Off for (Triggering unit)
 
Vậy Hero thì làm thế nào :-?
Hỏi thêm là làm thế nào để tạo lightingeffect cho 2 nguồn di chuyên .Ví du : Drain Mana khi cả 2 unit đều di chuyển
 
Có ai rảnh làm giúp mình 1 số spell bằng Trigger với.Mới mày mò cái WE đc 2 tuần chỉ hiểu Trigger thôi.Ai giúp đc để lại yahoo mình add nhá.
p/s:mấy tp tổng hợp Spell đã koi rồi,có cái hiểu cái ko mà nó bị closed hết nên post bài zô đây nhờ ae giúp dùm.
 
Back
Top