HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Further help with suicide ability

10-23-2006, 12:51 AM#1
WTFish
I had another thread on the forums, where I was having trouble making an ability. I have finished the ability, but it doesn't work as I want it to. Basically, it detonates the caster and heals allies nearby = Casters life / number of people nearby. (damages enemies too, but that part of the trigger works fine, so I'm not worrying about including that at the moment). The initial trigger was very simplistic, but I found that a lot of health was being lost, and the overall health was not retained, and I have tried a lot of things to fix this. At the moment, I think it is fine, I am quite sure that no health is being lost, due to uneven division etc.

Sometimes the ability works fine, sometimes it doesnt:

Eg. I have 4 units at 50 hp, I select them all and detonate them. I now have 2 units at 100 hp(max). In this instance, it worked.

I have 8 units with 25 hp each, I select them all and detonate them. They all blow up and I have 0 left.

I want to make it so the total hp is conserved, and even if you detonate 12 units at a time, you will be left with units, whose total hp will be the same as before.

Here is the trigger.

Trigger:
Detonate
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Detonate
Collapse Actions
Set Caster = (Triggering unit)
Set CasterPosition = (Position of Caster)
Set Temp_Group = (Units within 300.00 of CasterPosition matching (((Matching unit) Not equal to Caster) and ((((Matching unit) is alive) Equal to True) and (((Integer((Life of (Matching unit)))) Less than 100) and ((((Matching unit) belongs to an enemy of (Owner of Caster)) Equal to False) and ((Unit-type of (Matching unit)) Not equal to Sentry Ward))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in Temp_Group) Greater than or equal to 1
Collapse Then - Actions
Set Extralife = ((Integer((Life of Caster))) mod (Number of units in Temp_Group))
Set SpellDamage = (Abs(((Integer((Life of Caster))) / (Number of units in Temp_Group))))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
SpellDamage Less than 1
Collapse Then - Actions
Unit Group - Remove all units of (Random ((Number of units in Temp_Group) - (Integer((Life of Caster)))) units from Temp_Group) from Temp_Group
Set SpellDamage = ((Integer((Life of Caster))) / (Number of units in Temp_Group))
Set Extralife = 0
Collapse Else - Actions
Do nothing
Collapse Unit Group - Pick every unit in Temp_Group and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Integer((Life of (Picked unit)))) + SpellDamage) Greater than 100
Collapse Then - Actions
Set SpillingUnit = (Picked unit)
Set SpillPoint = (Position of SpillingUnit)
Set Temp_Spill_Group = (Units within 300.00 of SpillPoint matching (((Matching unit) Not equal to Caster) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of Caster)) Equal to False) and (((Matching unit) Not equal to SpillingUnit) and ((Unit-type of (Matching unit)) Not equal to Sentry Ward (Level 1))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in Temp_Spill_Group) Greater than 0
Collapse Then - Actions
Set Extralifespill = ((SpellDamage - (100 - (Integer((Life of SpillingUnit))))) / (Number of units in Temp_Spill_Group))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Extralifespill Less than 1
Collapse Then - Actions
Unit Group - Remove all units of (Random ((Number of units in Temp_Spill_Group) - Extralifespill) units from Temp_Spill_Group) from Temp_Spill_Group
Set Extralifespill = ((SpellDamage - (100 - (Integer((Life of SpillingUnit))))) / (Number of units in Temp_Spill_Group))
Collapse Else - Actions
Do nothing
Collapse Unit Group - Pick every unit in Temp_Spill_Group and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Integer((Life of (Picked unit)))) + Extralifespill) Greater than 100
Collapse Then - Actions
Unit - Set life of (Picked unit) to 100.00
Unit - Create 1 UnitName for (Owner of SpillingUnit) at (Position of SpillingUnit) facing 0.00 degrees
Unit - Set life of (Last created unit) to (Real(Extralifespill))
Collapse Else - Actions
Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + (Real(Extralifespill)))
Collapse Else - Actions
Set Extralifespill = (SpellDamage - (100 - (Integer((Life of SpillingUnit)))))
Unit - Create 1 UnitName for (Owner of SpillingUnit) at (Position of SpillingUnit) facing 0.00 degrees
Unit - Set life of (Last created unit) to (Real(Extralifespill))
Unit - Set life of SpillingUnit to 100.00
Custom script: call DestroyGroup (udg_Temp_Spill_Group)
Collapse Else - Actions
Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + (Real(SpellDamage)))
Set Extraliferecieveunit = (Random unit from (Units within 300.00 of CasterPosition matching (((Matching unit) Not equal to Caster) and (((Integer((Life of (Matching unit)))) + Extralife) Less than or equal to 100))))
Unit - Set life of Extraliferecieveunit to ((Life of Extraliferecieveunit) + (Real(Extralife)))
Collapse Unit - Kill Caster
Special Effect - Create a special effect at CasterPosition using Units\NightElf\Wisp\WispExplode.mdl
Special Effect - Destroy (Last created special effect)
Custom script: call RemoveLocation(udg_CasterPosition)
Custom script: call RemoveLocation(udg_SpillPoint)
Custom script: call DestroyGroup (udg_Temp_Group)
Collapse Else - Actions
Custom script: call RemoveLocation(udg_CasterPosition)
Custom script: call DestroyGroup (udg_Temp_Group)
Custom script: call RemoveLocation(udg_SpillPoint)

I know, It's probably a lot bigger than it needs to be, but I'm not very good at this stuff yet , havn't mapped for a while...

So... I was wondering if anyone could isolate the problem, and tell me what is making it not work. Also, any suggestions as to ways I could clean up the trigger would be nice.

