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] AOE Blinding Spell - MUI Spell

Discussion in 'Triggers & Scripts' started by rkemsley, Dec 2, 2019 at 6:46 PM.

  1. rkemsley

    rkemsley

    Joined:
    Sep 25, 2018
    Messages:
    35
    Resources:
    0
    Resources:
    0
    Here is the basic idea of the spell I am trying to create.

    Monster casts his ability; Hypnotic Void (Based on Channel)

    After successfully channelling for 2 seconds, a huge AOE debuff (which pierces spell immunity) silences every unit in a 1200 radius for 8 seconds.
    While silenced, Hero units vision is reduced to 400, and non-hero units vision is reduced to 0 (So you completely lose vision over your non-hero units). This is done using the "Unit - Set Unit: (Picked unit)'s Real Field: Sight Radius ('usir') to Value: 0.00".
    After the 8 second duration, all the affected units vision is returned to their original values.

    Here is what I have as a very basic test to see if the vision and silence part works.

    • HypnoticVoidCast
      • Events
        • Unit - A unit Finishes casting an ability
      • Conditions
        • (Ability being cast) Equal to Hypnotic Void
      • Actions
        • Set hvCast = (Casting unit)
        • Set hvGroup = (Units within 1200.00 of (Position of hvCast) matching ((((Matching unit) is Mechanical) Equal to False) and ((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an ally of (Owner of hvCast)) Equal to False))))
        • Unit - Create 1 Dummy (Hypnotic Void) for (Owner of hvCast) at (Position of hvCast) facing (Position of hvCast)
        • Unit - Add Hypnotic Void (Dummy Ability) to (Last created unit)
        • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
        • Unit - Set level of Hypnotic Void (Dummy Ability) for (Last created unit) to (Level of Hypnotic Void for hvCast)
        • Unit - Order (Last created unit) to Neutral Dark Ranger - Silence (Position of hvCast)
        • Trigger - Turn on HypnoticVoidEffect <gen>

    • HypnoticVoidEffect
      • Events
        • Time - Every 0.20 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in hvGroup and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Picked unit) has buff Silence) Equal to True
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • ((Picked unit) is An Ancient) Equal to False
                  • Then - Actions
                    • Unit - Set Unit: (Picked unit)'s Real Field: Sight Radius ('usir') to Value: 0.00
                  • Else - Actions
                    • Unit - Set Unit: (Picked unit)'s Real Field: Sight Radius ('usir') to Value: 400.00
              • Else - Actions
                • Trigger - Turn off (This trigger)

    The problem I have is making the spell MUI and also returning all of the affected units vision back to how is was before being hit by the spell. (Which I suppose is an MUI issue. I guess I would have to save each affected units vision before being hit by the spell.)

    Edit: I started making an attempt at converting this into an MUI spell. I just got a little lost with the stating of the variables. I have only ever successfully created a single targeted MUI spell (which didn't involve Dummy units). Was not sure what is the best way to go about making an MUI spell that is AOE.
     
    Last edited: Dec 4, 2019 at 9:46 PM
  2. Sabe

    Sabe

    Joined:
    Jul 30, 2018
    Messages:
    282
    Resources:
    1
    Spells:
    1
    Resources:
    1
    You'll need store information for each individual unit, so you need unit indexing. You could use hashtables too (personally I like hashtables, because once you get the hang on them, they are simple and clear to use).

    On the cast trigger you store the current (default) sight radius to the hashtable for each affected unit and then reduce it and use the dummy to Silence the unit. And then on the period trigger you run through the hashtable group and check the duration of the spell. Once the timer ends (or if you want to rely on the duration of the Silence, once the unit doesn't have the buff anymore) you reset the sight radius back to its default value.

    Here is a good tutorial on hashtables, if you're unfamiliar with them.
     
  3. rkemsley

    rkemsley

    Joined:
    Sep 25, 2018
    Messages:
    35
    Resources:
    0
    Resources:
    0
    I think I get the general idea of the use of hashtable. Current issue is following the tutorial, but making trying to make it AoE. (Tutorials examples are all single target, which are significantly easier.)
    When storing the current sight radius to the hashtable, would I do the trigger like this?

    • HypnoticVoidCast
      • Events
        • Unit - A unit Finishes casting an ability
      • Conditions
        • (Ability being cast) Equal to Hypnotic Void
      • Actions
        • Unit Group - Pick every unit in (Units within 1200.00 of (Position of (Casting unit)) matching (((Matching unit) has buff Silence) Equal to True)) and do (Actions)
          • Loop - Actions
            • Set HypnoticVoid_TargetSight = (Unit: (Picked unit)'s Real Field: Sight Radius ('usir'))

    The next part will be saving the picked units into the hashtable itself.
     
  4. Sabe

    Sabe

    Joined:
    Jul 30, 2018
    Messages:
    282
    Resources:
    1
    Spells:
    1
    Resources:
    1
    It shouldn't be any different for AoE, because you have to treat all units individually anyway. I didn't test it, but this should do it:

    • Cast Blind
      • Events
        • Unit - A unit Finishes casting an ability
      • Conditions
        • (Ability being cast) Equal to Channel
      • Actions
        • Set TempLoc = (Position of (Triggering unit))
        • Custom script: set bj_wantDestroyGroup = true
        • Unit Group - Pick every unit in (Units within 600.00 of TempLoc) and do (Actions)
          • Loop - Actions
            • Set TempUnit = (Picked unit)
            • Set TempHandle = (Picked unit)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (TempUnit is alive) Equal to True
                • (TempUnit is A structure) Not equal to True
                • (TempUnit belongs to an enemy of (Owner of (Triggering unit))) Equal to True
              • Then - Actions
                • Hashtable - Save 10.00 as (Key duration) of (Key TempHandle) in BlindTable
                • Hashtable - Save (Unit: TempUnit's Real Field: Sight Radius ('usir')) as (Key sightradius) of (Key TempHandle) in BlindTable
                • Unit - Set Unit: TempUnit's Real Field: Sight Radius ('usir') to Value: 0.00
                • -------- Use dummy to cast Silence on TempUnit --------
                • Unit Group - Add TempUnit to BlindGroup
              • Else - Actions
        • Custom script: call RemoveLocation(udg_TempLoc)
    • Blind Periodic
      • Events
        • Time - Every 0.10 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in BlindGroup and do (Actions)
          • Loop - Actions
            • Set TempUnit = (Picked unit)
            • Set TempHandle = (Picked unit)
            • Set Duration = (Load (Key duration) of (Key TempHandle) from BlindTable)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Duration Greater than 0.00
                • (TempUnit has buff Silence) Equal to True
              • Then - Actions
                • Hashtable - Save (Duration - 0.10) as (Key duration) of (Key TempHandle) in BlindTable
              • Else - Actions
                • Unit - Set Unit: TempUnit's Real Field: Sight Radius ('usir') to Value: (Load (Key sightradius) of (Key TempHandle) from BlindTable)
                • Unit - Remove Silence buff from TempUnit
                • Hashtable - Clear all child hashtables of child (Key TempHandle) in BlindTable
                • Unit Group - Remove TempUnit from BlindGroup
     
  5. rkemsley

    rkemsley

    Joined:
    Sep 25, 2018
    Messages:
    35
    Resources:
    0
    Resources:
    0
    Bit of a pain, but it seems I cannot use the custom script "RemoveLocation" when using Lua script language. When I try to use "Custom script: call RemoveLocation(udg_HypnoticVoid_CastPoint)", it keeps coming up with "Unknown compile error - syntax error near 'RemoveLocation'. Have you encountered this problem happen or could it be some other issue?

    Edit: Obviously, HypnoticVoid_CastPoint is my Point variable.
     
    Last edited: Dec 5, 2019 at 11:18 PM
  6. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,151
    Resources:
    1
    Spells:
    1
    Resources:
    1
    If using Lua you don’t need the “call”. Otherwise it could be an invisible character that exists somewhere in the line you can’t see. To fix that just delete the whole CS line and make a new one from scratch.
     
  7. rkemsley

    rkemsley

    Joined:
    Sep 25, 2018
    Messages:
    35
    Resources:
    0
    Resources:
    0
    Yeah, that was the problem, thanks!
     
  8. rkemsley

    rkemsley

    Joined:
    Sep 25, 2018
    Messages:
    35
    Resources:
    0
    Resources:
    0
    Here is the mostly working version I currently have (Thanks @Sabe you were right that once you get start to get hang of them, they are actually quite simple, in theory).

    • TheThirdEyeCast
      • Events
        • Unit - A unit Finishes casting an ability
      • Conditions
        • (Ability being cast) Equal to The Third Eye
      • Actions
        • Set TTE_Point = (Position of (Casting unit))
        • Custom script: bj_wantDestroyGroup = true
        • Unit Group - Pick every unit in (Units within 1200.00 of TTE_Point) and do (Actions)
          • Loop - Actions
            • Set TTE_TempUnit = (Picked unit)
            • Set TTE_TempHandle = (Picked unit)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (TTE_TempUnit is alive) Equal to True
                • (TTE_TempUnit belongs to an enemy of (Owner of (Casting unit))) Equal to True
              • Then - Actions
                • Hashtable - Save (6.00 + (2.00 x (Real((Level of The Third Eye for (Casting unit)))))) as (Key TTE_DurationHandle) of (Key TTE_TempHandle) in TTE_HastTable
                • Hashtable - Save (Unit: TTE_TempUnit's Real Field: Sight Radius ('usir')) as (Key TTE_SightradiusHandle) of (Key TTE_TempHandle) in TTE_HastTable
                • Unit - Create 1 Dummy (Hypnotic Void) for (Owner of (Casting unit)) at TTE_Point facing TTE_Point
                • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                • Unit - Add The Third Eye (Dummy Ability) to (Last created unit)
                • Unit - Set level of The Third Eye (Dummy Ability) for (Last created unit) to (Level of The Third Eye for (Casting unit))
                • Unit - Order (Last created unit) to Neutral Dark Ranger - Silence TTE_Point
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (TTE_TempUnit is A Hero) Equal to True
                  • Then - Actions
                    • Unit - Set Unit: TTE_TempUnit's Real Field: Sight Radius ('usir') to Value: 400.00
                    • Unit Group - Add TTE_TempUnit to TTE_Group
                  • Else - Actions
                    • Unit - Set Unit: TTE_TempUnit's Real Field: Sight Radius ('usir') to Value: 0.00
                    • Unit Group - Add TTE_TempUnit to TTE_Group
              • Else - Actions
                • Unit - Create 1 Dummy (Hypnotic Void) for (Owner of (Casting unit)) at TTE_Point facing TTE_Point
                • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                • Unit - Add The Third Eye (Dummy Ability) to (Last created unit)
                • Unit - Set level of The Third Eye (Dummy Ability) for (Last created unit) to (Level of The Third Eye for (Casting unit))
                • Unit - Order (Last created unit) to Neutral Dark Ranger - Silence TTE_Point
        • Custom script: RemoveLocation(udg_HypnoticVoid_CastPoint)

    • TheThirdEyeEffect
      • Events
        • Time - Every 0.10 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in TTE_Group and do (Actions)
          • Loop - Actions
            • Set TTE_TempUnit = (Picked unit)
            • Set TTE_TempHandle = (Picked unit)
            • Set TTE_Duration = (Load (Key TTE_DurationHandle) of (Key TTE_TempHandle) from TTE_HastTable)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • TTE_Duration Greater than 0.00
                • (TTE_TempUnit has buff The Third Eye ) Equal to True
              • Then - Actions
                • Hashtable - Save (TTE_Duration - 0.10) as (Key TTE_DurationHandle) of (Key TTE_TempHandle) in TTE_HastTable
              • Else - Actions
                • Unit - Set Unit: TTE_TempUnit's Real Field: Sight Radius ('usir') to Value: (Load (Key TTE_SightradiusHandle) of (Key TTE_TempHandle) from TTE_HastTable)
                • Unit - Remove Silence buff from TTE_TempUnit
                • Hashtable - Clear all child hashtables of child (Key TTE_TempHandle) in TTE_HastTable
                • Unit Group - Remove TTE_TempUnit from TTE_Group

    Thing I am trying to work out is how to make it so that if my spell is cast with only allies/own units nearby, it will still cast the dummy ability. (It currently doesn't). If I change the triggers slightly so that it casts my dummy ability when allies/own units are nearby, it seems to permanently reduce the units vision, (except the caster's vision) even though they are unaffected by the debuff, hmmm).
     
    Last edited: Dec 6, 2019 at 1:59 PM
  9. Sabe

    Sabe

    Joined:
    Jul 30, 2018
    Messages:
    282
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Sorry, but I don't quite get what you're saying. Isn't it supposed to only work on enemies..?
     
  10. rkemsley

    rkemsley

    Joined:
    Sep 25, 2018
    Messages:
    35
    Resources:
    0
    Resources:
    0
    So, normally, if you cast the ability, with no enemies nearby, after the channel is finished, it won’t spawn the dummy to cast the dummy spell. So there’s no effect from the dummy spell.

    I changed the trigger slightly so that it will spawn the dummy, however, all allies (except allied heroes) have their vision reduced to 400 permanently.

    Also, another problem which I’m trying to sort out is the automatic sight change between day and night. If the spell is cast at night, just before it becomes day, when day arrives, it will cancel the vision reduction, and force all affected units to have their day vision. I believe this can easily be fixed by having the vision reduction part moved to the Effect part of the trigger (rather than the cast part). I’ll have to do some more tests when I get back home.
     
  11. Sabe

    Sabe

    Joined:
    Jul 30, 2018
    Messages:
    282
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Can you post the modified trigger?

    Oh yeah, I didn't even think about that. Hmm.. It could get a bit tricky. Unless you give all units a fixed change in the vision between day and night (for example, all units have 50% vision at night) you could then just check if it's night or day when you store the original sight radius. Then check again the time of day when you return the sight radius.
     
  12. rkemsley

    rkemsley

    Joined:
    Sep 25, 2018
    Messages:
    35
    Resources:
    0
    Resources:
    0
    • TheThirdEyeCast
      • Events
        • Unit - A unit Finishes casting an ability
      • Conditions
        • (Ability being cast) Equal to The Third Eye
      • Actions
        • Set TTE_Point = (Position of (Casting unit))
        • Custom script: bj_wantDestroyGroup = true
        • Unit Group - Pick every unit in (Units within 1200.00 of TTE_Point) and do (Actions)
          • Loop - Actions
            • Set TTE_TempUnit = (Picked unit)
            • Set TTE_TempHandle = (Picked unit)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (TTE_TempUnit is alive) Equal to True
                • (TTE_TempUnit belongs to an enemy of (Owner of (Casting unit))) Equal to True
              • Then - Actions
                • Hashtable - Save (6.00 + (2.00 x (Real((Level of The Third Eye for (Casting unit)))))) as (Key TTE_DurationHandle) of (Key TTE_TempHandle) in TTE_HastTable
                • Hashtable - Save (Unit: TTE_TempUnit's Real Field: Sight Radius ('usir')) as (Key TTE_SightradiusHandle) of (Key TTE_TempHandle) in TTE_HastTable
                • Unit - Create 1 Dummy (Hypnotic Void) for (Owner of (Casting unit)) at TTE_Point facing TTE_Point
                • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                • Unit - Add The Third Eye (Dummy Ability) to (Last created unit)
                • Unit - Set level of The Third Eye (Dummy Ability) for (Last created unit) to (Level of The Third Eye for (Casting unit))
                • Unit - Order (Last created unit) to Neutral Dark Ranger - Silence TTE_Point
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (TTE_TempUnit is A Hero) Equal to True
                  • Then - Actions
                    • Unit - Set Unit: TTE_TempUnit's Real Field: Sight Radius ('usir') to Value: 400.00
                    • Unit Group - Add TTE_TempUnit to TTE_Group
                  • Else - Actions
                    • Unit - Set Unit: TTE_TempUnit's Real Field: Sight Radius ('usir') to Value: 0.00
                    • Unit Group - Add TTE_TempUnit to TTE_Group
              • Else - Actions
        • Custom script: RemoveLocation(udg_HypnoticVoid_CastPoint)

    This was the original script which works fine (no strange effects to allied/caster owned units), except that it does not cast the dummy spell if there are no enemies within 1200 of the channelled cast point.

    • TheThirdEyeCast
      • Events
        • Unit - A unit Finishes casting an ability
      • Conditions
        • (Ability being cast) Equal to The Third Eye
      • Actions
        • Set TTE_Point = (Position of (Casting unit))
        • Custom script: bj_wantDestroyGroup = true
        • Unit Group - Pick every unit in (Units within 1200.00 of TTE_Point) and do (Actions)
          • Loop - Actions
            • Set TTE_TempUnit = (Picked unit)
            • Set TTE_TempHandle = (Picked unit)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (TTE_TempUnit is alive) Equal to True
                • (TTE_TempUnit belongs to an enemy of (Owner of (Casting unit))) Equal to True
              • Then - Actions
                • Hashtable - Save (6.00 + (2.00 x (Real((Level of The Third Eye for (Casting unit)))))) as (Key TTE_DurationHandle) of (Key TTE_TempHandle) in TTE_HastTable
                • Hashtable - Save (Unit: TTE_TempUnit's Real Field: Sight Radius ('usir')) as (Key TTE_SightradiusHandle) of (Key TTE_TempHandle) in TTE_HastTable
                • Unit - Create 1 Dummy (Hypnotic Void) for (Owner of (Casting unit)) at TTE_Point facing TTE_Point
                • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                • Unit - Add The Third Eye (Dummy Ability) to (Last created unit)
                • Unit - Set level of The Third Eye (Dummy Ability) for (Last created unit) to (Level of The Third Eye for (Casting unit))
                • Unit - Order (Last created unit) to Neutral Dark Ranger - Silence TTE_Point
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (TTE_TempUnit is A Hero) Equal to True
                  • Then - Actions
                    • Unit - Set Unit: TTE_TempUnit's Real Field: Sight Radius ('usir') to Value: 400.00
                    • Unit Group - Add TTE_TempUnit to TTE_Group
                  • Else - Actions
                    • Unit - Set Unit: TTE_TempUnit's Real Field: Sight Radius ('usir') to Value: 0.00
                    • Unit Group - Add TTE_TempUnit to TTE_Group
              • Else - Actions
                • Unit - Create 1 Dummy (Hypnotic Void) for (Owner of (Casting unit)) at TTE_Point facing TTE_Point
                • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                • Unit - Add The Third Eye (Dummy Ability) to (Last created unit)
                • Unit - Set level of The Third Eye (Dummy Ability) for (Last created unit) to (Level of The Third Eye for (Casting unit))
                • Unit - Order (Last created unit) to Neutral Dark Ranger - Silence TTE_Point
        • Custom script: RemoveLocation(udg_HypnoticVoid_CastPoint)

    This is the script which casts (when allied units/caster owned units are nearby) the dummy spell. However, it seems to (when reducing the units vision) include the allied units as well, except it permanently reduces their vision (the allied/caster owned units vision).

    Edit: Really subtle difference, so it seems really strange that it affects the allied units...

    Edit Edit: Just realised it, but this leaks. I haven't got round to changing the updating the RemoveLocation custom script. But, to be honest, I don't think that should affect this trigger too adversely.