HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Using Integer A...

12-30-2005, 05:15 AM#1
Ignitedstar
Alright, now that I know what Integer A does, I decided to use it in response to a multi-healing spell.

It's purpose to to, under a specific area, heal a low amount of health per half second for 3 seconds.

It goes as such...

Code:
 
Multi-Heal
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Multi-Heal
    Actions
        Set TargetGroup = (Units within 400.00 of (Target point of ability being cast) matching (((Matching unit) belongs to an ally of (Triggering player)) Equal to True))
        Set Caster = (Casting unit)
        Set UnitDamageReal = (Real((15 + (3 x (Intelligence of Caster (Include bonuses))))))
        Set UnitHP = (Life of (Matching unit))
        For each (Integer A) from 1 to 7, do (Actions)
            Loop - Actions
                Unit - Set life of (Matching unit) to (UnitHP + UnitDamageReal)
                Floating Text - Create floating text that reads (String((Integer(UnitDamageReal)))) at (Target point of ability being cast) with Z offset 10.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
        Wait 0.50 seconds
        Unit Group - Pick every unit in (Units owned by (Triggering player) of type Cure All Model) and do (Actions)
            Loop - Actions
                Unit - Remove (Matching unit) from the game

While doing this, I kind of understood what I was doing. Anyways, when I tested the spell, the text works, but it only healed 5 times in the supposeably 3 seconds. Plus, the healing doesn't work. This problem also occurs with it's leading levels.

This is my first time actually using the looping action, so would someone mind telling what I did wrong?
12-30-2005, 07:00 AM#2
Panto
In this case, you don't want a For Loop, you want a Pick Every Unit Matching.

Your references to Matching Unit don't match up with anything except in your first use on line 7.
12-30-2005, 08:34 AM#3
Ignitedstar
Hmm... Now that makes a lot more sense. Maybe the only reason why it wasn't working was becuase of the [matching unit] being there... *sigh*

Thanks, Panto. I can't believe I missed that...

There are still 2 issues that remain unsolved that I have no clue on how to fix.

1. How do you make the healing work?
2. How come it only does the healing 5 times, and not 6?

Here is how it looks now:

Code:
 
Multi-Heal
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Multi-Heal 
Actions
Set TargetGroup = (Units within 400.00 of (Target point of ability being cast) matching (((Matching unit) belongs to an ally of (Triggering player)) Equal to True))
Set Caster = (Casting unit)
Set UnitDamageReal = (Real((15 + (3 x (Intelligence of Caster (Include bonuses))))))
Set UnitHP = (Life of (Picked unit))
For each (Integer A) from 1 to 7, do (Actions)
Loop - Actions
Unit Group - Pick every unit in TargetGroup and do (Actions)
Loop - Actions
Unit - Set life of (Picked unit) to (UnitHP + UnitDamageReal)
Floating Text - Create floating text that reads (String((Integer(UnitDamageReal)))) at (Target point of ability being cast) with Z offset 10.00, using font size 14.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 90.00 towards 90.00 degrees
Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
Wait 0.50 seconds

I don't understand why For Each Integer A from 1 to 7 doesn't do it 6 times. It's suppose to, right? Unless it's the Wait trigger...

I'll do what I can for the time being. If I find something out, I'll post it.
12-30-2005, 09:40 AM#4
Blade.dk
1-7 does it 7 times. 1-6 does it 6 times.

And replace [code] tags with [trigger] tags, please, makes it way easier to look at.
12-30-2005, 10:46 AM#5
qwertyui
I don't understand why it does only 5 heals. It should do 7 from what i can tell

I can help with the non-healing bit though.

You see, UnitHp is not auto-updated when you change unit's hp. It still stays the same.

So by doing:
Trigger:
Unit - Set life of (Picked unit) to (UnitHP + UnitDamageReal)
You repeatedly set the unit's hp to the same amount.

It should be like this:
Trigger:
Unit - Set life of (Picked unit) to (Life of (Picked unit) + UnitDamageReal)
And you should get rid of UnitHp variable.
12-30-2005, 10:55 AM#6
qwertyui
Oh yeah, another problem.
And this time its a big one.

Suppose you have 2 units under this spells effect?

The trigger you wrote won't heal them together at once.

He will pick one of them, heal him a bit, wait for 0.5 seconds, then heal the other one a bit, wait for 0.5 seconds more, then heal the first one a bit more, etc until he finishes executing the script.

See the problem?
12-30-2005, 12:55 PM#7
Anitarf
Quote:
Originally Posted by qwertyui
Suppose you have 2 units under this spells effect?

The trigger you wrote won't heal them together at once.

He will pick one of them, heal him a bit, wait for 0.5 seconds, then heal the other one a bit, wait for 0.5 seconds more, then heal the first one a bit more, etc until he finishes executing the script.

That depends on under which loop the wait action is. Of course, we can't know that, because he didn't use the [trigger] tags.

Also, the use of "triggering player" is wrong in this case, the event you use doesn't give you a triggering player, I'm surprised it works anyway. You should use "owner of (triggering unit)". Also, the waits can screw the trigger if you use the variables anywhere else, or if this trigger can run multiple times. The problem is that while this trigger runs, during a wait, another trigger can change your variables, like the TargetGroup and the ammount of hp healed. Same goes for "Target point of ability being cast" which you use in your floating text triggers, the cast event responses are bugged and act globaly, so if you have waits in your trigger, they can get changed by other triggers running.
12-31-2005, 03:39 AM#8
Ignitedstar
Cool, thanks a lot for the healing part. Since you guys want me to post it in trigger text, then I will. It's updated:

Trigger:
Multi-Heal
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Multi-Heal
Collapse Actions
Set TargetGroup = (Units within 400.00 of (Target point of ability being cast) matching (((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True))
Set Caster = (Casting unit)
Set UnitDamageReal = (Real((15 + (3 x (Intelligence of Caster (Include bonuses))))))
Collapse For each (Integer A) from 1 to 6, do (Actions)
Collapse Loop - Actions
Collapse Unit Group - Pick every unit in TargetGroup and do (Actions)
Collapse Loop - Actions
Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + UnitDamageReal)
Floating Text - Create floating text that reads (String((Integer(UnitDamageReal)))) at (Target point of ability being cast) with Z offset 10.00, using font size 14.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 90.00 towards 90.00 degrees
Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
Wait 0.50 seconds

I just tested it, but the intervals seem wrong...

Alright, I did a little test to figure out of the healing was actually healing six times. So, I reduced the healing to one and figured out that the units inside were, in fact, getting healed six. But, the problem was there even though there is a wait, there was no intervals.

Okay, so the only thing that seems to be wrong with the whole trigger is the Wait. How exactly do you fix that?
12-31-2005, 06:04 AM#9
Anitarf
No easy way, really. As I said, waits can really screw the execution of a triggered spell if you use global variables or cast event responses in the trigger. While the trigger waits, any other trigger can change these values.

The only way to avoid this is to have no other trigger than this one use these variables, and only one hero in the map at a time capable of casting this spell, and the spell must have a longer cooldown than duration. Oh, and you need another variable for the target point of casting, as I said, cast event responses are bugged, they can get reset by other triggers too... unless you base your spell on a point-target summon spell (like inferno) which summons a dummy unit and use the summon event and summon event responses, which aren't bugged like cast event responses... but just making another point variable is probably easier.

Btw, move the wait action from the "pick every unit" loop to the "Integer A" loop, I assume you want it to heal all the units each 0.5 seconds.
01-09-2006, 11:11 AM#10
Shisho
You can't use Integer A in loops regarding spells wait periods. When you use it where it's not executed immediately, Integer A gets reused everytime it's triggered. So if another unit triggers it's going to start using Integer A at the point it's currently at from the other units triggering iteration. Each wait condition will further the loop ahead an iteration, dividing the loop iterations between two units for the remainder of the loop. Only when the loop completes will Integer A be reset by the next loop call.

To understand what I'm saying just make a Game Message that Concatenates the following: "Player " + ToString(PlayerNumber(Owner(Triggering Unit))) + " - " + ToString(IntegerA)

You'll see how their loop indexes collide when using the same global.

They share the same looping index so a good easy GUI trigger way to solve this problem is to make an Array to hold your loop indexes. There's two ways you can incorporate this. If it's a unique unit that's using the spell per player you can make an array[] by 12 indexes. If it's a unit thing you'll want to make the index amount to how many units you want maximum being able to utilize the spell at one given period, and figure out a way to track their indexes.

1 unit per player solution:
PlayerArray[12] Integer in variable manager

For Each (PlayerArray[Owner of Triggering Unit]) 1 to 6

This gives each player their own unique integer value to loop through simultaneously if need be.

Trigger:
Example
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Animate Dead
Collapse Actions
Collapse For each (Integer PlayerArray[(Player number of (Owner of (Triggering unit)))]) from 1 to 6, do (Actions)
Collapse Loop - Actions
-------- Stuff --------
Wait 1.00 seconds
-------- Stuff --------

The multi unit one I think can only be done in JASS code, because I think you'll need a local variable to track the available and usable indexes, because the same problem will happen with waiting loops on a shared global.

I was just thinking if it's only 6 actions you can cheese it and just do it without a loop with like 6 waits and 6 duplicate blocks. I think that would work with with multiple units with multiple players .
01-09-2006, 01:10 PM#11
Jacek
Thats why I say GUI spells are :((
01-09-2006, 03:47 PM#12
SmileyJeff
I did it in 3 seperate triggers:
Trigger:
MultiHeal1
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Animate Dead
Collapse Actions
Set MultiHealCast = (Casting unit)
Set Group = (Units within 400.00 of (Target point of ability being cast) matching ((((Matching unit) belongs to an ally of (Owner of MultiHealCast)) Equal to True) and (((Matching unit) is alive) Equal to True)))
Set LifeBonus = (15 + (3 x (Intelligence of MultiHealCast (Include bonuses))))
Trigger - Turn on MultiHeal2 <gen>
Countdown Timer - Start MultiHealEnd as a One-shot timer that will expire in 3.00 seconds
Initially Off
Trigger:
MultiHeal2
Collapse Events
Time - Every 0.50 seconds of game time
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in Group and do (Actions)
Collapse Loop - Actions
Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + (Real(LifeBonus)))
Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Human\Heal\HealTarget.mdl
Trigger:
MultiHeal3
Collapse Events
Time - MultiHealEnd expires
Conditions
Collapse Actions
Trigger - Turn off MultiHeal2 <gen>
*Trigger tags looks weird
01-09-2006, 04:02 PM#13
Anitarf
Wrong, the event of MultiHeal2 gives you no casting unit or casting point. You need to create the unit group when the spell is cast and store it in a variable as well.
01-09-2006, 04:06 PM#14
SmileyJeff
Ops, done :)