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. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. 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.

Buying abilitys

Discussion in 'Trigger (GUI) Editor Tutorials' started by Parrothead, Aug 8, 2007.

  1. Parrothead

    Parrothead

    Joined:
    Jun 10, 2007
    Messages:
    778
    Resources:
    10
    Maps:
    8
    Tutorials:
    2
    Resources:
    10
    Buying Abilities

    Buying Abilities Through Items

    This tutorial will teach you how to make a system allowing the user to buy a skill from a shop (e.g. Avatar) through the purchase of a temporary item that will give you that skill. This can come in handy in games in which you wish for players to customize their heroes. For this tutorial I will use the Infernal and Dark Ritual spells.

    The Items
    First of all, make a dummy item for each skill you're adding, like this:
    Tut Image 1.png
    Basically, this will be the item the user buys when they want to learn a specific skill. You may modify any of the values to best suite your map. You will need a new item every time you want a different purchasable skill.

    Variables
    Next, you will need to create a trigger that gives you the spell, but before you create the triggers, you will need this variable:
    Tut Image 2.png
    Check 'array'. The variable stores most of the needed information, and you cannot make this trigger without it. To access the Variable Manager, go to the Trigger Editor and look for a green X, or press CTRL+B.
    After creating this variable and the object data, you will be ready to start making the trigger.

    One-level skills

    • Some Trigger
      • Events
        • Unit - A unit Acquires an item
      • Conditions
        • (Item-type of (Item being manipulated)) Equal to Summon Infernal
      • Actions
        • Set skill[(Player number of (Owner of triggering unit))] = Inferno
        • Wait 0.20 seconds
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Level of skill[(Player number of (Owner of triggering unit))] for (Triggering unit)) Less than 1
          • Then - Actions
            • Unit - Add skill[(Player number of (Owner of triggering unit))] to (Triggering unit)
            • Game - Display to (Player group((Owner of triggering unit))) for 10.00 seconds the text: You have bought the...
          • Else - Actions
            • Game - Display to (Player group((Owner of triggering unit))) for 5.00 seconds the text: You already have th...
            • Player - Add 350 to (Owner of triggering unit) Current lumber


    Ignore the parts cut off of the trigger - it is just telling you that you bought the skill. Now when somebody buys the Infernal item, it will add the skill to the hero/unit buying it and the item will disappear. This trigger will also give a refund if the spell is already learned. Make this trigger for every spell you want to sell at shops. The included condition is necessary. If you do not include it, whenever you buy any item it will give you the infernal spell, which is definitely not desirable.

    Leveling abilities from triggers

    For our example of a leveling ability, I will use the Dark Ritual spell.
    Again, a dummy item will be used. This item should be very similar to the item used for Infernal - the tooltips, gold cost, icon, etc, should be changed though (If desired).
    • Some Trigger
      • Events
        • Unit - A unit Acquires an item
      • Conditions
        • (Item-type of (Item being manipulated)) Equal to Dark Ritual
      • Actions
        • Set skill[(Player number of (Triggering player))] = Dark Ritual
        • Wait 0.20 seconds
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Level of skill[(Player number of (Owner of triggering unit))]for (Triggering unit)) Less than 1
          • Then - Actions
            • Unit - Add skill[(Player number of (Owner of triggering unit))] to (Triggering unit)
            • Game - Display to (All players) for 10.00 seconds the text: Dark Ritual Learned...
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Level of skill[(Player number of (Owner of triggering unit))] for (Triggering unit)) Less than 3
              • Then - Actions
                • Unit - Increase level of skill[(Player number of (Owner of triggering unit))] for (Triggering unit)
              • Else - Actions
                • Game - Display to (Player group((Owned of triggering unit))) for 5.00 seconds the text: This spell is...
                • Player - Add 100 to (Owner of triggering unit) Current lumber

    This would do the same exact thing as the infernal spell, but it will allow you to further level the ability by buying it multiple times. You can set a max on the trigger to also refund it if they attempt to buy the spell more times than the maximum ability level.

    Second Way

    There are lots of ways to do various things within the World Editor (like a cinematic, for example), and there is another way to do this as well. This way is somewhat easier (if you know how to manage variables) and can be more effective as it is more organized. Only continue if you know the World Editor beyond a novice level.
    Variable Setup
    First of all, we will need a lot of variables, and we will set them all in a single trigger, so right now create a trigger like this which we will use later.
    • Set Variables
      • Events
        • Time - Elapsed game time is 0.00 seconds
      • Conditions
      • Actions
        • -------- We will set our variables here. --------

    Now, we will need to create our variables. We will need one for skills, the items, and descriptions (optional).

    ScreenShotNum5.png

    Skills-Ability Array- Size 1-Value None
    Description-String Array- Size 1-Value None
    Item-Item-Type Array- Size 1-Value None

    Now that are variables are properly set, we may continue on. Go to the trigger you set up. Now we will place our variables in that trigger. Go to Action -> New Action -> All -> Set Variable by right clicking Actions.

    • Set Variables
      • Events
        • Time - Elapsed game time is 0.00 seconds
      • Conditions
      • Actions
        • -------- We will set our variables here. --------
        • -------- Each number corresponds to only 1 skill. So, the Inferno variable will ALWAYS be 0, and Dark Ritual will ALWAYS have 1. Do not change these up as you will experience glitches. --------
        • Set skills[0] = Inferno
        • Set skills[1] = Dark Ritual
        • Set Items[0] = Summon Infernal
        • Set Items[1] = Dark Ritual
        • Set Description[0] = <Your info here>
        • Set Description[1] = Dark Ritual is a level 1 normal ability with 3 levels.


    If you do not see square brackets to place numbers in your variables, then you didn't make the variable an array, and you must fix the variables. Do so by reading rereading the beginning of the tutorial.
    Keep setting variables for each item, skill, and description in this trigger. Now that this trigger is done and our variables are set, we may continue on.

    The Second Way - The Trigger

    We want it to make it so when a unit buys the item it will add the ability. Thus, make a new trigger. The event should be as follows:

    • Unit - A unit Acquires an item


    A generic event that is perfect for what we are doing. Make sure the items purchased in shops (Dark Ritual, Infernal) have there own category, I will use Powerup for mine. Now create this condition:

    • (Item-class of (Item being manipulated)) Equal to Powerup


    (Change Powerup to the category you have your purchasable items in) The item being manipulated is the one the object buys. Now to finish up this trigger, do these actions:

    • Actions
      • For each (Integer A) from 0 to <Last array slot you used>, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Items[(Integer A)] Equal to (Item-type of (Item being manipulated))
    • (Level of skill[(Player number of (Owner of triggering unit))]for (Triggering unit)) Less than 1
      • Then - Actions
    • Game - Display to (All players) for 1.00 seconds the text: Spell Learned...
    • Unit - Add skill[(Player number of (Owner of triggering unit))] to (Triggering unit)
      • Custom script: exitwhen true
      • Else - Actions
      • Game - Display to (Player group((Owned of triggering unit))) for 5.00 seconds the text: This spell is...
      • Player - Add [Gold Amount] to (Owner of triggering unit) Current lumber


    DOWNLOAD DEMO

    Edits

    Edit1: Did what Steel_Cold Suggested.
    Edit2: Added more information and used trigger tags.
    Edit3: Made it more clear and simple (Will add the second way to do this).
    Edit4: Added a second way to do this and 2 mirrors to download the demo.
    Edit5: Added another variable screenshot and fixed up way one a tad.
    Edit6: Fixed up way one again and added text part to way number 2.
    Edit7: Finalized way 2 actions so that it will get approved.
    Edit8: Engrish improved from 3 years ago: the tutorial is now better understandable :D.

    ~Thanks to everyone who helped in this tutorial (Including Purplepoot, myself, and some people who suggested content to be placed here)
     
    Last edited: Oct 23, 2010
  2. Steel_Cold

    Steel_Cold

    Joined:
    Apr 16, 2005
    Messages:
    154
    Resources:
    0
    Resources:
    0
    You could also include in the tutorial a way to level up the abilities through buying them
     
  3. wyrmlord

    wyrmlord

    Joined:
    Oct 13, 2005
    Messages:
    252
    Resources:
    5
    Tools:
    1
    Maps:
    1
    Tutorials:
    3
    Resources:
    5
    Here are my suggestions:
    • I would suggest using
      • tags for the triggers instead of posting the images of them. [*]In addition, I recommend you explain in some detail what each trigger does because all you're doing right now is just posting triggers with very little or no information.
      • [/LIST]
     
  4. Parrothead

    Parrothead

    Joined:
    Jun 10, 2007
    Messages:
    778
    Resources:
    10
    Maps:
    8
    Tutorials:
    2
    Resources:
    10
    Updated
     
  5. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    I myself don't care a lot about spelling errors in posts, but in a tutorial you should not make such errors as "dissapear" or "there" instead of "their".

    Now that you used trigger tags, you can remove the attachments. Other than that, it's a useful tutorial to newbies I guess
     
  6. Ivanneth

    Ivanneth

    Joined:
    Jun 1, 2006
    Messages:
    254
    Resources:
    4
    Maps:
    4
    Resources:
    4
    Nice enough, I guess. Reminds me of TGS ... ;)
    Maybe, though, you should go into more detail, so that people that just started triggering, or aren't so good with some things, can understand it better.
     
  7. Parrothead

    Parrothead

    Joined:
    Jun 10, 2007
    Messages:
    778
    Resources:
    10
    Maps:
    8
    Tutorials:
    2
    Resources:
    10
    Will this get approved?
     
  8. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,162
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    The method could be majorly improved, eg;

    -Create an ability array, Skills
    -Create an Item-type array, Items
    -Create a string array, descriptions

    • Init
      • Events
        • Map Initialization
      • Conditions
      • Actions
        • Set Skills[0] = Dark Ritual
        • Set Items[0] = Purchase Dark Ritual
        • Set Descriptions[0] = "Dark Ritual"
        • Set Skills[1] = Frost Nova
        • Set Items[0] = Purchase Frost Nova
        • Set Descriptions[1] = "Frost Nova"
        • ...


    • Buy
      • Events
        • Unit - A Unit Acquires an Item
      • Conditions
        • (Item-class of (Acquired Item)) Equal to <item class for purchased skills>
      • Actions
        • For Each Integer A from 0 to <last slot in the Skills array>, do Actions
          • Loop - Actions
            • If (All Conditions are True) Then do (Then actions) Else do (Else actions)
              • If - Conditions
                • Items[(For Loop Integer A)] Equal to (Item-Type of (Acquired Item))
              • Then - Actions
                • -------- add all the add ability stuff here, display message from Descriptions[0] --------
                • Custom script: exitwhen true
              • Else - Actions


    The wait in your above trigger makes it unweildy, also the fact that you would either have to have a trigger for every item, or a giant mass of if-statements.
     
  9. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,162
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    ~Revive~

    Well?
     
  10. Parrothead

    Parrothead

    Joined:
    Jun 10, 2007
    Messages:
    778
    Resources:
    10
    Maps:
    8
    Tutorials:
    2
    Resources:
    10
    Ill try to update it.

    Edit: Updated the tutorial with fixed spelling mistakes (some didnt catch most), I added the second way to add to do this (Thx PurplePoop +Repz0r) Fixed up the triggers and organized the tutorial, Hopefully it may have a chance at approval now. I made 2 ways to do it (1 is harder but better for people who want really dont wand to use variables) and 2 (uses variables and harder things but is easier to do). Added 2 download mirrors incase of one not working ( I dont know why) :smile:
     
    Last edited: Nov 1, 2007
  11. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,162
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    It could still use some polish (spelling, readability, etc) - I could tweak it, if you so desire.
     
  12. Parrothead

    Parrothead

    Joined:
    Jun 10, 2007
    Messages:
    778
    Resources:
    10
    Maps:
    8
    Tutorials:
    2
    Resources:
    10
    Do what you want with it :)
     
  13. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,162
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    I finally got around to updating it - now, it could use some more work on your part.

    • In way 1, you use Triggering Player. This will not work in this case (a Unit triggers the event) - you will need Owner of (Triggering Unit).
    • Could you please actually include the most useful actions for the Second way (i.e. the part where it actually displays the message and such - people reading the tutorial may want to know that)?
     
  14. Parrothead

    Parrothead

    Joined:
    Jun 10, 2007
    Messages:
    778
    Resources:
    10
    Maps:
    8
    Tutorials:
    2
    Resources:
    10
    Fixed up way one, going to school so I will do way 2 later.
     
  15. sonkan1

    sonkan1

    Joined:
    Jan 18, 2007
    Messages:
    333
    Resources:
    0
    Resources:
    0
    This toto is verry mutch like mine... (merged into the secrets of the spell book) so i think this one also shuld get merged! its kinda complicated....
    nice though.
     
  16. Parrothead

    Parrothead

    Joined:
    Jun 10, 2007
    Messages:
    778
    Resources:
    10
    Maps:
    8
    Tutorials:
    2
    Resources:
    10
    Updated Again :).
     
  17. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,162
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    In "The Second Way",

    • You need to do stuff before the "exitwhen true"
    • You don't actually add the ability or anything, just display a message.
     
  18. Parrothead

    Parrothead

    Joined:
    Jun 10, 2007
    Messages:
    778
    Resources:
    10
    Maps:
    8
    Tutorials:
    2
    Resources:
    10
    Updated once more.
     
  19. Archian

    Archian

    Site Director

    Joined:
    Jan 1, 2006
    Messages:
    2,781
    Resources:
    12
    Skins:
    1
    Tutorials:
    11
    Resources:
    12
    ~Thread Approved.
     
  20. underscore

    underscore

    Joined:
    Mar 17, 2008
    Messages:
    150
    Resources:
    0
    Resources:
    0
    Is this like the spell system in Imagica ORPG? Where in you buy an orb?