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. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. 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] Problem with the units group

Discussion in 'Triggers & Scripts' started by MatiS, Jul 30, 2015.

  1. MatiS

    MatiS

    Joined:
    Feb 23, 2015
    Messages:
    208
    Resources:
    29
    Models:
    27
    Packs:
    2
    Resources:
    29
    Hi
    I've made a spell that drains mana from every enemy unit in the area and transfers it to the caster. Problem is, that the actions in 'unit group' part doesn't happen - spell creates special effect in the point and after the time lightning appear between targeted location and caster, but there is no effect on enemy units. Here are triggers:
    • WCast
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equals to W_Ability
      • Actions
        • Set W_LightningIndex = 0
        • Set W_Caster = (Triggering unit)
        • Set W_Point = (Target point of ability being cast)
        • Set W_Level = (Level of W_Ability for W_Caster)
        • Special Effect - Create a special effect at W_Point using Abilities\Weapons\SpiritOfVengeanceMissile\SpiritOfVengeanceMissile.mdl
        • Set W_Effect = (Last created special effect)
        • Unit Group - Add all units of (Units within W_Range of W_Point matching ((Owner of (Matching unit)) Equals to (Random player from (All enemies of (Owner of W_Caster))))) to W_Group
        • Unit Group - Pick every unit in W_Group and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Mana of (Picked unit)) Greater than 0.00
              • To - Actions
                • Lightning - Create a Chain Lightning - Secondary Bolt lightning effect from source (Position of (Picked unit)) to target W_Point
                • Set W_Lightning[W_LightningIndex] = (Last created lightning effect)
                • Set W_LightningIndex = (W_LightningIndex + 1)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Mana of (Picked unit)) Greater or equal to W_ManaAmount[(W_Level - 1)]
                  • To - Actions
                    • Set W_StolenMana = (W_StolenMana + W_ManaAmount[(W_Level - 1)])
                    • Unit - Cause W_Caster to damage (Picked unit), dealing (W_DamageMultiplier[(W_Level - 1)] x W_ManaAmount[(W_Level - 1)]) damage of attack type Spells and damage type Magic
                    • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - W_ManaAmount[(W_Level - 1)])
                  • Else - Actions
                    • Set W_StolenMana = (W_StolenMana + (Mana of (Picked unit)))
                    • Unit - Cause W_Caster to damage (Picked unit), dealing (W_DamageMultiplier[(W_Level - 1)] x (Mana of (Picked unit))) damage of attack type Spells and damage type Magic
                    • Unit - Set mana of (Picked unit) to 0.00
              • Else - Actions
        • Wait 0.50 seconds
        • For each (Integer A) from W_LightningIndex to 0, do (Actions)
          • Loop - Actions
            • Lightning - Destroy W_Lightning[W_LightningIndex]
            • Set W_LightningIndex = (W_LightningIndex - 1)
        • Lightning - Create a Chain Lightning - Primary Bolt lightning effect from source W_Point to target (Position of W_Caster)
        • Wait 0.10 seconds
        • Lightning - Destroy (Last created lightning effect)
        • Unit - Set mana of W_Caster to ((Mana of W_Caster) + W_StolenMana)
        • Set W_StolenMana = 0.00
        • Set W_Group = (Random 0 units from W_Group)
        • Special Effect - Destroy W_Effect
        • Custom script: call RemoveLocation(udg_W_Point)


    I used waits 'cause the spell doesn't need to be MUI - there is only one hero that use it, and it has 4 seconds cooldown.
     
  2. ivofena

    ivofena

    Joined:
    Jan 17, 2014
    Messages:
    129
    Resources:
    0
    Resources:
    0
    Try indexing instead of unit group.
     
  3. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    1,968
    Resources:
    0
    Resources:
    0
    The trigger may not work because there is probably no unit group to begin with - you add units to a unit group, but for that to work the unit group has to be created. If there is no unit group assigned to the variable, you're adding units to no unit group and iterating over nothing. Also, the condition for unit group may not work as you want.
    For example Player2 and Player3 are enemies of Player1. Caster is from Player1, units that may be add to unit group are from Player3. Now the condition can actually choose Player2 (because you select random player), and Player2 is not the owner of the units (they are owner by player3), so no units may be picked. Also, afaik the condition leaks Player group. To fix this, simply use a boolean condition "Unit - unit belongs to an enemy/ally of Player", like this:
    • Set group = (Units within *Range* of *Location* matching (((Matching unit) belongs to an enemy of *Player*) Equal to True))



    Waits do not determine if spell is MUI or not - it is actually possible to make MUI spells using waits. The reason why they should be avoided is simply because they are inaccurate, inefficient and do not behave well in multiplayer maps.
     
  4. MatiS

    MatiS

    Joined:
    Feb 23, 2015
    Messages:
    208
    Resources:
    29
    Models:
    27
    Packs:
    2
    Resources:
    29
    Thank you both, I improved groups and changed the part that adds units to them. I also found out that configuration trigger was disabled (although it had to happen after I starded thread on hive). It's workin' correctly now, and I think I'm gonna make it MUI.

    EDIT: I tried to make it MUI and there is huge problem. Nothing happens, cast spell doesn't run. I had sth like that but I didn't managed to fix it, so I add map: View attachment dargontest.w3x
     
    Last edited: Jul 30, 2015