thomastuts / gwent

A port of the amazingly fun Witcher 3 card minigame.
8 stars 3 forks source link

action script decompiled #9

Open ghost opened 9 years ago

ghost commented 9 years ago

hi, you may find this helpful https://github.com/dhk-room101/gwent_as3/tree/master/WIP/gwint_game.swf_as/red/game/witcher3/menus/gwint it's the repository of the decompiled original game, it may help you with implementing the logic of various aspects, such as AI, special cards, etc.… Thanks!

thomastuts commented 9 years ago

Wow, this is absolutely amazing. Thank you! Did you reverse-engineer this yourself? Do you happen to know where I can find the card assets themselves (the images)?

I'm currently using images scraped off gosunoob.com but they're screenshots and inconsistent in quality and resolution. I did find a repo that has the card assets all in high quality that look like they come from the game assets, but I'd still like to know how they did it.

ghost commented 9 years ago

hi, I apologize for the delay, my health is not very good. Yes, the code is extracted by me from the original game. I used quickbms to extract everything from the original game, then I identified all the scaleform files which are basically GFX+ images, then GFX->SWF, then SWF->AS3. You can find everything after extracting with quickbms, but it's a good idea to know how to extrapolate various relevant info from various file headers. I personally did not look specifically for the images, but I guess someone else did, and they uploaded them here https://www.reddit.com/r/witcher/comments/39kmou/complete_printable_gwent_cards_now_in_highres_and/ I found all the relevant images as separate instances inside the Illustrator archive, they seem to be high quality. I apologize, but images were not my priority, instead getting the AI related classes was more important, for the obvious reason to be able to turn it into a standalone app for mobile/tablets platforms. Due to health reasons, it's highly unlikely I can do this, so I'm hoping my repository can help you or others :-) Thanks!

ghost commented 9 years ago

I extracted the textures using https://github.com/hhrhhr/Lua-utils-for-Witcher-3 the textures are in the content0 subfolder in the texture.cache file the images names can be found in the XML file that contains the card definitions %W3%\content\patch0\bundles\patch.bundle_extract\gameplay\items\def_gwint_cards_final.xml is the most updated one, you can get it using quickbms and extract it from the latest patch file/folder I'm migrating the code to a C sharp repository, would you like to join me?

VitalyVaryvdin commented 4 years ago

@dhk-room101 Hi! Sorry for necroposting, can you tell what files exactly and how did you decompile? I assume it's Sothink's decompiler? It totally didn't open any of .redswf I tried. JPEX Decompiler opened it but it's missing a lot of sprites which I'm after I'm building my own high quality printable Gwent version and for that I need sprites stored in swf

ghost commented 4 years ago

@VitalyVaryvdin

.redswf = .swf code + images.

So you need to know a bit about headers and data structures in order to extract the components of .redswf, which is basically a proprietary container where CDPR put the compiled .swf and all the external images referred by it. Maybe by now someone created a tool to extract this components out of .redswf, but in my case at that time I wrote my own scripts to do so, I just can't find them, it's been five years :) But it should be pretty easy to explore the header using a hex editor...

One thing I remember though, the images I extracted where missing one of the RGB channels, I think the red channel, but most of the images where blue and yellow. As a scientist I couldn't care less about the how it looks, I was more interested in learning about the code implementation, so I didn't bother understanding why the red channel is missing. But for sure I was able to extract all the images, albeit odd looking with only blue and yellow :) But I'm pretty sure I've seen the original gwent images uploaded somewhere by someone else, poke around Google a bit...

VitalyVaryvdin commented 4 years ago

@dhk-room101 Thank you for fast reply :)

I've also extracted the textures without red channel, but unfortunately the textures i'm after are in SWF and are missing in JPEX Decompiler I wouldn't be bothering, but these texture I'm looking for aren't raw quality, rather screenshot quality

edit: found Wolven Kit tool. It has ability to export images from .redswf. Goal achieved :) It also produces much cleaner swf file for decompilation

pimtegelaar commented 2 years ago

@VitalyVaryvdin which version of WolvenKit did you use? I would like to get the sprites out, but most of the sprites have red in them. Looking for a way to get them out clean.

VitalyVaryvdin commented 2 years ago

@pimtegelaar channels are swapped. After extracting I've used simple bat script to swap channels back with image magick

for %%f in (*.png) do ( magick convert "%%f" -set colorspace RGB -separate -swap 0,2 -combine "D:\WolvenKit\Swapped1\%%~nf.png" )

Run this in folder with extracted images and don't forget to change output path

pimtegelaar commented 2 years ago

Ah that works for the extracted DDS files, but what about the sprites? Or is there another way to get them out?

redsprites

pimtegelaar commented 2 years ago

@VitalyVaryvdin thanks for the scrip though, it did work on those other extracted images :)

VitalyVaryvdin commented 2 years ago

Oh you mean those.. Had no luck with those and gave up You might be able to find some help on WolvenKit's discord server

pimtegelaar commented 2 years ago

Thanks, I'll try that. I think the sprites are combinations of parts of the DDS files, stacked and rotated. and resized where needed. gwint-game{35e5b0c6}_i62 I couldn't get the flash decompilers to show them correctly though (tried both FF dec, Eltima Trillix and Sothink and all showed the same red colors).

pimtegelaar commented 2 years ago

It looks like it was made with the aurtodesk scaleform gfx sdk. It looks like that is no longer downloadable though :(

VitalyVaryvdin commented 2 years ago

I've got Scaleform 3.3.9 and 4.0.7 laying around, if this is of any help for you :)

pimtegelaar commented 2 years ago

@VitalyVaryvdin yeah that would be great :)

Btw, I also found that with XnConvert you can batch convert from dds to png and convert the colors in one go :)

VitalyVaryvdin commented 2 years ago

Ping me back at anomalray@gmail.com, i'll send the link