1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Making a tether ability's special effects MUI?

Discussion in 'Triggers & Scripts' started by A Rather Wily Beaver, Jan 16, 2020 at 4:09 PM.

  1. A Rather Wily Beaver

    A Rather Wily Beaver

    Joined:
    Jun 10, 2019
    Messages:
    32
    Resources:
    0
    Resources:
    0
    Hello again everyone,

    Today I'm working on an ability that's mostly working, but there's a key error I'm having difficulty correcting.

    Here's the goal: the caster activates the ability, Lightning Lure, which is based on Chain Lightning, on a target enemy unit. The Chain Lightning special effects play, and then 10 orbs of lightning spawn between the caster and the target. The target is dragged towards the caster, and the orbs move continuously, showing the tether between them.

    Here are my triggers:

    • Lightning Lure Cast
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Lightning Lure
      • Actions
        • Set VariableSet LightningLure_Instances = (LightningLure_Instances + 1)
        • Unit - Turn collision for (Target unit of ability being cast) Off.
        • Set VariableSet LightningLure_Caster[LightningLure_Instances] = (Triggering unit)
        • Set VariableSet LightningLure_Victim[LightningLure_Instances] = (Target unit of ability being cast)
        • Set VariableSet LightningLure_Damage[LightningLure_Instances] = (((20.00 x (Real((Level of Lightning Lure for (Triggering unit))))) + 20.00) + (2.00 x (Real((Intelligence of (Triggering unit) (Include bonuses))))))
        • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing LightningLure_Damage[LightningLure_Instances] damage of attack type Spells and damage type Normal
        • For each (Integer LightningLure_UnitInteger[LightningLure_Instances]) from 1 to 10, do (Actions)
          • Loop - Actions
            • Unit - Create 1 Lightning Lure Dummy for (Triggering player) at ((Position of (Triggering unit)) offset by ((Distance between (Position of (Triggering unit)) and (Position of (Target unit of ability being cast))) x ((Real(LightningLure_UnitInteger[LightningLure_Instances])) / 11.00)) towards (Angle from (Position of (Trig facing (Position of (Target unit of ability being cast))
            • Set VariableSet LightningLure_Units[LightningLure_UnitInteger[LightningLure_Instances]] = (Last created unit)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • LightningLure_Instances Equal to 1
          • Then - Actions
            • Trigger - Turn on Lightning Lure Loop <gen>
          • Else - Actions


    • Lightning Lure Loop
      • Events
        • Time - Every 0.02 seconds of game time
      • Conditions
      • Actions
        • For each (Integer LightningLure_Loop) from 1 to LightningLure_Instances, do (Actions)
          • Loop - Actions
            • For each (Integer LightningLure_UnitInteger[LightningLure_Loop]) from 1 to 10, do (Actions)
              • Loop - Actions
                • Unit - Move LightningLure_Units[LightningLure_UnitInteger[LightningLure_Loop]] instantly to ((Position of LightningLure_Caster[LightningLure_Loop]) offset by ((Distance between (Position of LightningLure_Caster[LightningLure_Loop]) and (Position of LightningLure_Victim[LightningLure_Loop])) x ((Real(LightningLure_UnitInteger[LightningLure_Loop])) / , facing (Position of LightningLure_Victim[LightningLure_Loop])
            • Unit - Move LightningLure_Victim[LightningLure_Loop] instantly to ((Position of LightningLure_Victim[LightningLure_Loop]) offset by 4.00 towards (Angle from (Position of LightningLure_Victim[LightningLure_Loop]) to (Position of LightningLure_Caster[LightningLure_Loop])) degrees.), facing (Position of LightningLure_Caster[LightningLure_Loop])
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Distance between (Position of LightningLure_Caster[LightningLure_Loop]) and (Position of LightningLure_Victim[LightningLure_Loop])) Less than or equal to 100.00
              • Then - Actions
                • Unit - Turn collision for LightningLure_Victim[LightningLure_Loop] On.
                • For each (Integer LightningLure_UnitInteger[LightningLure_Loop]) from 1 to 10, do (Actions)
                  • Loop - Actions
                    • Unit - Kill LightningLure_Units[LightningLure_UnitInteger[LightningLure_Loop]]
                • Set VariableSet LightningLure_Caster[LightningLure_Loop] = LightningLure_Caster[LightningLure_Instances]
                • Set VariableSet LightningLure_Victim[LightningLure_Loop] = LightningLure_Victim[LightningLure_Instances]
                • Set VariableSet LightningLure_Damage[LightningLure_Loop] = LightningLure_Damage[LightningLure_Instances]
                • Set VariableSet LightningLure_Loop = (LightningLure_Loop - 1)
                • Set VariableSet LightningLure_Instances = (LightningLure_Instances - 1)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • LightningLure_Instances Equal to 0
                  • Then - Actions
                    • Trigger - Turn off (This trigger)
                  • Else - Actions
              • Else - Actions


    The movement is working fine with multiple instances. The problem I'm having is that, if a caster uses Lightning Lure before a previous instance of Lightning Lure is complete, only the most recent set of orbs will move. Additionally, if the 1st instance target and 1st instance caster come into close contact after the 2nd instance has begun, the 2nd instance orbs will be the ones to get destroyed, not the 1st.

    I think the problem has something to do with how I'm assigning variables to the orbs of lightning.

    Any help would be appreciated.

    P.S. As a clarification, LightningLure_Units is the size-10 array of the lightning orbs, LightningLure_UnitInteger is a size-12 array I used to distinguish between the LightningLure_Units. LightningLure_Instances is the number of ongoing instances of the spell, and LightningLure_Loop is the integer I used for my attempt at dynamic indexing.

    Thanks!
     
  2. FeelsGoodMan

    FeelsGoodMan

    Joined:
    Dec 13, 2018
    Messages:
    823
    Resources:
    2
    Maps:
    2
    Resources:
    2
  3. A Rather Wily Beaver

    A Rather Wily Beaver

    Joined:
    Jun 10, 2019
    Messages:
    32
    Resources:
    0
    Resources:
    0
    @FeelsGoodMan, thank you for the link, but I've actually already gone through that tutorial and have successfully made several MUI abilities with that method. Even these triggers are partially MUI; the drag effect is working great, even with multiple instances going at once.

    There's just something about these triggers in particular that I'm missing. I feel like it should be working (although it's not so I'm clearly wrong about that).

    For each variable between 1 and the number of instances, you go through each variable between 1 and 10 and move them every 0.02 seconds. It's so simple, but alas, I'm missing something.

    Edit: I made 2 new triggers a similar movement system and I'm running into the same problem. Does having an array of arrays not work or something? I'm truly at a loss.

    Here are the 2 new triggers. They're very simple; you use an ability, orbs starting orbiting you. They're simple, but there's still something I'm missing, as only the most recent array of orbs will move.

    • Test Orbit Cast
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to TestOrbit
      • Actions
        • Set VariableSet TestOrbit_Instances = (TestOrbit_Instances + 1)
        • Set VariableSet TestOrbit_Caster[TestOrbit_Instances] = (Triggering unit)
        • Set VariableSet TestOrbit_AngleCounter[TestOrbit_Instances] = 0.00
        • For each (Integer TestOrbit_UnitInteger[TestOrbit_Instances]) from 1 to 4, do (Actions)
          • Loop - Actions
            • Unit - Create 1.Lightning Lure Dummy for (Triggering player) at ((Position of (Triggering unit)) offset by 200.00 towards (90.00 x (Real(TestOrbit_UnitInteger[TestOrbit_Instances]))) degrees.) facing Default building facing degrees
            • Set VariableSet TestOrbit_Units[TestOrbit_UnitInteger[TestOrbit_Instances]] = (Last created unit)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TestOrbit_Instances Equal to 1
          • Then - Actions
            • Trigger - Turn on Test Orbit Loop <gen>
          • Else - Actions


    • Test Orbit Loop
      • Events
        • Time - Every 0.02 seconds of game time
      • Conditions
      • Actions
        • For each (Integer TestOrbit_Loop) from 1 to TestOrbit_Instances, do (Actions)
          • Loop - Actions
            • Set VariableSet TestOrbit_AngleCounter[TestOrbit_Loop] = (TestOrbit_AngleCounter[TestOrbit_Loop] + 1.00)
            • For each (Integer TestOrbit_UnitInteger[TestOrbit_Loop]) from 1 to 4, do (Actions)
              • Loop - Actions
                • Unit - Move TestOrbit_Units[TestOrbit_UnitInteger[TestOrbit_Loop]] instantly to ((Position of TestOrbit_Caster[TestOrbit_Loop]) offset by 200.00 towards (((Real(TestOrbit_UnitInteger[TestOrbit_Loop])) x 90.00) + TestOrbit_AngleCounter[TestOrbit_Loop]) degrees.)


    Edit 2: I didn't bother triggering for when the spell ends as I simply made it permanent. I figure that, while that's important for a real spell, it's not super necessary when it's not the cause of the problem at hand.
     
    Last edited: Jan 16, 2020 at 7:03 PM
  4. Aeryn

    Aeryn

    Joined:
    Apr 17, 2017
    Messages:
    283
    Resources:
    0
    Resources:
    0
    • Set VariableSet TestOrbit_Units[TestOrbit_UnitInteger[TestOrbit_Instances]] = (Last created unit)
    Your problem is this line. Since array of arrays are not supported you have two options:
    • Use a hashtable
    • Add dummy units to a group with an array and inside your loop pick all units in that group and do the actions.
    Also your triggers are leaking. Check this out: Memory Leaks

    So your first trigger should look like this:
    • Lightning Lure Cast
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Lightning Lure
      • Actions
        • Set LightningLure_Instances = (LightningLure_Instances + 1)
        • Set LightningLure_Caster[LightningLure_Instances] = (Triggering unit)
        • Set LightningLure_Victim[LightningLure_Instances] = (Target unit of ability being cast)
        • Unit - Turn collision for LightningLure_Victim[LightningLure_Instances] Off
        • The Rest of your code here--
        • Custom script: set udg_LightningLure_DummyGroup[udg_LightningLure_Instances] = CreateGroup()
        • Set LightningLure_Location = (Position of (Triggering unit))
        • Set LightningLure_Location3 = (Position of (Target unit of ability being cast))
        • For each (Integer LightningLure_TempInt) from 1 to 10, do (Actions)
          • Loop - Actions
            • Set LightningLure_Location2 = (LightningLure_Location offset by ((Distance between LightningLure_Location and LightningLure_Location3) x ((Real(LightningLure_TempInt)) / 11.00)) towards (Angle from LightningLure_Location to LightningLure_Location3) degrees)
            • Unit - Create 1 LightningLureDummy for (Owner of (Triggering unit)) at LightningLure_Location2 facing LightningLure_Location3
            • Unit Group - Add (Last created unit) to LightningLure_DummyGroup[LightningLure_Instances]
            • Custom script: call RemoveLocation(udg_LightningLure_Location2)
        • Custom script: call RemoveLocation(udg_LightningLure_Location3)
        • Custom script: call RemoveLocation(udg_LightningLure_Location)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • LightningLure_Instances Equal to 1
          • Then - Actions
            • Trigger - Turn on Lightning Lure Loop <gen>
          • Else - Actions
     
    Last edited: Jan 16, 2020 at 7:15 PM
  5. A Rather Wily Beaver

    A Rather Wily Beaver

    Joined:
    Jun 10, 2019
    Messages:
    32
    Resources:
    0
    Resources:
    0
    @Aeryn , thank you so much! I knew there must be something involving arrays of arrays, but I couldn't find anything about that online.

    I'll also be sure to check out that link; leaks have been a problem for me, and I definitely need to work on fixing them.