• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] Loop without indexing and waits question

Status
Not open for further replies.
Level 18
Joined
Dec 17, 2009
Messages
1,114
Some people say that triggers without waits are MUI
Some people say that Waits + Indexing will make spells MUI
So if i don't use both will it be MUI?

Like this
  • Fireball
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Fireball
    • Actions
      • Set FB_Caster = (Triggering unit)
      • Set FB_PointA = (Position of FB_Caster)
      • Set FB_AnglePoint = (Target point of ability being cast)
      • Set FB_PointB = (FB_PointA offset by (600.00 + (50.00 x (Real((Level of Fireball for FB_Caster))))) towards (Angle from FB_PointA to FB_AnglePoint) degrees)
      • Unit - Create 1 Fireball dummy for (Owner of FB_Caster) at FB_PointA facing (Angle from FB_PointA to FB_AnglePoint) degrees
      • Unit - Order (Last created unit) to Move To FB_PointB
      • Unit - Add a ((Distance between FB_PointA and FB_PointB) / 522.00) second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_FB_PointA)
      • Custom script: call RemoveLocation(udg_FB_PointB)
      • Custom script: call RemoveLocation(udg_FB_AnglePoint)
  • Fireball Explosion
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Set FB_UG = (Units of type Fireball dummy)
      • Unit Group - Pick every unit in FB_UG and do (Actions)
        • Loop - Actions
          • Set FB_TempUnit = (Picked unit)
          • Set FB_Curpos = (Position of (Picked unit))
          • Set FB_UGDetector = (Units within 150.00 of FB_Curpos matching ((((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True) and (((Matching unit) is Magic Immune) Equal to False)))
          • Unit Group - Pick every unit in FB_UGDetector and do (Actions)
            • Loop - Actions
              • Unit - Cause FB_TempUnit to damage (Picked unit), dealing (10.00 x (Real((Level of Fireball for WizardHero[(Player number of (Owner of FB_TempUnit))])))) damage of attack type Spells and damage type Normal
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in FB_UGDetector) Greater than 0
            • Then - Actions
              • Special Effect - Create a special effect at FB_Curpos using Abilities\Weapons\RedDragonBreath\RedDragonMissile.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Remove (Picked unit) from the game
            • Else - Actions
          • Custom script: call DestroyGroup(udg_FB_UGDetector)
          • Custom script: call RemoveLocation(udg_FB_Curpos)
      • Custom script: call DestroyGroup(udg_FB_UG)
EDIT: Found another problem it leaks

Help me someone
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Waits generaly don't make spell not MUI. However, combining global variable data with waits in horrible.

Let me explain a bit:
  • init
    • Events
      • Unit - A unit Starts effect of ability
    • Conditions
    • Actions
      • Set Caster = (Triggering unit)
      • Wait 8.00 seconds
      • Unit - Kill Caster
One global parameter can be assigned to one value at a time. So if within those 8 seconds other unit casts a spell the global variable will be set to complete differend unit meaning that only the last one will be killed.

MUI in GUI can be archieved by Hashtables/complex Indexing or systems usage (such as Unit Indexer).

Your trigger in MUI only because you are picking every units of given type and create 'private' actions for each. Although you can improve trigger a bit.
Instead of creating/destroying group every 0.02 second just set one group and add new created dummies into it. Whenever instance ends (dummy role is over) remove it from group. Make sure you turn off the loop trigger is that group is empty to prevent useless looping.

I don't know where you set:
  • WizardHero[(Player number of (Owner of FB_TempUnit))]
Additionaly:
  • Set FB_UGDetector = (Units within 150.00 of FB_Curpos matching ((((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True) and (((Matching unit) is Magic Immune) Equal to False)))
    • If - Conditions
      • (Number of units in FB_UGDetector) Greater than 0
    • Then - Actions
      • Unit Group - Pick every unit in FB_UGDetector and do (Actions)
        • Loop - Actions
          • Unit - Cause FB_TempUnit to damage (Picked unit), dealing (10.00 x (Real((Level of Fireball for WizardHero[(Player number of (Owner of FB_TempUnit))])))) damage of attack type Spells and damage type Normal
      • Special Effect - Create a special effect at FB_Curpos using Abilities\Weapons\RedDragonBreath\RedDragonMissile.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Remove (Picked unit) from the game
    • Else - Actions
  • Custom script: call DestroyGroup(udg_FB_UGDetector)
 
Last edited:
Level 13
Joined
Jun 1, 2008
Messages
360
I also don't see any leaks, but maybe something is left in the memory after destroying a point/group etc? Shouldn't be that bad though.

But you can improve your trigger: Instead of picking the fireballs all the time, don't ever create/destroy the FB_UG and just add the fireballs when you cast the spell and remove them from the group before you remove them completely.
And also turn the trigger off when there are 0 units in FB_UG.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
You just forgot to enumerate through alive dummies only. If you don't know, the death + decay time in war3 takes around ~90 seconds by default. ForGroup() function enumerates only those units which UnitTypeId != 0 (means unit exists, not mater in what state. If unit-typeid == 0 usually it tells that unit has been removed from the game), so your loop still picks all the units even that their expiration timer is over (but they decay time is surely not). Fixed trigger below.

You could consider using UnitIndexer and store duration in real array variables instead of using expiration timer.
 

Attachments

  • Wizard's Brawl Testmap.w3x
    35.3 KB · Views: 75
Status
Not open for further replies.
Top