HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

AoE Heal on Attack

10-07-2009, 06:14 AM#1
FootysMaXeD
Hello, this is my first post on this forum. I found these forums looking for a good map protector, but I have found a lot more than that. :D

I'm trying to make a skill for a unit in my map, and i'm having a little bit of trouble making it work properly. I'm trying to create an ability that heals units in an AoE around the unit, only triggered upon attack, but has a cooldown of 5 seconds.

So what I did is use a base ability of Searing Arrows (made the damage zero, changed icon, and added 5s cd).

I created a trigger that looks like this:
Events-
Unit- A unit begins casting an ability
Condition-
(Ability being cast) Equal to Nature's Pulse
Action-
Pick every unit in (Units within 500 of (Position of (Trigger unit)) matching (((Owner of (Matching unit)) is in (All allies of (Triggering player))) equal to true)) and do (Actions)
Loop-Actions
Unit- Set life of (picked unit) to ((Life of picked unit) + 85)
10-07-2009, 07:55 AM#2
Anitarf
the problem is, autocast arrow abilities do not trigger the cast trigger events when they are autocast. You could bypass this by issuing the arrow ability order to the unit whenever it attacks, but that still leaves the problem of it looking weird since the heal effect would trigger long before the attack projectile hits the target. Personally, I would trigger such an ability completely using a damage detection system.
10-07-2009, 08:44 AM#3
Anachron
Couldn't you use an orb attack and set the chance to 100% and set the ability to an instant one, for example berserk, get the berserk cast with a trigger and then AOE heal with your trigger?
10-07-2009, 07:43 PM#4
TheWye
orb that casts frost nova that deals negative damage to allies?
10-07-2009, 08:31 PM#5
Anachron
No, that would suck horribly XD it got delay, and interrupts the attack.
10-07-2009, 08:34 PM#6
The Dark One
How about the following:
Trigger Nature’s Pulse
Event
A unit is attacked
Condition
Unit type of attacking unit equals to (your unit’s type)
Action
Pick every unit in (Units within 500 of (Position of (Trigger unit)) matching (((Owner of (Matching unit)) is in (All allies of (Triggering player))) equal to true)) and do (Actions)
Loop-Actions
Unit- Set life of (picked unit) to ((Life of picked unit) + 85)
Turn on trigger cooldown
Turn off this trigger

And make another trigger:
Trigger cooldown
Event
Time elapsed 5 seconds
Condition
Action
Turn on Trigger Nature’s Pulse
Turn off this trigger

This is a simple approach to the problem but this method doesn’t support mui, i.e. only one unit can have this ability. Nature’s Pulse would be some dummy passive ability and if the unit is a hero (the ability needs to be learned) you can add this condition to the Nature’s Pulse trigger: and level of Nature’s Pulse is equal to or greater then 1.
10-07-2009, 11:30 PM#7
Anitarf
Quote:
Originally Posted by The Dark One
This is a simple approach to the problem but this method doesn’t support mui,
Another problem is that it doesn't work. At all.
10-08-2009, 06:37 AM#8
TheWye
The main problem with the trigger you mentioned is that "Time elapsed 5 seconds" actually means the game has run for 5 seconds after it loads. So it will only run once. And the second thing is that that trigger will leak. After you run it for few times, it will eventually cause laggings.

I have modified your trigger a bit and it "should" work unless I made a few stupid mistakes :s

