• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Solved] Trigger spell issues

Status
Not open for further replies.
Level 7
Joined
Feb 23, 2020
Messages
253
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
 
Level 3
Joined
Feb 12, 2020
Messages
34
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?
 
Level 14
Joined
Nov 17, 2010
Messages
1,266
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.
 
Level 13
Joined
May 10, 2009
Messages
868
  • 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:
Level 7
Joined
Feb 23, 2020
Messages
253
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:

Uncle

Warcraft Moderator
Level 67
Joined
Aug 10, 2018
Messages
6,897
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.
 
Level 13
Joined
May 10, 2009
Messages
868
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
 
Status
Not open for further replies.
Top