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

[Trigger] Why this spell is not MUI?

Status
Not open for further replies.
Level 10
Joined
Jun 17, 2014
Messages
236
Why this spell is not MUI?
the problem is not the point
  • Blink
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (Boa) Poison Trail
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PT_Index Equal to 0
        • Then - Actions
          • Trigger - Turn on Blink Loop <gen>
        • Else - Actions
      • Set PT_Index = (PT_Index + 1)
      • Set PT_Caster[PT_Index] = (Triggering unit)
      • Set PT_Point[PT_Index] = (Target point of ability being cast)
      • Set PT_Counter[PT_Index] = 0
  • Blink Loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer PT_Looper) from 1 to PT_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PT_Counter[PT_Looper] Equal to 40
            • Then - Actions
              • Unit - Move PT_Caster[PT_Looper] instantly to PT_Point[PT_Looper]
              • Custom script: set udg_PT_Caster[udg_PT_Looper] = null
              • Custom script: call RemoveLocation (udg_PT_Point[udg_PT_Looper])
              • Set PT_Index = (PT_Index - 1)
              • Set PT_Looper = (PT_Looper - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • PT_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off Blink Loop <gen>
                • Else - Actions
            • Else - Actions
              • Set PT_Counter[PT_Looper] = (PT_Counter[PT_Looper] + 1)
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
It's not MUI because you have incorrect deindexing.

Let's imagine you have two instances of this spell going on. One for "Footman" unit, other for "Rifleman" unit.

Your PT_Index is equal to 2 (because you have two instances going on), so your trigger is only interested in the data in the first two slots of an array.
Code:
Your PT_Caster array looks like this:
Index 1: Footman
Index 2: Rifleman

PT_Point array:
Index 1: coordinates [280, 20]
Index 2: coordinates [150, 180]

PT_Counter array:
Index 1: 40
Index 2: 28
Notice I write only two instances everywhere, as I said, PT_index == 2, so we care for only the first two slots in each array.

As you can see, instance 1 PT_Counter is 40. By going through the trigger, it will right now "deindex" your instance like this:
Code:
PT_Caster array:
Index 1: Null
Index 2: Rifleman

PT_Point array:
Index 1: Null
Index 2: [150, 180]

PT_Counter array:
Index 1: 41
Index 2: 29
Then you decrease the index by 1. That means that in this case PT_Index == 1 - so you are only interested in the first slot of each array! After that your array look like this:
Code:
PT_Caster:
Index 1: Null

PT_Point:
Index 1: Null

PT_Counter:
Index 1: 41

See the problem now?

What you need to do is this:
Instead of deleting data of the finished instance and leaving it as it is, you delete some data to prevent memory leaks and overwrite the instance with the last indexed instance and decrease index by 1.

That means this:
  • Unit - Move PT_Caster[PT_Looper] instantly to PT_Point[PT_Looper]
  • Custom script: call RemoveLocation (udg_PT_Point[udg_PT_Looper]) //prevents memory leak
  • Set PT_Caster[PT_Looper] = PT_Caster[PT_Index]
  • Set PT_Point[PT_Looper] = PT_Point[PT_Index]
  • Set PT_Counter[PT_Looper] = PT_Counter[PT_Index]
  • Set PT_Index = (PT_Index - 1)
  • Set PT_Looper = (PT_Looper - 1)
Also, I advise putting this part:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • PT_Index Equal to 0
    • Then - Actions
      • Trigger - Turn off Blink Loop <gen>
    • Else - Actions
Completely outside the loop. It's enough if you check it after you do stuff with your instances. No need to check this for each instance, it's a global check (global for this spell).
 
Level 10
Joined
Jun 17, 2014
Messages
236
It's not MUI because you have incorrect deindexing.

Let's imagine you have two instances of this spell going on. One for "Footman" unit, other for "Rifleman" unit.

Your PT_Index is equal to 2 (because you have two instances going on), so your trigger is only interested in the data in the first two slots of an array.
Code:
Your PT_Caster array looks like this:
Index 1: Footman
Index 2: Rifleman

PT_Point array:
Index 1: coordinates [280, 20]
Index 2: coordinates [150, 180]

PT_Counter array:
Index 1: 40
Index 2: 28
Notice I write only two instances everywhere, as I said, PT_index == 2, so we care for only the first two slots in each array.

As you can see, instance 1 PT_Counter is 40. By going through the trigger, it will right now "deindex" your instance like this:
Code:
PT_Caster array:
Index 1: Null
Index 2: Rifleman

PT_Point array:
Index 1: Null
Index 2: [150, 180]

PT_Counter array:
Index 1: 41
Index 2: 29
Then you decrease the index by 1. That means that in this case PT_Index == 1 - so you are only interested in the first slot of each array! After that your array look like this:
Code:
PT_Caster:
Index 1: Null

PT_Point:
Index 1: Null

PT_Counter:
Index 1: 41
See the problem now?

What you need to do is this:
Instead of deleting data of the finished instance and leaving it as it is, you delete some data to prevent memory leaks and overwrite the instance with the last indexed instance and decrease index by 1.

That means this:
  • Unit - Move PT_Caster[PT_Looper] instantly to PT_Point[PT_Looper]
  • Custom script: call RemoveLocation (udg_PT_Point[udg_PT_Looper]) //prevents memory leak
  • Set PT_Caster[PT_Looper] = PT_Caster[PT_Index]
  • Set PT_Point[PT_Looper] = PT_Point[PT_Index]
  • Set PT_Counter[PT_Looper] = PT_Counter[PT_Index]
  • Set PT_Index = (PT_Index - 1)
  • Set PT_Looper = (PT_Looper - 1)
Also, I advise putting this part:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • PT_Index Equal to 0
    • Then - Actions
      • Trigger - Turn off Blink Loop <gen>
    • Else - Actions
Completely outside the loop. It's enough if you check it after you do stuff with your instances. No need to check this for each instance, it's a global check (global for this spell).

Oh, yeah its work!
thank you.
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
I rarely use integers to make MUI;Integer sucks.Try using unit groups instead and see if it works.
I want to emphasize what my moderator colleague already said. Using groups for MUI data structure is a bad recommendation.


There is a couple of good data structures such as stack, list, queue
which are gold standard when creating MUI spell/systems.
Which is best depends on the required complexity.

As GUI user you should stick to dynamic indexing.
Check out the tutorial. It's very well structured and you'll understand everything very fast.
 
You see this first line insine the loop of your linked code?

  • Set TempInteger = (Custom value of (Picked unit))
It uses integers as well, but on top of that it uses unit indexer to get it working.

I just want not that such phrases spread and people believe it,
but in reality you did not have enough knowlegde to make such statement.

Because "integer" does not suck at all. It is a data type, and even imo the most useful one.

Using unit groups is a similar approach, but the difference is that a system deals with the integers (indices), but not yourself.

hey hey hey, can you all stop this debate?
Only because you are finished with the thread does not mean others are.
We just wanted to clarify things.. it is okay. :)
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
@userid907: Is your issue beeing solved? Otherwise we should focus on that,

