1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Choose your ride to damnation in the 5th Special Effect Contest Poll.
    Dismiss Notice
  5. The winners of the 13th Techtree Contest have been announced!
    Dismiss Notice
  6. The 13th Music Contest Poll is up! Vote for the best tracks in this symphony of frost and flame.
    Dismiss Notice
  7. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  8. 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.

Mixing Units (into a better one)

Discussion in 'World Editor Help Zone' started by CRAZY-PENGUIN, Aug 8, 2008.

  1. CRAZY-PENGUIN

    CRAZY-PENGUIN

    Joined:
    Aug 7, 2008
    Messages:
    114
    Resources:
    0
    Resources:
    0
    I want to know ,how to make lot of units of the same type enter in a specific region and becomes another unit stronger

    example : 3 militia enters in a region and becomes 1 footman
     
  2. HermanTheGibbon

    HermanTheGibbon

    Joined:
    May 27, 2007
    Messages:
    174
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Reminds me of good ole' commando wars :D

    Anyhoo, here's how I would do it basically:

    • Untitled Trigger 001
      • Events
        • Unit - A unit enters (Your Region) <gen>
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to Militia
      • Actions
        • Unit Group - Add (Triggering unit) to MilitiaUnitGroup
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in MilitiaUnitGroup) Equal to 3
          • Then - Actions
            • Unit Group - Pick every unit in MilitiaUnitGroup and do (Actions)
              • Loop - Actions
                • Unit - Remove (Picked unit) from the game
                • Unit Group - Remove all units of MilitiaUnitGroup from MilitiaUnitGroup
                • Unit - Create 1 Footman for (Owner of (Triggering unit)) at (Center of Region 000 <gen>) facing Default building facing degrees
          • Else - Actions
            • Do nothing


    That should work in the majority of cases. Might get buggered if you have a ridiculous amount of militia pouring into the region at once but it would take me a while to figure out a more effective and reliable way of doing it.

    MilitiaUnitGroup is just a simple Unit Group variable.
     
  3. Squiggy

    Squiggy

    Joined:
    Mar 25, 2008
    Messages:
    2,627
    Resources:
    18
    Maps:
    2
    Spells:
    15
    Tutorials:
    1
    Resources:
    18
    And don't do the 'do nothing'
     
  4. CRAZY-PENGUIN

    CRAZY-PENGUIN

    Joined:
    Aug 7, 2008
    Messages:
    114
    Resources:
    0
    Resources:
    0
    Hmm nice post, thanks ill try it later if it works i change to solved and i reply! cya

    Well i tested and didnt work. =/
    Look
    [​IMG]

    Check it and reply,THANKS !

    is my mixunitgroup correct ? it is unit group...maybe the problem is the initial value !
     
    Last edited by a moderator: Aug 8, 2008
  5. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    You shouldn't store them in a permanent group.

    Just enum when a unit enters the area.

    ~Triple post merged
     
  6. CRAZY-PENGUIN

    CRAZY-PENGUIN

    Joined:
    Aug 7, 2008
    Messages:
    114
    Resources:
    0
    Resources:
    0
    Nobody knows what problem am i having with my trigger ?





    the image is above.
     
  7. YoshiRyu

    YoshiRyu

    Joined:
    Jun 26, 2007
    Messages:
    686
    Resources:
    0
    Resources:
    0
    global variable : integer militia_count (default value : 0)

    • Militia enter a region
      • Events
        • Unit - A unit enters a region <gen>
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to Militia
      • Actions
        • Custom script: local location udg_tmploc
        • Set militia_count = (militia_count + 1)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • militia_count Equal to 3
          • Then - Actions
            • Unit group - Pick every unit in (Units in a region <gen>) and do (Actions)
              • Loop - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Unit-type of (Picked unit)) Equal to Militia
                  • Then - Actions
                    • Unit - Remove (Picked unit) from the game
            • Set tmploc = (Center of a region <gen>)
            • Unit - Create 1 Footman for (Owner of (Triggering unit)) at tmploc facing 0.00 degrees
            • Custom script: call RemoveLocation(udg_tmploc)
            • Set militia_count = 0

    (i've removed the else to make it easier to read)

    • Militia leaves a region
      • Events
        • Unit - A unit leaves a region <gen>
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to Militia
      • Actions
        • Set militia_count = (militia_count - 1)
     
  8. turaak

    turaak

    Joined:
    Mar 13, 2008
    Messages:
    129
    Resources:
    0
    Resources:
    0
    why did u set tmploc local?
     
  9. YoshiRyu

    YoshiRyu

    Joined:
    Jun 26, 2007
    Messages:
    686
    Resources:
    0
    Resources:
    0
    why i shouldn't ?
     
  10. turaak

    turaak

    Joined:
    Mar 13, 2008
    Messages:
    129
    Resources:
    0
    Resources:
    0
    why should u?
    it won't interfere because there are no waits so it all fires at once...
    i think...^^
     
  11. YoshiRyu

    YoshiRyu

    Joined:
    Jun 26, 2007
    Messages:
    686
    Resources:
    0
    Resources:
    0
    to avoid storing a point which is use 0.01s in the memory all along the game execution...
    this variable is only use inside the trigger, that's somthing you can call "local use"...
    so i use a local variable for a local use, logic, isn't it ? ^^
     
  12. turaak

    turaak

    Joined:
    Mar 13, 2008
    Messages:
    129
    Resources:
    0
    Resources:
    0
    my bad,didn't know that "storing a point which is use 0.01s in the memory all along the game execution"^^
     
  13. YoshiRyu

    YoshiRyu

    Joined:
    Jun 26, 2007
    Messages:
    686
    Resources:
    0
    Resources:
    0
    my bad too, to be precise, that a "point's pointer" which is stored
    (it's a little smaller than an point ^^)

    but anyway, that's something very small, it's just a use of mine

    EDIT : not sure of my english
    by "a use of mine" i want to mean "something i'm used to do"
     
  14. turaak

    turaak

    Joined:
    Mar 13, 2008
    Messages:
    129
    Resources:
    0
    Resources:
    0
    lol, i'll use locals more often now, tnx
     
  15. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    I'm sorry Yosh, but I have to agree that there's no *point* in using a local point variable here.
     
  16. YoshiRyu

    YoshiRyu

    Joined:
    Jun 26, 2007
    Messages:
    686
    Resources:
    0
    Resources:
    0
    <stop the flood !>
    using local or global here is EXACTLY the same (except for some insignificant details)
    i prefer using local, that's a choice, that's only a choice, that's nothing more than a choice, and that's my choice and just mine, no need to argue about that during hours, thanks
     
  17. CRAZY-PENGUIN

    CRAZY-PENGUIN

    Joined:
    Aug 7, 2008
    Messages:
    114
    Resources:
    0
    Resources:
    0
    Hmm thanks all,