|
|
|
|
JASS Functions Approved JASS functions will be located here.
Remember to submit your own resources to the submission forum. |
 |
|
07-15-2009, 08:51 PM
|
#16 (permalink)
|
|
I'm The Supervisor
Join Date: Apr 2008
Posts: 730
|
Quote:
|
call this function (IsUnitDead(yourUnit)). It is shorter to type, not noticeably slower, and guaranteed to work for every circumstance.
|
why not this function instead then
Jass:
constant function A takes unit u returns boolean
return IsUnitType(u,UNIT_TYPE_DEAD)
endfunction
it's much shorter to type! and not abit slower!
|
|
|
07-15-2009, 11:23 PM
|
#17 (permalink)
|
|
aspiring programmer
Join Date: Aug 2006
Posts: 318
|
I see where you're going with this... but the main point of my function was that it would always work ("A" wouldn't)... and that is why I will use it in the future.
I have decided I am going to stop arguing. Those of you who like my function may use it. Those of you who prefer GetWidgetLife may continue to use it, and I will respect your decision. Sorry if I have offended you in any way; that was not my intention; rather, it was to help the community.
aznricepuff - I leave the fate of this thread up to you.
|
|
|
07-16-2009, 10:35 PM
|
#18 (permalink)
|
|
OOP freak.
Join Date: Feb 2006
Posts: 751
|
I am going to approve this. Normally I wouldn't but I'll make an exception since he's not asking for credit and at the very least this lets people know GetWidgetLife(u) < 0.405 can bug.
|
|
|
07-17-2009, 01:31 AM
|
#19 (permalink)
|
|
'Cos I had some sense
Join Date: Jun 2007
Posts: 1,267
|
It seems more fitting as a snippet.
|
|
|
07-17-2009, 11:24 AM
|
#20 (permalink)
|
|
User
Join Date: Aug 2008
Posts: 338
|
It cant bug, it can just fail as a dead check because of bad coding, but meh whatever.
__________________
No Marlo, no game.
Last edited by Viikuna; 07-17-2009 at 11:52 AM.
|
|
|
07-22-2009, 11:57 AM
|
#21 (permalink)
|
|
BBoy Silv
Join Date: Nov 2006
Posts: 1,192
|
I like this function a lot. Great explanation, I learned a lot.
Quote:
|
It cant bug, it can just fail as a dead check because of bad coding, but meh whatever.
|
If you accidentally screw around with a dead unit's hp, absolutely nothing happens, it can only bug GetWidgetLife. So I don't see any harm in being careful and preventing that from happening, because other than that, increasing a dead unit's hp doesn't have any downside.
Just imagine how many hours of work you would lose before you find out that one of your spell isn't working because of ANOTHER spell where you accidentally increase the life of dead units. When I come to think about it, I would probably have never figured out what is causing the problem.
|
|
|
07-22-2009, 12:16 PM
|
#22 (permalink)
|
|
User
Join Date: Aug 2008
Posts: 338
|
There is a neat feature called function in Jass that nicely solves this problem.
Instead of SetWidgetLife( myunit, myreal) you should be using some custom ModifyUnitLife function, which checks units health before changing it.
You might also wanna add some custom event script for that function later, in case you want to know when some units health is being modified or do whatever weird stuff you like.
My point is that this problem is so easy to avoid ( unless you are being stupid ) that this function is not usefull just because of that so called problem. It does what it is supposed to do, yes, but it is still not better than GetWidgetLife. ( Maybe GetWidgetLife is not better either, I dont know, but its deffinetly not worse. )
__________________
No Marlo, no game.
|
|
|
07-22-2009, 05:19 PM
|
#23 (permalink)
|
|
OOP freak.
Join Date: Feb 2006
Posts: 751
|
Quote:
|
Instead of SetWidgetLife( myunit, myreal) you should be using some custom ModifyUnitLife function, which checks units health before changing it.
|
How is that any different than using this if all you care about is dead checks? You're just going to replace all instances of another native with a user-made function instead of replacing GetWidgetLife() with IsUnitDead().
|
|
|
07-22-2009, 05:27 PM
|
#24 (permalink)
|
|
User
Join Date: Aug 2008
Posts: 338
|
Its basicly the same. Thats why there is no reason why this function would be any better than GetWidgetLife. Im just trying to say that there is nothing wrong with GetWidgetLife, if you do things correctly ( This applies to pretty much every function btw ). This IsUnitDead thing works too, but it is not the only option.
I used GetWidgetLife for long time and I never managed to accidentally modify dead units health even without any custom IsUnitDead function. Have any of you guys actually made this mistake and modified dead units health?
Anyways, I dont use neither of this methods anymore, since I recycle my units, which means that they dont really die, so I can just use IsUnitInGroup( unit, DeadGuys ) which works pretty well too.
__________________
No Marlo, no game.
|
|
|
07-23-2009, 03:47 AM
|
#25 (permalink)
|
|
aspiring programmer
Join Date: Aug 2006
Posts: 318
|
Quote:
Originally Posted by Silvenon
I like this function a lot. Great explanation, I learned a lot.
|
Thanks.
Viikuna, you have some valid points. However, I prefer to use IsUnitDead because it will only return true if a unit is dead. The only time that a unit has unittype UNIT_TYPE_DEAD is when the unit is in the state of being dead. It's kind of like the definition of being dead... I wouldn't want to use your "IsUnitInGroup( unit, DeadGuys )" because it (probably) has to loop through the group to check if the unit is in it. Meh, you can use whatever function you like.
|
|
|
07-30-2009, 09:51 AM
|
#26 (permalink)
|
|
Original and Proud
Join Date: Aug 2004
Posts: 835
|
Maskedpoptart is right
The GetWidgetLife or GetUnitState can bug sometimes.
And the problem I've encountered is his perfect example.
In my mini-map, I don't use Heroes, instead I use units, so I devise a trick on how to revive a unit when it's dead. So what I did was I used
Jass:
call SuspendUnitDecay(u)
and after a respawn timer is expired, I move the unit to the respawn location and create a Ressurection dummy.
Now this has messed up my AI. My AI works fine except that they recognize dead players AS ALIVE during the respawn wait period! lol, zombies!... Well even though I used the GetWidgetLife and also tried GetUnitState to differentiate dead units for the AI, it still recognizes those as... alive! So what really happened was AIs hogging dead corpses for 20 seconds (which is the respawn wait period)... lol...
Jass:
IsUnitDead()
This has helped me alot, I didn't know those two functions bugged.
Thanks maskedpoptar, + rep.
__________________
| My Website: |

