[System] Heal

Level 17
Joined
Apr 27, 2008
Messages
2,455
Honestly and without a joke i think it would be better to have a custom IsUnitDead function which takes an additional argument, a boolean would be enough (or maybe to be even more accurate an integer flag based on constants integers).

Something like that :

JASS:
function IsUnitDead takes unit whichUnit , boolean trulyDead returns boolean
    // trulyDead = true > IsUnitDead returns true only if the unit is not under resurection process or whatever
    // trulyDead = false > IsUnitDead returns true only if the unit is under resurection process or not
endfunction

The name "trulyDead" is maybe lame but hopefully you get the idea.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I personnaly think it fits better with one function and an additional argument, but that's me.
Now that i remember i'm talking to a speedfreak Mag, i suppose he won't like it, since imagine you declare a new argument each time you use the function and there is at least one if/then, it will cause your game to lag !

Seriously i talked more about a general standalone custom IsUnitDead function, not only in this library.
 
I don't like it for 2 reasons:
- It won't inline
- You could use IsUnitReincarnating as Bribe said :p

Man, you know me so well ;)

edit

Actually:

JASS:
function IsUnitDeadEx takes unit whichUnit, boolean trulyDead returns boolean
    return IsUnitDead(whichUnit) == trulyDead or IsUnitReincarnating(whichUnit)
endfunction

Clever? ;)
If you think about it, this function works perfectly :p
 
It might be better to use 2 timers rather than 1.

One timer for destroying the effect
One timer for applying the effect

This would be a faster solution. You would no longer have to do the +.03125 thing and compare it to the duration of the effect ; ).

When I do over time effects like this, I always do 2 timers, one for application and one for expiration.
 
More timers != slower map. More timers expiring at the same time = slower map ; P. However, if you make it so that the expiration one expires first, then the application one won't run =). Also, if you make them expire at slightly different periods, then they won't expire at same time : ).


If they both expire at the same time, I'm not sure which would be faster =o.
 
I'd like to see you expand the documenation with an argument on what makes this resource so great.

I'd like the emphasis to be on its usefulness, not on its speed. A timer system or a timer-dependant system can brag about speed, and I admire that you have part of this resource dedicated to that, but I could program that myself. What I'd like to see is why this event detection is important, how it fits into warcraft 3 and what kinds of things would benefit from it where they couldn't benefit from it before.
 
You should include documentation of the struct API with the function API since they are accessible.

Done.

The only thing I might suggest would be allowing the user to stop the healing over time prematurely, but that might be too complicated.

I'm not going to add that ;D
It's still possible while taking advantage of the TIMED event though.
That may be inefficient, but you aren't going to be doing something like that a lot of the time :p
I might consider adding something like this in the future, but that could make 'Heal' stacking impossible without countless 'pointer' Tables :(

Forcing user to pass boolexprs sucks.
Yeah code should always take the place of "boolexpr", this shortens the user's required verbosity and also allows the passed code to "return nothing".
Agreed and Fixed.
 
Ok, NOW this compiles.

TrollFace.png
 
Level 4
Joined
Jul 31, 2009
Messages
89
I get the "UNIT INDEXER ERROR: ATTEMPT TO LOCK NULL INDEX" error. But it seems to work. Could i just comment this debus msg out? or even better, whats the cause?
 
Ok, here comes the nasty nestharus review on your resource because I felt like making you mad at me too ;p

static boolean enabled
Useful for things like prevent units from being healed for a period of time. Good job.

JASS:
*       - Heal.INSTANT
*           - Fires on instant heal events.
*           - This would be used for systems like:
*               - Texttag Displays
*
*       - Heal.TIMED
*           - Fires 32x a second during a timed heal.
*           - This was only added for a sense of 
*             completeness. It may be useful.

These are useless. The only thing you need is ANY. This is useful for things like modifying a heal as well as displaying texttags. However, if you are going to do healing modifications, you should support healing types, that way the user know how to modify the heal. This would also mean that you could have 4 healing effects on a unit, meaning that you'd fire ANY for all 4 of them. You'd also want to show the texttag for the combined healing.

Look at my DamageEvent stuff in order to see how to properly implement this to support cool things.

The only way this library will ever be useful is if you code spells as a variety of effects. For example, one spell could have a healing effect + an armor boosting effect for a period of time. It'd create the healing effect using your heal system and the armor boosting effect using perhaps an incoming damage modifier.

Really, I'd almost implement a healing system by dealing damage of type HEAL or w/e that way it could run with the rest of the damage stuff. This would allow you to easily support healing types, like undead healing, which does in fact damage living targets.

I actually think that healing should only be done as damage now >.>. For example, if a unit has 33% spell resistance, they'd also resist healing spells. Having your thing not run on damage requires all of the same events to be registered for both damage and non damage types, which makes everything harder and messier to do.


So, in the end, my verdict is that this resource is not flexible enough to be a general system. If it was made to be flexible enough, then it'd be a copy of damage modifiers that just inverts the damage (-damage instead of +damage) ;\. Simpler maps would just use SetWidgetLife and advanced maps would use damage modifiers. The Heal system doesn't really fit in anywhere >.>.
 
Many required resources = modularity. Few required resources = lots of identical repeated code in your own resource that could otherwise be abstracted to another resource.

Modularity = less code, less work, smaller map sizes, same performance.

A resource should only do a specific task =). Anything beyond that task can be abstracted out to another resource ^_-.
 
Top