Perfect IsUnitAlive

Azlier

Old World Ghost
Reaction score
461
Whaddaya know. Blizzard provided it for us.

JASS:
native UnitAlive            takes unit id                               returns boolean


Just paste that into your map and you're good to go, if you have vJass that is.

It recognizes dead units with increased health as dead. Go Blizzard!
 

LearningCode

New Member
Reaction score
24
And why did no one else see this before? o.0
Would have saved a lot of debating, wouldn't it xD
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
It's not in common.j...

So, this is only accessible if you can enter definitions of hidden natives? :nuts:

What else is in there?
 

Jesus4Lyf

Good Idea™
Reaction score
397
Oh gosh.
Crap.
Now we have problems.
You realise people will want to use this in their spells... which means they'll all declare it... which means multiple declarations. Is that allowed for natives - are they merged in JassHelper? If not, we need to standardise this as a resource for people to use it in submissions, or they will all clash? :(

I vote Azlier checks multiple declarations, and if they fail, that he submits a one line lib as a resource. -_-
 

Azlier

Old World Ghost
Reaction score
461
Don't worry, Jesus4Lyf. Jasshelper handles multiple declarations of the same native just fine. Feel free to paste it into all your spells.

>So, this is only accessible if you can enter definitions of hidden natives?

You can declare natives in war3map.j, as long as you declare them before any other function. vJass allows freeform native declaration, [del]much[/del]exactly like freeform globals blocks.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Just a question... Where do I paste this ? :S
I don't really understand, is this a [ljass]native[/ljass] or what is it ? :S
 

Azlier

Old World Ghost
Reaction score
461
You paste the native declaration into your map and it's ready for use, as long as you're using vJass.

And only slightly related to this topic, there are other cool common.ai natives to use...
JASS:
library Income initializer Init

globals
    private constant real INCOME_INTERVAL = 5.
    //How often income is calculated and added to players.
    private integer Count = 0
    private integer array U
    private integer array I
endglobals

function RegisterIncomeStructure takes integer uid, integer amt returns nothing
    set Count = Count + 1
    set U[Count] = uid
    set I[Count] = amt
endfunction

native GetPlayerUnitTypeCount takes player p, integer unitid            returns integer
//This is a really cool native. It is absolutely perfect for this application.
//It doesn't count dead units.

private function Tick takes nothing returns nothing
    local integer p = 11
    local integer i
    local player P
    loop
        set i = Count
        loop
            exitwhen i == 0
            set P = Player(p)
            call SetPlayerState(P, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(P, PLAYER_STATE_RESOURCE_GOLD) + GetPlayerUnitTypeCount(P, U<i>) * I<i>)
            set i = i - 1
        endloop
        exitwhen p == 0
        set p = p - 1
    endloop
endfunction

private function Init takes nothing returns nothing
    call TimerStart(CreateTimer(), INCOME_INTERVAL, true, function Tick)
endfunction

endlibrary</i></i>
 

Azlier

Old World Ghost
Reaction score
461
I thank you heartily for that. /heartily thank phyrex1an
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Thanks for these natives then ! ;)

Can they be placed in a library or the header ? :S

And also, where did you find these ?
Are there more to be found ?
 

Azlier

Old World Ghost
Reaction score
461
There are definitely more to be found, but only a handful work. I just decided to test a few of the interesting looking ones.

JASS:
native DebugS               takes string str                            returns nothing
native DebugFI              takes string str, integer val               returns nothing
native DebugUnitID          takes string str, integer val               returns nothing
native DisplayText          takes integer p, string str                 returns nothing
native DisplayTextI         takes integer p, string str, integer val    returns nothing
native DisplayTextII        takes integer p, string str, integer v1, integer v2 returns nothing
native DisplayTextIII       takes integer p, string str, integer v1, integer v2, integer v3 returns nothing
native DoAiScriptDebug      takes nothing                               returns boolean

