• 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.

Total Damage Output Per Wave?

Status
Not open for further replies.
Level 1
Joined
Sep 22, 2011
Messages
2
Hello everyone,

This is the first time I've registered here under this name, but been a fan of this website for a long time (Since back in my wc3 days).

I've come to the experts with a question. I'm still learning the SC2 Editor, but even after rising up over every single issue I've had with my current tower defense, I can't figure out how to give the total damage done at the end of the wave.

I may end up implementing this in my map at some point, but for now, I really just need it for testing purposes.

I've tried setting a variable to a real value, and the real value being Player Score - Total Life Damage Dealt. I made sure the player was 1, Made sure to enable scores for player 1, etc. Everything seems to be in order, but when my text message appears, it seems the value is at zero.

Is there another way to go about doing this, or is there a way to make sure the total damage dealt score is working properly?

Thanks in advance for whatever help you can give me. :)

- Chris (Cancelface)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
I do not think that score works by default. I believe it is designed for trigger incrimentation (some campaign missions I think used it).

The idea is prety simple. Every time a tower owned by player 1 damages an enemy you add the damage it delt to a variable. At the end of the round you just display the value of the variable and reset its value to 0 for the next round.

In WC3 this was impossibly difficult to do without introducing instability or leaks into your map. Fortunatly not so in SC2 as you can just use the generig unit takes damage event. The same handler function could be used for all players as well with correct array use.

Be aware that if your towers start to deal stupid quantities of damage, you will likly overflow the primitive types. Be especially aware that the fixed type in SC2 (its equivelent of the WC3 real type) has a very low upper bound (much less than the int type). If overflow is a problem you should consider eithor reballencing your TD (as such large numbers are likly unnescescary) or you will have to resort to larger pimitive type emulation (such as 64 or 128 bit structures using the also new to SC2 bit opperators).
 
Level 1
Joined
Sep 22, 2011
Messages
2
Thanks for the reply. I actually experimented with this some more and found out that this is the case. I haven't even set up a balance to my TD yet. That's why I wanted some damage calculation. I already have the towers set to certain damage types and everything. I just wanted to test a few different builds on each wave, on different difficulties to see around how much damage output would be sufficient but never overkill or underkill. Thanks for the help!

I finally got it to work by implementing a damage done trigger and removing the variable. Instead of having text pull from the Real variable, i had it pull straight from Total Life Damage Dealt. :)
 
I'm not sure if you'd want to use this but I found away to script the damage and not have them blow up. Just create a damage effect that does 0 damage of the type you want (such as normal) then you can use this to add the damage you actually want it to do:

  • Damage
    • Events
      • Unit - Any Unit takes Fatal or Non-Fatal Any damage (from Proj Dmg effects)
    • Local Variables
      • u = (Triggering unit) <Unit>
      • dmg u = (Damaging unit) <Unit>
      • cv = FixedToInt(UnitGetCustomValue(lv_dmgu, gv_CVS)) <Integer>
    • Conditions
    • Actions
      • General - Custom Script: if (lv_dmgu == null) {...
JASS:
UnitDamage(lv_dmgu, "ProjDmg", lv_u, gv_projDmg[lv_cv]);
 
Status
Not open for further replies.
Top