Trigger:
Natures Pulse
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
(Unit-type of (Attacking unit)) Equal to (==) Footman
Collapse Actions
Trigger - Turn off (This trigger)
Set TempPoint = (Position of (Attacked unit))
Set TempGroup = (Units within 500.00 of TempPoint matching ((((Matching unit) is alive) Equal to (==) True) and ((((Matching unit) is hidden) Equal to (==) False) and ((((Matching unit) is A structure) Equal to (==) False) and ((((Matching unit) belongs to an ally of (Owner
Collapse Unit Group - Pick every unit in TempGroup and do (Actions)
Collapse Loop - Actions
Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 85.00)
Custom script: call RemoveLocation(udg_TempPoint)
Custom script: call DestroyGroup(udg_TempGroup)
Countdown Timer - Start CooldownTimer as a One-shot timer that will expire in 5.00 seconds

and the cooldown trigger will be :

Trigger:
Natures Pulse CooldownActions
Collapse Events
Time - CooldownTimer expires
Conditions
Collapse Actions
Trigger - Turn on Natures Pulse <gen>

You will need to add 3 variables here : TempGroup, TempPoint and CooldownTimer.
The reason why we need TempGroup and TempPoint is to prevent memory leaks caused by the trigger. Everytime "Position of (Attacked unit)" is called, a new location is defined by the trigger. So if you run the trigger for 100 times, there will be 100 different locations on the map. Same thing with "Units within 500.00 of TempPoint matching...blabla", when you call that function, a new group will be created and it will consume memory if it is not disposed.

I suggest you read the "How to clean memory leaks" tutorial in the tutorial section. Hope this helps
10-08-2009, 09:31 AM#9
The Dark One
And that is the difference between an amateur triggerer and an experienced coder, but at least my thought does work, and without a damage detection system.

Clean as it may be, but is there a way to make this ability mui? I don’t think this approach can allow it but maybe another approach can accomplish that.

And about the variables, why not use locals for the TempPoint and TempGroup? And is there any difference between using and not using locals in this case?
10-08-2009, 12:47 PM#10
TheWye
Quote:
And that is the difference between an amateur triggerer and an experienced coder, but at least my thought does work, and without a damage detection system.
This code does work, but it will look a little awkward since it fires everytime the unit "attacks" another unit not when the attack hits. But well, if you don't really care about it in that much detail, it shouldn't be a problem.

Quote:
Clean as it may be, but is there a way to make this ability mui? I don’t think this approach can allow it but maybe another approach can accomplish that.
I have thought of several ways if you want to do it in GUI, but it would involve in using hashtables. Anyway, the new version of the Worldeditor allows the access to attaching data to hashtables in GUI doesn't it?

Quote:
And about the variables, why not use locals for the TempPoint and TempGroup? And is there any difference between using and not using locals in this case?
Well, I'm using globals here because I assume that you will be using TempGroups and TempPoints for other triggers as well. It will be faster to declare one global and use it in many triggers rather than declaring new local variables everytime you want to use it. And if you declare new local variables for location and group, you will need to nullify it in the end to prevent a minor leak.
10-08-2009, 02:00 PM#11
Rising_Dusk
The magickal answer is to use a damage detection system and then code the spell in 15 lines. Really.
10-09-2009, 04:39 PM#12
FootysMaXeD
I found your Damage Detection System in the Resource section Rising_Duck, but it states that it requires all your spells to be triggered. This is not true for my map, so I don't think I can use it.

I made the trigger that you proposed, and it's working nicely except for the Special Effect.

Trigger:
Nature's Respite
Events
Unit - A unit is attacked
Conditions
(Unit type of (Attacking Unit)) equal to Tree
Actions
Set TempPoint = (Position of (Attacked unit))
Set TempGroup = (Units within 500.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is hidden) Equal to False) and ((((Matching unit) is A structure) Equal to False) and ((Matching unit) belongs to an ally of (Owner of (Attacking Unit)) Equal to True)
Collapse Unit Group - Pick every unit in TempGroup and do (Actions)
Loop - Actions
Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 100.00)
Special Effect - Create a special effect attached to overhead of (Picked Unit) using Abilities/heal
Special Effect - Create a special effect attached to overhead of (Attacking Unit) using Replenish
Custom script: call RemoveLocation(udg_TempPoint)
Custom script: call DestroyGroup(udg_TempGroup)
Countdown Timer - Start CooldownTimer as a One-shot timer that will expire in 5.00 seconds

The Special Effect that I triggered makes it so that the (Attacking Unit) gets both of the effects, when I only want him to do the Replenish Effect. Using both special effects causes a very odd rainbow to appear over the unit permanently. Is there some way i can exclude the (Attacking Unit) from the TempGroup for the Heal Special Effect or something along those lines? I still want all the units to be healed though. Also...I need to know if this Trigger is able to be used on multiple units at the same time (I think you call it MUI).

Thank you very much TheWye, I did +reputation to you :). Also thanks for the reference to the Trigger Cleanup thread, I will go ahead and read that now.

Btw, I really like the way i'm able to format triggers in a forum. It even auto-generates the icon based on the first word or two of each line.
10-09-2009, 06:04 PM#13
Rising_Dusk
Your bug originates from the attacking unit being grouped up by your "Pick all units" line. You need to add a check that "Matching Unit is equal to Attacking Unit equal to false" or something like that.
10-09-2009, 06:44 PM#14
The Dark One
It is as Dusk said if you don't want the attacking unit to be healed, but if you do then it is Simple

Trigger:
If picked unit is not equal to (attacking unit) then Special Effect - Create a special effect attached to overhead of (Picked Unit) using Abilities/heal

And why did you put the attacking unit special effect attachment command within the loop? There is only one attacking unit.
And the ability itself can be used by as many units as you want (granted that not too many units are using it at the same time, not very sure). The problem is with the cooldown counter, you have only one and it will run for all of them, i.e. when a unit uses it, it’ll be 5 seconds before another unit can (shared cooldown). To make an mui cooldown system you’ll need a timer array with an array clean up code to keep track of each cooling unit individually.

And wouldn’t the special effects leak and cause lag after some time? There is a destroy special effect code in GUI and I think it is there for a reason (I never experimented with special effects before).