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

[Trigger] HELP! Problems Regarding MUI/MPIness

Status
Not open for further replies.
Level 10
Joined
Sep 3, 2009
Messages
458
Well I'm making my "Lock-On Battle System" MUI or atleast MPI. I just can't seem to make it work.

Basically you have a "Target" skill that once used on any unit it will mark it as your target. An invisible dummy unit will then be created for the hero with the shop sharing model and will follow the target. When the caster dies, acquires a new target, or the target dies, the arrow unit will be destroyed. But then even when I destroy it in the trigger it just doesn't work.

Here's my trigger

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Target --------
      • For each (Integer Target) from 1 to 1000, do (Actions)
        • Loop - Actions
          • Set TargetId[Target] = Target
          • Set TargetCaster[Target] = No unit
          • Set TargetUnit[Target] = No unit
  • Target Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Target
    • Actions
      • Trigger - Run Target NewIndex <gen> (ignoring conditions)
      • Unit - Kill TargetDummy[TargetCurrentIndex]
      • Set TargetCaster[TargetCurrentIndex] = (Triggering unit)
      • Set TargetUnit[TargetCurrentIndex] = (Target unit of ability being cast)
      • Set TargetPoint[TargetCurrentIndex] = (Position of TargetUnit[TargetCurrentIndex])
      • Unit - For (Owner of TargetCaster[TargetCurrentIndex]) create 1 Dummy Target at TargetPoint[TargetCurrentIndex] facing Default building facing degrees
      • Set TargetDummy[(Player number of (Owner of TargetCaster[TargetCurrentIndex]))] = (Last created unit)
      • Custom script: call RemoveLocation(udg_TargetPoint[udg_TargetCurrentIndex])
  • Target Loop
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Target) from 1 to 1000, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TargetCaster[Target] Not equal to No unit) or (TargetUnit[Target] Not equal to No unit)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TargetCaster[Target] Not equal to No unit) or (TargetUnit[Target] Not equal to No unit)
                • Then - Actions
                  • Set TargetPoint[Target] = (Position of TargetUnit[Target])
                  • Unit - Move TargetDummy[Target] instantly to TargetPoint[Target]
                  • Custom script: call RemoveLocation(udg_TargetPoint[udg_Target])
                • Else - Actions
                  • Unit - Kill TargetDummy[Target]
                  • Set TargetCurrentIndex = Target
                  • Set TargetCaster[Target] = No unit
                  • Set TargetUnit[Target] = No unit
                  • Custom script: call RemoveLocation(udg_TargetPoint[udg_Target])
                  • Trigger - Run Target ReturnIndex <gen> (ignoring conditions)
            • Else - Actions
              • Custom script: call RemoveLocation(udg_TargetPoint[udg_Target])
  • Target NewIndex
    • Events
    • Conditions
    • Actions
      • Set TargetIndex = (TargetIndex + 1)
      • Set TargetCurrentIndex = TargetId[TargetIndex]
  • Target ReturnIndex
    • Events
    • Conditions
    • Actions
      • Set TargetId[TargetIndex] = TargetCurrentIndex
      • Set TargetIndex = (TargetIndex - 1)
Please and thank you
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Map Init-trigger seems futile, you can set this in the variable editor.

