Page 28 of 52

Re: World of Warships

Posted: Thu Oct 22, 2015 4:17 pm
by Coffee
I'm getting no where fast with this python shit.
Massive import exceptions.
I really need a basic script that I can pass an argument to and it will convert the pickle to XML, and save it in the same directory as the source pickle.
If some one reading this knows how to work in python, I posted an example from some site that has code to convert it but.. I don't know python enough to strip it down to the most basic functions.

If the XML is valid, I can read it right back in to a dataset.
From there I can just take what ever I want from the tables.

Here is the XML section from that link:

Code: Select all

# -----------------------------------------------------------------------------
# XML

class Format_xml(Format):
    """Standard XML 1.0 using Python builtins."""

    def __init__(self):
        Format.__init__(self)

    def dict2xml(self, dct, root='Root', indent='\t'):
        """Convert a dictionary to an XML string.

        Rules:
            string -> escape(string)
            int, float -> as-is
            dict -> <key>value</key>
            tuple, list -> repeat tag for each value
            bool -> int(bool)
            None, empty string -> empty node
            other object -> escape(str(obj))

        """
        # from xml.sax.saxutils import escape
        
        def tagset(key, val, level):
            if val in (None, ""):
                return "%s<%s />\n" % (indent*level, key)

            if type(val) in (list, tuple):
                return "".join(tagset(key, v, level) for v in val)

            if type(val) is bool: 
                val = int(val)

            return "%s<%s>%s</%s>\n" % (indent*level, key, 
                                        format_value(key, val, level), key)

        def format_value(key, val, level):
            if type(val) in (float, int, str):
                pass

            elif type(val) is dict:
                lines = [tagset(k, v, level+1) for k, v in val.iteritems()]
                lines.sort()  # NB: Py dicts are unordered
                val = "\n%s%s" % (''.join(lines), indent*level)

            elif type(val) is not str:
                val = str(val)

            return val

        return tagset(root, dct, 0)

    def write(self, obj):
        """Serialize."""
        return '<?xml version="1.0" encoding="UTF-8">\n' + \
                self.dict2xml(obj.__dict__, root=__name__)


Re: World of Warships

Posted: Thu Oct 22, 2015 8:14 pm
by Coffee
I got python working but when I unzip the GameParams it is not complete.
I obviously have something wrong in my unzip routine but have not located it yet.
I also think I can use the code posted before to get what I need but I need to do some testing.

Re: World of Warships

Posted: Thu Oct 22, 2015 9:13 pm
by xtcmax
Hello, Coffee.
I am interested in your project of WoWS ship viewer. I am trying to pull out ships as well to make wallpapers. I managed to pullout the hull of the ship but there are so many elements missing, like guns, AA, lifeboats, etc ,etc. I would assume the guns could be found more or less easy, but there are so many other elements. I wonder if you have any info if there is a file in the game that specifies what other miscellaneous items to be placed on ship.

Also, I have a question about .visual file. If you get this message, please reply.

Thank you

Re: World of Warships

Posted: Thu Oct 22, 2015 9:33 pm
by Coffee
xtcmax wrote:Hello, Coffee.
I am interested in your project of WoWS ship viewer. I am trying to pull out ships as well to make wallpapers. I managed to pullout the hull of the ship but there are so many elements missing, like guns, AA, lifeboats, etc ,etc. I would assume the guns could be found more or less easy, but there are so many other elements. I wonder if you have any info if there is a file in the game that specifies what other miscellaneous items to be placed on ship.

Also, I have a question about .visual file. If you get this message, please reply.

Thank you
I am working on adding the ability to export everything but its going to take time.
In the mean time, you can install the editor (there are links to my VPS in this thread somewhere to get it) and afterwards, under the install folder there is one called "WoWs_Scripts". This has been almost the entire effort in this thread.
If the ship you want to use has a master done, all the items for that ship are listed in that file that matches the name of the ship.
Transforming these can be done by looking them up in the XML files.

Re: World of Warships

Posted: Thu Oct 22, 2015 9:37 pm
by Coffee
OK.. back on topic..

I can get the data from the GamesParams :)
I am working on filtering to get the HP items and anything else that is needed.
Hey Wobble.. If you have a script for this already, please post it OK bud?

Re: World of Warships

Posted: Thu Oct 22, 2015 11:55 pm
by Wobble
[out]

Re: World of Warships

Posted: Fri Oct 23, 2015 1:23 am
by Coffee
Thanks Wobble..

