• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Health Cost spells cause game crash.

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,986
Hello everyone!

In my map, I have this Hero that uses Health as a resource for his abilities. Some time ago I noticed that occasionaly his spells cause game crashing. I tested more and I found out that it happens only if his spell is about to kill him.

What have I done so far?

1.) Initially in order to decrease his health, I used the action that sets his Life to a certain value (ex: Curren Life - Health Cost). I thought this could be causing the problem, so I changed the action with another one - now an unreachable unit in one of the map corners damages the hero for amount equal to the health cost every time he casts an ability. The problem is still there.

2.) I made a condition that checks if his current health is greater than 0. That way, none of the actions will happen. It did not work, so i removed it.

EDIT: Me and a friend of mine went through some ideas and found out some stuff. We also changed the triggers, so maybe it will now be easier to find the issue. Here is what we did/found:
  • We added a condition at the beginning of each trigger. If the unit's current health is less than the health cost we kill it. If not -> execute the actions. However, even with this seemingly resolving solution, the game still crashed.
  • I made a test trigger that simply kills the hero if I press ESC, because in the point above I also kill him if he lacks health to cast the ability. This test trigger did not crash the game.
  • That makes it very weird, because the outcome of the first and second point is the same -> the hero dies, killed by a trigger. However the first point crashes the game and the second doesn't.
  • Triggers have been updated.

Here is the code for his spells:

Setting up Health Costs

[trigger=""]Health Costs Setup
Events
Unit - A unit Learns a skill
Conditions
(Unit-type of (Triggering unit)) Equal to |c00575655Shadow Knight|r
Actions
-------- Shadow Coil --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Shadow Coil for ShadowKnight) Equal to 1
Then - Actions
Set SK_ShadowCoilCost = 40.00
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Shadow Coil for ShadowKnight) Equal to 2
Then - Actions
Set SK_ShadowCoilCost = 105.00
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Shadow Coil for ShadowKnight) Equal to 3
Then - Actions
Set SK_ShadowCoilCost = 180.00
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Shadow Coil for ShadowKnight) Equal to 4
Then - Actions
Set SK_ShadowCoilCost = 240.00
Else - Actions
-------- Shadow Strength --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Shadow Strength for ShadowKnight) Equal to 1
Then - Actions
Set SK_ShadowStrengthCost = 30.00
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Shadow Strength for ShadowKnight) Equal to 2
Then - Actions
Set SK_ShadowStrengthCost = 80.00
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Shadow Strength for ShadowKnight) Equal to 3
Then - Actions
Set SK_ShadowStrengthCost = 130.00
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Shadow Strength for ShadowKnight) Equal to 4
Then - Actions
Set SK_ShadowStrengthCost = 180.00
Else - Actions
-------- Obliterate --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Obliterate for ShadowKnight) Equal to 1
Then - Actions
Set SK_ObliterateCost = 45.00
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Obliterate for ShadowKnight) Equal to 2
Then - Actions
Set SK_ObliterateCost = 125.00
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Obliterate for ShadowKnight) Equal to 3
Then - Actions
Set SK_ObliterateCost = 200.00
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Obliterate for ShadowKnight) Equal to 4
Then - Actions
Set SK_ObliterateCost = 275.00
Else - Actions
[/trigger]


Ability 1 (Shadow Coil)

[trigger=""]Shadow Coil Cost
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Shadow Coil
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Life of (Triggering unit)) Greater than SK_ShadowStrengthCost
Then - Actions
Trigger - Turn on Shadow Coil <gen>
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Triggering unit) has buff Death Incarnate ) Equal to True
Then - Actions
Else - Actions
Unit - Cause |c00f6df3eKergaloth|r 0922 <gen> to damage (Triggering unit), dealing SK_ShadowCoilCost damage of attack type Spells and damage type Universal
Else - Actions
Unit - Kill (Triggering unit)
[/trigger]

The events for the next trigger are added elsewhere. Here they are:
[trigger=""]Configuration2
Events
Unit - A unit enters (Playable map area)
Conditions
(Max life of (Triggering unit)) Greater than 5.00
Actions
Trigger - Add to Shadow Coil <gen> the event (Unit - (Triggering unit) Takes damage)[/trigger]

[trigger=""]Configuration
Events
Map initialization
Conditions
Actions
Set ShadowCoil_Group = (Units in (Playable map area))
Unit Group - Pick every unit in ShadowCoil_Group and do (Trigger - Add to Shadow Coil <gen> the event (Unit - (Picked unit) Takes damage))
Custom script: call DestroyGroup(udg_ShadowCoil_Group)[/trigger]


