Spell Chain Reaction

S

steveROGERS

Guest
GUI: Yes
Leak less: Yes
MUI: No
Import Difficulty: Medium-Low
Units Affected: Enemy, ground, neutral
Target Type: Unit

Chain Reaction- A meltdown occurs inside targeted unit spewing debris to nearby units. Due to the unstable nature of the materials, fragments continue to detonate exposing neighboring units to the pain. Effects based on a percentage per level.

Screenshot:
CR2.jpg

Note: I used Tinki3’s Spells Test Map Template.

Code:
 Chain Reaction
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Chain Reaction (Channel)
    Actions
        -------- Safety --------
        Countdown Timer - Pause CR_Timer
        Set CR_Continue = 0.00
        -------- ----- --------
        Set CR_AOE = 500.00
        Set CR_TimerInterval = 0.80
        Set CR_MaxTargets = 3
        Set CR_Damage = 200.00
        Set CR_SpecialEffect[1] = Abilities\Spells\Other\Doom\DoomDeath.mdl
        Set CR_SpecialEffect[2] = Objects\Spawnmodels\Human\HCancelDeath\HCancelDeath.mdl
        Set CR_Caster = (Triggering unit)
        Set CR_TargetedUnit = (Target unit of ability being cast)
        Set CR_Level = (Level of Chain Reaction (Channel) for CR_Caster)
        Set CR_TargetPoint = (Position of CR_TargetedUnit)
        Set CR_CasterPoint = (Position of CR_Caster)
        Set CR_Group[1] = (Units within CR_AOE of CR_CasterPoint matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of CR_Caster)) Equal to True) and ((Matching unit) Not equa
        Custom script:   call RemoveLocation (udg_CR_CasterPoint)
        Set CR_Group[2] = (Random CR_MaxTargets units from CR_Group[1])
        Unit - Cause (Last created unit) to damage CR_TargetedUnit, dealing (CR_Damage + (100.00 x (Real(CR_Level)))) damage of attack type Normal and damage type Normal
        Special Effect - Create a special effect at CR_TargetPoint using CR_SpecialEffect[2]
        Special Effect - Destroy (Last created special effect)
        Unit Group - Pick every unit in CR_Group[2] and do (Actions)
            Loop - Actions
                Unit - Create 1 Dummy Caster for (Owner of CR_Caster) at CR_TargetPoint facing Default building facing degrees
                Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                Unit - Add Chain Reaction (AcidBomb) to (Last created unit)
                Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb (Picked unit)
                Unit - Cause (Last created unit) to damage (Picked unit), dealing (CR_Damage + (100.00 x (Real(CR_Level)))) damage of attack type Normal and damage type Normal
        Custom script:   call RemoveLocation (udg_CR_TargetPoint)
        Countdown Timer - Start CR_Timer as a Repeating timer that will expire in CR_TimerInterval seconds

Code:
 Chain Reaction Cont
    Events
        Time - CR_Timer expires
    Conditions
    Actions
        Set CR_Continue = (CR_Continue + (10.00 - (2.00 x ((Real(CR_Level)) - 1.00))))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random real number between 0.00 and 100.00) Greater than or equal to CR_Continue
            Then - Actions
                Set CR_Level = (Level of Chain Reaction (Channel) for CR_Caster)
                Set CR_NextCaster = (Random unit from CR_Group[2])
                Set CR_NextCasterPoint = (Position of CR_NextCaster)
                Custom script:   call DestroyGroup(udg_CR_Group[1])
                Set CR_Group[1] = (Units within CR_AOE of CR_NextCasterPoint matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of CR_Caster)) Equal to True) and ((Matching unit) Not 
                Custom script:   call DestroyGroup(udg_CR_Group[2])
                Set CR_Group[2] = (Random CR_MaxTargets units from CR_Group[1])
                Unit - Create 1 Dummy Caster for (Owner of CR_Caster) at CR_NextCasterPoint facing Default building facing degrees
                Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
                Unit - Add Chain Reaction (FoK) to (Last created unit)
                Unit - Set level of Chain Reaction (FoK) for (Last created unit) to CR_Level
                Unit - Order (Last created unit) to Night Elf Warden - Fan Of Knives
                Special Effect - Create a special effect at CR_NextCasterPoint using CR_SpecialEffect[2]
                Special Effect - Destroy (Last created special effect)
                Custom script:   call RemoveLocation (udg_CR_NextCasterPoint)
            Else - Actions
                Countdown Timer - Pause CR_Timer


steveROGERS
 

Attachments

  • Chain Reaction.w3x
    66.3 KB · Views: 409

NapaHero

Back from the dead...
Reaction score
43
Put your spoiled triggers in code tags.

Just some points:

- Leaks
- Leaks
- Leaks
- Leaks

Read a leak remove tutorial before submiting. Spells will not be approved if they have leaks.
 
S

steveROGERS

Guest
Specific

Put your spoiled triggers in code tags.

Just some points:

- Leaks
- Leaks
- Leaks
- Leaks

Read a leak remove tutorial before submiting. Spells will not be approved if they have leaks.

Most of the obvious leaks have been removed. Thanks for your input, if you could mention any specific leaks I may have missed, that would be most helpful.
 

Tinki3

Special Member
Reaction score
418
This is cool :D

A "bug" I must point out - the target is damaged before the 1st projectile hits, which doesn't look right.

Leaks are in bold (quite a few):
Code:
Chain Reaction
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Chain Reaction (Channel)
    Actions
        -------- Safety --------
        Countdown Timer - Pause CR_Timer
        Set CR_Continue = -5.00
        -------- Customizing --------
        Set CR_AOE = 500.00
        Set CR_TimerInterval = 0.80
        Set CR_MaxTargets = 3
        Set CR_Damage = 200.00
        Set CR_SpecialEffect[1] = Abilities\Spells\Other\Doom\DoomDeath.mdl
        Set CR_SpecialEffect[2] = Objects\Spawnmodels\Human\HCancelDeath\HCancelDeath.mdl
        -------- Setup --------
        Set CR_Caster = (Triggering unit)
        Set CR_TargetedUnit = (Target unit of ability being cast)
        Set CR_Target = ([B]Random CR_MaxTargets units from (Units within CR_AOE of (Position of CR_TargetedUnit) matching ((((Matching unit) belongs to an enemy of (Owner of CR_Caster)) Equal to True) and ((((Matching unit) is A flying unit) Equal to False) and ((((Matching unit) is ...[/B]
        Set CR_Level = (Level of Chain Reaction (Channel) for CR_Caster)
        Set CR_TempPoint = (Position of CR_Caster)
        Unit - Create 1 Dummy Caster for (Owner of CR_Caster) at CR_TempPoint facing Default building facing degrees
        Custom script:   call RemoveLocation (udg_CR_TempPoint)
        Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
        Unit - Add Chain Reaction (AcidBomb) to (Last created unit)
        Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb CR_TargetedUnit
        Unit - Cause (Last created unit) to damage CR_TargetedUnit, dealing (CR_Damage + (100.00 x (Real(CR_Level)))) damage of attack type Normal and damage type Normal
        Wait until ((CR_TargetedUnit has buff Chain Reaction (Acid Bomb)) Equal to True), checking every 0.10 seconds
        [B]Special Effect - Create a special effect at (Position of CR_TargetedUnit) using CR_SpecialEffect[1][/B]
        Unit Group - Pick every unit in CR_Target and do (Actions)
            Loop - Actions
                Set CR_TempPoint = (Position of CR_TargetedUnit)
                Unit - Create 1 Dummy Caster for (Owner of CR_Caster) at CR_TempPoint facing Default building facing degrees
                Custom script:   call RemoveLocation (udg_CR_TempPoint)
                Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                Unit - Add Chain Reaction (AcidBomb) to (Last created unit)
                Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb (Picked unit)
                Unit - Cause (Last created unit) to damage (Picked unit), dealing (CR_Damage + (100.00 x (Real(CR_Level)))) damage of attack type Normal and damage type Normal
        Wait CR_TimerInterval seconds
        Countdown Timer - Start CR_Timer as a Repeating timer that will expire in CR_TimerInterval seconds
-> Random CR_MaxTargets units from (Units within CR_AOE of (Position of CR_TargetedUnit) matching ((((Matching unit) belongs to an enemy of (Owner of CR_Caster)) Equal to True) and ((((Matching unit) is A flying unit) Equal to False) and ((((Matching unit) is ...

This is a big leak. You need to store both groups (yes, it does contain 2 unit groups) into variables before you make reference to their content, and "Position of CR_TargetedUnit" is a seperate leak inside the other 2; to clean it, you must first store "Position of CR_TargetedUnit" into a point variable, reference that variable when need be, then remove the variable (just like the way you've done in the unit group statement with the "CR_TempPoint" variable).

Here is a quick example of how to clean these leaks:

Code:
Set Temp_Point = (Position of (Triggering unit))  [COLOR="Green"]//Set our point[/COLOR]
Set Group[1] = (Units within 512.00 of Temp_Point)  [COLOR="Green"]//The big cheese[/COLOR]
Set Group[2] = (Random 4 units from Group[1])  [COLOR="Green"]//The sub-group[/COLOR]
[COLOR="DarkGreen"]-------- Do something with the 2nd/sub group --------[/COLOR] 
Custom script:   call RemoveLocation(udg_Temp_Point)
Custom script:   call DestroyGroup(udg_Group[1])
Custom script:   call DestroyGroup(udg_Group[2])
If you're wondering why the leak contains 2 unit groups, it's because the function "Random N Units From Group" is actually a sub-group, which is a unit group, which is a leak if not handled properly. The sub-group is "created" here: "Random CR_MaxTargets units from...". The 2nd group in the leak is basically everything after "Random CR_MaxTargets units from".


-> Special Effect - Create a special effect at (Position of CR_TargetedUnit) using CR_SpecialEffect[1]

2 leaks here. The special effect itself is leaking, as it isn't destroyed, and "(Position of CR_TargetedUnit)" is a point leak.

Simple cleaning here:
Code:
Set Temp_Point = (Position of CR_TargetedUnit)
Special Effect - Create a special effect at Temp_Point using CR_SpecialEffect[1]
Special Effect - Destroy (Last created special effect)
Custom script:   call RemoveLocation(udg_Temp_Point)

Those seem to be the only leaks in the "Chain Reaction" trigger.
In the "Chain Reaction Cont" trigger, the only leaks are located in the "CR_Target" unit group. Clean them exactly the same way as shown above.

Also, CR_TempPoint can be used/referenced more than once before removing; you were setting, referencing once, removing, then setting again and referencing once and then removing in the "Chain Reaction Cont" trigger. You can just set it once and remove it when your finished with it. A time when you should remove a point variable more than once in the same trigger, is when you need to change what point it is storing inside of it (the "new" point should be set after removing the "old"/previous point).

If you havn't already, I advise you to have a read over this memory-leak-cleaning tutorial:
http://www.thehelper.net/forums/showthread.php?t=27219
 
S

steveROGERS

Guest
Unbelievable

Your last post was an unbelievable help, thanks for taking the time to sort through my messes. I read over the advice you gave and the link you gave, with fingers crossed I eliminated all the major leaks.

>>>A "bug" I must point out - the target is damaged before the 1st projectile hits, which doesn't look right.

I found this to be too large a problem to handle, and just eliminated the first projectile making it more of an instant cast.

>>>Random CR_MaxTargets units from (Units within CR_AOE of (Position of CR_TargetedUnit) matching ((((Matching unit) belongs to an enemy of (Owner of CR_Caster)) Equal to True) and ((((Matching unit) is A flying unit) Equal to False) and ((((Matching unit) is ...

I had no idea using random units created another unit group; took your advice.

Finally after all this, I noticed that on start-up there is a bit of lag only with the first cast. Is there a suggestion to fix this? Forum searches suggested to pre-load units and abilities?

Thanks again for all your help and patience.
 

Tinki3

Special Member
Reaction score
418
Code is almost leakless, gj.

> lag only with the first cast. Is there a suggestion to fix this?

Yeah you got it right - preload.
It's not that bigger deal though, I wouldn't worry about it.


The cont trigger needs to be set out exactly like this:
Code:
Chain Reaction Cont
    Events
        Time - CR_Timer expires
    Conditions
    Actions
        Set CR_Continue = (CR_Continue + (10.00 - (2.00 x ((Real(CR_Level)) - 1.00))))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random real number between 0.00 and 100.00) Greater than or equal to CR_Continue
            Then - Actions
                Set CR_Level = (Level of Chain Reaction (Channel) for CR_Caster)
                Set CR_NextCaster = (Random unit from CR_Group[2])
                Set CR_NextCasterPoint = (Position of CR_NextCaster)
                Custom script:   call DestroyGroup(udg_CR_Group[1])
                Set CR_Group[1] = (Units within CR_AOE of CR_NextCasterPoint matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of CR_Caster)) Equal to True) and ((Matching unit) Not 
                Custom script:   call DestroyGroup(udg_CR_Group[2])
                Set CR_Group[2] = (Random CR_MaxTargets units from CR_Group[1])
                Unit - Create 1 Dummy Caster for (Owner of CR_Caster) at CR_NextCasterPoint facing Default building facing degrees
                Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
                Unit - Add Chain Reaction (FoK) to (Last created unit)
                Unit - Set level of Chain Reaction (FoK) for (Last created unit) to CR_Level
                Unit - Order (Last created unit) to Night Elf Warden - Fan Of Knives
                Special Effect - Create a special effect at CR_NextCasterPoint using CR_SpecialEffect[2]
                Special Effect - Destroy (Last created special effect)
                Custom script:   call RemoveLocation (udg_CR_NextCasterPoint)
            Else - Actions
                Countdown Timer - Pause CR_Timer
Before, you had the custom scripts for destroying the groups in the "Else - Actions" - they needed to be in "Then - Actions" (in the order as seen in the above trig.)

Leave the other trigger as is - seems to be fine.
 
S

steveROGERS

Guest
>>Before, you had the custom scripts for destroying the groups in the "Else - Actions" - they needed to be in "Then - Actions" (in the order as seen in the above trig.)

Makes much more sense to have them where you placed them. To be honest I had just thrown them in there hoping they worked. :banghead:

Thanks again for everything.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top