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

Status
Không mở trả lời sau này.
trong hàm đó có "CreateTrigger", "Register..." thấy không? đó là tạo trigger, thêm event, condition, action...

nếu hàm này không chạy thì trigger không được tạo do đó ability không có tác dụng

thêm initializer để làm cho hàm đó chạy
 
Sao map mình đã thay biến và remove đầy đủ mà vẫn leak nhỉ. Làm mãi cũng nản.
 
trong hàm đó có "CreateTrigger", "Register..." thấy không? đó là tạo trigger, thêm event, condition, action...

nếu hàm này không chạy thì trigger không được tạo do đó ability không có tác dụng

thêm initializer để làm cho hàm đó chạy

sẵn đây hỏi anh lun :3cool_nosebleed:
sao đôi lúc đặt scope màk em ko để initializer đó vào thì nó chạy, còn lúc thì ko?:9onion48: (tên của function tạo event luôn theo kiểu là InitTrig_<tên scope>
mà thường thì lúc em viết event trong GUI rồi chuyển sang thì hk bị, còn đôi lúc tự viết thì nó bị!
- vì vậy nên em viết spell toàn bỏ trong library - :2onion2:
 
sẵn đây hỏi anh lun :3cool_nosebleed:
sao đôi lúc đặt scope màk em ko để initializer đó vào thì nó chạy, còn lúc thì ko?:9onion48: (tên của function tạo event luôn theo kiểu là InitTrig_<tên scope>
mà thường thì lúc em viết event trong GUI rồi chuyển sang thì hk bị, còn đôi lúc tự viết thì nó bị!
- vì vậy nên em viết spell toàn bỏ trong library - :2onion2:

GUI chuyển sang thì nó có dạng: InitTrig_<tên trigger>, cái này mặc định được chạy khi map khởi tạo (initialization)
tự viết thì phải viết đúng, không thì dùng initializer của library/scope cho lành :-j

Sao map mình đã thay biến và remove đầy đủ mà vẫn leak nhỉ. Làm mãi cũng nản.

sao bạn biết là leak? lag quá?
 
A Tom cho em hỏi thêm là dùng code nào để chọn các Doodad xung quanh 200AoE của 1 unit r` destroy v. ạ ?
 
vẫn bị 2 lỗi. 1 là bây giờ random ra con Archmage hoài. 2 là ko remove hero @@
Mã:
Set Random Hero
    Events
        Time - Elapsed game time is 0.00 seconds
    Conditions
    Actions
        -------- The Light --------
        Set Random_hero[1] = Paladin
        Set Random_hero[2] = Mountain King
        Set Random_hero[3] = Archmage
        Set Random_hero[4] = Blood Mage
        Set Random_hero[5] = Priestess of the Moon
        -------- The Darkness --------
        Set Random_hero[7] = Troll
        Set Random_hero[6] = Grom Hellscream
        Set Random_hero[99] = Grom Hellscream
Player 1
    Events
        Player - Player 1 (Red) types a chat message containing -rd as An exact match
    Conditions
    Actions
        Player - Add -1 to Player 1 (Red) Current lumber
        Player - Add 200 to Player 1 (Red) Current gold
        Wait 5.00 seconds
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                Player - Limit training of (Unit-type of (Last created unit)) to 0 for (Picked player)
        Unit - Create 1 Random_hero[(Random integer number between 1 and 5)] for (Triggering player) at (Center of Hero 1 <gen>) facing Default building facing degrees
        Selection - Select (Last created unit)
        Trigger - Turn off (This trigger)


---------- Post added at 11:36 ---------- Previous post was at 11:35 ----------

dù sao lỗi 1 ko quan trọng (vì chẳng qua nó random ra con Archmage hơi nhiều thôi chứ ko phải hoài hoài :D), fix lỗi 2 dùm em

---------- Post added at 11:38 ---------- Previous post was at 11:36 ----------

à thôi em biết cách fix rồi, xin lỗi nha :))
 
A Tom cho em hỏi thêm là dùng code nào để chọn các Doodad xung quanh 200AoE của 1 unit r` destroy v. ạ ?

chọn Destructible thôi, ở mục Destructible ấy

Pick Every Destructible In Region...
Pick Every Destructible In Circle...
 
GUI chuyển sang thì nó có dạng: InitTrig_<tên trigger>, cái này mặc định được chạy khi map khởi tạo (initialization)
tự viết thì phải viết đúng, không thì dùng initializer của library/scope cho lành :-j



sao bạn biết là leak? lag quá?

cha của lag anh ạ. Cứ chơi được khoảng 15-20 phút là bắt đầu chuột chậm. đến khoảng 22 phút thì gần như đơ
 
chọn Destructible thôi, ở mục Destructible ấy

Pick Every Destructible In Region...
Pick Every Destructible In Circle...
Dạ code trong jass ý a .....
Hiện e tìm được r` ..... a cho e hỏi sai chỗ nào trong đây ạ ..... nó cứ báo Undeclared "takes"

Mã:
scope NetherSwap initializer Trig_HoanDoi

globals
     private integer ABIL_ID = 'A06Q' 
endglobals     

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ABIL_ID
endfunction

private function Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real xcaster = GetUnitX(caster)
    local real ycaster = GetUnitY(caster)
    local real xtarget = GetUnitX(target)
    local real ytarget = GetUnitY(target)
    local location cas = GetUnitLoc(caster)
    local location tar = GetUnitLoc(target)
    local real distance = DistanceBetweenPoints(GetUnitLoc(caster),GetUnitLoc(target))
    local string model = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
    call AddSpecialEffect(model, xcaster, ycaster)
    call DestroyEffect(GetLastCreatedEffectBJ())
    call SetUnitX(target, xcaster)
    call SetUnitY(target, ycaster)
    call SetUnitX(caster, xtarget)
    call SetUnitY(caster, ytarget)
    call AddSpecialEffect(model, xtarget, ytarget)
    call DestroyEffect(GetLastCreatedEffectBJ())
    if IsUnitEnemy(target, GetOwningPlayer(caster))== true then
            call UnitDamageTargetBJ( caster, target, distance/3, ATTACK_TYPE_HERO, DAMAGE_TYPE_UNIVERSAL )
    endif
    function Trig_HoanDoi_Actions takes location cas, location tar returns nothing
        EnumDestructablesInCircleBJ(600, cas, function Swap_Func)
        EnumDestructablesInCircleBJ(600, tar, function Swap_Func2)
    endfunction
    
    function Swap_Func takes nothing returns nothing
        call KillDestructable( GetEnumDestructable() )
    endfunction
    
    function Swap_Func2 takes nothing returns nothing
        call KillDestructable( GetEnumDestructable() )
    endfunction
    
    set caster = null
    set target = null
endfunction

//=============================================================
public function Trig_HoanDoi takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Conditions))
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction

endscope
 
Dạ code trong jass ý a .....
Hiện e tìm được r` ..... a cho e hỏi sai chỗ nào trong đây ạ ..... nó cứ báo Undeclared "takes"

Mã:
scope NetherSwap initializer Trig_HoanDoi

globals
     private integer ABIL_ID = 'A06Q' 
endglobals     

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ABIL_ID
endfunction

private function Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real xcaster = GetUnitX(caster)
    local real ycaster = GetUnitY(caster)
    local real xtarget = GetUnitX(target)
    local real ytarget = GetUnitY(target)
    local location cas = GetUnitLoc(caster)
    local location tar = GetUnitLoc(target)
    local real distance = DistanceBetweenPoints(GetUnitLoc(caster),GetUnitLoc(target))
    local string model = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
    call AddSpecialEffect(model, xcaster, ycaster)
    call DestroyEffect(GetLastCreatedEffectBJ())
    call SetUnitX(target, xcaster)
    call SetUnitY(target, ycaster)
    call SetUnitX(caster, xtarget)
    call SetUnitY(caster, ytarget)
    call AddSpecialEffect(model, xtarget, ytarget)
    call DestroyEffect(GetLastCreatedEffectBJ())
    if IsUnitEnemy(target, GetOwningPlayer(caster))== true then
            call UnitDamageTargetBJ( caster, target, distance/3, ATTACK_TYPE_HERO, DAMAGE_TYPE_UNIVERSAL )
    endif
    [COLOR="#FF0000"]function Trig_HoanDoi_Actions takes location cas, location tar returns nothing
        EnumDestructablesInCircleBJ(600, cas, function Swap_Func)
        EnumDestructablesInCircleBJ(600, tar, function Swap_Func2)
    endfunction
    
    function Swap_Func takes nothing returns nothing
        call KillDestructable( GetEnumDestructable() )
    endfunction
    
    function Swap_Func2 takes nothing returns nothing
        call KillDestructable( GetEnumDestructable() )
    endfunction[/COLOR]
    
    set caster = null
    set target = null
endfunction

//=============================================================
public function Trig_HoanDoi takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Conditions))
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction

endscope

function trong function làm sao được?

[spoil]
Mã:
scope NetherSwap initializer Trig_HoanDoi

globals
     private integer ABIL_ID = 'A06Q' 
endglobals     

[COLOR="#0000FF"]function Swap_Func takes nothing returns nothing
    call KillDestructable( GetEnumDestructable() )
endfunction[/COLOR]

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ABIL_ID
endfunction

private function Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real xcaster = GetUnitX(caster)
    local real ycaster = GetUnitY(caster)
    local real xtarget = GetUnitX(target)
    local real ytarget = GetUnitY(target)
    local location cas = GetUnitLoc(caster)
    local location tar = GetUnitLoc(target)
    local real distance = DistanceBetweenPoints(GetUnitLoc(caster),GetUnitLoc(target))
    local string model = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
    call AddSpecialEffect(model, xcaster, ycaster)
    call DestroyEffect(GetLastCreatedEffectBJ())
    [COLOR="#0000FF"]call EnumDestructablesInCircleBJ(600, cas, function Swap_Func)
    call EnumDestructablesInCircleBJ(600, tar, function Swap_Func)[/COLOR]
    call SetUnitX(target, xcaster)
    call SetUnitY(target, ycaster)
    call SetUnitX(caster, xtarget)
    call SetUnitY(caster, ytarget)
    call AddSpecialEffect(model, xtarget, ytarget)
    call DestroyEffect(GetLastCreatedEffectBJ())
    if IsUnitEnemy(target, GetOwningPlayer(caster))== true then
            call UnitDamageTargetBJ( caster, target, distance/3, ATTACK_TYPE_HERO, DAMAGE_TYPE_UNIVERSAL )
    endif
    
    set caster = null
    set target = null