Thanks.
10-24-2006, 02:37 AM#2
[VDM]Amn
Maybe the trigger is picking units it shouldn't.
debug it all, add a -game message- action once a while, specially in the loops. u know, like;
Trigger:
Game - Display to (All players) the text: string(name of (picked unit))
Game - Display to (All players) the text: string(name of (Caster))
Game - Display to (All players) the text: string(position of (Caster))
Game - Display to (All players) the text: string(integer(life of(Caster)))
then, u just go and cast the skill once. go to messages log and there u have a nice list of messages your trigger created.
there u can realize what's wrong.

(i hope i did write it all ok.)
10-24-2006, 07:10 AM#3
WTFish
K sweet.. I'll do that when I have time and reply with results. Ty.
10-26-2006, 12:44 AM#4
WTFish
Ok I ran a test, here are the results:

4 units in temp group, 25 hp each, 207 total
5 units in temp group, 6 hp each, 2 extra hp for 1 unit, 207 hp total
3 units in temp group, 2 hp each, 2 extra hp for 1 unit, 207 hp total
5 units in temp group, 11 hp each, 4 extra hp for 1 unit, 207 hp total
4 units in temp group, 24 hp each, 2 extra hp for 1 unit, 207 hp total
3 units in temp group, 27 hp each, 1 extra hp for 1 unit, 207 hp total
1 units in temp group, 76 hp each, 41 spilled amongst units, 243 hp total

At the end of this, I have one guy left at 55 hp, nowhere near 243. (max hp of the unit type is 100). How can total hp be 243 when it isn't? the trigger I used to check the amount of total hp was this:
Trigger:
Collapse Unit Group - Pick every unit in (Units owned by Player 1 (Red) matching (((Unit-type of (Matching unit)) Equal to UnitType) and (((Matching unit) is alive) Equal to True))) and do (Actions)
Collapse Loop - Actions
Set totalhealth = (totalhealth + (Integer((Life of (Picked unit)))))
Game - Display to (All players) the text: ((String(totalhealth)) + health total.)
Set totalhealth = 0

Perhaps that problem is with the spilling health part of the trigger? It still doesn't prove why it kills all of the units in certain instances...

Hope this helps someone understand it more, because it only serves to confuse me more, lol .
10-26-2006, 01:07 AM#5
Joker
in your else options, get rid of the
Trigger:
Do Nothing
action. Itll automatically set it as nothing

above your Unit groups put
Trigger:
Custom script: set bj_wantDestroyGroup = true
stops a leak :)
10-26-2006, 07:18 AM#6
WTFish
K sweet thanks. Any other opinions on how to clean up the trigger, or make it work properly would be greatly appreciated.
10-30-2006, 03:52 AM#7
WTFish
Sorry to have to bump this, but I really need some help getting this trigger to work properly.

Thanks.
10-30-2006, 05:47 AM#8
Ignitedstar
I'm not quite sure about what you want help with? Are you "fusing" units together?
10-30-2006, 09:03 AM#9
Pheonix-IV
What exactly is this spell supposed to do? It's too complecated to work out without WE or investing more time than i have.
10-30-2006, 09:20 AM#10
Thunder_Eye
you can make totalhealth an real variable so you dont have to convert it to integer
10-31-2006, 06:18 AM#11
WTFish
Basically what the ability is mean to do is kill the caster distributing their health they had as health amongst allies, where the total health is conserved. Ie: I have 1 guy at 100 hp and 2 at 50 hp. I order the unit at 100 hp to cast this spell, he will die, and the other two units are at 100 hp each. (Health before [100+50+50] = health after [100 + 100].

Other than perhaps problems with the working of this health distribution that I might have missed, the main problem is when getting more than one unit to cast it at the same time. No unit is meant to cast the ability if there is noone under 100 hp (full health) to heal. Sometimes it works (usually when like 4 or under units), sometimes all units cast it and all blow up. (healing... who?)

I did a test, and with text messages, it said for the total health, that it was all there, when I had only one unit left(with a fraction of that hp),

So.. I hope that clears some things up, lol.
11-01-2006, 08:21 AM#12
[VDM]Amn
u know.. if u order a unit to cast detonate, it won't stop no matter what your trigger says. Cuz the event is - unit starts the effect...

i wouldn't use Detonate ability but..

if the unit shouldn't cast it, create another trigger to stop him.
use the - unit begins casting - event. then order him to stop immediately, no waits.

edit: btw, consider that the Pick action may be picking the casting unit too.
11-03-2006, 02:24 AM#13
WTFish
I didn't base the ability of detonate, I based it off 'Roar'. Also, I tried to eliminate the caster from the selected units, and I don't think he is in any of the groups...

So... I really don't know what to do, lol.
11-03-2006, 02:43 AM#14
[VDM]Amn
Quote:
Originally Posted by WTFish
I didn't base the ability of detonate, I based it off 'Roar'. Also, I tried to eliminate the caster from the selected units, and I don't think he is in any of the groups...

So... I really don't know what to do, lol.
mmh...
maybe... save the trigger, the spell, everything. then create slowly all over again. and remember the messages actions, to know what's coming on inside the trigger.

testing that way surely u'll find where the trigger is failing and then u'll go back to the original one as a new man with no mistakes(?).
11-04-2006, 01:22 AM#15
[VDM]Amn
Quote:
Originally Posted by WTFish
Well... I've never done jass before, but I might be able to understand it... lol. Would jass fix the problem I have, where if multiple units are told to cast at the same time, it doesn't work? If so... then I'll have to accept it lol. And if I can't understand it, I'll have to learn to.
No! dont let the dark side tempt you!