[trigger=""]Shadow Coil
Events
Conditions
Actions
Set ShadowCoil_Damaged = (Triggering unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(ShadowCoil_Damaged has buff Shadow Coil ) Equal to True
Then - Actions
Unit - Remove Shadow Coil buff from ShadowCoil_Damaged
Unit - Cause ShadowKnight to damage ShadowCoil_Damaged, dealing ((10.00 + (80.00 x (Real((Level of Shadow Coil for ShadowKnight))))) + (0.03 x (Max life of ShadowKnight))) damage of attack type Spells and damage type Normal
Unit - Order ShadowCoil_Damaged to Attack ShadowKnight
Trigger - Turn off (This trigger)
Else - Actions
[/trigger]


Ability 2 (Shadow Strength)

This is a Roar-like spell that resets the cooldown of his other 2 abilities. The code is just for the health cost and the reset.
[trigger=""]Shadow Strength Cost
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Shadow Strength
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Life of (Triggering unit)) Greater than SK_ShadowStrengthCost
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Triggering unit) has buff Death Incarnate ) Equal to True
Then - Actions
Else - Actions
Unit - Cause |c00f6df3eKergaloth|r 0922 <gen> to damage (Triggering unit), dealing SK_ShadowStrengthCost damage of attack type Spells and damage type Universal
Set ShadowCoil_Level = (Level of Shadow Coil for (Triggering unit))
Set Obliterate_Level = (Level of Obliterate for (Triggering unit))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Obliterate for (Triggering unit)) Greater than or equal to 1
Then - Actions
Unit - Remove Obliterate from (Triggering unit)
Unit - Add Obliterate to (Triggering unit)
Unit - Set level of Obliterate for (Triggering unit) to Obliterate_Level
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Shadow Coil for (Triggering unit)) Greater than or equal to 1
Then - Actions
Unit - Remove Shadow Coil from (Triggering unit)
Unit - Add Shadow Coil to (Triggering unit)
Unit - Set level of Shadow Coil for (Triggering unit) to ShadowCoil_Level
Else - Actions
Else - Actions
Unit - Kill (Triggering unit)
[/trigger]


Ability 3 (Obliterate)

