1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Trigger spell issues

Discussion in 'World Editor Help Zone' started by Xzere, May 1, 2020.

Tags:
  1. Xzere

    Xzere

    Joined:
    Feb 23, 2020
    Messages:
    152
    Resources:
    0
    Resources:
    0
    Hello, i have an issue with this, the spell and everything works just perfectly fine BUT the random number which should be 50%, feels more like 5%, so the question is. Am i doing anything wrong with the chance of the spell to activate?

    • Shaman Experience Work
      • Events
        • Game - GDD_Event becomes Equal to 0.00
      • Conditions
        • ((Item carried by GDD_DamageSource of type Shaman Experience) is owned) Equal to True
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Random integer number between 1 and 100) Greater than or equal to 50
          • Then - Actions
            • Set VariableSet ShamanExperience_CasterPoint = (Position of GDD_DamageSource)
            • Set VariableSet ShamanExperience_Group = (Random 1 units from (Units within 5000.00 of ShamanExperience_CasterPoint.))
            • Unit Group - Pick every unit in ShamanExperience_Group and do (Actions)
              • Loop - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • ((Picked unit) is A structure) Equal to False
                    • (Owner of (Picked unit)) Not equal to Player 12 (Brown)
                    • ((Picked unit) belongs to an ally of (Owner of GDD_DamageSource).) Equal to True
                  • Then - Actions
                    • Unit - Create 1 Shaman Experience Caster for (Owner of GDD_DamageSource) at ShamanExperience_CasterPoint facing Default building facing degrees
                    • Custom script: call RemoveLocation(udg_ShamanExperience_CasterPoint)
                    • Unit - Add Heal (Shaman Experience) to (Last created unit)
                    • Unit - Order (Last created unit) to Human Priest - Heal (Picked unit)
                    • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                  • Else - Actions
            • Custom script: call DestroyGroup(udg_ShamanExperience_Group)
          • Else - Actions
     
  2. Kapharna

    Kapharna

    Joined:
    Feb 12, 2020
    Messages:
    29
    Resources:
    0
    Resources:
    0
    Have you tested this for over a hundred times? You might just be having 'bad luck'. The triggers seems fine, right? Or could you try and go smaller like 1/16? does this help?
     
  3. Veritas 117

    Veritas 117

    Joined:
    Nov 17, 2010
    Messages:
    1,238
    Resources:
    0
    Resources:
    0
    Try adding a debug message that displays the number each time to see if it is working properly. Also if you are using “Test Map” it will give you the same random numbers in the same order each time I believe. Try opening the map as a custom game and see if it changes.
     
  4. BloodSoul

    BloodSoul

    Joined:
    May 10, 2009
    Messages:
    865
    Resources:
    2
    Spells:
    2
    Resources:
    2
    • Set VariableSet ShamanExperience_Group = (Random 1 units from (Units within 5000.00 of ShamanExperience_CasterPoint.))

    This line might return any unit - enemy, dead, structure, full HP, owned by Player 12, etc (except locust). So, even if RandomInt is greater than 49, your dummy unit won't always be created / capable of casting heal.

    Edit: Also, that specific line also generates 2 unit groups, and one of them is leaking.
     
    Last edited: May 1, 2020
  5. Xzere

    Xzere

    Joined:
    Feb 23, 2020
    Messages:
    152
    Resources:
    0
    Resources:
    0
    Thank you guys, i will try these things out! :)

    Edit: I found the issue, and the issue is that it picks units with full HP, i tried putting a condition like this:
    (Integer((Life of (Picked unit)))) Less than (Max HP of (Picked unit))

    But that did not seem to fix it, is there another condition?
     
    Last edited: May 2, 2020
  6. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    2,471
    Resources:
    0
    Resources:
    0
    You're going about this trigger the wrong way. You should pick EVERY unit within 5000 range of the caster. Then you filter out the incorrect units in your If Then Else and Break out of the Loop once you've found your first eligible target.

    To do this:
    1) Set ShamanExperience_Group = Units within 5000 range of Point
    2) Create a BOOLEAN variable, we can call it "TargetFound"
    3) Set TargetFound to FALSE at the start of your trigger (as long as it's before the Pick Every Unit function it's fine)
    4) In your If Then Else condition, add the condition "TargetFound equal to FALSE"
    5) In your Pick Every Unit - Actions, add the action "Set TargetFound equal to TRUE"

    This will cause the Loop to only work for the first eligible target it finds.

    ALSO, you probably want to put "Custom script: call RemoveLocation(udg_ShamanExperience_CasterPoint)" OUTSIDE of the Pick Every Unit function. Put it next to your "call DestroyGroup" action. This is because if it doesn't find an eligible target then the Point will never get destroyed.
     
  7. BloodSoul

    BloodSoul

    Joined:
    May 10, 2009
    Messages:
    865
    Resources:
    2
    Spells:
    2
    Resources:
    2
    You should enumerate all units around the GDD_DamageSource, evaluate all of them (remove units that can't be healed), then pick a random unit out of that group. Like so:
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Random integer number between 1 and 2) Equal to 1
      • Then - Actions
        • Set tmp_point = (Position of GDD_DamageSource)
        • Set tmp_group = (Units within 5000.00 of tmp_point)
        • -------- Enumerate units around the attacker (5000 range) --------
        • Unit Group - Pick every unit in tmp_group and do (Actions)
          • Loop - Actions
            • -------- Remove undesired units from this group, such as --------
            • -------- Strucutres, enemies, dead, owned by 12, etc --------
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Picked unit) is dead) Equal to False
                • ((Picked unit) is A structure) Equal to False
                • ((Picked unit) is Mechanical) Equal to False
                • (Owner of (Picked unit)) Not equal to Player 12 (Brown)
                • (Percentage life of (Picked unit)) Less than 100.00
                • ((Picked unit) belongs to an ally of (Owner of GDD_DamageSource)) Equal to True
              • Then - Actions
                • -------- Do nothing here. Units that meet the conditions above are the ones that can be healed up by this ability, and they already are in this group --------
              • Else - Actions
                • -------- Units that ended up here aren't the ones we want to heal. Remove them from this group --------
                • Unit Group - Remove (Picked unit) from tmp_group
        • -------- After filtering out units, pick a random unit out of that group --------
        • Set tmp_group2 = (Random 1 units from tmp_group)
        • Unit Group - Pick every unit in tmp_group2 and do (Actions)
          • Loop - Actions
            • -------- Spawn dummy, order it to cast heal upon Picked Unit, etc --------
        • -------- Destroy objects to prevent memory leak --------
        • Custom script: call DestroyGroup(udg_tmp_group)
        • Custom script: call DestroyGroup(udg_tmp_group2)
        • Custom script: call RemoveLocation(udg_tmp_point)
      • Else - Actions
     
  8. Xzere

    Xzere

    Joined:
    Feb 23, 2020
    Messages:
    152
    Resources:
    0
    Resources:
    0
    Wow, thank you very much @Uncle and @BloodSoul for your help! Appreciate this a lot! :)
     
  9. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    2,471
    Resources:
    0
    Resources:
    0
    No problem, either of our methods should work