I am trying to get the data directly from the file after un-pickling it.
I can get tons of info but I cant figure out how to get the "HP_" variables.
I don't even know if this will work.
Almost every american ship has for example "HP_AGM_1".
If these HP_s in the gameparams can't be joined up to a particular ship, I'm not sure where Im headed.

Im tired.. I have been working on this since I got up.
I managed to get Python integrated with .NET and I can pass variables to the scripts. (good for passing the path to the gamesparams.data)
Using some of the code people have been posting in this thread, I can read and convert the data.
Now I need to figure out how to get the HP_ parts and their links to the ships.

Any insight would be helpful..

Re: World of Warships

Posted: Fri Oct 23, 2015 2:18 am
by Wobble
[out]

Re: World of Warships

Posted: Fri Oct 23, 2015 2:32 pm
by Coffee
Yes.. I know this lol
The thing is.. I can't extract "HP_AGM_1" or any "HP"s so far.
This is from the ASA015_Midway_1945_MidFront_compound.visual

Code: Select all

         <node>
            <identifier>   HP_Deck_31  </identifier>
We know this is a location of an Aircraft but nothing more.
I was hoping there was a table or something that could be used to cross reference this to the actual plane... but I'm not finding it.
I can find HP_ strings but they are not indexes or any other type. They look to be key names but so far, I cant figure out a way to find them using filtering.
Are these located under the ships tree? Maybe I need to get a json viewer.

Re: World of Warships

Posted: Fri Oct 23, 2015 7:20 pm
by Coffee
OK..
I found the HP_ lists for most items on the ships.. They are inside the ship objects.
I can not figure out how to read them.
I tried to access them as k.AirDefenseDefault but I can't iterate through the sub objects even tho clearly there.
I wish I knew Python.. This is being a bitch!

Re: World of Warships

Posted: Fri Oct 23, 2015 9:25 pm
by Coffee
OK..
I'm dead in the water...
The ship objects have the data.. It's nested. I can't figure out how to read it.
I don't really want to convert this from pickle to read the data. There should not be a reason to convert this to anything but an XML AFTER/WHILE getting the data out of the pickle and save that.
It takes so long just to read the data and a lot longer to write it as json. XML never did work.. it was stuck in a loop with non-stop exceptions.

Something else.. I can NOT find anything about what planes are used for the HP_Deck_n properties. If they are in there.. I can't find them and I spent a good 2 hours looking.
The best I can get are the amount of slots for them and how many planes there are for each type. The actual planes are listed in the ships object BUT.. they are just listed in the root for that ship. This makes it tough to extract them. They will have to be searched for using their prefix and.. there are a lot of nations and plane types.. 5 nations.. 4 plane types.. this means 5 x 4 different prefixes. I guess you could setup an array of strings ahead of time and search by each element in the array. That would make it easier OR.. you could get all the plane names and search using that. I however do not know how to do jack shit in Python and have no interest, as I said before, in learning it.

I need code.. examples of how to split this file by the ships and keep all its sub objects with it.. and also how to read the sub objects data.
If converting this to json first is the only option.. fine.. But that wont help me because I don't know how to work with json so I will still need some one to code exploding this data in to the ship objects.

As far as the HP_ for the guns, detectors and so on.. the ship objects have these sub objects under different names regardless of nation.
For example:
the AA guns might be under AirDefenseDefault.. or A_AirDefense.
This is the same for most items we need for the HP_

Also.. I noticed there is a lot of game data specific to hit points and damage... how much a shell does in damage.. how much HP an object has.
I sure as hell hope by figuring this file out we have not opened the door to a shit load of hacks.

Re: World of Warships

Posted: Sat Oct 24, 2015 12:16 am
by Wobble
[out]

Re: World of Warships