I've got a question for the second trigger:
You kill TargetDummy[TargetCurrentIndex], while TargetCurrentIndex is (most likely) "Target" (what's that anyway?).
Can't you use the custom value of a unit or something instead of the TargetCurrentIndex, as it doesn't seem right to me.

In the second trigger, you loop something 1000 times every 0.01 seconds, talking about efficiency... o_O
Why not add the caster to a unit group and pick all units in that group?
Ohh, and the loop... reduce it to 0.05 or something, which is 5 times slower, but really... that's fast enough.
(This also goes along with the custom value idea).
 
Level 10
Joined
Sep 3, 2009
Messages
458
is the unit invulnerable of have locust? I think KillUnit don't work will invu and locust units... just add a .01 second expiration timer to them.

oh lol thanks for the info +REP


Map Init-trigger seems futile, you can set this in the variable editor.

I've got a question for the second trigger:
You kill TargetDummy[TargetCurrentIndex], while TargetCurrentIndex is (most likely) "Target" (what's that anyway?).
Can't you use the custom value of a unit or something instead of the TargetCurrentIndex, as it doesn't seem right to me.

In the second trigger, you loop something 1000 times every 0.01 seconds, talking about efficiency... o_O
Why not add the caster to a unit group and pick all units in that group?
Ohh, and the loop... reduce it to 0.05 or something, which is 5 times slower, but really... that's fast enough.
(This also goes along with the custom value idea).

hmmmm never thought about that ._. ....uhm well Target is an integer variable I used like Integer A...

ermmm I just copied this from a tutorial (Forgot the name) basically this is the only way I could make stuff mui.

unit group eh. Like units within range or something then the actions run? am I right? Well Thanks for the info and help. Oh one more thing does that mean I dont need the newindex and return indexes anymore? I'm still confused. +REP

EDIT: I cant seem to rep you O. O Adiktuz
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
No, just create a unit group (something like "IndicatorCasters" or whatever) and add the caster in there.
Then pick all units inside that group and pick their custom value, then load all the variables with that custom value and... I hope you can fill in the rest xD

I know target is an integer, but I was talking about this: Set TargetId[Target] = Target (in the init-trigger).
Why would you do that? :p
 
Level 10
Joined
Sep 3, 2009
Messages
458
No, just create a unit group (something like "IndicatorCasters" or whatever) and add the caster in there.
Then pick all units inside that group and pick their custom value, then load all the variables with that custom value and... I hope you can fill in the rest xD

I know target is an integer, but I was talking about this: Set TargetId[Target] = Target (in the init-trigger).
Why would you do that? :p

oh ok got the unit group part.

well as for the integer erm...I really don't know. I didn't understand the tutorial that much. I use the example as a template and well made that ._.

thanks again ^^. Oh another question. I set the unit group thingy in what trigger?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
oh ok got the unit group part.

well as for the integer erm...I really don't know. I didn't understand the tutorial that much. I use the example as a template and well made that ._.

thanks again ^^. Oh another question. I set the unit group thingy in what trigger?
You've got to start somewhere ^^
Using another spell (or a tutorial) as a template is often a good idea for starting out.

Well, it looks like hashtables, but then it's done with indexes :p (if you know hashtables).
Initially, the unit group is just empty, but when the spell is cast, then you add the caster to the unit group (and add the custom value to the caster and set all variables for the custom value).

In the loop-trigger, pick all units in that group.

Never destroy that group, by the way: it doesn't leak when you just add/remove units from it.
 
Level 10
Joined
Sep 3, 2009
Messages
458
You've got to start somewhere ^^
Using another spell (or a tutorial) as a template is often a good idea for starting out.

Well, it looks like hashtables, but then it's done with indexes :p (if you know hashtables).
Initially, the unit group is just empty, but when the spell is cast, then you add the caster to the unit group (and add the custom value to the caster and set all variables for the custom value).

In the loop-trigger, pick all units in that group.

Never destroy that group, by the way: it doesn't leak when you just add/remove units from it.


oooohhhh cool so basically:

Spell is cast = Add caster to unit group
Loop = pick every unit in group

Since you added units in unit group it will run but if there aren't any units it wont. cool! But I have to remove that unit sometime right. Once it's finished casting. Right?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Since you added units in unit group it will run but if there aren't any units it wont. cool! But I have to remove that unit sometime right. Once it's finished casting. Right?
Yeah (you can also add a trigger that when the spell is done and there are no units in the unit group, you completely turn off the trigger - when the spell is cast, check whether the trigger is on, if it's not, turn it on).

Erm, yeah, but the problem is that I don't really know when your system is done :p
You probably need to remove it when someone who already has a target is casting the spell (otherwise he would have 2 targets >.>).
Ehh... well, when the targetted unit is dead, I guess you can remove the unit from the unit group and remove him from the game, then clear the variables ^^
 
Level 10
Joined
Sep 3, 2009
Messages
458
Yeah (you can also add a trigger that when the spell is done and there are no units in the unit group, you completely turn off the trigger - when the spell is cast, check whether the trigger is on, if it's not, turn it on).

Erm, yeah, but the problem is that I don't really know when your system is done :p
You probably need to remove it when someone who already has a target is casting the spell (otherwise he would have 2 targets >.>).
Ehh... well, when the targetted unit is dead, I guess you can remove the unit from the unit group and remove him from the game, then clear the variables ^^

ohhh hehe thanks for the help. You'll sure be credited once I'm finished with the system ^^.
 
Level 10
Joined
Sep 3, 2009
Messages
458
BUMP!

Ok so the target works but how do I work with the custom value cause all units start with a custom value of 0.

here's the trigger

  • Target Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Target
    • Actions
      • Unit - Kill TargetDummy[(Custom value of (Triggering unit))]
      • Set TargetCaster[(Custom value of (Triggering unit))] = (Triggering unit)
      • Set TargetUnit[(Custom value of (Triggering unit))] = (Target unit of ability being cast)
      • Set TargetPoint[(Custom value of (Triggering unit))] = (Position of TargetUnit[(Custom value of (Triggering unit))])
      • Unit - For (Owner of TargetCaster[(Custom value of (Triggering unit))]) create 1 Dummy Target at TargetPoint[(Custom value of (Triggering unit))] facing Default building facing degrees
      • Set TargetDummy[(Custom value of (Triggering unit))] = (Last created unit)
      • Custom script: call RemoveLocation(udg_TargetPoint[GetUnitUserData(GetTriggerUnit())])
      • Unit Group - Add TargetUnit[(Custom value of (Triggering unit))] to TargetCasterGroup
  • Target Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TargetCasterGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Is TargetCaster[(Custom value of (Picked unit))] dead) Equal to True) or ((Is TargetUnit[(Custom value of (Picked unit))] dead) Equal to True)
            • Then - Actions
              • Unit - Kill TargetDummy[(Custom value of (Picked unit))]
              • Custom script: call RemoveLocation(udg_TargetPoint[GetUnitUserData(GetEnumUnit())])
              • Unit Group - Remove TargetCaster[(Custom value of (Picked unit))] from TargetCasterGroup
            • Else - Actions
              • Set TargetPoint[(Custom value of (Picked unit))] = (Position of TargetUnit[(Custom value of (Picked unit))])
              • Unit - Move TargetDummy[(Custom value of (Picked unit))] instantly to TargetPoint[(Custom value of (Picked unit))]
              • Custom script: call RemoveLocation(udg_TargetPoint[GetUnitUserData(GetEnumUnit())])
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Just set the custom of the casting unit to (Value)

Here is an example-map I created especially for you xD
(it's a simple push-back, completely MUI...)

If you have any further questions, feel free to ask.
I think the code on itslef is quite clear (it's a pretty small code), but if you experience any problems, I'm here to help ^^
(ohh, you can make it more clear by setting the trigger colors by the way :p I find that useful).
 

Attachments

  • IndexingDemo.w3x
    19.6 KB · Views: 48
Level 10
Joined
Sep 3, 2009
Messages
458
Just set the custom of the casting unit to (Value)

Here is an example-map I created especially for you xD
(it's a simple push-back, completely MUI...)

If you have any further questions, feel free to ask.
I think the code on itslef is quite clear (it's a pretty small code), but if you experience any problems, I'm here to help ^^
(ohh, you can make it more clear by setting the trigger colors by the way :p I find that useful).

Ok I get it, thanks lol ima test it with my spell. Ima tell you what happens haha.

BUMP!

OMG thanks! LOTS! it works now! Ima just do some spells and my system is finished. Thanks to you! credits will surely be given. Thanks dudez :thumbs_up:
 
Last edited by a moderator:
Status
Not open for further replies.
Top