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. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. The results are out! Check them out.
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    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.

How to start this trigger (buffs)

Discussion in 'World Editor Help Zone' started by Paulus, Dec 4, 2014.

  1. Paulus

    Paulus

    Joined:
    Jan 17, 2014
    Messages:
    155
    Resources:
    0
    Resources:
    0
    Hi y'all,

    Im making a unit who has 3 spells. Each spell gives a buff. And when the first buff is placed, a timer should go for 5 sec. After that timer is finished, the trigger should look at the unit and count howmany buffs there are (1,2 or 3). Then (optinal: remove the buffs and) give damage equal to the buffs. Like 50 damage for 1 buff, 125 damage for 2 buffs and 175 for 3 buffs.

    My problem is, what triggers should i use. And how do i begin.
    Thx in advance
     
  2. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    1,968
    Resources:
    0
    Resources:
    0
    Not sure if there exists an equation to calculate the damage. Let's say you save damage amount in an array upon map initialization.
    e.g.
    • Set Dmg[1] = 50.00
    • Set Dmg[2] = 125.00
    • Set Dmg[3] = 175.00


    Now the trigger will depend on whether this spell should be MUI/MPI or not. If it can be used by only one unit in game, then you do something like this:
    1) Unit casts an ability
    2) the ability is one of the following: Ability1, Ability2, Ability3
    3) Turn off the trigger
    4) Save the caster and the target.
    5) Make some kind of wait that lasts for 5 seconds
    6) Run a trigger that sets some random int value to 0.
    7) That trigger will check each buff separately in its own If/Then/Else.
    8) If target has specific buff (buff from Ability1/Ability2/Ability3), increase value of int by 1
    9) Lastly, after all three ITEs, if value of int is greater than 0, deal Dmg[int value] to the target and switch the initial trigger back on.

    ---
    If it were to be MUI or MPI, you would need to use a boolean variable called for example "AlreadyActive" or something. Default value should be false and when unit casts the spell, you change the value to true. Whenever unit casts one of the three spells, you check the value of the boolean and let the trigger continue only if the value is set to False... basically instead of switching trigger off and then back on, you would set the value of boolean to True and then back to False.
    A better option here than variables would be hashtable, but the approach would be the same.

    If it were to be MPI, you would use player's index as the index for the caster.
    For MUI, you would need to index each unit separately with its own unique index assigned via the triggger.
    --
    The reason for switching off the trigger, or setting the boolean value is so when the caster casts another of the 3 spells, it won't re-activate the trigger.