Posted: Sat Oct 24, 2015 5:27 am
by Andrakann
Coffee wrote:I can NOT find anything about what planes are used for the HP_Deck_n properties. If they are in there.. I can't find them and I spent a good 2 hours looking.
The best I can get are the amount of slots for them and how many planes there are for each type. The actual planes are listed in the ships object BUT.. they are just listed in the root for that ship. This makes it tough to extract them. They will have to be searched for using their prefix and.. there are a lot of nations and plane types.. 5 nations.. 4 plane types.. this means 5 x 4 different prefixes. I guess you could setup an array of strings ahead of time and search by each element in the array. That would make it easier OR.. you could get all the plane names and search using that. I however do not know how to do jack shit in Python and have no interest, as I said before, in learning it.
For ASA015_Midway_1945 I see three pre-setups - A1_FlightControl, A2B_FlightControl and A2F_FlightControl. I think A1 it's base setup and other two it's for fighters/bombers specializations or something alike.
So, we stick to A1.
Inside A1 sub-tree we have "squadrons" section, which indicates how deck is filled by planes: 6+6 fighters (HP_Deck_0-11), 6 bombers (HP_Deck_12-17), 6+6 dives (HP_Deck_18-29). This setup fully matches in-game screenshot of this ship.
Also we have list of planes used:

Code: Select all

        "PAUB009_Douglas_AD1": {
            "planeType": "PAAB009_Douglas_AD1"
        },
        "PAUB013_A2D_SKYSHARK": {
            "planeType": "PAAB013_A2D_Skyshark"
        },
        "PAUD001_Curtiss_SB2C": {
            "planeType": "PAAD001_Curtiss_SB2C"
        },
        "PAUD005_DOUGLAS_XSB2D": {
            "planeType": "PAAD005_Douglas_XSB2D"
        },
        "PAUI010_F8F_Bearcat": {
            "planeType": "PAAF010_F8F_Bearcat"
        },
        "PAUI016_MCDONNELL_F2H": {
            "planeType": "PAAF016_McDonnell_F2H"
        },
So, here 2 bombers, 2 dives and 2 fighters. For me, it's good to import them all, and place 2 different models to each HP_Deck_# point, but second ones is hidden by default, so I can have really complete model for export.
Not sure I understand correctly your problem with path finding for planes - it's already in their names, for examlpe PAAF010_F8F_Bearcat have this path: (res\content\gameplay\)usA\Aircraft\Fighter\AAF010_F8F_Bearcat\AAF010_F8F_Bearcat.primitives (.model)
Also.. I noticed there is a lot of game data specific to hit points and damage... how much a shell does in damage.. how much HP an object has.
I sure as hell hope by figuring this file out we have not opened the door to a shit load of hacks.
Cheating can be easily prevented with checksums, like md5. I think it's done already.

Re: World of Warships

Posted: Sat Oct 24, 2015 3:45 pm
by Coffee
Yes.. you didn't understand what I was saying :mrgreen: I'll post a image.
Image
Not only are the HP_ listed.. Inside of them is the path to the model.
Everything is there to build the entire masters.
I need help writing scripts for Python to extract the information and build a XML I can read in as a dataset.

If some one can show me how to get to just one of the sub objects in the pickle and iterate through them, I can do the rest.
ALSO.. I need to know how to find a sub objects using wildcards so I can grab the Planes using the PAU part of the name.
This will wind up being a lot of code as there are different nations and the ships have different names for the sub objects.

Right now.. I am completely lost as to how to "get at" these sub objects in the pickle.
I spent most of yesterday searching the net and trying different code. I could not get anything to work.

I Installed World of Warplanes last night. Someone was asking about my editor working with it. It used to but I don't know if it still does.

Re: World of Warships

Posted: Sat Oct 24, 2015 7:46 pm
by TheSeeker
Wobble wrote:
Coffee wrote: Hey Wobble.. If you have a script for this already, please post it OK bud?
I didn't write a script, so if you're trying to automate the process, my method would probably be useless.

What I used:
JSONedit
http://tomeko.net/software/JSONedit/
http://tomeko.net/software/JSONedit/bin ... 0_9_14.zip

For validating and resaving JSON files, so they load better in other programs, like dicttoxml.

dicttoxml
https://pypi.python.org/pypi/dicttoxml
https://github.com/quandyfactory/dicttoxml

For converting JSON to XML. Python scripting required:

Code: Select all

# NOTE: dicttoxml by default is adding types to the XML
# OPTIONS:
# attr_type=False = Turn off types

import json
import dicttoxml

f = open('GameParams.json', 'r')
obj = json.loads(f.read())

xml = dicttoxml.dicttoxml(obj, attr_type=False)
#print xml

from xml.dom.minidom import parseString
dom = parseString(xml)

f2 = open('GameParams.xml', 'w')
f2.write("%s" % dom.toprettyxml())
f2.close()
OK, you can use the .json to .XML script with IKU's pickle-to-json script

http://www.mediafire.com/download/9hupl ... ractor.zip

Run reverse and then inflate, then everything.py