• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[List] Common.j natives that do nothing/are useless/are broken

Status
Not open for further replies.
The goal of these lists is to compile a bunch of fail stuff.

If you'd like to contribute, please don't bother with the uselessness
of location functions like SetUnitPositionLoc, or wrappers such as
GetDestructableX/Y instead of GetWidgetX/Y or GetEnteringUnit as
opposed to GetTriggerUnit.


Ones that do nothing:

JASS:
TriggerWaitOnSleeps
IsTriggerWaitOnSleeps
SetTerrainFog
FinishUbersplat
ResetUbersplat
AddSpellEffectLoc
AddSpellEffect
AddSpellEffectTarget
AbilityId
AbilityId2String

Ones that are useless (and why):

JASS:
IsUnitIdType //Only works with UNIT_TYPE_HERO and has the same flaw as IsHeroUnitId by only checking if the first letter of the rawcode is an uppercase

IsUnit //Could use unit == otherUnit

TriggerExecuteWait //Does the same thing as TriggerExecute

Deg2Rad & Rad2Deg //Just use the Blizzard.j constants

ability //All associated API - including the "buff" type

Ones that are broken (and why):

JASS:
UnitDamagePoint //Has been known to cause crashes in battle.net (I've experienced it myself)

GroupEnumUnitsOfTypeCounted
GroupEnumUnitsInRectCounted
GroupEnumUnitsInRangeCounted
GroupEnumUnitsInRangeOfLocCounted //Cause irregular behavior when used with large numbers

IsUnitType //Often requires == true or == false when used alone inside a boolexpr

AddItemToAllStock // NOT BUGGED, see link below*

SetUnitScale //Y and Z are usless parameters here, only the X is counted for scale

UnitId2String //Always returns null after the game is loaded/if the game is a replay

*Fix for AddXToAllStock
 
Last edited by a moderator:
Level 10
Joined
Jul 12, 2009
Messages
321
Ones that do nothing:

JASS:
native ResetUbersplat               takes ubersplat whichSplat returns nothing
native FinishUbersplat              takes ubersplat whichSplat returns nothing
// Correct me if I'm wrong

Ones that are useless (and why):

JASS:
native Deg2Rad  takes real degrees returns real
native Rad2Deg  takes real radians returns real
// May as well use the bj_ constants

constant native GetSpellAbility             takes nothing returns ability
// It returns an agent which has no use (no functions use it except for saving/loading it in a hashtable) and cannot be destroyed

Ones that are broken (and why):

JASS:
native GroupEnumUnitsOfTypeCounted          takes group whichGroup, string unitname, boolexpr filter, integer countLimit returns nothing
native GroupEnumUnitsInRectCounted          takes group whichGroup, rect r, boolexpr filter, integer countLimit returns nothing
native GroupEnumUnitsInRangeCounted         takes group whichGroup, real x, real y, real radius, boolexpr filter, integer countLimit returns nothing
native GroupEnumUnitsInRangeOfLocCounted    takes group whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing
// "Those two natives seems to show irregular behaviour when used on large numbers of units"
// [url]http://www.wc3c.net/showthread.php?t=80693[/url]
// For that matter, I don't personally even know what they are supposed to do

Ones that are broken (and why):

JASS:
UnitDamagePoint //Causes Macs to crash
As a Mac user who has used this function and not even experienced a desync, even when playing with a Windows user, I submit that it is an insufficient description of the problems with this function, if there are even any problems at all.
 
Ones that are broken:

JASS:
constant native AbilityId                   takes string  abilityIdString   returns integer
// This will always return 0, despite whatever input you provide

constant native AbilityId2String            takes integer abilityId         returns string
// This will always return null, despite whatever input you provide

native AddItemToAllStock            takes integer itemId, integer currentStock, integer stockMax returns nothing
native AddItemToAllStock            takes integer itemId, integer currentStock, integer stockMax returns nothing
// After adding an item to a neutral building through either of these functions,
// it will cause any units that purchase the item to receive only one of it 
// before it is completely removed from the stock. Regardless of the stock 
// amount, the item will only remain available in the building for one purchase. 

native AddSpellEffectLoc            takes string abilityString, effecttype t,location where returns effect
native AddSpellEffect               takes string abilityString, effecttype t, real x, real y returns effect
native AddSpellEffectTarget         takes string modelName, effecttype t, widget targetWidget, string attachPoint returns effect
// These functions don't work, it will always return a null effect
// (Use the AddSpellEffectById natives instead)

I suppose some could count as "do nothing" since they return 0/null, but I didn't know if that classified it as a "do nothing" native.
 
JASS:
// Not currently working correctly...
constant native AbilityId                   takes string  abilityIdString   returns integer
constant native AbilityId2String            takes integer abilityId         returns string

^ Direct from common.j, yeah even Blizzard admitted that they were lazy here

JASS:
type ability            extends     agent
type buff               extends     ability

Yeah I must admit these are laughable. Since abilities are rather integer rawcodes, I guess Blizzard changed their mind but didn't bother removing these from common.j

