[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums | Starcraft II |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Resources > JASS Functions

JASS Functions Approved JASS functions will be located here.
Remember to submit your own resources to the submission forum.

Reply
 
LinkBack (10) Thread Tools
Old 07-15-2009, 08:51 PM   #16 (permalink)
Registered User Ciebron
I'm The Supervisor
 
Ciebron's Avatar
 
Join Date: Apr 2008
Posts: 730
Ciebron will become famous soon enough (110)Ciebron will become famous soon enough (110)Ciebron will become famous soon enough (110)
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!
Ciebron is offline   Reply With Quote
Old 07-15-2009, 11:23 PM   #17 (permalink)
Registered User maskedpoptart
aspiring programmer
 
maskedpoptart's Avatar
 
Join Date: Aug 2006
Posts: 318
maskedpoptart is on a distinguished road (70)maskedpoptart is on a distinguished road (70)
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.
__________________
My JASS resourcesMy Spells
ListFire Wall
IsUnitDead
String functions
maskedpoptart is offline   Reply With Quote
Old 07-16-2009, 10:35 PM   #18 (permalink)
Registered User aznricepuff
OOP freak.
 
Join Date: Feb 2006
Posts: 751
aznricepuff is a jewel in the rough (181)aznricepuff is a jewel in the rough (181)
Former Staff Member: This user used to be on the Hive Workshop staff. 
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.
aznricepuff is offline   Reply With Quote
Old 07-17-2009, 01:31 AM   #19 (permalink)
Registered User hvo-busterkomo
'Cos I had some sense
 
Join Date: Jun 2007
Posts: 1,267
hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)hvo-busterkomo is a jewel in the rough (238)
Former Staff Member: This user used to be on the Hive Workshop staff. 
It seems more fitting as a snippet.
hvo-busterkomo is offline   Reply With Quote
Old 07-17-2009, 11:24 AM   #20 (permalink)
Registered User Viikuna
User
 
Viikuna's Avatar
 
Join Date: Aug 2008
Posts: 338
Viikuna is on a distinguished road (61)Viikuna is on a distinguished road (61)
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.
Viikuna is offline   Reply With Quote
Old 07-22-2009, 11:57 AM   #21 (permalink)
Registered User Silvenon
BBoy Silv
 
Silvenon's Avatar
 
Join Date: Nov 2006
Posts: 1,192
Silvenon is a jewel in the rough (161)
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.
Silvenon is offline   Reply With Quote
Old 07-22-2009, 12:16 PM   #22 (permalink)
Registered User Viikuna
User
 
Viikuna's Avatar
 
Join Date: Aug 2008
Posts: 338
Viikuna is on a distinguished road (61)Viikuna is on a distinguished road (61)
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.
Viikuna is offline   Reply With Quote
Old 07-22-2009, 05:19 PM   #23 (permalink)
Registered User aznricepuff
OOP freak.
 
Join Date: Feb 2006
Posts: 751
aznricepuff is a jewel in the rough (181)aznricepuff is a jewel in the rough (181)
Former Staff Member: This user used to be on the Hive Workshop staff. 
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().
aznricepuff is offline   Reply With Quote
Old 07-22-2009, 05:27 PM   #24 (permalink)
Registered User Viikuna
User
 
Viikuna's Avatar
 
Join Date: Aug 2008
Posts: 338
Viikuna is on a distinguished road (61)Viikuna is on a distinguished road (61)
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.
Viikuna is offline   Reply With Quote
Old 07-23-2009, 03:47 AM   #25 (permalink)
Registered User maskedpoptart
aspiring programmer
 
maskedpoptart's Avatar
 
Join Date: Aug 2006
Posts: 318
maskedpoptart is on a distinguished road (70)maskedpoptart is on a distinguished road (70)
Quote:
Originally Posted by Silvenon View Post
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.
__________________
My JASS resourcesMy Spells
ListFire Wall
IsUnitDead
String functions
maskedpoptart is offline   Reply With Quote
Old 07-30-2009, 09:51 AM   #26 (permalink)
Registered User DoOs_101
Original and Proud
 
DoOs_101's Avatar
 
Join Date: Aug 2004
Posts: 835
DoOs_101 has little to show at this moment (28)DoOs_101 has little to show at this moment (28)DoOs_101 has little to show at this moment (28)
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:

DoOs_101 is offline   Reply With Quote
Old 08-04-2009, 06:25 PM   #27 (permalink)
Registered User Troll-Brain
Anozer jasser
 
Join Date: Apr 2008
Posts: 244
Troll-Brain has little to show at this moment (15)Troll-Brain has little to show at this moment (15)
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
Troll-Brain is offline   Reply With Quote
Old 08-05-2009, 03:24 PM   #28 (permalink)
Registered User TheHellMan
User
 
Join Date: Sep 2004
Posts: 15
TheHellMan is an unknown quantity at this point (0)
Quote:
Originally Posted by maskedpoptart View Post
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.
TheHellMan is offline   Reply With Quote
Old 08-05-2009, 08:33 PM   #29 (permalink)
Registered User Viikuna
User
 
Viikuna's Avatar
 
Join Date: Aug 2008
Posts: 338
Viikuna is on a distinguished road (61)Viikuna is on a distinguished road (61)
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.
Viikuna is offline   Reply With Quote
Old 08-05-2009, 09:12 PM   #30 (permalink)
Registered User DoOs_101
Original and Proud
 
DoOs_101's Avatar
 
Join Date: Aug 2004
Posts: 835
DoOs_101 has little to show at this moment (28)DoOs_101 has little to show at this moment (28)DoOs_101 has little to show at this moment (28)
Quote:
Originally Posted by Viikuna View Post
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:

DoOs_101 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


LinkBacks (?)
LinkBack to this Thread: http://www.hiveworkshop.com/forums/jass-functions-413/isunitdead-135811/
Posted By For Type Date
Worldedit : Voir le sujet - condition This thread Refback 02-19-2010 04:27 PM
VOTE - Spell-Contest (September09) - Seite 2 - inWarcraft Forum This thread Refback 01-24-2010 11:21 AM
Critic my (bad) projectile system - Page 2 - The Helper Forums This thread Refback 11-06-2009 04:14 PM
Variable keeps reference to removed dummy - The Helper Forums This thread Refback 10-02-2009 10:29 AM
Variable keeps reference to removed dummy - The Helper Forums This thread Refback 10-01-2009 04:49 PM
inWarcraft.de Foren by ingame. - VOTE - Spell-Contest (September09) This thread Refback 10-01-2009 04:07 PM
inWarcraft.de Foren by ingame. - VOTE - Spell-Contest (September09) This thread Refback 09-27-2009 11:51 PM
inWarcraft.de Foren by ingame. - VOTE - Spell-Contest (September09) This thread Refback 09-27-2009 10:48 AM
inWarcraft.de Foren by ingame. - VOTE - Spell-Contest (September09) This thread Refback 09-27-2009 06:54 AM
A few questions - The Helper Forums This thread Refback 08-21-2009 03:44 PM

All times are GMT. The time now is 12:55 AM.






Hosting by SliceHost 
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.1
Copyright©Ralle