|
|
|
|
08-04-2009, 06:25 PM
|
#27 (permalink)
|
|
Anozer jasser
Join Date: Apr 2008
Posts: 244
|
I realized that before see this function.
But i had already read that, shame on me xD.
Anyway it's fine you post it and with good explanations, so + rep
|
|
|
08-05-2009, 03:24 PM
|
#28 (permalink)
|
|
User
Join Date: Sep 2004
Posts: 15
|
Quote:
Originally Posted by maskedpoptart
No offense, but I do not understand you people. Why use a function that is guaranteed to screw up some of the time?
|
This made me laugh.
|
|
|
08-05-2009, 08:33 PM
|
#29 (permalink)
|
|
User
Join Date: Aug 2008
Posts: 338
|
I just feel sorry for all those people who do some stuff to save their asses in case they might just screw up with thei code someday, instead of properly structuring and debugging their code and doing things right.
__________________
No Marlo, no game.
|
|
|
08-05-2009, 09:12 PM
|
#30 (permalink)
|
|
Original and Proud
Join Date: Aug 2004
Posts: 835
|
Quote:
Originally Posted by Viikuna
I just feel sorry for all those people who do some stuff to save their asses in case they might just screw up with thei code someday, instead of properly structuring and debugging their code and doing things right.
|
I feel sorry for all those people who lack understanding of JASS, for instance not knowing the flaws of a GetUnitState call or not knowing that corpses can have full health.
__________________
| My Website: |

|
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|