• 🏆 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!

Is THis "MUI" or "MPI"

Status
Not open for further replies.
Level 7
Joined
Mar 6, 2014
Messages
203
Is this spell is MUI?

  • Trigger 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (some spell)
    • Actions
      • Set X = (X + 1)
      • Set Caster[X] = (Triggering unit)
      • Set CasterPoint[X] = (Position of Caster[X])
      • Set CasterP[X] = (Triggering player)
      • Set Distance[X] = 1000.00
      • Set TempPoint[X] = (Target point of ability being cast)
      • Unit - Create 1 (someunit) for CasterP[X] at TempPoint[X] facing Default building facing degrees
      • Set Turret[X] = (Last created unit)
      • Set TurretPoint[X] = (Position of Turret[X])
      • Set DummyLimiter = (DummyLimiter + 1)
      • Set DummyLimiterUnitID[DummyLimiter] = Turret[X]
      • Custom script: call RemoveLocation(udg_TurretPoint[udg_X])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by (Owner of Caster[X]) of type Turret)) Greater than 3
        • Then - Actions
          • Unit - Remove DummyLimiterUnitID[(DummyLimiter - 3)] from the game
        • Else - Actions
  • Dummy Disabled
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Y) from 1 to X, do (Actions)
        • Loop - Actions
          • Set CasterPoint[Y] = (Position of Caster[Y])
          • Set TurretPoint[Y] = (Position of Turret[Y])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between CasterPoint[Y] and TurretPoint[Y]) Greater than or equal to Distance[Y]
            • Then - Actions
              • Special Effect - Create a special effect attached to the origin of Turret[Y] using Abilities\Spells\Orc\Purge\PurgeBuffTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Animation - Change Turret[Y]'s vertex coloring to (0.00%, 0.00%, 0.00%) with 0.00% transparency
              • Animation - Change Turret[Y]'s animation speed to 0.00% of its original speed
              • Unit - Pause Turret[Y]
            • Else - Actions
              • Animation - Change Turret[Y]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
              • Animation - Change Turret[Y]'s animation speed to 100.00% of its original speed
              • Unit - Unpause Turret[Y]
          • Custom script: call RemoveLocation(udg_CasterPoint[udg_Y])
          • Custom script: call RemoveLocation(udg_TurretPoint[udg_Y])
im trying to make when the caster move away with distance of greater than 1000 on his unit the unit will unable to make action either move or attack. but when caster move with distance lessthan 999 the unit the unit will able to do any action.

IS THE SPELL IS MUI ?? ITS ONLY MPI but i wanna really do it MUI too.:ogre_haosis: Need some help
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
Your spell isn't MUI and it ain't even MPI.
The problem is in the first trigger where you check number of turrets for a caster.
The trigger will work in this situations:
You have this: Caster, Turret1, Turret2, Turret3.
Now Caster casts the spell again. He summons Turret4, so the trigger checks if he has more than 3 turrets, which he does, so the game does this:
Caster, Turret1, Turret2, Turret3, Turret4 - it deletes the Turret[last index - 3], which is in this case [4-3] = index 1.

That works all fine and well, but look what happens when you have more casters:
You have CasterA, CasterB. The order, in which they summoned their turrets is as follows:
Turret1, Turret2, Turret3, Turret4.
Now CasterA summons another turret - Turret5.
CasterA does have more than 3 turrets, so the game correctly removes Turret with index [last index - 3] which is Turret[2]. But look: Turret with index 2 is this turret: Turret2! The end result looks like this:
Turret1, Turret2, Turret3, Turret4, Turret5
Now CasterA has 4 turrets and CasterB lost his one and only turret!
So basically, since you don't differentiate between owners of turrets (since all are saved under dummyLimiterUnitID), your trigger will remove turrets from different players.

----------
Other problems you have in your triggers are:
In first trigger: CasterPoint[X] and TempPoint[X] leak locations, since you don't remove them.
In first trigger, TurretPoint[X] makes no sense and is completely useless action. What you do is this:
Set loc1 = somewhere
Create Turret at loc1
Set loc2 = somewhere else
<few actions that have no impact on what I'm trying to point out>
remove loc2
As you can see, loc2 has no use. The very same can be applied to CasterPoint[X].

If I'm not mistaken, the unit group actions "Unit of type X" cause permanent leak.

Also, you only remove DummyLimiterUnitID from game, but then you still use its index (as Turret[Y]) in the second trigger - that means you're working with non-existing units. You need to learn to deindex stuff you indexed.
This is also bad, because after some hours playing your map, your casters could get to for example index 200, but there would be only for example 3 casters, each with 3 turrets, so basically, your trigger would make 191 useless iterations for non-existing units every 0.03 seconds.
Which gets me to...
is it really important for the loop to fire every 0.03 seconds? Ain't 0.1 seconds enough? Sure, it won't be that accurate, but you will hardly notice any difference in game.

Variables that are not needed:
CasterP[X] - saving stuff into variables is needed when you: 1) need to save some information for some time (and this information could change from the intended value) or 2) when you need to use the thing you saved multiple times. You do none of the two with CasterP. You only use it once - when you create the Turret unit.
Distance[X] - if the distance is same for all units using this spell, there is no need to save it into variable. Not to mention saving the same value multiple times into an array. That's not really what arrays are for.
You can simply put the value 1000.00 into the second trigger right instead of Distance[Y] in the condition.
Only have it in variable (not array) if you plan to upload this spell here on hive, since it's a requirement (so people who would download your spell can easily change the range without having to understand your code), but if it's only for your map, you can place the value directly into the condition.
DummyLimiter[X] and DummyLimiterUnitID[X] - these have same values as variables X and Turret[X].
CasterPoint and TurretPoint - these may give the idea that they are needed, but all you actually need are temporal variables (aka tempPoint that you use in first trigger), since you don't need any locations saved for any amount of time... you only use them to check the distance, which is an immediate action.

----
What I would do to fix your problems is that I would give each caster his own unit group and save his turrets in it. Then check, when he summons another turret, if he has more than 3 units in his unit group and if yes, remove one of the units in there.
Of course, you would need to make sure your caster is not already indexed into Caster[] array, so that you don't index him multiple times.
 
Status
Not open for further replies.
Top