Whoever made the hashtable ability natives wasn't thinking at all.

I'll add everything so far to the list unless someone can prove otherwise.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
ability is not the same as the integer representation. Each unit obtains a unique ability-object for first-casting (first time calling the function), even if they have the same object editor ability, they get different objects. This may be used to attach something under the combination.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Natives that contain faults...
JASS:
native DestroyTimer takes timer whichTimer returns nothing
// A timer will still remain schedualed to expire even after being destroyed by this native.
// Pausing the timer before destruction is a work around.

native PauseTimer takes timer whichTimer returns nothing
native ResumeTimer takes timer whichTimer returns nothing
// Pausing and resuming a running timer object using these natives will discard the perodic flag (so a perodic timer will revert to single expiry mode).
Two really annoying faults I found...
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Based on my old tests and memory (not checked), so correct me if i'm wrong :

- DisplayTimedTextFromPlayer display the text for all players, as long the player argument is valid, or maybe even unvalid (should be checked with replays also)

- It's false to say that AbilityId and AbilityId2String always returns null, sometimes they return a correct value, but never for custom rawcodes. (well it's lame enough anyway ...)

- TriggerWaitOnSleeps / IsTriggerWaitOnSleeps

Maybe they could be used to link a boolean value to the trigger :p

- Deg2Rad / Rad2Deg

They could have the same efficiency as using the constants, i believe my old benchmarks with japi natives.
And there are some crazy people which don't use anything from blizzard.j (i'm not one of them)

UnitId2String //Always returns null after the game is loaded/if the game is a replay

Do you mean that :

Returns null when the game is loaded AND is a replay.

or that :

Returns null when the game is loaded OR is a replay.

Because i'm sure it returns null for loaded games but don't remember for replays.

- GetLocalPlayer is broken in the sense it will always return the first slot that was played by a people (or a bot i guess) in a replay.
That's why i prefer to use BJDebugMsg for debug message, DisplayTimedTextFromPlayer is just longer :p .
But it seems to affect only visual things, which won't affect the result of the game in any way (like a DisplayText, a visual effect, ...)
For example if you select an unit with GetLocalPlayer and have a trigger with all player unit selection event, the trigger will still fire as many time there was people.

- Also you can't initialize a global variable with GetLocalPlayer (in the global declaration), else wc3 will crash.

- These natives can't be used in a global setting (no effect, maybe even a leak) :

CreateRegion
CreateUnit
CreateDestructable
CreateItem


It must have some other ones like Rect.

- For the GroupEnum...Counted functions, the last argument should has no effect, aka useless or NotYetImplanted.

My 2 cents.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I've forgotten about TriggerClearActions which only deactivate actions of a trigger but doesn't clean up the memory.

Unless you really want a TriggerSleepAction/PolledWait, you should use conditions instead of actions, because they don't leak, you don't have to remove them when you destroy a trigger and they are faster, while they still open a new thread like a trigger action.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Read me again i say trigger conditions don't leak, no that trigger actions leak (that was not implicit ^^)

I mean TriggerClearActions doesn't clean up the memory, so the trigger actions will leak.
TriggerRemoveAction work as intended, but you have to link the trigger with its trigger actions.
There is really no reason to use trigger actions except if you want to use TriggerSleepAction or its hybrid PolledWait.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Then, I like to not write the return statement though as people use to. Do not know if this still exists but had a problem in past where I had something like

JASS:
function a takes nothing returns nothing
    if (GetLocalPlayer() == <player>) then
        ...
    endif
endfunction

as a triggercondition. Since the local block contained the final instructions and the return value undetermined, it caused a split.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
That was mac related, no ?
I don't know if it's fixed or not, i wouldn't bet on it since pjass refuse to "compile" such scripts (but in an other side pjass was not updated since a while).

It could be fixed with a jass preprocessor (i mean auto-adding return false and returns boolean instead of nothing), but i guess it's too much overhead.

Anyway if you don't like it you're not forced to use it and when the speed doesn't matter and the trigger will never be destroyed, trigger actions are enough.

So you've found one more reason of using trigger actions : the usual human laziness :p
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
You meant trigger action, right ?

Also that was only a joke, nevermind, i'm personnaly fine with returns boolean since i know that coding in jass is tricky, it's natural now.

But you have to admit that in case of dynamic triggers, trigger conditions is the way to go, because of the needed overhead with trigger actions.
Same when you want your code running as fast as possible.
 
DisplayTimedTextFromPlayer works fine and has actually a different behavior than ~ToPlayer : it displays to every players the message with the player's name replacing the first "%s" in the string. It acts like the C line :

printf ( message, GetPlayerName(toPlayer) );

That means you can also use %d or whatever you want but the result will be quiet random after the player's name. So there may be an exploit issue there :goblin_yeah: wait, I wanted to say this native works perfectly, no?

Anyway, it doesn't give a lot more functionnality than the other displays. Maybe you can avoid few string leaks but I don't see anything else. Even the exploit could only be used as a display or a crash action.
 
Status
Not open for further replies.
Top