tdauth / wowr

Warcraft III: Reforged funmap World of Warcraft Reforged.
https://wowreforged.org
8 stars 0 forks source link

Add a tool wc3objectdataextractor which extracts object data fields and then use it to generate a JASS file initializing the fields #2106

Closed tdauth closed 5 months ago

tdauth commented 1 year ago

Add the tool to wc3ib. Usage:

objectdatafieldextractor -f ucam,utran -d A000-A010,u023 -o out.j -i war3map.w3o

ucam utran etc.

Generated JASS code:

globals
integer array utran
integer array utranCount
constant integer MAX_OBJECT_DATA_FIELD_ENTRIES = 100
endglobals

function GetUtran takes integer objectId, integer index returns integer
          return utran[index * MAX_OBJECT_DATA_FIELD_ENTRIES  + objectId]
endfunction

function GetUtranCount takes integer objectId returns integer
       return utranCount[objectId]
endfunction

function InitObjectDataFields takes nothing returns nothing
set utran[0 * MAX_OBJECT_DATA_FIELD_ENTRIES  + 'u023'] = 'u023'
set utran[1 * MAX_OBJECT_DATA_FIELD_ENTRIES  + 'u023'] = 'u023'
set utran[2 * MAX_OBJECT_DATA_FIELD_ENTRIES  + 'u023'] = 'u023'
set utranCount['u023'] = 3
endfunction

Add options:

Example call:

./wc3objectdataextractor -Fjpg -f umki,usei,urq,urqa,ures,useu,utra,uupt,upgr,ucam -t integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integer -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3u -o test.j
tdauth commented 1 year ago

Does a hashtable make more sense because if the size limits of int?

tdauth commented 1 year ago

Add an option --oplimitoperations 100 It will split the initializer into functions with 100 operations and use a generated NewOpLimit function.

tdauth commented 1 year ago

Extract hero abilities as well, so we do not have to register them all: uhab

and maybe abilities in general: uabi

tdauth commented 1 year ago
./wc3objectdataextractor -Fjpg -f umki,usei,urq,urqa,ures,useu,utra,uupt,upgr,ucam,uhab,uabi -t integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integer,integerlist,integerlist -l 500 -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3u -o test.j
tdauth commented 1 year ago

https://www.hiveworkshop.com/threads/wc3objectdataextractor.349994/

tdauth commented 1 year ago

Allow specifying SLKs with meta data and TXT files so the standard values are loaded.

tdauth commented 1 year ago

Use a hashtable because of constant integer JASS_MAX_ARRAY_SIZE = 32768.

tdauth commented 1 year ago

Use a hashtable and the parent key is the object ID, the child key is the field ID and the value is an instance of struct F.

struct F
      integer/string array values
      integer count
endstruct
tdauth commented 1 year ago

Revised with hastable struct. New call:

./wc3objectdataextractor -Fp -f umki,usei,urq,urqa,ures,useu,utra,uupt,upgr,ucam,uhab,uabi -t integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integer,integerlist,integerlist -l 500 -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3u -o test.j
tdauth commented 1 year ago

With SLKs:

 ./wc3objectdataextractor -Fp -k ~/privaterepos/wc3lib/src/map/test/UnitMetaData.slk -s ~/privaterepos/wc3lib/src/map/test/UnitData.slk -f umki,usei,urq,urqa,ures,useu,utra,uupt,upgr,ucam,uhab,uabi -t integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integerlist,integer,integerlist,integerlist -l 500 -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3u -o test.j
tdauth commented 1 year ago

Add script and SLK and TXT files into a folder in this repository to run it on Linux.

tdauth commented 1 year ago

New command with new option to add all SLKs and TXT files automatically:

./wc3objectdataextractor -vFp -c ~/privaterepos/wowr-website/objectdata -f umki,usei,ureq,urqa,ures,useu,utra,uupt,upgr,ucam,uhab,uabi  -l 500 -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3u -o test.j > out.txt
tdauth commented 1 year ago

Trim Aspt.

tdauth commented 1 year ago
function GetUtraCount takes integer objectId returns integer
    local Finteger f = LoadInteger(fieldsHashTable, objectId, 'utra')
    if (f == 0) then
        return 0
    endif
    return f.count
endfunction
tdauth commented 1 year ago

If it is a single value like ucam it does not need a struct behind it.

tdauth commented 1 year ago

Finteger[10000]

tdauth commented 1 year ago
./wc3objectdataextractor -vFp -c ~/privaterepos/wowr-website/objectdata -f umki,usei,ureq,urqa,ures,useu,utra,uupt,upgr,ucam,uhab,uabi -l 500 -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3u -o test.j > out.txt
tdauth commented 1 year ago

Parsing SLK files with wc3lib seems a bit slow.

tdauth commented 1 year ago

Use the new data for Trains, Researches, Items and Upgrades to lists.

tdauth commented 1 year ago

There is a bug: If the field is not modified for an object type with a custom ID, the standard values from the base ID are not generated.

tdauth commented 1 year ago

To extract gold and lumber base for upgrades use:

tdauth@ubuntu:~/privaterepos/wc3lib-build/src/app$ ./wc3objectdataextractor -vFp -c ~/privaterepos/wowr-website/objectdata -f umki,usei,ureq,urqa,ures,useu,utra,uupt,upgr,ucam,uhab,uabi,glmb,gglb -l 500 -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3u -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3q -o test.j > out.txt

The ItemMetaData.slk file is missing. I need to add it to extract igol and ilum.

tdauth commented 1 year ago

Extracts item abilities, gold and lumber cost as well. The meta data for items is in UnitMetaData.slk.

./wc3objectdataextractor -vFp -c ~/privaterepos/wowr-website/objectdata -f umki,usei,ureq,urqa,ures,useu,utra,uupt,upgr,ucam,uhab,uabi,glmb,gglb,iabi,igol,ilum -l 500 -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3u -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3q -i ~/privaterepos/wowr-website/map/wowr.w3x/war3map.w3t -o test.j > out.txt
tdauth commented 5 months ago

Nice idea but go back to registering in JASS which is easier to maintain in trigger editor and without a separate script.