[trigger=""]Obliterate
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Obliterate
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Life of (Triggering unit)) Greater than SK_ObliterateCost
Then - Actions
Set Obliterate_Center = (Position of (Triggering unit))
Set Obliterate_Bonus = (0.06 x (Life of (Triggering unit)))
Set Obliterate_Group = (Units within 225.00 of Obliterate_Center matching (((Owner of (Matching unit)) Not equal to Player 1 (Red)) and (((Owner of (Matching unit)) Not equal to Player 2 (Blue)) and (((Owner of (Matching unit)) Not equal to Player 3 (Teal)) and (((Owner of (Matchin
-------- ----------------------------------- --------
-------- ------------HEAL------------ --------
-------- ----------------------------------- --------
Set Obliterate_HealCounter = (Number of units in Obliterate_Group)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Triggering unit) has an item of type |c001e53c9Sword of Darkness|r) Equal to True
Then - Actions
Set Heal_Obliterate_Amount = ((0.02 x (Max life of (Triggering unit))) + ((5.00 + (15.00 x (Real((Level of (Ability being cast) for (Triggering unit)))))) x (Real(Obliterate_HealCounter))))
Else - Actions
Set Heal_Obliterate_Amount = (0.00 + ((5.00 + (15.00 x (Real((Level of (Ability being cast) for (Triggering unit)))))) x (Real(Obliterate_HealCounter))))
Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + Heal_Obliterate_Amount)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Obliterate_HealCounter Greater than or equal to 1
Then - Actions
Floating Text - Create floating text that reads (|c0010db0a+ + (String((Integer(Heal_Obliterate_Amount))))) above (Triggering unit) with Z offset 0.00, using font size 8.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 100.00 towards (Random real number between 45.00 and 135.00) degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the lifespan of (Last created floating text) to 1.30 seconds
Floating Text - Change the fading age of (Last created floating text) to 0.65 seconds
Else - Actions
-------- ----------------------------------- --------
-------- ------------DAMAGE------------ --------
-------- ----------------------------------- --------
Unit Group - Pick every unit in Obliterate_Group and do (Actions)
Loop - Actions
Set Obliterate_Damage = (70.00 x (Real((Level of Obliterate for (Triggering unit)))))
Unit - Cause (Triggering unit) to damage (Picked unit), dealing (Obliterate_Damage + Obliterate_Bonus) damage of attack type Spells and damage type Normal
Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Undead\OrbOfDeath\AnnihilationMissile.mdl
Set ObliterateSFX = (Last created special effect)
Special Effect - Destroy ObliterateSFX
Sound - Play PossessionMissileHit1 <gen>
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Triggering unit) has buff Death Incarnate ) Equal to True
Then - Actions
Else - Actions
-------- ----------------------------------- --------
-------- ------------COST------------ --------
-------- ----------------------------------- --------
Unit - Cause |c00f6df3eKergaloth|r 0922 <gen> to damage (Triggering unit), dealing SK_ObliterateCost damage of attack type Spells and damage type Universal
Custom script: call RemoveLocation (udg_Obliterate_Center)
Custom script: call DestroyGroup(udg_Obliterate_Group)
Else - Actions
Unit - Kill (Triggering unit)
[/trigger]
 
Last edited:
spasorc said:
I know I can check if his current health is less than or equal to the health cost. If it isn't - nothing happens. That way, if the hero has no health to cast the ability, nothing will happen. And then I reset the ability cooldown. This method, I still haven't tried and I wish to use it only if we don't find another solution here.

This method is perfectly fine, why don't you want to use it (assuming I understand what you're saying)?
 

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,986
I want to only see the line(s) that crash?

If I knew which were the lines, I wouln't be posting here. :)
I stated what's the problem, I gave my code so people can look through it for mistakes (cause something is obviously wrong, I just don't know what). If noone finds any stupid mistakes, or does not find something that may cause the problem, I will use the method I talked about.
 

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,986
I made some changes hopefully in the right direction. The issue is still there though. Triggers have been updated and I posted my thoughts on the edit above.

I also want to clarify something again. These tirggers crash the game only if the health cost is about to kill the hero. The rest of the time, they work flawlessly.
 
You don't need to set a variable for special effects when your gonna destroy them anyway :)

In Shadow Coil Ability... do you really need to order the ShadowCoil_Damaged unit to attack the ShadowKnight? what if ShadowCoil_Damaged is dead?

According to your 3rd Ability the Obliterate..
It will heal the triggering unit so u can remove it's condition (Life of (Triggering unit)) Greater than SK_ObliterateCost
if u r healing the triggering unit and damaging it also it doesn't make sense xD
 

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,986
You don't need to set a variable for special effects when your gonna destroy them anyway :)

Thanks, I'll keep it in mind, but let's stick to the problem here, alright?

In Shadow Coil Ability... do you really need to order the ShadowCoil_Damaged unit to attack the ShadowKnight? what if ShadowCoil_Damaged is dead?

Shadow Coil is a taunting ability, it orders the targeted unit to attack the caster. And I clearly said that game crash happens only if the hero casts an ability and the health cost kills him. Apart from that, abilities work perfectly.

According to your 3rd Ability the Obliterate..
It will heal the triggering unit so u can remove it's condition (Life of (Triggering unit)) Greater than SK_ObliterateCost
if u r healing the triggering unit and damaging it also it doesn't make sense xD

The Obliterate ability restores an amount of health that increases for each damaged unit.


Don't take this personally, but I hate it when someone asks how to solve a specific problem, posts the triggers and people start looking through them and suggest stuff that is totally irrelevant to the problem. Like this:

You can store the TriggeringUnit() to a unit variable, you use it so many times.

Ok, thanks for the info, but this clearly doesn't cause the problem. And I posted here for the problem, not to optimize it. I don't wanna sound rude, but when someone asks about a specific porblem, if you wanna help, think how to solve the problem........

Thanks for your reply, but please I am looking for the reason that causes game crash. Game crash that happens only when the hero is about to be killed by his own ability. The hero & his abilities perform well, ok? They work perfectly. Only when he is extremely low on health and casts one of his abilities, game crashes.
 
Level 9
Joined
Dec 12, 2007
Messages
489
Check the HP of the hero before executing the whole codes may solve the issue easily.
If it's below X value, skip remaining actions.
he did it already.

honestly, judging from the trigger you posted, there's nothing wrong with it.

have you try copy only your ability and trigger to empty map and test it there?
if the problem exists then its true the trigger is the problem, else other trigger in map might causes it.

the fact that you use another trigger to see if the crash happen because the unit dies can't be used as base ground if the situation / sequence you do during of testing is different since we're dealing with trigger here.
 

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,986
maybe it's because of |c00f6df3eKergaloth|r?? who is this unit ?
I mean,... do you own this unit?... or a neutral hostile?
This is the one who damages the triggering unit right?

Yes, he is the one that damages the unit. It's a unit that belongs to Player 12, who is an enemy player. As I mentioned before, I decided to use this method instead of set health to.. because I thought this may be causing the problem. However, both methods end up with game crash.
 
Level 12
Joined
Oct 16, 2010
Messages
680
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Light
    • Actions
      • Unit - Cause Footman 0002 <gen> to damage (Triggering unit), dealing 1000.00 damage of attack type Hero and damage type Universal
works flowlessly for me:/ i don't think the problem really is that the unit dies from the damage, but it is sure connected with it.
But as told earlier share test map
 
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Light
    • Actions
      • Unit - Cause Footman 0002 <gen> to damage (Triggering unit), dealing 1000.00 damage of attack type Hero and damage type Universal
works flowlessly for me:/ i don't think the problem really is that the unit dies from the damage, but it is sure connected with it.
But as told earlier share test map

Try making a condition where..
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Light
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Life of triggering unit Greater than HP COST
        • Then - Actions
          • Unit - Cause Footman 0002 <gen> to damage (Triggering unit), dealing HP COST damage of attack type Hero and damage type Universal
        • Else - Actions
          • Unit - Kill triggering unit
 
Last edited:
Level 11
Joined
Nov 15, 2007
Messages
800
I don't see anything that would be crashing. It's possible the unit dying to its health costs is causing something else entirely to run which you've overlooked, and that's where the crash comes in.

I'd recommend disabling every other trigger and seeing if it still happens.

Oh, this is a couple months old. :bored:
 
Status
Not open for further replies.
Top