HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Functions in common.j that do not work in AI scripts, please contribute

11-16-2003, 11:28 AM#1
Tommi
I've already stumbled upon a few functions in common.j, which do not work in AI scripts. I believe that advanced users here are rather knowledgeable about these problems, but I couldn't find a comprehensive list of functions that do not work AI scripts. I'll start listing them, and hope that people on this board would add more. It would save a lot of time for people to know which functions work and which do not.

Functions in common.j that do NOT work in AI scripts
ForGroup
I2S

Enjoy,

Tommi
11-16-2003, 12:32 PM#2
Zalamander
No function that returns string in common.j works in AI script.

that is:
OrderId2String()
UnitId2String()
AbilityId2String()
I2S()
R2S()
R2SW()
SubString()
GetLocalizedString()
GetPlayerName()
GetSaveBasicFilename()
GetEventPlayerChatString()
GetEventPlayerChatStringMatched()
GetUnitName()
GetStoredString()
LeaderboardGetLabelText()
MultiboardGetTitleText()

and there is some others I don't know of.
11-16-2003, 03:10 PM#3
AIAndy
As Zalamander said all the natives that return strings do not work.
Also all the natives that take code or similar things like filters do not work in respect to that code. That means that you can use the GroupEnum... natives but you can't use the filter aspect of them.
Last thing that does not work is ExecuteFunc. It only gives you a very nasty crash.
I think that is pretty much all. The reason that they don't work has been stated in an old post by Magnus99. It is a problem that the data is separated between AI and triggers. You can see that by the strings that the natives do return. They return names of functions from AI and similar stuff.
11-16-2003, 06:49 PM#4
Tommi
Thanks for replies. I'm beginning to get the big picture. How come some functions, such as CreateGroup, work in AI scripts, even though they return pointers to objects? Shouldn't created groups reside in the memory space accessible by common.j and not AI scripts? Am I missing something?

Hmm... Jass Manual says the following:
Quote:
Important Note: Others have observed that the following functions in common.j do not function correctly when used in AI scripts:

- native functions that take strings as arguments or return string.
- native functions that take callbacks (code, trigger, boolexpr, etc.) as arguments such as triggers and enumerators (ForGroup, etc.).

These functions work normally in map scripts. Also be aware that native functions declared in common.ai are obviously not available to map scripts.
However, DisplayTimedTextToPlayer seems to work correctly, which invalidates the "takes string" argument. Are native functions able to reference strings in AI scripts, or am I missing something here?
11-16-2003, 09:17 PM#5
AIAndy
All natives that take strings except ExecuteFunc work I think.
Natives that return handles or similar (a lot of types are derived from that) do work.
I think all these problems come from the way Warcraft passes parameters and returns values.
All the more complex types are probably passed as references and it seems that some of that is not properly implemented to work for both memory spaces.
11-17-2003, 04:21 AM#6
silverdrake
no wonder my I2S and ExecuteFunc werent working! good to know this, at least most of these methods arent hard to replicate
11-17-2003, 05:29 PM#7
Tommi
Quote:
Originally posted by AIAndy
All the more complex types are probably passed as references and it seems that some of that is not properly implemented to work for both memory spaces.

Thanks. Which of these subtypes of handle are then known to work and not work as arguments in AI Scripts. Here's a list of them:
- ability
- aidifficulty
- alliancetype
- blendmode
- boolexpr --> DOES NOT WORK (including subtypes conditionfunc and filterfunc, of course)
- button
- camerafield
- camerasetup
- defeatcondition
- dialog
- effect
- effecttype
- event
- eventid
- fogmodifier
- fogstate
- force
- gamecache
- gamedifficulty
- gamespeed
- gamestate
- gametype
- group --> WORKS
- itempool
- itemtype
- leaderboard
- location
- mapcontrol
- mapdensity
- mapflag
- mapsetting
- mapvisibility
- multiboard
- multiboarditem
- placement
- player --> WORKS
- playercolor
- playergameresult
- playerslotstate
- playerstate
- quest
- questitem
- race
- racepreference
- raritycontrol
- rect
- region
- sound
- startlocprio
- terraindeformation
- texmapflags
- texttag
- timer
- timerdialog
- trackable
- trigger --> DOES NOT WORK, RIGHT?
- triggeraction
- triggercondition
- unitpool
- unitstate
- unittype
- version
- volumegroup
- weathereffect
- widget

Quite many of these are not really AI stuff, but you never know which work and which do not... :mtk:
11-17-2003, 07:28 PM#8
AIAndy
My guess is that they all work but for some you need natives that take code to create or use them like boolexpr. So probably trigger will also work but since you cannot add action functions it has no real purpose.
11-18-2003, 07:11 PM#9
Tommi
Alright. I compiled a page of this info for future reference. Here a link to it:

Functions in common.j that do not work in AI scripts
http://www.hut.fi/~tgustafs/wc3_donotworkinai.html

Hope I got everything correct.

Enjoy,

Tommi