• 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.

Modify Wc3 GUI script handle.

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi

I was wondering how to modify Wc3 default functions used on GUI and else. Example:

This GUI:
  • Actions
    • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
Turned to JASS:
JASS:
call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )

Which means:
JASS:
function CreateNUnitsAtLoc takes integer count, integer unitId, player whichPlayer, location loc, real face returns group
    call GroupClear(bj_lastCreatedGroup)
    loop
        set count = count - 1
        exitwhen count < 0
        call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face)
        call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
    endloop
    return bj_lastCreatedGroup
endfunction

So, that GUI action is related to this function CreateNUnitsAtLoc and does all that stuff. What I if want the same GUI action to do this:

JASS:
function CreateUnits takes integer count, integer unitId, player unitOwner, location loc, real face, returns nothing.
    loop
        set count = count - 1
        exitwhen count < 0
        set bj_lastCreatedUnit = CreateUnit(unitOwner, unitId, GetLocationX(loc), GetLocationY(loc), face)
    endloop
    call RemoveLocation(loc)
endfunction
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I plan to modify default wc3 script handle to avoid bj's and make a more efficient GUI to share it here as a resource, or to avoid having to modify Whole good maps in GUI just because the creator didn't know about leaks or some GUI problems.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Well, i wouldn't like to mess with GUI as it's right now to add or remove or modify stuff in it. Maybe implement Bribe's Damage Engine to add easy damage detection and manipulation for GUI'ers, but i'm more interested in modifying the default jass function definitions for GUI actions.

Where are the .js? How to modify them?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Editing it should be less of a problem but how do you want to set a standard? Unlike with jass libraries, you would require the user to take the whole pack of new GUI and his previous work has to be compatible. Unless you realize updates by new named functions everytime.

The js are in Scripts\. I dunno if they are replaceable though and you would have to import all of the file. Rather consider injection into the map's header if GUI mechanics allow the reference.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
That's exactly what I aim for Chaosy, just as the example in the first post. It still uses the location, but removes it within the function and avoids the group thing.

If the functions remains the same, returns the same stuff using the same arguments, but are improved and No leak is included, then no one would have to modify their already crappy and leaky GUI Triggers and still have a more or less efficienttly coded map.

(Years doing this stuff and never noticed I could use Last Created Group after creating N number of units to handle them all. I wonder if someone does)
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
a problem I thought of was this.
lets say we got a new guy that we call mapper.
mapper makes a n00by map but manages to remove most leaks.
then I download the map and open it up with my GUI 2.0 and then test the map.
since I got automatic leak removal and the map is triggered for normal GUI we would have a double leak cleanup

this would be a issue for maps with inactive creators.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I tough about another problem:

If the user will use the same location variable several times in the trigger, the UnitCreation (or any other) would remove the location, and the rest of the functions would have no location.

User would use (Position of (xxx)) several times, making the system look over and over for the same arguments that, though they're handled more efficently and leaks are removed, they still remain inefficient, and people wouldn't be forced to learn better coding habits (like reducing the amount of parentheses)

Now i'm thinking that maybe more and better tutorials are the way :p
 
