Giúp làm trigger chọn tướng

  • Thread starter Thread starter boss9x
  • Ngày gửi Ngày gửi

boss9x

Mr & Ms Pac-Man
Tham gia ngày
22/8/08
Bài viết
269
Reaction score
152
Mình muốn lànhưng nghĩ mãi ko ra nếu như làm nhiều trigger bằng m trigger chọn tướng bằng doubleclick (do mình ngu vụ jass) cách set giá trị thì ok nhưng mình muốn làm gộp lại chỉ vài ba trigger thôi có ai biết cách làm ko
 
sao không làm cách chọn tướng = cách cho 1 uint đi vào 1 vòng tròn rồi chọn được tướng ý như thế nó đơn giản hơn =...= mà bạn post nhầm chỗ rồi lên topic hỏi đáp mà post post ở đây thế nào cũng bị mod khiển trách O.O
 
lên đó biết đời nào mới được trả lời nhiều bài quá ai mà quan tâm đến chứ mình muốn làm click nhìn sẽ hay hơn mình ko thích kiểu truyền thống giống dday ton thời gian select
 
Đầu tiên ta cần tạo 2 region: HeroSelectArea (nơi chọn hero) và HeroSpawnPlace (nơi hero ra)
Hai biến chính:
CurrentSelectedUnit là unit và có array, biến này để xem unit nào đã được ấn vào.
HasSelectedHero là boolean và có array, biến này để xem player đã chọn hero chưa.
----
Đặt các hero muốn select vào khu vực HeroSelectArea
----
  • Trigger đầu tiên:

    Mã:
    HeroSelect Init
        Events
            Time - Elapsed game time is 0.00 seconds
        Conditions
        Actions
            For each (Integer A) from 1 to 12, do (Actions)
                Loop - Actions
                    Set TempInt = (Integer A)
                    Set CurrentSelectedUnit[TempInt] = No unit
                    Set HasSelectedHero[TempInt] = False
                    Trigger - Add to HeroSelect Click <gen> the event (Player - (Player(TempInt)) Selects a unit)
                    Trigger - Add to HeroSelect Repick <gen> the event (Player - (Player(TempInt)) types a chat message containing -repick as An exact match)
            Wait 60.00 seconds
            -------- turn off repick --------
            Trigger - Turn off HeroSelect Repick <gen>

    Trigger trên đặt "giá trị khởi tạo" tại index 1->12 của các biến CurrentSelectedUnitHasSelectedHero là No unit và False
    đồng thời "add event" cho 2 trigger HeroSelect ClickHeroSelect Repick
    sau đó đợi 60 giây đề tắt trigger repick đi
  • Trigger thứ 2: HeroSelect Description
    - trigger này hơi dài nên Tom sẽ ko post.
    - cơ bản là, khi chạy trigger này (mà ko kiểm tra điều kiện) thì TempString sẽ là tên (với chữ viết thường tất) của TempUnit (đã được đặt trước khi chạy trigger) và TempForce là "player group" mà chỉ có một player là TempPlayer (đã được đặt từ trước)
    - sau đó kiểm tra TempString để biết được dòng chữ sẽ xuất hiện trên màn hình, là "giới thiệu về hero" đã ấn
    - cuối cùng là xóa TempForce để tránh leak
  • Trigger thứ 3:

    Mã:
    HeroSelect Click
        Events
        Conditions
            (Owner of (Triggering unit)) Equal to Neutral Passive
            ((Triggering unit) is A Hero) Equal to True
        Actions
            Set TempPlayer = (Triggering player)
            Set TempUnit = (Triggering unit)
            Set TempInt = (Player number of TempPlayer)
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                    HasSelectedHero[TempInt] Equal to True
                Then - Actions
                    -------- this player has already selected a hero, no need to run the trigger any further --------
                    Skip remaining actions
                Else - Actions
            -------- --------------- --------
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                    CurrentSelectedUnit[TempInt] Equal to TempUnit
                Then - Actions
                    Set CurrentSelectedUnit[TempInt] = No unit
                    -------- second click --------
                    Set HasSelectedHero[TempInt] = True
                    -------- unit type of TempUnit is the unit that the player has chosen, now create hero for him/her --------
                    Set TempPoint = (Center of HeroSpawnPlace <gen>)
                    Unit - Create 1 (Unit-type of TempUnit) for TempPlayer at TempPoint facing Default building facing degrees
                    Set TempUnit = (Last created unit)
                    Selection - Select TempUnit for TempPlayer
                    Camera - Pan camera for TempPlayer to TempPoint over 0.10 seconds
                    Set TempForce = (Player group(TempPlayer))
                    Cinematic - Clear the screen of text messages for TempForce
                    Custom script:   call DestroyForce( udg_TempForce )
                    Game - Display to (All players) the text: ((Name of TempPlayer) + ( has picked  + (Name of TempUnit)))
                    Custom script:   call RemoveLocation( udg_TempPoint )
                    -------- a little special effect won't hurt  --------
                    Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
                    Special Effect - Destroy (Last created special effect)
                Else - Actions
                    -------- first click --------
                    Animation - Play TempUnit's Attack animation
                    Animation - Queue TempUnit's stand animation
                    Trigger - Run HeroSelect Description <gen> (ignoring conditions)
                    Set CurrentSelectedUnit[TempInt] = TempUnit

    - event của trigger này đã được thêm vào nhờ trigger HeroSelect Init
    - điều kiênh ở đây kiểm tra "owner" (người sở hữu) của unit bị click vào có phải là Neutral Passive ko và dĩ nhiên unit bị ấn vào sẽ phải là một hero
    - action thì kiểm tra xem player (mà click vào unit) đã chọn hero chưa, chọn rồi thì "skip". Chưa chọn thì xem unit đang bị ấn vào có phải là CurrentSelectedUnit (unit đã bị ấn vào) hay ko. Nếu ko thì cho unit bị ấn vào "attack" 1 cái và chạy trigger HeroSelect Description để biết thông tin về hero. Nếu đúng là unit đã bị ấn vào từ trước (giờ là "double click" rồi đó) thì tạo hero thôi, thêm vài hiệu ứng đặc biệt, camera...
  • Trigger thứ 4:
    Mã:
    HeroSelect Repick
        Events
        Conditions
        Actions
            Set TempPlayer = (Triggering player)
            Set TempInt = (Player number of TempPlayer)
            Set HasSelectedHero[TempInt] = False
            Set CurrentSelectedUnit[TempInt] = No unit
            Set TempGroup = (Units owned by TempPlayer matching (((Matching unit) is A Hero) Equal to True))
            Unit Group - Pick every unit in TempGroup and do (Actions)
                Loop - Actions
                    Set TempUnit = (Picked unit)
                    Unit - Remove (Picked unit) from the game
            Game - Display to (All players) the text: ((Name of TempPlayer) + ( has repicked  + (Name of TempUnit)))
            Set TempPoint = (Center of HeroSelectArea <gen>)
            Camera - Pan camera for TempPlayer to TempPoint over 0.10 seconds
            Custom script:   call RemoveLocation( udg_TempPoint )

    - như trên, event của trigger này đã được thêm vào nhờ trigger HeroSelect Init
    - điều kiện: cần thì thêm
    - action: phải đặt biến HasSelectedHero = false vì chọn lại hero -> coi như chưa chọn. Rồi "pick" tất cả hero của player đã gõ -repick rồi remove, pan camera tới HeroSelectArea

