Unit's dying life point?

waaaks!

Zinctified
Reaction score
255
Each time I check if is a unit dead or not, I always used < 0.405 for checking dead units, and > 0.405 for checking alive units, while some coders use 0.406, so what is the right and accurate value to be used to check dead or alive units?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
IsUnitType(whichUnit,UNIT_TYPE_DEAD).
This is faster than GetWidgetLife and more accurate.
However, the value is 0.403, so far I researched it.
 

Kenny

Back for now.
Reaction score
202
>IsUnitType(whichUnit,UNIT_TYPE_DEAD).
This is faster than GetWidgetLife and more accurate.

Since when? From what I've heard, [ljass]GetWidgetLife()[/ljass] is quite a fast native. And [ljass]IsUnitType()[/ljass] would only be more accurate if your coding is of poor quality.

Also, 0.403 seems a bit off. From most tests, it seems to be around 0.406 or so.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Since when? From what I've heard, GetWidgetLife() is quite a fast native. And IsUnitType() would only be more accurate if your coding is of poor quality.
I benchmarked it. IsUnitType faster about 20%.
 

Azlier

Old World Ghost
Reaction score
461
I won't believe it without the benchmark script.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
scope S initializer Init
private function THE_TRUTH_ABOUT_LIFE_AND_DEATH takes nothing returns nothing
    local unit u = CreateUnit(Player(0),&#039;hfoo&#039;,0,0,0)
    call SetWidgetLife(u,.405)
    call SetWidgetLife(u,9001)
    if GetWidgetLife(u)==0 then
        call BJDebugMsg(&quot;!&quot;)
    endif
    if GetWidgetLife(u)&gt;9000 then
        call BJDebugMsg(&quot;IT&#039;S OVER 9000!&quot;)
    elseif GetWidgetLife(u)&gt;1 then
        call BJDebugMsg(&quot;Well, it&#039;s not 0.&quot;)
    endif
    if IsUnitType(u,UNIT_TYPE_DEAD) then
        call BJDebugMsg(&quot;The Footman is &#039;dead&#039;.&quot;)
    endif
    call UnitRemoveType(u,UNIT_TYPE_DEAD)
    if IsUnitType(u,UNIT_TYPE_DEAD) then
        call BJDebugMsg(&quot;The Footman is not &#039;dead&#039;.&quot;)
    endif
endfunction

private function Init takes nothing returns nothing
    call TimerStart(CreateTimer(),2,true,function THE_TRUTH_ABOUT_LIFE_AND_DEATH)
endfunction
endscope

Someone try?
If anyone thinks it unrealistic, remember that heals over time may exist...

Edit: The remove dead type is completely unrealistic. Let us know if the footman dies, and what displays.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
-The unit died
-'Well, it's not over 0' displayed (the health gets set to the unit's max, in this case 420)
-'The footman is 'dead'.' displayed
-'The footman is not 'dead'.' displayed; the type was properly removed




In other words, Blizzard is froodlenutzskying hilarious. Units die below ~.405 life, and their life gets set to zero on the spot, and it seems they receive a dead type. HOWEVER, you can manipulate the life after that anyway (based on prior life bounds for the unit), AND you can remove the dead type.

So none of these checks are theoretically completely safe.
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
>If anyone thinks it unrealistic, remember that heals over time may exist...

for my heals over time spells, I always check if the unit is dead or not first :D
---
But I concern about the speed now

>I won't believe it without the benchmark script.

me too, even though I don't know much about benchmark :eek:
 

Jesus4Lyf

Good Idea™
Reaction score
397
>So none of these checks are theoretically completely safe.
Exactly my point. Which is why [LJASS]IsUnitType(unit,UNIT_TYPE_DEAD)[/LJASS] is the safest, because the user must intentionally remove the type to screw it up. A heal over time could mess with the unit's health, so I don't think it as appropriate.

I might run a benchmark on the issue as well for interest, but personally I'd say people shouldn't use this whole GetWidgetLife nonsense for checking if a unit is dead. It doesn't make much sense, compared to the type check, since health is much more likely to change than removing the UNIT_TYPE_DEAD status, I imagine.

So: Schrödinger's cat
JASS:
function SchrodingersCat takes nothing returns nothing
    local unit u=CreateUnit(Player(15),&#039;hfoo&#039;,0,0,0)
    call SetWidgetLife(u,0)
    call SetWidgetLife(u,9001)
    call UnitRemoveType(u,UNIT_TYPE_DEAD)
endfunction

The footman is both alive and dead.
You could check by issuing a stop order, to see if it is dead, probably. But is there any way to tell without interrupting the unit or something?
I suppose you could have a dummy unit try to issue an order to attack it, and see if it fails, or something... but then what about [LJASS]call ShowUnit(unit,false)[/LJASS]? :p

What a puzzle.
 

Kenny

Back for now.
Reaction score
202
>I might run a benchmark on the issue as well for interest, but personally I'd say people shouldn't use this whole GetWidgetLife nonsense for checking if a unit is dead. It doesn't make much sense.

I have always used [ljass]GetWidgetLife()[/ljass] and not once have I had a problem.

To me, the only way you would cause it to bug is if you don't pay attention when you are coding something.

Also...

[ljass]IsUnitType(unit,UNIT_TYPE_DEAD) == true[/ljass] returns false for non-existant units. Which could also be a problem...
 

Jesus4Lyf

Good Idea™
Reaction score
397
>IsUnitType(unit,UNIT_TYPE_DEAD) == true returns false for non-existant units. Which could also be a problem...
We're all doomed.
WC3 mapping is no longer possible, go home everyone. :p

>To me, the only way you would cause it to bug is if you don't pay attention when you are coding something.
I suppose you're right.
 

Kenny

Back for now.
Reaction score
202
I suppose you could use something like:

JASS:
function IsUnitDead takes unit u returns boolean
    return IsUnitType(u,UNIT_TYPE_DEAD) == true or GetUnitTypeId(u) == 0
endfunction


So if you do attempt to check if a non-existant unit is dead (which to me would be as common as increasing a dead units life) it will still return true as the unit will not have a unit type id. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top