• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Need help with MUI spell (only one line)

Status
Not open for further replies.
Level 9
Joined
Jun 25, 2009
Messages
427
Hey guys, long time no see. So i started making MUI spells (multiinstansable=multiple units can cast it at the same time) so yeah, i made one spell for the "Hive spellpack" and it's MUI, it works, but one thing doesn't. The spell does this: i use it, i rush 600 range (through triggers) picking units in 150 aoe and dealing somewhat damage and then stopping.

The problem: when one unit uses it, it works and only damages the units one time. BUUUUT when two or more units use it, it works, but damages the same unit in 150 for about 100 times while picking.

The triggers.

  • Sonic Rush
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Sonic Rush
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Sonic_Rush_Mui_Turnoff Equal to 0
        • Then - Actions
          • Trigger - Turn on Sonic Rush Loop <gen>
        • Else - Actions
      • Set Sonic_Rush_Mui_Integer = (Sonic_Rush_Mui_Integer + 1)
      • Set Sonic_Rush_Mui_Turnoff = (Sonic_Rush_Mui_Turnoff + 1)
      • Set Sonic_Rush_Distance[Sonic_Rush_Mui_Integer] = 600
      • Set Sonic_Rush_Facing[Sonic_Rush_Mui_Integer] = (Facing of (Triggering unit))
      • Set Sonic_Rush_Off[Sonic_Rush_Mui_Integer] = True
      • Set Sonic_Rush_Rusher[Sonic_Rush_Mui_Integer] = (Triggering unit)
      • Unit - Turn collision for (Triggering unit) Off
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Focused Force for (Triggering unit)) Less than or equal to 1
        • Then - Actions
          • Unit - Remove Focused Force from (Triggering unit)
        • Else - Actions
          • Unit - Decrease level of Focused Force for (Triggering unit)
      • Set Sonic_Rush_Damage[Sonic_Rush_Mui_Integer] = ((100.00 x (Real((Level of Sonic Rush for (Triggering unit))))) + (20.00 x (Real((Level of Focused Force for (Triggering unit))))))
And the second one

  • Sonic Rush Loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Sonic_Rush_Mui_Loop) from 1 to Sonic_Rush_Mui_Integer, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Sonic_Rush_Off[Sonic_Rush_Mui_Loop] Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Sonic_Rush_Distance[Sonic_Rush_Mui_Loop] Less than or equal to 0
                • Then - Actions
                  • Unit - Turn collision for Sonic_Rush_Rusher[Sonic_Rush_Mui_Loop] On
                  • Unit Group - Remove all units from Sonic_Rush_Group_2[Sonic_Rush_Mui_Loop]
                  • Set Sonic_Rush_Mui_Turnoff = (Sonic_Rush_Mui_Turnoff - 1)
                  • Set Sonic_Rush_Off[Sonic_Rush_Mui_Loop] = False
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Sonic_Rush_Mui_Turnoff Equal to 0
                    • Then - Actions
                      • Set Sonic_Rush_Mui_Integer = 0
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
                  • Set Sonic_Rush_Pos = (Position of Sonic_Rush_Rusher[Sonic_Rush_Mui_Loop])
                  • Set Sonic_Rush_Pos_Off = (Sonic_Rush_Pos offset by 48.00 towards Sonic_Rush_Facing[Sonic_Rush_Mui_Loop] degrees)
                  • Set Sonic_Rush_Distance[Sonic_Rush_Mui_Loop] = (Sonic_Rush_Distance[Sonic_Rush_Mui_Loop] - 48)
                  • -------- The problem i guess is somewhere here --------
                  • Set Sonic_Rush_Group = (Units within 150.00 of Sonic_Rush_Pos matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of Sonic_Rush_Rusher[Sonic_Rush_Mui_Loop])) Equal to True) and ((((Matching unit) is alive) Equal to True)
                  • -------- ^ And matching unit is not in Sonic_Rush_Group_2[Sonic_Rush_Mui_Loop] --------
                  • Unit Group - Add all units of Sonic_Rush_Group to Sonic_Rush_Group_2[Sonic_Rush_Mui_Loop]
                  • Unit Group - Pick every unit in Sonic_Rush_Group and do (Actions)
                    • Loop - Actions
                      • Unit - Cause Sonic_Rush_Rusher[Sonic_Rush_Mui_Loop] to damage (Picked unit), dealing Sonic_Rush_Damage[Sonic_Rush_Mui_Loop] damage of attack type Normal and damage type Normal
                      • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
                      • Set Sonic_Rush_Sfx = (Last created special effect)
                      • Special Effect - Destroy Sonic_Rush_Sfx
                  • -------- The problem i guess is somewhere ABOVE --------
                  • Special Effect - Create a special effect attached to the chest of Sonic_Rush_Rusher[Sonic_Rush_Mui_Loop] using Abilities\Spells\Human\Defend\DefendCaster.mdl
                  • Set Sonic_Rush_Sfx = (Last created special effect)
                  • Special Effect - Destroy Sonic_Rush_Sfx
                  • Special Effect - Create a special effect attached to the chest of Sonic_Rush_Rusher[Sonic_Rush_Mui_Loop] using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
                  • Set Sonic_Rush_Sfx = (Last created special effect)
                  • Special Effect - Destroy Sonic_Rush_Sfx
                  • Special Effect - Create a special effect attached to the chest of Sonic_Rush_Rusher[Sonic_Rush_Mui_Loop] using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
                  • Set Sonic_Rush_Sfx = (Last created special effect)
                  • Special Effect - Destroy Sonic_Rush_Sfx
                  • Unit - Move Sonic_Rush_Rusher[Sonic_Rush_Mui_Loop] instantly to Sonic_Rush_Pos_Off, facing Sonic_Rush_Facing[Sonic_Rush_Mui_Loop] degrees
                  • Special Effect - Create a special effect attached to the chest of Sonic_Rush_Rusher[Sonic_Rush_Mui_Loop] using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
                  • Set Sonic_Rush_Sfx = (Last created special effect)
                  • Special Effect - Destroy Sonic_Rush_Sfx
                  • Custom script: call RemoveLocation(udg_Sonic_Rush_Pos)
                  • Custom script: call RemoveLocation(udg_Sonic_Rush_Pos_Off)
                  • Custom script: call DestroyGroup(udg_Sonic_Rush_Group)
            • Else - Actions
I would be friggin' happy if you helped me solve this, cause this is the second time i have problems with it.

For your help i will give a +rep.

Tiche3
 
Level 9
Joined
Jun 25, 2009
Messages
427
Create a group for the spell caster when the spell is cast. Save the group. Add all damaged units to the group. Before damaging, check whether the picked unit is in the group or not. When the spell ends, destroy the group.

Sounds good but could you show it in a trigger? :)
Would appreciate it very much.

Tiche3
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
In the starts effect trigger:

  • Custom script: set udg_Sonic_Rush_Group[udg_Sonic_Rush_Mui_Integer] = CreateGroup()
^That creates an empty group and saves it. Check whether there's a group in there or not. If the group is not null, don't create it.

Then in this:
  • Set Sonic_Rush_Group = (Units within 150.00 of Sonic_Rush_Pos matching ((((Matching unit) is A structure) Equal to False)...
add that "unit is not in Sonic_Rush_Group[Sonic_Rush_Mui_Loop]".

Then when you do this: Set Sonic_Rush_Off[Sonic_Rush_Mui_Loop] = False, remove all units from the group.
 
Status
Not open for further replies.
Top