Staredit Network > Forums > SC2 Assistance > Topic: Changing Total Damage Done
Changing Total Damage Done
Apr 28 2011, 7:36 pm
By: DevliN  

Apr 28 2011, 7:36 pm DevliN Post #1

OVERWATCH STATUS GO

I have an ability that does constant damage over 2 seconds. To larger enemies, it can deal a ton more damage than it could to smaller enemies, but I don't necessarily want that to happen. I've already found a way to fix this by dealing damage over time via behaviors rather than a damage effect.

I was playing around with the "Unit takes damage from effect" event before I figured out the behavior solution, and I was wondering if it was possible to set a cap on the amount of damage that is done via triggers. I know you can set it so the unit takes no damage, minimal, or maximum damage, but is it possible to prevent all damage that the effect does after a certain point, like capping it at 50 or something?



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Apr 28 2011, 10:38 pm Ahli Post #2

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

If you only want to track damage done by triggers, I would use a custom value to track the dealt damage by triggers and lower it before.
You can use catalog to modify the damage value before applying it with the effect action.

-> Calc damage, check damage upper border (read unit's custom value), set damage effect's damage, add applied damage value to custom value, apply damage effect.




Apr 28 2011, 11:52 pm DevliN Post #3

OVERWATCH STATUS GO

I don't think I understand completely, but I probably should have added more info to the OP.

Originally I had an ability that creates a Persistent Effect with a duration of 2 seconds. It deals 1 damage every .1 second for the entire duration, and I have a Search Effect managing what gets hit. For a unit the size of a Marine, it is fine, and deals something like 30 damage total. For a larger unit (like the size of a Thor), it deals around 200 damage (as it is getting hit by multiple Damage Effects). I was looking into using Triggers to create a damage cap so the ability couldn't deal more than 50 damage to a single enemy unit.

The issue I was having is that I want it to be a constant stream of damage until it hits a certain point. I wanted to avoid having to apply damage afterward as the ability isn't channeled or anything, it just freely hits enemies in front of the unit as the unit is moving. My assumption is that with that trigger, if I use the ability and spin around quickly (hitting all nearby enemies in a circle) then they would all take the maximum amount of damage, but I really want them to take whatever damage they would normally get as long as it doesn't exceed 50.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Apr 29 2011, 1:28 am Roy Post #4

An artist's depiction of an Extended Unit Death

Quote from DevliN
Originally I had an ability that creates a Persistent Effect with a duration of 2 seconds. It deals 1 damage every .1 second for the entire duration, and I have a Search Effect managing what gets hit. For a unit the size of a Marine, it is fine, and deals something like 30 damage total. For a larger unit (like the size of a Thor), it deals around 200 damage (as it is getting hit by multiple Damage Effects). I was looking into using Triggers to create a damage cap so the ability couldn't deal more than 50 damage to a single enemy unit.
Which part of this is being controlled via triggers? Or is this all handled by the data editor? Using unit groups, it wouldn't be a problem to have one unit not take the hit multiple times, so I'm going to assume the latter.

Using the "Unit Takes Damage" you can find each instance of when the unit is harmed by the effect. You can increment a custom value of the unit by the amount of damage the unit receives (i.e. "Set (Last created unit) custom value 0 to (Triggering damage amount)"). When this value is above your damage cap, you have to disable or negate the effect on the unit. Since I don't think disabling an effect for one unit is possible, you would have to go with negation. Put the actions in an if/then/else, and if the custom value is below the damage cap (50), then increase the custom value by the damage cap. Else, give the unit back the HP that they took from the effect (i.e. "Unit - Set (Triggering unit) Life to (((Triggering unit) Life (Current)) + (Triggering damage amount))"). It would look like this:

DamageCap
    Events
        Unit - Any Unit takes Fatal or Non-Fatal Any damage (from MY_EFFECT effects)
    Local Variables
        damageCap = 50.0 <Real>
        currentHP = ((Triggering unit) Life (Current)) <Real>
        customValue = (Custom value 0 of (Triggering unit)) <Real>
        damageAmount = (Triggering damage amount) <Real>
    Conditions
    Actions
        General - If (Conditions) then do (Actions) else do (Actions)
            If
                customValue <= damageCap
            Then
                Unit - Set (Triggering unit) custom value 0 to (customValue + damageAmount)
            Else
                Unit - Set (Triggering unit) Life to (currentHP + damageAmount)


Of course, you'd need to do some more math to make this a perfect cap, but this will roughly cap it at 50. It's definitely handled better in the Data Editor.

In fact, a better way to do this via triggers would be to have a dummy effect that does no damage (if that would still fire the event), and control the damage directly through triggers. This way, you wouldn't have to re-add the lost damage when it has hit the cap. Then you can throw any unit affected by the ability into a unit group, apply the damage over a period of time for all units in that unit group (basically a periodic event trigger on a global Unit Group variable), and remove the units from the group when they have hit the cap (keeping track of their damage using a custom value, very similar to the trigger above). This would essentially be emulating the "Take X damage over Y time" effect (which seems like it should exist in triggers, but I couldn't find it).




Apr 29 2011, 1:58 am DevliN Post #5

OVERWATCH STATUS GO

Based on your trigger, it is preventing more than 50 damage being done, but it also makes sure that 50 damage is done to all enemies that are hit, right?

The ability does at most 50 damage based on how long the enemy stands in the "Search Area" that deals the damage, rather than dealing exactly 50 damage to every unit it hits. This is for my "Flamethrower" ability I gave up on months ago for Invasion, to give you a visual sense of what I might be talking about. The idea is that you activate the ability, flames shoot out for 2 seconds in front of the unit, and anything hit by the flames takes damage based on how long they stand in it.

