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 Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    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.

Need help with bonus xp trigger

Discussion in 'Triggers & Scripts' started by gogeta55, Nov 9, 2019.

  1. gogeta55

    gogeta55

    Joined:
    Jul 12, 2017
    Messages:
    50
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Hi, I wanna create a trigger that if a unit equips this item, he/she will gain bonus xp but mine seem to leak and cause lag so I need help here.

    There are 3 levels of this equipment so I separate its trigger to 3 but I think there might be a better way to do this? Any suggestion?

    • Boots of Experience 1
      • Events
        • Unit - A unit Dies
      • Conditions
        • ((Dying unit) belongs to an enemy of Neutral Hostile) Equal to True
        • (Random integer number between 1 and 100) Less than or equal to 20
      • Actions
        • Set UnitGroup1 = (Units in (Playable map area))
        • Unit Group - Pick every unit in UnitGroup1 and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Picked unit) has an item of type Boots of Experience) Equal to True
              • Then - Actions
                • Hero - Add 10 experience to (Picked unit), Hide level-up graphics
              • Else - Actions
        • Custom script: call DestroyGroup(udg_UnitGroup1)


    There is also an item where it gives gold as well which is similar to this one and I think it need help as well since I think it also causes lag?

    • Golden Boots 1
      • Events
        • Unit - A unit Dies
      • Conditions
        • ((Dying unit) belongs to an enemy of Neutral Hostile) Equal to True
        • (Random integer number between 1 and 100) Less than or equal to 75
      • Actions
        • Set UnitGroup1 = (Units in (Playable map area))
        • Unit Group - Pick every unit in UnitGroup1 and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Picked unit) has an item of type Golden Boots) Equal to True
              • Then - Actions
                • Player - Add 1 to (Owner of (Picked unit)) Current gold
              • Else - Actions
        • Unit Group - Pick every unit in UnitGroup1 and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Dying unit) belongs to an enemy of Neutral Hostile) Equal to True
                • ((Dying unit) is A Hero) Equal to True
                • ((Picked unit) has an item of type Golden Boots) Equal to True
              • Then - Actions
                • Set Point1 = (Position of (Picked unit))
                • Player - Add 25 to (Owner of (Picked unit)) Current gold
                • Floating Text - Create floating text that reads |c00FFFF00+25 Gold!... at Point1 with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                • Set Floating_Text10 = (Last created floating text)
                • Floating Text - Set the velocity of Floating_Text10 to 64.00 towards 90.00 degrees
                • Floating Text - Change Floating_Text10: Disable permanence
                • Floating Text - Change the lifespan of Floating_Text10 to 5.00 seconds
                • Floating Text - Change the fading age of Floating_Text10 to 2.50 seconds
                • Custom script: call RemoveLocation(udg_Point1)
              • Else - Actions
        • Custom script: call DestroyGroup(udg_UnitGroup1)
     
  2. FeelsGoodMan

    FeelsGoodMan

    Joined:
    Dec 13, 2018
    Messages:
    574
    Resources:
    2
    Maps:
    2
    Resources:
    2
    You don't need to set all units in the map as a unit group all the time. Do like this instead:

    • Bonus
      • Events
        • Unit - A unit Dies
      • Conditions
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Killing unit) has an item of type Bonus XP Item) Equal to True
          • Then - Actions
            • Hero - Add 10 experience to (Killing unit), Hide level-up graphics
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Killing unit) has an item of type Bonus Gold Item) Equal to True
          • Then - Actions
            • Player - Set (Owner of (Killing unit)) Current gold to (((Owner of (Killing unit)) Current gold) + 50)
          • Else - Actions


    Also in your second trigger there's only a 75% chance to get the gold bonus. Is that intentional?

    Another thing to note is that all of the units with said item in their inventory will trigger the bonus in your triggers. I'm not sure if that's intentional or not?
     
    Last edited: Nov 9, 2019
  3. gogeta55

    gogeta55

    Joined:
    Jul 12, 2017
    Messages:
    50
    Resources:
    1
    Maps:
    1
    Resources:
    1
    1. The 75% chance to get gold is intentional due to it may be too OP
    2. That is also intentional as well. All heroes with this item will gain bonus as well

    Well, the thing is, I don't want only the killing unit to gain xp bonus but also the holder of the item.

    The owner of this item may be a support type character who rarely get kills which makes them fall behind in term of resources so I want this item to help them.
     
  4. FeelsGoodMan

    FeelsGoodMan

    Joined:
    Dec 13, 2018
    Messages:
    574
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I don't see anything that leaks here, or anything that might cause lag except for the fact that you always pick every single unit in the map every time a unit dies. Try narrowing down your set unit group variable a bit, like so:

    • Set TempGroup = (Units in (Playable map area) matching ((((Unit-type of (Matching unit)) is A Hero) Equal to True) and (((Matching unit) has an item of type Your Item) Equal to True)))


    See if that helps with the lag.

    EDIT: Ah, also include a check to see if the units you save to TempGroup are alive, or else you will add every single unit that has died, unless they have been properly removed.
     
  5. gogeta55

    gogeta55

    Joined:
    Jul 12, 2017
    Messages:
    50
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Thanks, I'll try. I'll reply back if there's any progression or problem further. Hopefully I can fix this.
     
  6. Cespie

    Cespie

    Joined:
    May 21, 2019
    Messages:
    350
    Resources:
    0
    Resources:
    0
    It kinda seems like you want the holder of the item to be the only one getting bonus exp/gold.
    What you need to do, is select all units within the shared EXP radius of the dying target owned by an ally of the killing player (Currently enemy of neutral hostile, but that would actually give you exp when friendly units die).
    Then you cycle through those units and give units holding the bonus exp/gold items the desired bonuses.
     
  7. gogeta55

    gogeta55

    Joined:
    Jul 12, 2017
    Messages:
    50
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I kinda get what you're saying, but can I get an example of that kind of trigger? You mean I need to use like unit group/radius of units around dying unit?
     
  8. BloodSoul

    BloodSoul

    Joined:
    May 10, 2009
    Messages:
    760
    Resources:
    2
    Spells:
    2
    Resources:
    2
    Here's an example
    Triggers

    • Acquiring EXP
      • Events
        • Unit - A unit Acquires an item
      • Conditions
        • ((Triggering unit) is A Hero) Equal to True
        • (Item-type of (Item being manipulated)) Equal to Knowledge is Power // *Ahem*... Boots of Experience
      • Actions
        • Unit Group - Add (Triggering unit) to Item_KiP_Group

    • Units Dies EXP
      • Events
        • Unit - A unit Dies
      • Conditions
        • (Owner of (Triggering unit)) Not equal to Neutral Hostile
      • Actions
        • Unit Group - Pick every unit in Item_KiP_Group and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Random integer number between 1 and 10) Less than or equal to 2
                • ((Picked unit) is dead) Equal to False
              • Then - Actions
                • Hero - Add 10 experience to (Picked unit), Hide level-up graphics
              • Else - Actions

    • Dropping EXP
      • Events
        • Unit - A unit Loses an item
      • Conditions
        • ((Triggering unit) is A Hero) Equal to True
        • (Item-type of (Item being manipulated)) Equal to Knowledge is Power
      • Actions
        • Unit Group - Remove (Triggering unit) from Item_KiP_Group

    This way you don't need to worry about enumerating units that do not have such item. Also, the unit group is permanent.

    It's worth noting that the filter needs to be improved as you could potentially earn XP from your own units (including structures).