Có gì chưa rõ cứ xem demo map :)>-

EDIT: Chống chọn hero giống nhau và có 2 nơi "spawn" hero
pick với -random
 

Attachments

cảm ơn bạn mình làm được rồi nhưng ko biết có chống chọn giống nhau ko vậy
 
Cách này là chọn Hero ở 1 team, nếu có 2 team thì làm thế nào hả Tom? Ý mình là nếu có 2 HeroSelectArea và 2 HeroSpawnPlace khác nhau, hoặc 1 HeroSelectArea và 2 HeroSpawnPlace thì làm ntn?
 
cảm ơn bạn mình làm được rồi nhưng ko biết có chống chọn giống nhau ko vậy

Trong trigger thứ 3:
Mã:
HeroSelect Click
    Events
    Conditions
        (Owner of (Triggering unit)) Equal to Neutral Passive
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Set TempPlayer = (Triggering player)
        Set TempUnit = (Triggering unit)
        Set TempInt = (Player number of TempPlayer)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                HasSelectedHero[TempInt] Equal to True
            Then - Actions
                -------- this player has already selected a hero, no need to run the trigger any further --------
                Skip remaining actions
            Else - Actions
        -------- --------------- --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                CurrentSelectedUnit[TempInt] Equal to TempUnit
            Then - Actions
                Set CurrentSelectedUnit[TempInt] = No unit
                -------- second click --------
                Set HasSelectedHero[TempInt] = True
                -------- unit type of TempUnit is the unit that the player has chosen, now create hero for him/her --------
                Set TempPoint = (Center of HeroSpawnPlace <gen>)
                [B]Unit - Create 1 (Unit-type of TempUnit) for TempPlayer at TempPoint facing Default building facing degrees[/B]
                Set TempUnit = (Last created unit)
                Selection - Select TempUnit for TempPlayer
                Camera - Pan camera for TempPlayer to TempPoint over 0.10 seconds
                Set TempForce = (Player group(TempPlayer))
                Cinematic - Clear the screen of text messages for TempForce
                Custom script:   call DestroyForce( udg_TempForce )
                Game - Display to (All players) the text: ((Name of TempPlayer) + ( has picked  + (Name of TempUnit)))
                Custom script:   call RemoveLocation( udg_TempPoint )
                -------- a little special effect won't hurt  --------
                Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
                Special Effect - Destroy (Last created special effect)
            Else - Actions
                -------- first click --------
                Animation - Play TempUnit's Attack animation
                Animation - Queue TempUnit's stand animation
                Trigger - Run HeroSelect Description <gen> (ignoring conditions)
                Set CurrentSelectedUnit[TempInt] = TempUnit