http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/modding-we-trigger-editor-52529/
A good Tutorial about hacking GUI Functions.
I was lazy to use it except the destroy effect, the modification has 2 things to notes this :
1. People will need the same UI to open your unprotected maps if they use those functions [one more tool skipped for map protector who don't need to optimize their maps, but protecting it :ogre_hurrhurr:], but if you add the additional line call script in the tutorial, the map still openable in normal WE without UI injection.
2. The Datas must be configured correctly, because one wrong step can cause many troubles.

I have test this tutorial a bit [planning to add JASS function [even tho I'm a noob in JASS] and stuffs on it] and it works.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
I would re design that code regarding the location.

function x takes bla bla,loc returns x
local location l = loc
do stuff
call remove location

that would fix both problems since if you use a point variable it wont get removed so it will support any map. and if you use something like position of unit the leak will be cleaned.

edit: fucking awesome link :eek:
If possible I would teamup with spartilo on this project. It could really improve the current GUI
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I read the whole tut. I found it modifies the GUI interface, but not the script behind them.

I found this is absurdly easy -.- I wonder why no one did this before. You just have to create a "Script" folder in the Warcraft 3 directory and add Blizzard.j and common.j edited text files. I'll make some test.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
The tutorial says that if you create the Text files in the UI folder in Wc3 directory the game will read those instead of the ones in the MPQ. I'm doing the same with the Scripts folder and isn't working >.<. I'll test further.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I'm so excited about this xD But i'm really frustrated. MiscData works. Those txt in the UI works, but scripts doesn't!

Well... I modified AngleBetweenPoints function with some other stuff. Opened WE, and Ctrl+Click in the function, but it displays the default one with no modifications. I'm not sure if it's the TESH or it's i'm doing something wrong :(

@Chaosy: Users would have to add these to their folders manually, just as they install JNPG.
 
As far as I have the modified UI, the only thing that happens is that people without the UI has only one issue : people without the UI unable to edit my map [error when loading triggers]

Well, you should make it like this instead for common.j because I afraid it will cause desync if you don't :
Code:
DestroyEffectBJ=0,effect
_DestroyEffectBJ_Defaults=GetLastCreatedEffectBJ
_DestroyEffectBJ_Category=TC_SPECIALEFFECT
_DestroyEffectBJ_ScriptName=DestroyEffect
Well, sorta of.
Also, if we destroy those BJ's instead of this we need to use 1 additional action for each removed BJ's so we can load unedited common.j script maps.
That's what I think, no Test for it tho.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I Took Blizzard.j from MPQ and saved it in Scripts folder in Wc3 directory. I modified the AngleBetweenPoints function with comments and other stuff. I also modified the Blizzard.j in vexorianjasshelper and cohadar's jasshelper folders.

Any of them displayed the changes I made in them when i did Ctrl+Click in the function.

I'm not sure if the Changes are taking place in the Wc3 core or script interpretation but aren't displayed because the Ctrl+Click thing takes the data from some other file, or if it isn't working at all. Sadly I don't have time to test right now with some BJDebugMsg >.<
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Muahahaha...

I'm pleased to say that the game parses the data in the Blizzard.j file in the Scripts folder in Wc3 directory. I made a parse error, and it's displayed exactly as I made it, BUT the Ctrl+Click thing isn't showing me the data in the Blizzard.j file, but some other file I'm still missing.

EDIT1: I extracted the file directly from Wc3 MpQ and i got the return bug from GetFadeFromSeconds function. Had to check on cohadars jasshelper Blizzard.j file and copy the function there to paste it in my Scripts folder Blizzard.j file to fix it. I was still able to test maps, but the error was displaying.

EDIT2: My bad; when JassHelper is parsing data with blizzard.j it shows the information I placed in blizzard.j file in Scripts folder, but that data isn't taking place, it's being used. I changed the CreateNunitsAtLoc to create more units, but it isnt :(

EDIT3: Found that vexorian's JassHelper Blizzard.j mimics the Blizzard.j file I put in Wc3/Scripts/Blizzard.j file. Still the game isn't running what I put in those functions.

EDIT4: Modified the funclist.db in TESH folder and added a "count+5" on CreateNUnitsAtLoc, but when I checked the function lists with Ctrl+Click it gave me some errors about missing data or something like that (I modified that db with a simple text editor, and looked in all the mess for that function). I've searched over and over through Inernet about DB files, and I can't open them.

I would really like to know how to modify default GUI functions scripts to work/behave in a differente way.

EDIT5: I'm following the tutorial. I already created a custom GUI Function, but it still uses the default GUI BJ.

EDIT6: Wow... It's not THAT hard. It's easy to modify the Actions that GUI uses. I just did here:
  • Actions
    • Special Effect - Destroy (Last created special effect)
    • Special Effect - Destroy bj_lastCreatedEffect
JASS:
    call DestroyEffect( GetLastCreatedEffectBJ() )
    call DestroyEffect( bj_lastCreatedEffect )

The "bj_lastCreatedEffect" isn't available on the list to select special effects, it's there by default, so, as long a no one touches it, it's ok :p

However, i'm still unable to transform the GUI "last crated special effect" to "bj_lastCreatedEffect" on the script so users don't have to modify anything at all.

EDIT7: Just reading the tutorial found that, If you don't have the exact same files I have in the UI folder, the map I gave you will crash if you try to open it with the WE. Doesn't seem practical to me. I'm thinkin that making tutorials is still better than modifying all this stuff. Maybe a really huge tutorial or guide or manual that includes an improved form of Custom Script of each GUI function would be better. I think having people know what they're doing is good, and if they understand the JASS thing, they'll be able to do stuff that, no matter how much effort we put in it, they wouldn't be able to do with our super-ultra-hyper-improved GUI.

Something like a "Func per func tutorial" that explains, from the GUI form, to the best possible JASS form of each function, so users just have to Copy/paste and, if they want, understand it.
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
I managed to achieve this:

  • Actions
    • Special Effect - Destroy bj_lastCreatedEffect
    • Special Effect - Destroy LastEffect *
JASS:
    call DestroyEffect( bj_lastCreatedEffect )
    call DestroyEffect( bj_lastCreatedEffect )

* The LastEffect is a Predefined Variable. It's reaaally easy to use and add, just as for integers, units, and stuff. No more need of BJ's that returns a variable.

Sadly, mappers would still have to modify their "DestroyEffect" trigger to work this way + importing the Text file. There is no way to make WE replace "GetLastCreatedEffectBJ()" automatically with bj_lastCreatedEffect.

I would have to say that Tutorials and kind teachers are the way to improve community coding, rather than modifying the GUI. Maybe it Wc3 would have made it easier with simple Function Declarations and stuff, but no :(
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Chaosy: I don't think its possible. I haven't found the file that manipulates default GUI scripts to behave differently. If we found a way to do it, then we can make any GUI trigger do anything with header scripts.

moyack is working on modifying all the GUI interface behavior and scripts behind and else, and do what we're planning to do to; but I don't know how to contact him to team up or something.
 
Status
Not open for further replies.
Top