So I'm guessing if I did this through triggers and a dummy effect, I would need to set up a system that monitors how long the enemy is taking damage, and then apply damage based on that length of time.

The solution I'm using for now is a work-around using Behaviors. All units hit by the flames will have a Behavior applied that lasts for .5 seconds and can't be stacked. In that time, they will take 12.5 damage from the Behavior. If they are still standing in the fire, the Behavior will be reapplied. Theoretically that will cap the damage done on larger units, and also make it so that any unit hit still takes a portion of the damage dealt (if not all of the damage dealt).

Based off your example above, couldn't I set up a trigger that has a variable that is set to the amount of damage the effect does, and then when that amount = 50, prevent damage from being done with that "Set Effect damage to no damage" action? I can't remember what the action is called but I recall seeing it.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

May 12 2011, 1:51 am Roy Post #6

An artist's depiction of an Extended Unit Death

So if you're going for damage based on the length of time the unit is in the flames, you can easily do this with part of what I posted above with a unit group that contains the units in front of the casting unit.

If you recall my flashlight system, I used a series of points going in the direction a unit was facing and revealing that area. You could use this system, but rather than revealing the area, add all units in that area to some global unit group. Then you'd have a trigger running periodically that gives a small amount of damage to all units in that unit group. Using the custom value, you can keep track of how much damage each unit has taken, and if you wanted to cap it at say 50 hp, you would have a conditional to not damage the unit in the group if their custom value was 50.

Flamethrower
      Events
            Unit - Any Unit uses Flamethrower at Generic1 - Any stage (Ignore shared abilities)
      Local Variables
            allHitUnits = (Empty unit group) <Unit Group>
            targetUnits = (Empty unit group) <Unit Group>
      Conditions
      Actions
            General - Pick each integer from 1 to 50, and do (Actions)
                  Actions
                        Variable - Set targetUnits = (Empty unit group)
                        Unit Group - Add all units in (Any units in (Region(((Position of (Triggering unit)) offset by 1.0 towards (Facing of (Triggering unit)) degrees), 0.5)) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) to targetUnits
                        Unit Group - Add all units in (Any units in (Region(((Position of (Triggering unit)) offset by 1.5 towards (Facing of (Triggering unit)) degrees), 0.5)) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) to targetUnits
                        Unit Group - Add all units in (Any units in (Region(((Position of (Triggering unit)) offset by 2.0 towards (Facing of (Triggering unit)) degrees), 0.5)) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) to targetUnits
                        Unit Group - Add all units in targetUnits to allHitUnits
                        Unit Group - Pick each unit in targetUnits and do (Actions)
                              Actions
                                    General - If (Conditions) then do (Actions) else do (Actions)
                                          If
                                                (Custom value 0 of (Picked unit)) < 50.0
                                          Then
                                                Environment - Deal damage using Dummy_Effect on (Picked unit) from (Triggering unit) with 1.0 extra damage
                                                Unit - Set (Picked unit) custom value 0 to ((Custom value 0 of (Picked unit)) + 1.0)
                                          Else
                        General - Wait 0.04 Game Time seconds
            Unit Group - Pick each unit in allHitUnits and do (Actions)
                  Actions
                        Unit - Set (Picked unit) custom value 0 to 0.0


So it basically goes through a loop of 1 to 50, doing 1 damage to each unit in front of the caster each iteration. It pauses .04 seconds on each iteration, making this loop last a total of 2 seconds. Then, it takes all affected units and resets their custom value back to 0.

Of course, the If/Then/Else isn't needed for these numbers, because the max damage would be 50 no matter what. If you had it loop 100 times with a .02 pause on each iteration, though, it would cap the damage at 50, and the targeted unit would not take further damage (even though the loop would run for another second).

So yeah, that's how you would approach it using a dummy effect.




May 12 2011, 2:07 am NicholasBeige Post #7



It is possible to do this entirely through the data editor if I understand the problem correctly.

Have the ability trigger a create persistent which activates the search area (arc 40 or so, conical radius in front of caster). Have the search area apply two buffs to the target unit, one stackable up to 5 times that does nothing, another that causes 12.5 damage provided that the target unit has <5 of the other buff on it.

It is 3am here and I'm knee deep in excel documents so I can't look into the validation side of things - but if you compare the way that Spawn Larvae checks to see if the Hatchery is already spawning larvae (behaviour count validation), you should be able to emulate it quite easily.



None.

May 12 2011, 2:10 am DevliN Post #8

OVERWATCH STATUS GO

Quote from name:Cardinal
It is possible to do this entirely through the data editor if I understand the problem correctly.

Have the ability trigger a create persistent which activates the search area (arc 40 or so, conical radius in front of caster). Have the search area apply two buffs to the target unit, one stackable up to 5 times that does nothing, another that causes 12.5 damage provided that the target unit has <5 of the other buff on it.
Quote from DevliN
The solution I'm using for now is a work-around using Behaviors. All units hit by the flames will have a Behavior applied that lasts for .5 seconds and can't be stacked. In that time, they will take 12.5 damage from the Behavior. If they are still standing in the fire, the Behavior will be reapplied. Theoretically that will cap the damage done on larger units, and also make it so that any unit hit still takes a portion of the damage dealt (if not all of the damage dealt).
Yeah, that's sort of similar to what I ended up doing. Or rather, I utilized a persistent/behavior combo.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:41 am]
v9bettel -- Nice
[01:39 am]
Ultraviolet -- no u elky skeleton guy, I'll use em better
[10:50 pm]
Vrael -- Ultraviolet
Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
hey cut it out I'm getting all the minerals
[10:11 pm]
Ultraviolet -- :P
[10:11 pm]
Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
[2024-4-17. : 11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
[2024-4-17. : 1:53 am]
Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
Please log in to shout.


Members Online: jun3hong, eksxo