1. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  2. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  3. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  4. Shoot to thrill, play to kill. Sate your hunger with the 33rd Modeling Contest!
    Dismiss Notice
  5. Do you hear boss music? It's the 17th Mini Mapping Contest!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Help with trigger!

Discussion in 'Triggers & Scripts' started by Watcher, Feb 27, 2018.

  1. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Hi guys,

    I have one problem with this trigger, how to make it mui?

    Trigger explanation: When u research research named "Afterlife" all of triggering players "Witches" should transform into "Banshess", but now it transforms all witches on the map into banshees, not just the triggering players...

    Need some help pls :(

    Trigger

    • Banshees
      • Events
        • Unit - A unit Finishes research
      • Conditions
        • (Researched tech-type) Equal to Afterlife
      • Actions
        • Set banshees = (Units of type Witch)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
          • Then - Actions
            • Unit Group - Pick every unit in banshees and do (Actions)
              • Loop - Actions
                • Unit - Replace (Picked unit) with a Banshee (forsaken) using The new unit's default life and mana
            • Custom script: call DestroyGroup (udg_banshees)
          • Else - Actions

     
  2. Rheiko

    Rheiko

    Joined:
    Aug 27, 2013
    Messages:
    2,926
    Resources:
    7
    Icons:
    2
    Spells:
    3
    Tutorials:
    2
    Resources:
    7
    Why bother creating a trigger for it when you can just use upgrades? Try to base it on Berserker Upgrade.
     
  3. david200923

    david200923

    Joined:
    May 12, 2015
    Messages:
    32
    Resources:
    0
    Resources:
    0
    • Banshees
      • Events
        • Unit - A unit Finishes research
      • Conditions
        • (Researched tech-type) Equal to Afterlife
      • Actions
        • Set banshees = (Units owned by (Triggering player) of type Witch)
        • Unit Group - Pick every unit in banshees and do (Actions)
          • Loop - Actions
            • Unit - Replace (Picked unit) with a Banshee (forsaken) using The new unit's default life and mana
        • Custom script: call DestroyGroup (udg_banshees)
     
  4. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,523
    Resources:
    9
    Models:
    1
    Icons:
    2
    Maps:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    9
    Don't forget the GUI magic trick!

    • Custom Script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units owned by (Triggering player) of type Witch) and do (Actions)
      • Loop - Actions
        • Unit - Replace (Picked unit) with a Banshee (forsaken) using The new unit's default life and mana
     
  5. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Thank you for help guys!

    @MyPad Isn't this "Custom Script: set bj_wantDestroyGroup = true" same as this "Custom script: call DestroyGroup (udg_banshees)" ?
     
  6. Rheiko

    Rheiko

    Joined:
    Aug 27, 2013
    Messages:
    2,926
    Resources:
    7
    Icons:
    2
    Spells:
    3
    Tutorials:
    2
    Resources:
    7
    Yup and you can shorten the code with that magic trick.
     
  7. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Ooooh I get it now, thank you for clarification m8 :D
     
  8. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,532
    Resources:
    23
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    5
    JASS:
    3
    Resources:
    23
    Hm, but Rheiko's suggestion does sound good, too, maybe even more elegant. Maybe not very important for you in this specific case, but usually it might be not prefered if units are removed and re-placed with a new creation. If the unit morphs, or changes form with maybe an other ability, then references to units get not lost, and handle id does not change (maybe important for hashtable entries).
     
  9. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Totally forgot about Berseker Upgrade until Rheiko mentioned it, but for now this trigger works properly and it will, until I try to do and insert more complicated things into my map (hashtables for example), since I am just grasping and learning the basics of triggering (best things I can do for now are arrays and very simple systems).

    But thanks for your tips IcemanBo :D
     
  10. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,523
    Resources:
    9
    Models:
    1
    Icons:
    2
    Maps:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    9
    As to how I initially interpreted it...

    No, the keyword is not the same. You use the "set" keyword when assigning variables and "call" when calling functions in JASS.

    Example:

    Code (Text):

    // Pseudocode
    // This is a variable
    real someVar = 0

    // This is a function
    function newVar(real r)
        set someVar = r

    ...

    function foo()
        // We're assigning the variable directly to a value
        set someVar = 2.5

        // We're calling a function, so we use the "call" keyword.
        call newVar(2.5)
     


    When I re-read the message...

    Operationally, in-game, behavior would be identical.


    After reading the rest...

    Tried that trick, which somehow did not really suit me. Personal Preference. Best of wishes in your journey to triggering!
     
  11. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Funny explanation haha, but yeah I will just stick to the function calls.

    Thank you m8, best wishes 2u2! :D