sau dòng in đậm đó, thêm Unit - Remove TempUnit from the game.
---------------------------------------------------------------------------

YAN[asian];11553328 nói:
Cách này là chọn Hero ở 1 team, nếu có 2 team thì làm thế nào hả Tom? Ý mình là nếu có 2 HeroSelectArea và 2 HeroSpawnPlace khác nhau, hoặc 1 HeroSelectArea và 2 HeroSpawnPlace thì làm ntn?

cũng trong trigger trên:

Mã:
HeroSelect Click
    Events
    Conditions
        (Owner of (Triggering unit)) Equal to Neutral Passive
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Set TempPlayer = (Triggering player)
        Set TempUnit = (Triggering unit)
        Set TempInt = (Player number of TempPlayer)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                HasSelectedHero[TempInt] Equal to True
            Then - Actions
                -------- this player has already selected a hero, no need to run the trigger any further --------
                Skip remaining actions
            Else - Actions
        -------- --------------- --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                CurrentSelectedUnit[TempInt] Equal to TempUnit
            Then - Actions
                Set CurrentSelectedUnit[TempInt] = No unit
                -------- second click --------
                Set HasSelectedHero[TempInt] = True
                -------- unit type of TempUnit is the unit that the player has chosen, now create hero for him/her --------
                [B]Set TempPoint = (Center of HeroSpawnPlace <gen>)[/B]
                Unit - Create 1 (Unit-type of TempUnit) for TempPlayer at TempPoint facing Default building facing degrees
                Set TempUnit = (Last created unit)
                Selection - Select TempUnit for TempPlayer
                Camera - Pan camera for TempPlayer to TempPoint over 0.10 seconds
                Set TempForce = (Player group(TempPlayer))
                Cinematic - Clear the screen of text messages for TempForce
                Custom script:   call DestroyForce( udg_TempForce )
                Game - Display to (All players) the text: ((Name of TempPlayer) + ( has picked  + (Name of TempUnit)))
                Custom script:   call RemoveLocation( udg_TempPoint )
                -------- a little special effect won't hurt  --------
                Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
                Special Effect - Destroy (Last created special effect)
            Else - Actions
                -------- first click --------
                Animation - Play TempUnit's Attack animation
                Animation - Queue TempUnit's stand animation
                Trigger - Run HeroSelect Description <gen> (ignoring conditions)
                Set CurrentSelectedUnit[TempInt] = TempUnit

dòng in đậm đó là dòng lấy vị trí "spawn" của hero
vậy thay dòng đó bằng:
Mã:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (TempPlayer is an ally of <một player nào đó trong team 1>) Equal to True
    Then - Actions
         Set TempPoint = (Center of HeroSpawnPlace1 <gen>)
    Else - Actions
         Set TempPoint = (Center of HeroSpawnPlace2 <gen>)

HeroSpawnPlace1 là nơi "spawn" hero của team 1
nếu TempPlayer là "ally" của 1 player nào đó trong team 1 thì sẽ tạo hero ra ở vị trí spawn hero của team 1.
Ngoài ra có thể tạo 2 biến Player Group và cho các player thuộc team 1 vào player group 1, player team 2 vào player group 2 sau đó dùng lệnh Player - Player In Player Group để kiểm tra.

nếu TempPlayer "ko thuộc team 1" thì chắc sẽ thuộc team 2, vì vậy điểm spawn hero sẽ là giữa region HeroSpawnPlace2
 
1 câu hỏi nhỏ nữa : Nếu thêm lệnh -random (ko phải -ar nhé) vào trigger chọn tướng theo kiểu này thì làm ntn?
 
Mã:
Set TempGroup = (Units in (HeroSelectArea <gen>) matching ((((Matching unit) is A Hero) Equal to True) and ((Owner of (Matching unit)) Equal to Neutral Passive)))
Set TempUnit = (Random unit from TempGroup)
Custom script:   call DestroyGroup( udg_TempGroup )