endfunction

//=============================================================
public function Trig_HoanDoi takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Conditions))
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction

endscope
[/spoil]

chưa biết lệnh JASS thì viết GUI rồi convert ra :-??
 
cách giải quyết các vụ giật giật đó ko hẳn là leak từ trigger, mà còn từ các phần khác nhé bạn. :cuteonion38:
Đôi khi liên quan đến trigger về các phần thời gian lặp (time loop), với cách sử dụng set đi set lại một giá trị nhiều lần trong một giãn cách cực ngắn (<1s) thì cũng sẽ gây giật.
Và một số lúc khác ở trên map, bạn tạo quá nhiều đơn vị (unit), chết đi chết lại mà các bone của chúng ko được xử lí triệt để bằng cách remove những loại unit ko quan trọng đi như dummy, lính thường.:cuteonion40:
Hoặc giả khi chúng ta tạo cùng một lúc quá nhiều đơn vị (unit), hiệu ứng thời tiết, splat,... thì cũng có nguy cơ gây giật .:cuteonion37:
Cẩn thận với việc tạo quá nhiều Doodad tại một vị trí, quá nhiều cây cối, như vậy sẽ làm bản đồ của bạn rất giật vì phải xử lí vị trí của chúng, nên đặt nó hơi thưa ra nhưng phải trang trí sao cho cảnh vật vẫn mang điểm rậm rạp! :cuteonion9:
Xét lại một số hiệu ứng/ trạng thái dính kèm, đôi lúc một số hiệu ứng chứa Period time (hiệu ứng lặp lại mỗi lượng giây đã chỉnh sẵn), khi bạn chỉnh thời lượng này quá thấp (ex: 0 ~ 0.5s) thì có thể gây giật map khi ảnh hưởng hiệu ứng đó lên một hoặc nhiều mục tiêu . Điển hình là các buff như Soul Burn, Faerie, v.v... :1onion49::7onion8:

Chúc bạn thành công! Thân ! :)
 
cách giải quyết các vụ giật giật đó ko hẳn là leak từ trigger, mà còn từ các phần khác nhé bạn. :cuteonion38:
Đôi khi liên quan đến trigger về các phần thời gian lặp (time loop), với cách sử dụng set đi set lại một giá trị nhiều lần trong một giãn cách cực ngắn (<1s) thì cũng sẽ gây giật.
Và một số lúc khác ở trên map, bạn tạo quá nhiều đơn vị (unit), chết đi chết lại mà các bone của chúng ko được xử lí triệt để bằng cách remove những loại unit ko quan trọng đi như dummy, lính thường.:cuteonion40:
Hoặc giả khi chúng ta tạo cùng một lúc quá nhiều đơn vị (unit), hiệu ứng thời tiết, splat,... thì cũng có nguy cơ gây giật .:cuteonion37:
Cẩn thận với việc tạo quá nhiều Doodad tại một vị trí, quá nhiều cây cối, như vậy sẽ làm bản đồ của bạn rất giật vì phải xử lí vị trí của chúng, nên đặt nó hơi thưa ra nhưng phải trang trí sao cho cảnh vật vẫn mang điểm rậm rạp! :cuteonion9:
Xét lại một số hiệu ứng/ trạng thái dính kèm, đôi lúc một số hiệu ứng chứa Period time (hiệu ứng lặp lại mỗi lượng giây đã chỉnh sẵn), khi bạn chỉnh thời lượng này quá thấp (ex: 0 ~ 0.5s) thì có thể gây giật map khi ảnh hưởng hiệu ứng đó lên một hoặc nhiều mục tiêu . Điển hình là các buff như Soul Burn, Faerie, v.v... :1onion49::7onion8:

Chúc bạn thành công! Thân ! :)

tks. có lẽ là vậy. trog trigger mình cũng có khá nhiều chỗ như bạn nói
 
^
à lưu ý nhé bạn, phần time loop mình nói chỉ dành cho trường hợp bạn ko 'làm trống' giá trị đó thôi nhé, và đặc biệt là biến point,location xài rồi màk hk call RemoveLocation(<biến>) đó đi! :cuteonion4:
 
^
thích tạo nhiều nick quá ha (phòng hờ bị ban lấy ra xài giống em hả :"> :)))
cho em hỏi cách làm skill passive frost nova cho attacking unit
 
Mã:
library Devotion
globals
        private constant integer ABILID = 'A000'
        private constant integer DUMABILID = 'AOcr'
        private constant real TIME = 10
endglobals


private function CHANCE takes integer level returns real
        return 20.0 + ( 20.0 * level )
endfunction

function Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetAttackedUnitBJ(),ABILID) > 0
endfunction

function Actions takes nothing returns nothing
    local unit attacker = GetAttacker()
    local unit attacked = GetAttackedUnitBJ()
    local real random = GetRandomReal(0.0,100.0)
    local integer level = GetUnitAbilityLevel(attacked, ABILID)
    if random <= CHANCE then
    call UnitAddAbility(attacked, DUMABILID)
    call TriggerSleepAction(TIME)
    call UnitRemoveAbility(attacked, DUMABILID)
    endif
    set attacker = null
    set attacked = null
endfunction

//===========================================================================
function InitTrig_DevotionAura takes nothing returns nothing
    local trigger t
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(t, Condition(function Conditions)) 
    call TriggerAddAction(t, function Actions )
endfunction
endlibrary
cho em hỏi cái trigger này :|~ ....... s nó chạy 1 lần r` n~ lần s k thấy nó + 1000 armor nữa v. ạ :D ...... mặc dù e set CHANCE lv 4 = 100% r` vậy mà ra đúng 1 lần duy nhất thôi
 
Chỉnh sửa cuối:
cho mình hỏi cái nút Tick "Modifi Ally Priorities" bên phần Ally Priorities trong bảng Scenario Properties để làm gì vậy
 
cho em hỏi cái trigger này :|~ ....... s nó chạy 1 lần r` n~ lần s k thấy nó + 1000 armor nữa v. ạ :D ...... mặc dù e set CHANCE lv 4 = 100% r` vậy mà ra đúng 1 lần duy nhất thôi

1. nó ko MUI
2. giá trị CHANCE ko có, phải có local real ex=CHANCE(level), rồi mới so sánh random <= ex

~ Giải quyết:
Bạn nên học hỏi thêm một vài cách sử dụng các loại library và system liên quan đến timer để tích hợp với trigger jass MUI hiệu quả trong những trường hợp này. :7onion68:
 
Chỉnh sửa cuối:
Mã:
Secret Package
    Events
        Unit - A unit comes within 450.00 of Blacksmith 0104 <gen>
    Conditions
        ((Triggering unit) has an item of type Secret Package) Equal to True
    Actions
        Trigger - Turn off (This trigger)
        Set Hero_Weapon = True
        Trigger - Run Victory, ignore condition.
Mã:
Victory
    Events
    Conditions
    Actions
        Game Cache - Create a game cache from DOH04.w3v
        Game Cache - Store Hero_Weapon as Hero of Weapon in (Last created game cache)
        Game Cache - Save (Last created game cache)
        Game - Set the next level to DOH - 05.w3x
        Game - Show custom campaign button 5
        Game - Victory Player 1 (Red) (Show dialogs, Show scores)
Mã:
Load Hero
    Events
        Time - Elapsed game time is 0.00 seconds
    Conditions
    Actions
        Game Cache - Create a game cache from DOH04.w3v
        Set Hero_Weapon = (Is Boolean in gamecache (Last created game cache) with mission key Hero and key Weapon already stored)
2 trigger đầu của MAP A, trigger sau của MAP B. Đã save đầy đủ mà sao load MAP B biến Hero_Weapon luôn = false :-?
 
Có ai có thể cho mình xin cái demo map hướng dẫn làm ulti của Ursa (tăng damage theo % máu) trong Dota với, ngày trc có nhưng giờ tìm lại ko thấy đâu. Thanks!
 
Status
Không mở trả lời sau này.
Back
Top