lep / jassdoc Goto Github PK
View Code? Open in Web Editor NEWDocument the WarCraft 3 API
Document the WarCraft 3 API
public enum TargetsAllowed
{
Ground = 1 << 1,
Air = 1 << 2,
Structure = 1 << 3,
Ward = 1 << 4,
Item = 1 << 5,
Tree = 1 << 6,
Wall = 1 << 7,
Debris = 1 << 8,
Decoration = 1 << 9,
Bridge = 1 << 10,
Self = 1 << 12,
PlayerUnits = 1 << 13,
Allied = 1 << 14,
Neutral = 1 << 15,
Enemy = 1 << 16,
Vulnerable = 1 << 20,
Invulnerable = 1 << 21,
Hero = 1 << 22,
NonHero = 1 << 23,
Alive = 1 << 24,
Dead = 1 << 25,
Organic = 1 << 26,
Mechanical = 1 << 27,
NonSuicidal = 1 << 28,
Suicidal = 1 << 29,
NonAncient = 1 << 30,
Ancient = 1 << 31,
NotSelf = PlayerUnits | Allied | Neutral | Enemy,
Friend = PlayerUnits | Allied,
}
so I believe this is its structure
By Arxos in Hive Discord
Hey I finally finished the extraction of Jass for different game versions: https://github.com/Luashine/jass-history/
How to deal with these?
Old Deleted functions: I think to put them in a separate file, there aren't many
Renamed functions: ??? very few if any, I'd probably put them in a different file yet, for easier copy-pasting during doc updates
... but it begs the question if @alias
would be worth it, there are also swapped BJ functions where it could come in handy
Functions with changed signatures: this is tricky. For example, when the widget
type was added, some functions changed their input variable type. Other functions expanded by an argument, such as EndGame
used to be takes nothing
, now it takes a boolean
Tracking initial version: most functions have never changed since the first ROC Beta. On one hand if this was blindly added to every function, it'd create unnecessary clutter. On the other hand, if you dont add it then later you cant be certain if that's because the func was always there or the version info was never added?
Finally I don't know it it all belongs inside a @patch
. I'd rather see the @since
tag added just for that info and keep @patch
for any changes in behavior/removal.
I don't have anything to do code-level comparisons with, will your perl parser cut it? I dont think so because I thought of these:
I had looked at actboy's totally undocumented and messy parser, AST and all that stuff... if the above requirements are too much for your perl script I guess I will go the noob route and regex my way through Jass again. Like I dont think AST would be worth it really or learning how to run ANTLR or writing my own even if Jass is really easy 😅
Sorry I accidentality submitted before finishing my question.
I'm really glad I found this repository, thanks for making this! I am just getting started with Jass and vJass. Since vJass seems to be officially supported by the World Editor I am asking if this documentaiton includes vJass and if pull requests regarding vJass will be considered?
With moyack's permission I wanted to move the few previous contributions remaining on his website to here. There's one minor problem: Starquizer dedicated most of his work to the AI natives. These aren't tracked by this jassdoc.
Would you add it? Attached version 1.33.0.19203 (changed file extension due to github restrictions)
common.ai.txt
See these pages:
https://www.hiveworkshop.com/pastebin/1ce4fe042832e6bd7d06697a43055373.5801
A user library: https://www.hiveworkshop.com/threads/sync-game-cache.279148/
https://www.hiveworkshop.com/threads/about-host-detection-and-local-player-code.94709/
https://www.hiveworkshop.com/threads/a-really-really-ridiculously-easy-way-to-sync-data-new-gethost-command.114475/
SyncStoredInteger, SyncStoredReal, SyncStoredBoolean, SyncStoredUnit, SyncStoredString
The website disappeared in 2008. Some of it remains on the Wayback Machine: https://web.archive.org/web/20080911204136/http://wc3jass.com/
Moyack recreated the website in 2012 but it has been erased since.
Apparently some of the tips described there made it verbatim to current day, like Jass: Known bugs says:
GroupEnumUnitsInRectCounted and GroupEnumUnitsInRangeCounted
Those two natives seems to show irregular behaviour when used on large numbers of units.
I remember seeing that exact wording not too long ago (until I described these functions).
Most info on Jass will still be relevant. Some info is not, because various bugs have been fixed. Still, the community is pretty much split between 1.24 (old maps with return bug), 1.26 (maps making use of memhack), 1.30/1.31 (our reforged-less brothers and sisters), 1.32 (due to buggy 1.33), and the latest official 1.33. While nobody's gonna develop for 1.24; 1.26 and others are still somewhat relevant.
The priority should be undocumented natives first and if anyone has the motivation, separately note 1.26+ bugs and quirks.
You can freely* browse the website on archive.org. *But not really freely. Because some topics are not saved (example #2373) and others will be saved under a different URL.
For example,
http://wc3jass.com/viewtopic.php?p=9396
andhttp://wc3jass.com/viewtopic.php?p=9396&sid=1e01ceb19fe171c30c697b63a6bf9713#9396
are different.If you have the latter URL, you can easily try its short version, but if you have the short URL then you have to search/filter all of the archived URLs. It's possible, but limited and buggy: https://web.archive.org/web/*/http://wc3jass.com/*
(takes a long time to load, don't open unless you intend to work on it)
If multiple people will work on this, I suggest each person to create a single comment and add to it the topic you've read and processed to organize the effort between multiple people. Example:
[x] https://web.archive.org/web/20080113045551/http://www.wc3jass.com:80/viewtopic.php?t=2039
= Jass tutorial by Vexorian
[ ] https://web.archive.org/web/20080607065301/http://www.wc3jass.com:80/viewtopic.php?t=1999&sid=bbe8304984c3779b4fd9c7c6d19ded6a
= Tutorial, "Using Timers and Handle Vars"
// Update: Not needed, there were 800 saved post links total with many duplicates.
So far I have used @param, @bug, @note, @pure, @async and @event annotations. Other possible annotations could be @nosideeffect.
async, pure, event
. Everything else appears as normal text, right?@bug Reforged:
or @bug 1.31-1.32.2:
- without adding complexility like @bug <version> <text>
I would like to prepare an easy to follow style guide and installation instructions for those willing to contribute. Github is a one hoop on the way to contribution, no need to add more :)
For now I've used the hive's thread to motivate people, so I'm gonna continue discussing technical stuff here.
Msg updated
From wurst docs:
Executes the given closure for every unit of the given type. Remember that names of custom units are "custom_[typeId]"
I think event constants like EVENT_PLAYER_UNIT_SPELL_EFFECT
and EVENT_UNIT_DAMAGED
are interesting because they control bindings.
For example, EVENT_UNIT_DAMAGE
contexts have no binding for GetAttacker()
, but do have a binding for GetEventDamageSource()
.
Continuation of #108 (comment) -- following lep's last reply about it.
I'm typing this out below for my future self... it has wasted hours of my time already to grasp this :(
git blame points to this commit containing LF in the diffs: 828d7ab 828d7ab
.
I typed out the response yesterday but didn't have time to test so I didn't comment then. The only good article on this matter is https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/
just skip the history part.
git config --local core.autocrlf true
git rm --cached -r .
git reset --hard
The commands you typed out are really the only way to safely re-extract the files and apply new EOL rules. Use them for testing in the future. The only command I'd like to add is git show <REVISION>:<FILE> > stdout.txt
to get the file as-is without conversions. WARNING though, you must NOT use CMD or Powershell else they may introduce LF->CRLF conversion on their own. For example:
git show HEAD~1:Blizzard.j > prenormalized-Blz.j
git show HEAD:Blizzard.j > postnormalized-Blz.j
git ls-files --eol
Keep in mind, git's preferred internal representation for text is LF and only LF. The issue really is/was not that git automatically converts between LF/CRLF. It's that the file in working dir ended up having MIXED LF/CRLF, which git did not dare to convert to LF and thus checked in & committed MIXED into internal index.
The fact that git "did not dare" has to do with OS && autocrlf setting && writing LF in our case, when it had to be CRLF (as the rest of the file was CRLF already). You might've extracted the file as CRLF initially but then patched it with a tool in LF style.
In this context I regard .gitconfig
as "what can I do with my setup to avoid having/introducing these issues" and .gitattributes
as "what can the repository do with its settings to avoid issues" sort of a soft policy.
.gitattributes
(otherwise high chance of ending up with MIXED)* text=auto eol=lf
-- for all files automatically detect if its binary/text (already default) but if it's text, git will respect our eol
instead of core.autocrlf
core.autocrlf
is == true/inputBack to the repo. Blizzard.j right now is in MIXED state internally with 98% CRLF and 2% LF.
text
is "unspecified") will continue to cause spurious merge conflicts and line conversions depending on user's core.autocrlf, especially dual-booting.-text
will instruct git to not touch the lines anymore. We would live on with mixed lines. Doesn't seem too bad on the surface, but software would get confused and line replacements will pop up from time to time.
Let's take Notepad++ for example. I've noticed it before, it will autodetect EOL based on the few lines in the beginning and only choose and only show one type of EOL (even if file is mixed). It sees Blizzard.j as CRLF (in reality MIXED).
Pressing ENTER after "arithmetici" and continuing to write will turn into:
-> We just changed the EOL and moved LF onto the other line
Pressing DELETE after "arithmetici", but then changing mind and pressing ENTER will remove LF but write CRLF:
-> We just changed EOL (renormalizing the file one line at a time lol)
I suggest to say fuck it, bite the bullet and normalize Blizzard.j to only contain LF as the other files do (huge commit). Then set eol=lf for all files. And if you enabled safecrlf = true
for yourself in config it would shout at you with (and abort the git add
):
fatal: CRLF would be replaced by LF in creditsother.pld
here you tried to add a CRLF'ed .pld file while the attributes require LF on the input side. I think it's a good thing, you can convert on your own (dos2unix). With safecrlf = warn
it would work as it says but give you a warning.
.gitattributes
# All game scripts are CRLF, but LF works fine and we already use it
# aka "text" is set, enabling EOL conversion the way we want it if not forbidden by safecrlf
*.j text eol=lf
*.ai text eol=lf
# Not yet included in repo but can go with LF for consistency?
*.pld text eol=lf
*.wts text eol=lf
Sorry about the wall of text, I'm not happy with all this work either but finally got to the root of it ❤
18:56 ^ two craters of r = 256, depth = -128
18:56 step size 8
18:57 starting at -256 - 16
^ step-size 4
^ step-size 2
Observations:
Questions:
OH YES, Willy, if you somehow manage to make the game use more than 16 ground* textures, YOU'LL BE MY ABSOLUTE HERO 😍 AND I'LL FAVOR HIVEFORGED FOREVER 🤟
MindWorX:
Unlikely to happen 😄
It's still kinda funky that you have unlimited tiles in SD Reforged.
But not in HD Reforged.
And not in SD pre-Reforged.
Yep, apparently if you use the natives to set terrain tiles, in SD it allows you to set any tile.
Even ones you didn't include.
From Hive Discord, message link
Retera:
I remember doing this in patch 1.22-1.26
Werent tiles always unlimited?
...
But i recall thinking tiles seemed infinite via triggers in the old days
That was how I felt about it, at least
Find out and document.
As a part of #73 I was going to add this note, but decided to look further into "why":
+@note You should not initialize game sounds as constants in Jass (why?)
In a reply there moyack says that the problem he had was due to a constant sound
handle. He had an issue after loading a saved game.
Searching further, all I really found were posts on hive like this:
You shouldn't use handle variables as constant globals, make them nonconstant.
And then the only interesting discussion here, where nobody understands the logic of constant vs non-constant functions, and for handles only the issue with "wc3mapoptimizer" is pointed out (wrongly constant-folding handle variables). Though that's different from whatever bug moyack had after game load.
Basically, does anybody know what constants are good for (except basic types like int)? Should we add a general warning to handle
type? (and then each descendant type too?) to never save handles as a constant?
https://web.archive.org/web/20140213050502/http://www.wc3c.net/showthread.php?t=102576
Moving a unit outside the map's bounds using SetUnitX/Y will STILL crash the game. But I did not want to use a wrapper for SetUnitX/Y that does the bounds checking, an extra function call seems like killing the whole purpose of using SetUnitX/Y... Adding this library to your map (just adding it) [...]
Post 5:
Really, been testing:
Left/Right/Top edges do not crash.
Bottom edge crashes: However it doesn't crash at the instant you call SetUnitY, it crashes when the frame is rendered (apparently, could be another thing besides rendering...) so, yep this library really prevents crashes.
There is another thing with edges, regardless of the crash we knew about for so long, if you issue an order to a unit too far from the edges, the game will freeze, yep BoundSentinel prevents that as well.
Pages 2 and 3 were not archived.
Maybe no longer crashes on Reforged.
This resource is crashing the game during loading time on patch 1.31.1.
The following line is the culprit:call SetUnitY(dummy, GetRectMaxY(world) + 1000).
Removing the + 1000 fixed the issue.
Line 645 in e568f1c
the source (first arg) must be an actual unit
Setting source and target as the same unit is an easy way to resolve if intentionally don't have a source
http://www.wc3c.net/showthread.php?t=95756
(unconfirmed by me)
Existed in 1.32.10 as an undocumented native (available via Lua).
Completely removed in v1.33.0.18897 PTR.
Is there a chance to add this info manually?
See this discussion: https://www.hiveworkshop.com/threads/selections-and-desyncs.244932/
IsUnitSelected, SyncSelections,
Looking at this thread i was looking for this function in jassdoc but i couldn't find it.
Now next time i do want to find it in jassdoc, so i ask myself where such a function should be documented at? CreateUnit
, CreateImage
and DestroyImage
seem like good candidates.
Now of course that's under the premise that it still works))
@lep you had some concern about using SetUnitColor in my map, and it maybe resetting the local player's choice for team color vs player colors.
insert into annotations (fnname, anname, value) values (
'bj_HASHTABLE_STRING',
'source-code',
' constant integer bj_HASHTABLE_STRING = 3
'
);
These get inserted into the database as \x0a
(I am on Linux). Even some of the @pure
annotations have that trailing new line while others don't.
Does have new line on pure: OrderId
Line 1376 in ca10ef7
Does not have: OrderId2String
Line 1395 in ca10ef7
I see it's simply not trimming trailing new lines from the .j files and processing them literally. That's clutter in my opinion and should be removed.
https://lep.duckdns.org/app/jassbot/doc/TriggerSleepAction via #60
Assigned: myself
Tasks:
pauses the current execution thread, sleeps for timeout of real-time seconds and resumes execution where this function was called. You may only use this inside trigger actions!
The [u]timeout[/u] timer has a granularity of 10Hz, this means you can only sleep in 100ms intervals at best (1000ms/10 = 100ms). [u]Timeout[/u] of 0 also sleeps for 100ms. [u]Timeouts[/u] -120 < x < 0 are the same as 0. [u]Timeouts[/u] <=-120 abort further execution.
[quote=WorldEdit help text]The duration of this wait is specified in real-time seconds.[/quote]
Therefore the game speed does not affect this timeout. Reforged (v1.32.10): Pausing the game also pauses the ticking of the timeout.
The behavior is similar to [url=https://www.lua.org/manual/5.3/manual.html#2.6]coroutines in Lua[/url], this principle is called [url=https://en.wikipedia.org/wiki/Cooperative_multitasking]cooperative multitasking[/url] where you hand off control of the execution thread and it is returned to you at a later time.
See: [jassdoc]PolledWait[/jassdoc] for sleeps in game-time seconds.
Example (Lua):
[code=lua]local secretWord = "please"
DisplayTextToPlayer(Player(0), 0, 0, "Current time is: ".. os.date())
TriggerSleepAction(10) -- sleeps for 10 seconds
DisplayTextToPlayer(Player(0), 0, 0, "After sleep the time is: ".. os.date() .." and the secret word is: ".. secretWord)[/code]
[23-48-49] Wietlol: i was implementing items and came across a function I find a bit weird
[23-49-02] Wietlol: ItemAddIndicator() and ItemAddIndicatorBJ()
[23-49-33] Wietlol: the parameters seem to make it like SetUnitVertexColor() but for items, but the name is more like something for UI
There is some myths that using this native can reduce a unit's effective attack range, but that only works in special circumstances and has some caveats
"Daratrix" on Discord:
just finished testing it and it does that exactly, but thank you for that resource!
And it also ignores dead units, perfect 👌dead with corpses is ignored?
Seems like it
Although is seems to not behave correctly with building currently being upgraded
A building being upgraded counts toward its equivalent dependency count and not itself, even it is not yet unlocking the related tach, that's an odd quirk
Might be related to the fact I'm an older version though
The use of gamecache and related APIs seems to carry a lot of problems with it. See: https://web.archive.org/web/20100118203110/http://wiki.thehelper.net/wc3/jass/common.j/Gamecache_API
Making an issue to track it formally.
https://www.hiveworkshop.com/threads/setblight-desync-issues.350885/
I haven't seen anyone post about this but thanks to the guys working on W3CE it's been revealed that the SetBlight native has a major problem: it will remove blight (regardless of the value of the addBlight argument) for any player that is holding down the shift key. This can easily cause a desync.
The solution is to use the other natives, which aren't affected by the shift key:
JASS:
native SetBlightRect takes player whichPlayer, rect r, boolean addBlight returns nothing
native SetBlightPoint takes player whichPlayer, real x, real y, boolean addBlight returns nothing
native SetBlightLoc takes player whichPlayer, location whichLocation, real radius, boolean addBlight returns nothing
Abilities that create blight, such as the Sacrificial Skull and Undead building creation, also don't suffer from the issue.
Searching for BlzGetAbilityId native doesn't actually show it as a result, even though the native is defined in common.j and can be accessed through: https://lep.duckdns.org/app/jassbot/doc/BlzGetAbilityId
no docu in wiki
One of my pressing reasons, to move Lucan's Frames doc here and to link every undescribed function from moyacks jassdoc -> here, was to "unify" the search. To not waste time researching something that already has been described before - without you knowing it, because you couldnt find. There's now one fewer place to look in for documenation.
Side note: I was going at a speed of ~25s per link, quite good ^_^ and fast enough to not bother with a script yet
With that done, there's now the issue of issues that are opened on Github. Their info appears neither here nor there, creating yet another place to look up the information. My idea is to get rid of them use them less. Anything that's a long-standing WIP or where the author takes a break, should go straight into the doc as it is, encouraging people to complete a description later (when they want to).
Good example: #27 has been hanging there for 2.5 years. Let question marks be question marks, i.e. "its something!"
Anti example: On the other hand #31 has no value in a doc until it's complete. Maybe add a tag for such notes? @wip https://github.com/lep/jassdoc/issues/31
-> "This function's description is being worked on, you can help! "
This is a different kind of thinking, becoming more agile (though not the literal agile haha). A partial documentation can be helpful in itself. A beginning of a description (a stub in Wikipedia's terms) can be helpful to motivate people to complete it, avoiding the blank sheet problem.
This won't become a professionally polished documentation so I would not bother trying to reach perfection. I myself try to go in-depth but I expect most people won't, yet even minimal answers can be enough:
Question: anyone know what ResetTrigger does?
Answer: clears execution/evaluation count of the trigger
Reply: interesting
No docu avail
Noticed the three natives added in commit 9358c78 have been annotated with patch 1.32.3, however these already exist since 1.31
This post describes how to achieve the "hidden" inventory slots that go beyond the default maximum of 6 through an ability bug: https://www.hiveworkshop.com/threads/hidden-inventories-with-little-code.238761/
Describe native behavior with this hack in place. Keep in mind, this may have changed in Reforged and only works in old versions.
I think it could be interesting to know how certain BJ functions work, for example cinematic/UI functions, and melee initialization functions.
How should the official GUI trigger/native description be implemented and added? I haven't looked into the format of these files yet, I will do that later.
Technical note: Apparently all of these files are stored in Game MPQ/CASC under UI/
(1) I thought if WE descriptions added to the docs source as-is, it'd violate some loicences in this repo (but there's no loicence at all). Plan: add a custom @tag to distinguish between official descriptions and ours.
(2) Same as above but instead of adding new tags to the docs source, the build system fetches them from an intermediate format (json?) - Easier than (1) because there's no need to find and inject tags at the right places in files.
(3) Handled in a separate repo(?) and merged into the .db for the front-end to process and display differently.
I have pointed some users to this documentation and some are confused about 'what all hose .j files are for'.
I think the readme could have some simple introduction like the one you gave me in irc.
Line 83 in 98fc2bf
techid
: is this the 'hfoo'
id of the research/upgrade?
boolean specificonly
-- ??? wtf
В 1.31 существует баг, проявляющийся после загрузок сохранённых игр. В этом случае перестают работать почти все раннее добавленные события триггеров типа Specific Unit Event (EVENT_UNIT_SPELL_EFFECT, EVENT_UNIT_USE_ITEM и т.п.) Из подобных остаются работать всего несколько (EVENT_UNIT_DAMAGED, EVENT_UNIT_DEATH).
Если ваша карта не односессионная, то необходимо либо использовать только события типа Generic Unit Event (EVENT_PLAYER_UNIT_SPELL_EFFECT, EVENT_PLAYER_UNIT_USE_ITEM и т.п.). Либо отслеживать событие загрузки игры (EVENT_GAME_LOADED) и добавлять заново потерянные события.
There's a bug in 1.31 that comes up after loading a saved game. In this case almost all Specific Unit Events stop working (EVENT_UNIT_SPELL_EFFECT, EVENT_UNIT_USE_ITEM etc.) Of all these only a few continue to work correctly (EVENT_UNIT_DAMAGED, EVENT_UNIT_DEATH).
If your map isn't a single-session map, you must use only events of type Generic Unit Event (EVENT_PLAYER_UNIT_SPELL_EFFECT, EVENT_PLAYER_UNIT_USE_ITEM etc.). Alternatively track game loading (EVENT_GAME_LOADED) and readd the lost trigger events.
Although https://wowpedia.fandom.com/wiki/Warcraft_III/Patch_1.31.0 says (see below) its worth to verify and add.
Triggers won't be lost during saves (Thank you, Bribe)
Before 1.24c: did not properly handle groups with destroyed (null) units
- Fixed a minor memory leak when using GroupEnum natives.
https://web.archive.org/web/20200918161954/http://wc3c.net/showthread.php?t=104464
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.