• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

UnitAlive undeclared function

Status
Not open for further replies.
Level 22
Joined
Feb 6, 2014
Messages
2,466
Greetings hivers,
Can you use the UnitAlive function? Mine doesn't work

I tried using jassnewgenpack5d and jassnewgenpack207 but both doesn't work. I tried placing the common.ai in the jasshelper folder of JNGP but it also doesn't work.
It says UnitAlive is an undeclared function.

145728d1432941043-unitalive-undeclared-function-error.jpg
 

Attachments

  • error.JPG
    error.JPG
    24.6 KB · Views: 375
You have to declare the native somewhere in your code. See:
http://www.wc3c.net/vexorian/jasshelpermanual.html#ndf

In your case, you would just need to add this line of code somewhere:
native UnitAlive takes unit u returns boolean
JassHelper will take care of the rest. If you can't get native declarations to work for some reason, you can always declare it as a custom function yourself just to achieve the same functionality:
JASS:
function UnitAlive takes unit u returns boolean
    return not IsUnitType(u, UNIT_TYPE_DEAD) and GetUnitTypeId(u) != 0
endfunction
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
You have to declare the native somewhere in your code. See:
http://www.wc3c.net/vexorian/jasshelpermanual.html#ndf

In your case, you would just need to add this line of code somewhere:
native UnitAlive takes unit u returns boolean
JassHelper will take care of the rest.

Thanks! it worked. But since UnitAlive is found in common.ai, can I also used ither common.ai functions but I just have to declare it first?

EDIT: Nvm, I read it in your link.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
What is the difference between JASS and GUI triggers?
Using JASS lets you make triggers via coding/typing, while using GUI lets you makes triggers in a "Event/Condition/Action" structure and mouse clicks.GUI is easier for starters because all you need is some English knowledge.

Does JASS take less space?
Yes, but this is almost never a reason to use JASS instead of GUI since difference is little.

And are there things you can't make with GUI but you can using JASS?
Not much, but when you use "custom script" you actually putting a line of jass code in your trigger.Pretty much all things can be made with combination of GUI + custom scripts, but even though it can be made, it might be harder.
 
Level 18
Joined
May 11, 2012
Messages
2,103
JASS is script language of Wc3. It is way more efficient, more thingsbare opened to you and it is just better, but hardrr to learn.
GUI, on the otger side, is easier to learn, but lacks lot's of functions that are available using JASS, and is heavier.
 
Level 11
Joined
Jan 23, 2015
Messages
788
Using JASS lets you make triggers via coding/typing, while using GUI lets you makes triggers in a "Event/Condition/Action" structure and mouse clicks.GUI is easier for starters because all you need is some English knowledge.


Yes, but this is almost never a reason to use JASS instead of GUI since difference is little.


Not much, but when you use "custom script" you actually putting a line of jass code in your trigger.Pretty much all things can be made with combination of GUI + custom scripts, but even though it can be made, it might be harder.

Then why do some people use JASS instead of GUI? It is obviously better to use (at least for me :D, I'd like to learn coding but it's harder and I know how to use GUI so I think I that's enough)
 
A GUI user myself but I still have knowledge of Jass usage, though not to a maximum extend yet. GUI actually do a lot if you know what you're doing.

-Out of derailing.

Anyway, UnitAlive iirc is only the efficient form of let's see... IsUnitAlive?
Btw, thanks to Purge for the manual (I rarely read manuals xD) and find something good there for me to use ^^
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
Anyway, UnitAlive iirc is only the efficient form of let's see... IsUnitAlive?
Btw, thanks to Purge for the manual (I rarely read manuals xD) and find something good there for me to use ^^

In the Spell Section, using UnitAlive is sort of a requirement for checking if unit is alive. They don't want IsUnitAlive or GetWidgetLife(u) > 0.405.
 
Status
Not open for further replies.
Top