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

Help with Mind Control Trigger

Status
Not open for further replies.
Level 9
Joined
Jun 10, 2013
Messages
473
Thanks to an example I found of LordDz's I manage to get a time charm working perfectly however I would like it only be allowed to be casted upon units which are level 4 and below.

Here"s the trigger and I based it on the channel spell:

  • Mind Control
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Control
    • Actions
      • Set Bob = (Target unit of ability being cast)
      • Set BobPlayer = (Owner of Bob)
      • Unit - Change ownership of Bob to (Owner of (Triggering unit)) and Change color
      • For each (Integer tempInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Item carried by Bob in slot tempInt) is Sellable) Equal to True
            • Then - Actions
              • Item - Make (Item carried by Bob in slot tempInt) Undroppable
            • Else - Actions
              • Wait 45.00 seconds
              • For each (Integer tempInt) from 1 to 6, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Item carried by Bob in slot tempInt) is Sellable) Equal to True
                    • Then - Actions
                      • Item - Make (Item carried by Bob in slot tempInt) Droppable
                    • Else - Actions
                      • Unit - Change ownership of Bob to BobPlayer and Change color
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
you make an if/then/else and check if the level of the targeted unit is lower than 4.
If true, then you do this.
If false, you order the caster to "stop".

About the actual effect of the spell... "Wait <real> seconds" is a really bad thing to use.
You should instead use "Wait <real> seconds of gametime", but that one leaks, so you should instead make a custom function that does exactly the same but then without the leak and use that instead. But that is not all... both waits have a slight (~0.167) longer duration... in single player... in multiplayer this can be up to 20-30 seconds (I am assuming that the players are connected :D).

It is much better to make a timer which is 99.9% accurate but is hard to use in GUI.
On the other hand, I just suggest you to use a system which I actually recall from the Spell Section under the name "Mind Control".
Yes, it does not stop you from dropping/selling the items, but hey you have a mind control.
It is much easier for us to edit that system for your needs than to make it from scratch... which is (even though you may not see it yet) what you are asking.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
I think this should work:

  • Charm
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Charm (Neutral Hostile)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of (Target unit of ability being cast)) Less than 4
        • Then - Actions
          • Set Silence_Index = (Silence_Index + 1)
          • Set Silence_TargetUnit[Silence_Index] = (Target unit of ability being cast)
          • Set Silence_CasterPlayer[Silence_Index] = (Owner of (Triggering unit))
          • Set Silence_TargetPlayer[Silence_Index] = (Owner of (Target unit of ability being cast))
          • Unit - Change ownership of Silence_TargetUnit[Silence_Index] to Silence_CasterPlayer[Silence_Index] and Change color
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Item carried by Silence_TargetUnit[Silence_Index] in slot (Integer A)) is Sellable) Equal to True
                • Then - Actions
                  • Item - Make (Item carried by Silence_TargetUnit[Silence_Index] in slot (Integer A)) Undroppable
                • Else - Actions
          • Set Silence_Counter[Silence_Index] = 0.00
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Silence_Index Equal to 1
            • Then - Actions
              • Trigger - Turn on Charm Loop <gen>
            • Else - Actions
        • Else - Actions
          • Unit - Order (Triggering unit) to Stop
  • Charm Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Silence_LoopInteger) from 1 to Silence_Index, do (Actions)
        • Loop - Actions
          • Set Silence_Counter[Silence_LoopInteger] = (Silence_Counter[Silence_LoopInteger] + 1.00)
          • -------- Put wait time within the condition --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Silence_Counter[Silence_LoopInteger] Greater than or equal to 45.00
            • Then - Actions
              • Unit - Change ownership of Silence_TargetUnit[Silence_LoopInteger] to Silence_TargetPlayer[Silence_LoopInteger] and Change color
              • For each (Integer A) from 1 to 6, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Item carried by Silence_TargetUnit[Silence_LoopInteger] in slot (Integer A)) is Sellable) Equal to True
                    • Then - Actions
                      • Item - Make (Item carried by Silence_TargetUnit[Silence_LoopInteger] in slot (Integer A)) Droppable
                    • Else - Actions
              • Set Silence_CasterPlayer[Silence_LoopInteger] = Silence_CasterPlayer[Silence_Index]
              • Set Silence_TargetPlayer[Silence_LoopInteger] = Silence_TargetPlayer[Silence_Index]
              • Set Silence_TargetUnit[Silence_LoopInteger] = Silence_TargetUnit[Silence_Index]
              • Set Silence_TargetUnit[Silence_Index] = No unit
              • Set Silence_Counter[Silence_LoopInteger] = Silence_Counter[Silence_Index]
              • Set Silence_Index = (Silence_Index - 1)
              • Set Silence_LoopInteger = (Silence_LoopInteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Silence_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
Edit: Fixed a couple of bugs.
 
Status
Not open for further replies.
Top