• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Need help for a spell

Status
Not open for further replies.
Level 2
Joined
May 3, 2008
Messages
18
Take into consideration that this is my first post here, sorry if i make any mistakes.

So, the thing i need help with is probably some fault in logic i made while making my spell with triggers in GUI.
The problem is as follows:
The spell executes, the special effects work, but when the damage part of the spell comes it seems to do some random damage instead a fixed one while sometimes hitting the same unit more than once and sometimes doesn't damage the unit at all.
  • Test 2
    • Events
      • Unit - Tester 0016 <gen> Takes damage
      • Unit - Tester 0017 <gen> Takes damage
      • Unit - Tester 0018 <gen> Takes damage
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (String((Damage taken)))

  • Magic The Gathering
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Magic: The Gathering [Spell Breaker]
    • Actions
      • Set MTGCasterUnit = (Casting unit)
      • Set MTGGlaivePoint = ((Position of MTGCasterUnit) offset by 48.00 towards ((Facing of MTGCasterUnit) - 45.00) degrees)
      • Set MTGUG = (Units within 500.00 of (Position of MTGCasterUnit) matching (((Matching unit) belongs to an enemy of (Owner of MTGCasterUnit)) Equal to True))
      • Set MTGUGInteger = (Number of units in MTGUG)
      • For each (Integer A) from 1 to MTGUGInteger, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in MTGUG) Greater than or equal to 1
            • Then - Actions
              • Set MTGUnitTarget[(Integer A)] = (Random unit from MTGUG)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (MTGUnitTarget[(Integer A)] is dead) Equal to True
                • Then - Actions
                  • Unit Group - Remove MTGUnitTarget[(Integer A)] from MTGUG
                • Else - Actions
                  • Set tempPoint = (Position of MTGUnitTarget[(Integer A)])
                  • Unit - Create 1 Magic: The Gathering for (Owner of MTGCasterUnit) at tempPoint facing Default building facing degrees
                  • Set MTGSpecialEffectUnit[(Integer A)] = (Last created unit)
                  • Custom script: call RemoveLocation(udg_tempPoint)
            • Else - Actions
              • Do nothing
      • Animation - Play MTGCasterUnit's spell animation
      • Animation - Change MTGCasterUnit's animation speed to 150.00% of its original speed
      • Trigger - Turn on Magic The Gathering Special Effect <gen>
      • Wait 0.50 seconds
      • Trigger - Turn off Magic The Gathering Special Effect <gen>
      • Animation - Change MTGCasterUnit's animation speed to 100.00% of its original speed
      • For each (Integer A) from 1 to MTGUGInteger, do (Actions)
        • Loop - Actions
          • Unit - Set mana of MTGUnitTarget[(Integer A)] to ((Mana of MTGUnitTarget[(Integer A)]) x 0.90)
          • Unit - Cause MTGCasterUnit to damage MTGUnitTarget[(Integer A)], dealing ((12.00 x (Real((Hero level of MTGCasterUnit)))) + (0.10 x (Mana of MTGUnitTarget[(Integer A)]))) damage of attack type Spells and damage type Normal
          • Unit - Cause MTGCasterUnit to damage MTGUnitTarget[(Integer A)], dealing ((((12.00 x (Real((Hero level of MTGCasterUnit)))) + (0.10 x (Mana of MTGUnitTarget[(Integer A)]))) x (Real((Level of + Power for MTGCasterUnit)))) x 0.10) damage of attack type Spells and damage type Normal
          • Unit Group - Remove MTGUnitTarget[(Integer A)] from MTGUG
      • -------- Removal --------
      • For each (Integer A) from 1 to MTGUGInteger, do (Actions)
        • Loop - Actions
          • Unit - Remove MTGSpecialEffectUnit[(Integer A)] from the game
      • Set MTGCasterUnit = No unit
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: call RemoveLocation(udg_MTGGlaivePoint)
      • Set MTGUGInteger = 0
I am not good with JASS, so i may(probably) have misplaced some RemLoc custom text.
-------------
Problem.jpg
-------------
EDIT: The first 3 numbers in the picture are the damage caused by the skill i based my skill of (Thunder Clap).
 
Last edited:
Here you've scripted basically to damage a random unit once for each unit in the group.

For each (Integer A) from 1 to MTGUGInteger, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in MTGUG) Greater than or equal to 1
Then - Actions
Set MTGUnitTarget[(Integer A)] = (Random unit from MTGUG)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(MTGUnitTarget[(Integer A)] is dead) Equal to True
Then - Actions
Unit Group - Remove MTGUnitTarget[(Integer A)] from MTGUG
Else - Actions
Set tempPoint = (Position of MTGUnitTarget[(Integer A)])
Unit - Create 1 Magic: The Gathering for (Owner of MTGCasterUnit) at tempPoint facing Default building facing degrees
Set MTGSpecialEffectUnit[(Integer A)] = (Last created unit)
Custom script: call RemoveLocation(udg_tempPoint)

If you want to damage all the units in the group for the same amount, use "unit group - pick every unit in group and do actions"

Edit: Please excuse the lack of [trigger][/trigger] tags as it rendered poorly the first time..
 
Level 2
Joined
May 3, 2008
Messages
18
I'm not sure, but i think that i read somewhere that "unit group - pick every unit in group and do actions" leaks and that it cannot be fixed.
Also thanks for the reply, gonna try using it now. Wasted a few hours busting my ass over it yesterday, caused me quite a headache.
EDIT: Thanks man, all works as intended now. The trigger damages every unit and subtracts their mana if they have it.
+ I feel stupid about never using this trigger to damage units, now I'm having flashbacks about all the time wasted during many years of having fun in WE....
 
Status
Not open for further replies.
Top