native GetAiPlayer          takes nothing                               returns integer
native GetHeroId            takes nothing                               returns integer
native GetHeroLevelAI       takes nothing                               returns integer

native GetUnitCount         takes integer unitid                        returns integer
native GetPlayerUnitTypeCount takes player p, integer unitid            returns integer
native GetUnitCountDone     takes integer unitid                        returns integer
native GetTownUnitCount     takes integer id, integer tn, boolean dn    returns integer
native GetUnitGoldCost      takes integer unitid                        returns integer
native GetUnitWoodCost      takes integer unitid                        returns integer
native GetUnitBuildTime     takes integer unitid                        returns integer

native GetMinesOwned        takes nothing                               returns integer
native GetGoldOwned         takes nothing                               returns integer
native TownWithMine         takes nothing                               returns integer
native TownHasMine          takes integer townid                        returns boolean
native TownHasHall          takes integer townid                        returns boolean

native GetUpgradeLevel      takes integer id                            returns integer
native GetUpgradeGoldCost   takes integer id                            returns integer
native GetUpgradeWoodCost   takes integer id                            returns integer
native GetNextExpansion     takes nothing                               returns integer
native GetMegaTarget        takes nothing                               returns unit
native GetBuilding          takes player p                              returns unit
native GetEnemyPower        takes nothing                               returns integer
native SetAllianceTarget    takes unit id                               returns nothing
native GetAllianceTarget    takes nothing                               returns unit

native SetProduce           takes integer qty, integer id, integer town returns boolean
native Unsummon             takes unit unitid                           returns nothing
native SetExpansion         takes unit peon, integer id                 returns boolean
native SetUpgrade           takes integer id                            returns boolean
native SetHeroLevels        takes code func                             returns nothing
native SetNewHeroes         takes boolean state                         returns nothing
native PurchaseZeppelin     takes nothing                               returns nothing

native MergeUnits           takes integer qty, integer a, integer b, integer make returns boolean
native ConvertUnits         takes integer qty, integer id               returns boolean

native SetCampaignAI        takes nothing                               returns nothing
native SetMeleeAI           takes nothing                               returns nothing
native SetTargetHeroes      takes boolean state                         returns nothing
native SetPeonsRepair       takes boolean state                         returns nothing
native SetRandomPaths       takes boolean state                         returns nothing
native SetDefendPlayer      takes boolean state                         returns nothing
native SetHeroesFlee        takes boolean state                         returns nothing
native SetHeroesBuyItems    takes boolean state                         returns nothing
native SetWatchMegaTargets  takes boolean state                         returns nothing
native SetIgnoreInjured     takes boolean state                         returns nothing
native SetHeroesTakeItems   takes boolean state                         returns nothing
native SetUnitsFlee         takes boolean state                         returns nothing
native SetGroupsFlee        takes boolean state                         returns nothing
native SetSlowChopping      takes boolean state                         returns nothing
native SetCaptainChanges    takes boolean allow                         returns nothing
native SetSmartArtillery    takes boolean state                         returns nothing
native SetReplacementCount  takes integer qty                           returns nothing
native GroupTimedLife       takes boolean allow                         returns nothing
native RemoveInjuries       takes nothing                               returns nothing
native RemoveSiege          takes nothing                               returns nothing

native InitAssault          takes nothing                               returns nothing
native AddAssault           takes integer qty, integer id               returns boolean
native AddDefenders         takes integer qty, integer id               returns boolean

native GetCreepCamp         takes integer min, integer max, boolean flyers_ok returns unit

native StartGetEnemyBase    takes nothing                               returns nothing
native WaitGetEnemyBase     takes nothing                               returns boolean
native GetEnemyBase         takes nothing                               returns unit
native GetExpansionFoe      takes nothing                               returns unit
native GetEnemyExpansion    takes nothing                               returns unit
native GetExpansionX        takes nothing                               returns integer
native GetExpansionY        takes nothing                               returns integer
native SetStagePoint        takes real x, real y                        returns nothing
native AttackMoveKill       takes unit target                           returns nothing
native AttackMoveXY         takes integer x, integer y                  returns nothing
native LoadZepWave          takes integer x, integer y                  returns nothing
native SuicidePlayer        takes player id, boolean check_full         returns boolean
native SuicidePlayerUnits   takes player id, boolean check_full         returns boolean
native CaptainInCombat      takes boolean attack_captain                returns boolean
native IsTowered            takes unit target                           returns boolean