I wasn't talking about that kind of integer.
From my point of view, you and IcemanBo just don't have them same knowledge of programming.
Some of your comments are contradictory to me aswell.

Towards groups and MUI:
Yes it is possible to build a MUI spell using the unit list in a unit group handle.
It's not recommended out of many reasons. If you wish I list them for you in a new comment.

Tried that to my Pheonix Fury ability and it doesn't work.People keeps on downloading the spell even though I them told not to.I also ask pro MUI spell makers for help but none did.I am forced to delete it before a moderator does.And I feel slightly ashamed in Hive with bad reps and/or Unacceptable moderator ratings.
If in your opinion a resource of yours or another user of The Hive Workshop is unfair rated,
feel free to contact the moderator in charge via PM or take it directly to our superiors.
Make sure you have more solid arguments than your gut instincts, otherwise
the request can't be considered as a serious issue.

Regards THW moderation team.
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
Tried that to my Pheonix Fury ability and it doesn't work.People keeps on downloading the spell even though I them told not to.I also ask pro MUI spell makers for help but none did.I am forced to delete it before a moderator does.And I feel slightly ashamed in Hive with bad reps and/or Unacceptable moderator ratings.
You know what? IcemanBo is one of those "pro MUI spell makers" or whatever. There is a good reason why he is a Code Moderator, so don't be that ignorant. I am here to help people (at least i try xD) and to get help from people LIKE IcemanBo. You spread wrong information and don't accept any help obviously. That's sad.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
Spellbound's custom harvest system for his contest entry works perfectly MUI without integers.
Then you look at the second action "Set TempInteger = (Custom value of (Picked unit))" and that statement seems kind of contradictory.

You need to make it clear that you meant "unit based ticks" instead of "object based ticks". Both approaches have their advantages and disadvantages. Object based approach is recommended if you have some persistent state with a finite life cycle (created, does stuff, expires). This brings better speed and better control over object life. Unit based approach is recommended if state is simple and has the same life cycle as the unit itself. There is no concern of accidental duplicates being made and allows for easy external state modification by other systems.

An example of where I would use an object based tick system would be for a triggered version of Shockwave. For every successful cast made, it would create a separate object which will be periodically ticked to progress it.

An example of where I would use a unit based tick system would be for a housing income system. Every "house" made would be added to the group. State attached to each house would be accessed every tick and processed to provide income. Other systems such as attractions, weather etc could interact with houses on an individual basis to affect the income they provide.

"pro MUI spell makers"
Wait, you honestly telling me that it is difficult to make MUI spells? I thought anyone could make them if they read a few of the dozens of tutorials, check a few ready made spells from the spell section and have some idea of why it works the way it is.

If you are willing to use vJASS then it can be potentially a cake walk due to structs handling all the object allocation/decallocation for you.
 
Level 18
Joined
Oct 17, 2012
Messages
820
Also, I advise putting this part:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • PT_Index Equal to 0
    • Then - Actions
      • Trigger - Turn off Blink Loop <gen>
    • Else - Actions
Completely outside the loop. It's enough if you check it after you do stuff with your instances. No need to check this for each instance, it's a global check (global for this spell).

Then the trigger would check for that unnecessarily every 0.02 seconds, when it could just check once every an instance finishes.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
YIt is a data type, and even imo the most useful one.
Code:
private byte[] data;
Get on my level :D

I wasn't talking about that kind of integer.I'm talking about the integer types of:
-For Loop , Integer A
-For Loop , Integer B
-For Loop , Variable Integer
You think linear loops are bad?

Code:
while (true) {
Get on my level :D

No seriously, loops are 10^10^10% better than... whatever.

believe what you want,but I'm speaking the truth. :ogre_icwydt:
Thats an interesting statement... almost like I said it.
The basic difference though, I only say such things when I am actually right about something...

Its abit too late if you wish to help me,GIM.the spell is already deleted.the thing that makes me dull the most is why no moderators came to at least comment about it.I dont know how to PM that day.So I don't think I wanna continue this argument anymore.I wont respond.
Who deleted it? You?
You should not upload non-working spells and ask for feedback before uploading it.
There are too few moderators to actually give feedback for all uploaded resources all at once.
 
Status
Not open for further replies.
Top