• 🏆 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!

File changes from GUI to Jass

Status
Not open for further replies.
Level 3
Joined
Jan 29, 2021
Messages
34
Hello guys.

The main problem I faced when starting learning all this stuff is that there is nowhere complete tutorial/docs that cover all of the topics
I mean advanced topics
- multithreading (it all ends with the word ExecuteFunc)
- native functions descriptions (it all ends with there signature)
- advanced elements like timers etc
Ok, wont bother you with that for now

There lots of newbies guides like of how to declare a function or how to use trigger or how to call native functions but that's preety it

All right, lets start with the actuall topic

Before we start, please consider that I am not familiar with World Editor, so some questions could be pretty silly
And actually I dont want to work in Editor, I want to work with the logic via code

At the moment Im working with a map that is a protected one. Its korean map so probably some advanced protection was used there, Im not sure

Im extracting sources from .w3x file using MPQ and trying to work with .j file

The things I want to figure out:

1)Triggers
I create map via World Editor, and add just a single trigger there with the name, for example, Test. Then I open war3map.j file and see, that this trigger is translated into 3 functions

//===========================================================================
// Trigger: Test
//===========================================================================
function Trig_Test_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_Test takes nothing returns nothing
set gg_trg_Test = CreateTrigger( )
call TriggerAddAction( gg_trg_Test, function Trig_Test_Actions )
endfunction

//===========================================================================
function InitCustomTriggers takes nothing returns nothing
call InitTrig_Test( )
endfunction


and one global variable

globals
// Generated
trigger gg_trg_Test = null
endglobals

When I work with korean map I can see there a bunch of global triggers starting with gg_trg like

trigger gg_trg_Init=null
trigger gg_trg_CodeKey=null
trigger gg_trg_Frame=null
trigger gg_trg_Leave=null
trigger gg_trg_GameLoad=null
trigger gg_trg_GameTime=null

etc
But there are nowhere else in the code 3 functions that are attached to each of these triggers

So, what am I missing?

2)Another triggers
There are another triggers in global variables but this time without prefix gg_trg
Again, no functions for each of them.

What's with these ones?

3)Losing data
For example, we lose that functions of the triggers and cannot restore it, only manually.
What else can be lost throw extracting sources from protected map? And how is this happening?

4)Global variables
I've read that creating global variables via World Editor and translating them into Jass leads to renaming them, this time via prefix udg_
Actually, there is no variable starting with udg_ in jass code of that map

What's here?

5)Another prefixes
Some other variables start with some other prefixes like
- LIBRARY (they are all constants and interesting that again none of them is used anywhere in the code but when I tried for example to delete all these global constants it affected the game process, but I still was able to start the game and play it)
- other prefixes
The thing is there are like blocks of global variables, each block starts with unique prefix
For example:

dialog array Command_Code_Dialog
button array Command_Kick_Button
button array Command_Code_Button
integer array Command_Enter_Code_Type
integer array Command_Code_Unit_Type

My thoughts that it is possible to group variables in World Editor, putting them in one block with the name Command this time, and the actuall names of that variables in World Editor were

Code Dialog
Kick Button
Code Button
Enter Code Type
Code Unit Type

6) .slk tables
No idea of how to ask it right. The thing is that it is probably possible to create custom user data types like STRUCT or may be ENUM via Vjass or whatever and then it translates into pure Jass via .slk tables with that data

What are your thoughts about that?

THANKS A LOT for your patience to be able to finish this
Would be thankfull for any of your thoughts
 
Last edited:
Level 3
Joined
Jan 29, 2021
Messages
34
Guys, please, post your suggestions.
I splitted questions into parts so you can post a reply to specific one, like 1) or 5)
 

~El

Level 17
Joined
Jun 13, 2016
Messages
556
1) 2)

Look for "TriggerAddAction" and "TriggerAddCondition" calls which involve those triggers. They'll point to the functions that those triggers use. If the variables aren't used anywhere, they're probably just disabled or dead code.

3) WE stores data in the map file that only WE itself uses. Unit positions, GUI trigger definitions, global variable definitions, etc. All of that can be thrown out, and the map will still work in the game. There are tools that explicitly do that as a means of optimizing the map size (which was relevant when the map size limit was 8MB), and a half-assed way of "protecting" the map. That's how they disappear.

4) Yeah, globals created through the WE interface will have those prefixes. They don't need to, though. If you're using vJASS you can just bypass that.

5) This is JASS code generated from vJASS. It names variables and functions based on their location. "Command" in this case is probably either a vJASS library or struct. Has nothing to do with the global variable interface in WE.

Same thing about the LIBRARY_ stuff. vJASS emits them so that other libraries can check whether another library exists or not. It doesn't do a good job of erasing dead code though, as you can tell.

6) SLKs are a very fragile and finicky way of optimizing map load times. If you want to generate objects programmatically (if I'm reading you correctly), you're out of luck unless you want to mess with a bunch of overcomplicated tools. There's no easy way to do that.
 
Level 3
Joined
Jan 29, 2021
Messages
34
1) 2) I know allready that these functions
"TriggerAddAction" and "TriggerAddCondition"
could be used

but you have to give them your trigger as a parameter. I look into the code and find out that some global triggers aren't used anywhere and it is pretty impossible that the author of the map just created some variables(pretty a lot of them) and didnt use them anywhere

3) thats where the explanation comes, thank you. At the moment, however, this info

WE stores data in the map file that only WE itself uses.
All of that can be thrown out, and the map will still work in the game

looks very strange to me

5) <It names variables and functions based on their location>
Here, what does the word "location" exactly mean?

6) I am new to the SLK and all the general stuff about map editing/jass programming/etc
I just see that author of the map uses it(.slk structures) and I want to figure out HOW and WHY
Is anywhere complete guide to SLK tables like what is it, when and why do you need to use them and how

P.S.
Again, so few information about all this stuff
When you start learning Python, for example, or Java, there are TONS of tutorials, books, videos, articles, frameworks, libraries, APIs etc
When, learning Jass, I want to figure out, for example, what exactly does some native function - I CANT DO that!
The only thing I can do is go to JASS Manual: API Browser - API Browser: Functions and see pure signatures, no docs at all
And lucky to be when parameres names in function signature are at least name-explained like
native DefineStartLocationLoc integer whichStartLoc, location whichLocation
instead of
integer x, location l
 
Status
Not open for further replies.
Top