native ClearHarvestAI       takes nothing                               returns nothing
native HarvestGold          takes integer town, integer peons           returns nothing
native HarvestWood          takes integer town, integer peons           returns nothing
native GetExpansionPeon     takes nothing                               returns unit

native StopGathering        takes nothing                               returns nothing
native AddGuardPost         takes integer id, real x, real y            returns nothing
native FillGuardPosts       takes nothing                               returns nothing
native ReturnGuardPosts     takes nothing                               returns nothing
native CreateCaptains       takes nothing                               returns nothing
native SetCaptainHome       takes integer which, real x, real y         returns nothing
native ResetCaptainLocs     takes nothing                               returns nothing
native ShiftTownSpot        takes real x, real y                        returns nothing
native TeleportCaptain      takes real x, real y                        returns nothing
native ClearCaptainTargets  takes nothing                               returns nothing
native CaptainAttack        takes real x, real y                        returns nothing
native CaptainVsUnits       takes player id                             returns nothing
native CaptainVsPlayer      takes player id                             returns nothing
native CaptainGoHome        takes nothing                               returns nothing
native CaptainIsHome        takes nothing                               returns boolean
native CaptainIsFull        takes nothing                               returns boolean
native CaptainIsEmpty       takes nothing                               returns boolean
native CaptainGroupSize     takes nothing                               returns integer
native CaptainReadiness     takes nothing                               returns integer
native CaptainRetreating    takes nothing                               returns boolean
native CaptainReadinessHP   takes nothing                               returns integer
native CaptainReadinessMa   takes nothing                               returns integer
native CaptainAtGoal        takes nothing                               returns boolean
native CreepsOnMap          takes nothing                               returns boolean
native SuicideUnit          takes integer count, integer unitid         returns nothing
native SuicideUnitEx        takes integer ct, integer uid, integer pid  returns nothing
native StartThread          takes code func                             returns nothing
native Sleep                takes real seconds                          returns nothing
native UnitAlive            takes unit id                               returns boolean
native UnitInvis            takes unit id                               returns boolean
native IgnoredUnits         takes integer unitid                        returns integer
native TownThreatened       takes nothing                               returns boolean
native DisablePathing       takes nothing                               returns nothing
native SetAmphibious        takes nothing                               returns nothing

native CommandsWaiting      takes nothing                               returns integer
native GetLastCommand       takes nothing                               returns integer
native GetLastData          takes nothing                               returns integer
native PopLastCommand       takes nothing                               returns nothing
native MeleeDifficulty      takes nothing                               returns integer
 

UndeadDragon

Super Moderator
Reaction score
447
Wow, theres some pretty cool natives in there :thup:
 

Azlier

Old World Ghost
Reaction score
461
It does not matter where you put it.
 

Viikuna

No Marlo no game.
Reaction score
265
Pretty interesting functions there indeed.

I expect someone to find a way to run bytecode with this function, so we can get Blizzard to patch shit again:

JASS:
native StartThread          takes code func                             returns nothing



Anyone knows if theres some compilation about these functions and which ones work and what they do
and stuff?

edit.

lols, wonder what [lJASS]GetMegaTarget[/lJASS] does.

Also, I always thought that only like those GoldCost thingies work. That UnitAlive working is pretty cool thing indeed.
 

Azlier

Old World Ghost
Reaction score
461
Calling StartThread results in an instant crash.
 

Azlier

Old World Ghost
Reaction score
461
Oh, it does nothing. No sleep at all.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top