| 01-05-2008, 01:16 PM | #1 |
Heya, I wanted to have someone check this; I think the claim is correct - but I might be mistaken: A flawless attack/magic damage detection system This system accurately detects damage dealt to a unit AND it can accurately determine whether the damage type comes from an attack or an ability. It is perfect in that sense. Furthermore it doesn't mess up any orb-effects or removes any functionality from any other system in the Warcraft engine. It even is easy to do in GUI! (Though my implementation is JASS only.) It isn't perfect in the sense that it requires a bit of work from the coder or GUI programmer, but that is relatively painless. Frankly, I'm surprised that this system wasn't discussed before (to my knowledge). It is pretty obvious and is guaranteed to work without any errors. Perfect detection and distinction of attack and spell damage. In principle the system can be used to distinguish between different forms of magic as well (using different "dummy" markers) - but this particular implementation is quite happy to illustrate just the basics. In principle it is possible to create an entire framework that can register units and create pseudo-events "OnUnitGetsHit" and "OnUnitHits", and magical equivalents (or, for that matter, multiple classes of magical equivalents: poison, magic, etc) How does it work? Very easy actually - it is based on a simple rule: All spell-based damage is dealt via dummy units, all normal attacks are dealt by normal units and heroes. In other words, the coder is obliged to implement abilities (such as Stormbolt) using a dummy caster - in return for this small complication he/she can now perfectly distinguish damage sources by checking whether or not the source of the damage has a marker (is a dummy, hence magic damage) or no marker (not a dummy, hence attack damage). The only slight complication is the "Lightning Orb" ability - to ensure that this ability still functions correctly it is necessary to change it to a dummy ability that places a buff on the target (I make use of Acid Bomb) then on damage detection (the "0" damage from the Acid Bomb is detected) you can test for the Acid Bomb buff and, if present, remove it and cast the appropriate ability. Anybody interested in testing/refuting/confirming these claims is welcome to try the test map (attached). |
| 01-05-2008, 01:33 PM | #3 | |
Quote:
|
| 01-05-2008, 02:00 PM | #5 |
In future, don't post answer then reason. Post them together. |
| 01-05-2008, 02:14 PM | #6 |
Just from glancing over the code, i'll try and give a few curveballs for ya. Channeling Spells, make dummies channel but then what about the hero (case in point, mana drain and life drain)? Existing Orbs? How do you implement frost arrows, searing arrows, poison arrows, etc.. In a lot of maps damage occurs and the damage source is null, you don't compensate for that. Windwalk can give bonus damage on initial attack, is that physical or magical? What about immolation, since that would be a drag to do on a dummy unit would it then be physical? Did you know that a ranged unit using bash has magical bonus damage and a melee unit using bash has physical bonus damage (or so i think, maybe backwards)? In your Display Damages trigger, you create a dummy every time a unit takes damage, not just when chain lightning should be casted, may want to move that creation inside the if statement ^^. And now to the concept... Making 2 abilities (one dummy channel, one real ability) for each ability is going to be a pain. Any autocast features will fail (i think abolish magic might be the only one affected). You have no easy way of actually using the damage detection to your advantage. I fear you'll have a VERY large block of if/elseif/endif inside the damage detection.. sloppy. In all honesty the extra work is not worth the small bonus that you can differentiate magic and physical damage. If blizzard gave us GetEventDamageAttackType(), GetEventDamageDamageType(), and GetEventDamageWeaponType() natives, that would be great, but until then nothing will ever be perfect. I still believe in the hash table of unit types/units that actually require damage detection, otherwise once you have too much going on when a generic unit takes damage you get slowdown (imagine, 10 if/elseif statements all fail compared to one hash function returning null). Obviously it depends more on how you use it, so this may be the solution for you. I personally don't ever feel the need to differentiate magic/physical. You know, one major alternative is to pick a prime number P, and for each spell another prime number Q such that P*Q = damage. Then if the damage a unit takes mod P == 0 you have magical damage. So prime P = 7, you could use spell damages of like 49, 77, 91, 119, 133, 161, 203, 217, 259, 287, etc. All of those numbers mod 7 == 0. Obviously divide the damage by the possible spell resistances and test again (just dont have too many). This would only conflict with physical damage on the rare occasion that a unit has 0 armor (hopefully rare) and no damage reduction, otherwise they will deal damage that has a fraction associated with it. If you wanted to be REALLY clever you could use different primes P for different classes of spells (dmg mod 7 == 0 means fire spells, dmg mod 11 == 0 means ice spells, but then you couldnt use 7*11 for damage), Minor unrelated issues: Don't forget to null your handle variables, every unit that deals damage or takes damage will leak its handle. Not huge deal, but its good practice, and doesnt hurt anything (only helps). |
| 01-05-2008, 06:16 PM | #8 |
So, instead of detecting attacks you are just removing normal spells from the game, so you are not really detecting attacks, you are just detecting damage... sounds like we are back to 2005. And the reason it was never discussed is that besides of being obvious, it is simply too much to ask sometimes. You are just saying all spell damage should come from dummy units, that's not too practical unless that was in the map's plan already, so it is good for private use but not anywhere else. "Triggering" all spells in the game is as hard or harder than "Triggering" all attacks. Both solutions are equivalent in that they are "flawless" and also an overkill. Only that simulating attacks is suggested much more often. |
| 01-05-2008, 06:58 PM | #9 |
war3 suck -_- |