HeroSelectArea <- là region chứa các hero để pick

sau khi TempUnit được "nhặt" random thì cứ tiếp tục xác định vị trí tạo hero, tạo,... như đã "click 2 lần" ở trigger HeroSelect Click.
 
Làm thế này xong ko biết thiếu j mà -random ko đc :

Mã:
Random All Heroes
    Events
        Player - Player 1 (Red) types a chat message containing -random as An exact match
        Player - Player 2 (Blue) types a chat message containing -random as An exact match
        Player - Player 3 (Teal) types a chat message containing -random as An exact match
        Player - Player 4 (Purple) types a chat message containing -random as An exact match
        Player - Player 5 (Yellow) types a chat message containing -random as An exact match
        Player - Player 6 (Orange) types a chat message containing -random as An exact match
        Player - Player 7 (Green) types a chat message containing -random as An exact match
        Player - Player 8 (Pink) types a chat message containing -random as An exact match
    Conditions
    Actions
        Set TempGroup = (Units in HeroSelectArea <gen> matching ((((Matching unit) is A Hero) Equal to True) and ((Owner of (Matching unit)) Equal to Neutral Passive)))
        Set TempUnit = (Random unit from TempGroup)
        Custom script:   call DestroyGroup( udg_TempGroup )
 
sau khi TempUnit được "nhặt" random thì cứ tiếp tục xác định vị trí tạo hero, tạo,... như đã "click 2 lần" ở trigger HeroSelect Click.

vậy là cái này của tôi bị bỏ luôn @-)

chắc cái gì tôi cũng phải viết ra mất 8-|
Mã:
Random All Heroes
    Events
        Player - Player 1 (Red) types a chat message containing -random as An exact match
        Player - Player 2 (Blue) types a chat message containing -random as An exact match
        Player - Player 3 (Teal) types a chat message containing -random as An exact match
        Player - Player 4 (Purple) types a chat message containing -random as An exact match
        Player - Player 5 (Yellow) types a chat message containing -random as An exact match
        Player - Player 6 (Orange) types a chat message containing -random as An exact match
        Player - Player 7 (Green) types a chat message containing -random as An exact match
        Player - Player 8 (Pink) types a chat message containing -random as An exact match
    Conditions
    Actions
        Set TempPlayer = (Triggering player)
        Set TempInt = (Player number of TempPlayer)
        Set TempGroup = (Units in HeroSelectArea <gen> matching ((((Matching unit) is A Hero) Equal to True) and ((Owner of (Matching unit)) Equal to Neutral Passive)))
        Set TempUnit = (Random unit from TempGroup)
        Custom script:   call DestroyGroup( udg_TempGroup )
        -------- có TempUnit rồi thì cũng làm như đã pick = double click thôi --------
        Set HasSelectedHero[TempInt] = True
        -------- unit type of TempUnit is the unit that the player has chosen, now create hero for him/her --------
        Set TempPoint = (Center of HeroSpawnPlace <gen>)
        Unit - Create 1 (Unit-type of TempUnit) for TempPlayer at TempPoint facing Default building facing degrees
        Unit - Remove TempUnit from the game
        Set TempUnit = (Last created unit)
        Selection - Select TempUnit for TempPlayer
        Camera - Pan camera for TempPlayer to TempPoint over 0.10 seconds
        Set TempForce = (Player group(TempPlayer))
        Cinematic - Clear the screen of text messages for TempForce
        Custom script:   call DestroyForce( udg_TempForce )
        Game - Display to (All players) the text: ((Name of TempPlayer) + ( has picked  + (Name of TempUnit)))
        Custom script:   call RemoveLocation( udg_TempPoint )
        -------- a little special effect won't hurt  --------
        Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
        Special Effect - Destroy (Last created special effect)
 
có thể làm hệ thống kich người chơi giống cf ko vậy
 
có thể làm hệ thống kich người chơi giống cf ko vậy

những hệ thống như vậy cần nhiều player (4 ng` là ít) để test nên tạo xong cũng chả biết nó có hoạt động hay ko 8-}

=> cứ tạm cho là "chưa làm đc" đi
 
có hệ thống Voting Kick System đây , nhưng chả biết có dùng đc hay ko nữa :|
Đây nè
 
vậy là cái này của tôi bị bỏ luôn @-)

chắc cái gì tôi cũng phải viết ra mất 8-|

[/CODE]

Bạn thông cảm, tại mình chưa hiểu hết ý bạn nói. Mới làm quen với trigger mà tự viết hết đc bằng đấy dòng thì đúng là mình ko thể, làm phiền bạn vậy :).
 
Back
Top