Register FAQ Search Today's Posts Mark Forums Read
Go Back   JazzJackrabbit Community Forums » Open Forums » JCS & Scripting

Custom .j2a files

Reply
 
Thread Tools
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,691

Violet CLM has disabled reputation

Apr 6, 2015, 08:01 PM
Violet CLM is offline
Reply With Quote
Custom .j2a files

JJ2+ version 5.0 includes two new .j2a files, but no instructions for how to make your own. Sorry. See, what happened is I came up with an internal tool for us to use, but then never found the time to make anything more user-friendly out of it, and didn't feel quite right bundling the internal tool with the main release.

But here you go, if you do want to make your own .j2a files.

It's just some very basic Python 2.x files using PIL. Run j2a-extract.py and type the filepath of one of your existing .j2a files to see what kind of file structure is expected of you, compile your own set of sprites, then run j2a-import.py. If you're extracting C:\Games\Jazz2\foo.j2a, the results will be stored in a few folder C:\Games\Jazz2\foo-j2a\ as a series of subfolders, one for each anim set in the file. Each subfolder will contain a series of subsubfolders, one for each animation, and those will each contain a series of .png files, one for each anim frame. Then later when you're importing, the file/folder name relation will be the same—import the folder C:\Games\Jazz2\bar-j2a\ to build C:\Games\Jazz2\bar.j2a.

The .png files store all the frame metadata in their filenames, using the format FRAMENUMBER,HOTSPOTX,HOTSPOTY,COLDSPOTX,COLDSPOTY, GUNSPOTX,GUNSPOTY.png. If the frame should be drawn as transparent by default, include the letter "t" right after FRAMENUMBER, e.g. 0t,-9,-11,0,0,0,0.png.

It hopefully sounds more complicated than it is. Look at one or more existing .j2a files and you should figure out how it works pretty quickly. What you shouldn't do is try to use this to rebuild anims.j2a, since this has absolutely no support for sounds, only sprites, and anims.j2a has hundreds of sounds in it that you would end up deleting. And if you can't figure how to run .py files, wait around and hope that someone will make an executable version.

Post any related questions here and I'll do my best to answer them, even if that answer is "google python", though consider also the general AngelScript help thread.

(thanks go to Stijn, whose code I modified, and Neobeo, whose research this was based on.)
__________________

Last edited by Violet CLM; Apr 8, 2015 at 12:32 PM.
FawFul FawFul's Avatar

JCF Member

Joined: Jun 2007

Posts: 493

FawFul is a forum legendFawFul is a forum legendFawFul is a forum legend

Apr 7, 2015, 02:04 PM
FawFul is offline
Reply With Quote
I have python, but i can't seem to get a prompt by just opening the file and selecting the python tool. This could use some more explanation i feel :0.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,691

Violet CLM has disabled reputation

Apr 7, 2015, 04:36 PM
Violet CLM is offline
Reply With Quote
You need to run the file, not just open it.
__________________
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

Apr 8, 2015, 08:02 AM
XxMoNsTeRXM is offline
Reply With Quote
It doesn't work I run it with the specified arguments but still invalid syntax.
__________________
~XxMoNsTeR
Stijn Stijn's Avatar

Administrator

Joined: Mar 2001

Posts: 6,936

Stijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to behold

Apr 8, 2015, 08:16 AM
Stijn is offline
Reply With Quote
You probably installed Python 3. The scripts are only compatible with Python 2.x, so install that and try again.
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

Apr 8, 2015, 08:20 AM
XxMoNsTeRXM is offline
Reply With Quote
Quote:
Originally Posted by Stijn View Post
You probably installed Python 3. The scripts are only compatible with Python 2.x, so install that and try again.
oh, ok... that explains everything...
EDIT: Another error:
__________________
~XxMoNsTeR

Last edited by XxMoNsTeRXM; Apr 8, 2015 at 08:33 AM.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,691

Violet CLM has disabled reputation

Apr 8, 2015, 12:34 PM
Violet CLM is offline
Reply With Quote
Okay, that one's on me. I forgot misc.py in the zip. Sorry, try again now.
__________________
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

Apr 8, 2015, 12:59 PM
XxMoNsTeRXM is offline
Reply With Quote
Quote:
Originally Posted by Violet CLM View Post
Okay, that one's on me. I forgot misc.py in the zip. Sorry, try again now.
Ok, what now? Another file that you forgot?

I looked into the code, and the module is imported on j2a.py line 11
__________________
~XxMoNsTeR
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,691

Violet CLM has disabled reputation

Apr 8, 2015, 01:11 PM
Violet CLM is offline
Reply With Quote
Quote:
#needs python image library, http://www.pythonware.com/library/pil/
import Image
It's right there in the file.
__________________
FawFul FawFul's Avatar

JCF Member

Joined: Jun 2007

Posts: 493

FawFul is a forum legendFawFul is a forum legendFawFul is a forum legend

Apr 8, 2015, 02:36 PM
FawFul is offline
Reply With Quote
"please type the .j2a file you wish to extract"
Anims
file plus.j2a could not be read!

"please type the .j2a file you wish to extract"
plus
file plus.j2a could not be read!

"please type the .j2a file you wish to extract"
Anims.j2a
file plus.j2a could not be read!

"please type the .j2a file you wish to extract"
plus.j2a
file plus.j2a could not be read!

......

Also it was a pain finding the right PIL library, your link did not provide the right info. I think you meant:

http://www.pythonware.com/products/pil/

not,

http://www.pythonware.com/library/pil/

Even then it link for 2.7 was not working so i searched the internet. Apparently something named PILLOW took it place but i still manage to find the right library here: http://christianakesson.com/compiling-pil/ at the bottom of the article.

Still not working though...
Stijn Stijn's Avatar

Administrator

Joined: Mar 2001

Posts: 6,936

Stijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to behold

Apr 8, 2015, 02:39 PM
Stijn is offline
Reply With Quote
I'm not sure what happened for you, but the link in misc.py leads me to http://effbot.org/media/downloads/PI...in32-py2.7.exe after a few clicks. Is that what you installed?

Looking at j2a.py the error you're getting means the j2a file can't be read. Are you sure the path is right? Are you maybe entering "Anims" instead of "Anims.j2a"? The script needs the full filename, including extension.

Last edited by Stijn; Apr 8, 2015 at 02:57 PM.
FawFul FawFul's Avatar

JCF Member

Joined: Jun 2007

Posts: 493

FawFul is a forum legendFawFul is a forum legendFawFul is a forum legend

Apr 8, 2015, 02:57 PM
FawFul is offline
Reply With Quote
I can't open the link you just gave, it is the same link on the page i send. It gives a web-page error. 'Web page not available'.. or simply doesn't exist anymore. That's why i downloaded it elsewhere. I'm quite sure this what I have should also work.

Also no, i have D:\Games\Jazz2. so on the D: directory, not C:.
I entered D:\games\jazz2\j2a-extract.py in the command prompt.

Then received a message

"please type the .j2a file you wish to extract"

Anims

and then..

file Anims.j2a could not be read!

It is from C:\Users\Lennart> though, but imo asking 'which j2a I want to extract' shows it has the right .py file in the jazz2 folder.
Stijn Stijn's Avatar

Administrator

Joined: Mar 2001

Posts: 6,936

Stijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to behold

Apr 8, 2015, 03:01 PM
Stijn is offline
Reply With Quote
I think I opened the wrong file, and I edited my post accordingly. You need to enter the full file name, including the extension. So "Anims.j2a", not "Anims", unless you renamed your file to not include an extension. Make sure the file is in the same folder as the scripts too, I'm not certain it will work otherwise.
FawFul FawFul's Avatar

JCF Member

Joined: Jun 2007

Posts: 493

FawFul is a forum legendFawFul is a forum legendFawFul is a forum legend

Apr 8, 2015, 03:04 PM
FawFul is offline
Reply With Quote
jazz2 folder contains the pil library, the given .py extensions in the zip (also the misc). j2a files and i typed "Anims.j2a" and still it doesn't read. Folder is 1.23 if it's important.
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

Apr 8, 2015, 10:34 PM
XxMoNsTeRXM is offline
Reply With Quote
Quote:
Originally Posted by FawFul View Post
jazz2 folder contains the pil library, the given .py extensions in the zip (also the misc). j2a files and i typed "Anims.j2a" and still it doesn't read. Folder is 1.23 if it's important.
Wait, you say the given .py extensions in the zip, you gotta extract them into the jazz2 folder.

EDIT: Wat?

And this is all it gave to me

This is the command I typed in Command Prompt: python j2a-extract.py "{path to jj2folder, not to .j2a file, I found that by myself}" after this it told me:
Please type the filename of the .j2a file you wish to extract:
So I type: plus.j2a
and then the error happens, and I only get two folders and only one file, fps.10
__________________
~XxMoNsTeR

Last edited by XxMoNsTeRXM; Apr 8, 2015 at 10:57 PM.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,691

Violet CLM has disabled reputation

Apr 8, 2015, 11:43 PM
Violet CLM is offline
Reply With Quote
Ah, yeah, it's been long enough since I used j2a-extract that I'd forgotten it wants a palette file. I've put that in the zip too.

You'll probably still have trouble with plus.j2a, but the other two .j2a files in your folder should work fine. FawFul noticed earlier that plus.j2a was accidentally assembled in a way that JJ2+ accepts but j2a-extract doesn't
__________________

Last edited by Violet CLM; Apr 8, 2015 at 11:56 PM.
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

Apr 8, 2015, 11:55 PM
XxMoNsTeRXM is offline
Reply With Quote
Quote:
Originally Posted by Violet CLM View Post
Ah, yeah, it's been long enough since I used j2a-extract that I'd forgotten it wants a palette file. I've put that in the zip too.

You'll probably still have trouble with plus.j2a, but the other two .j2a files in your folder should work fine. FawFul noticed earlier that plus.j2a was accidentally assembled in a way that JJ2+ accepts but plus-extract doesn't
Now it works! Finally! Thanks!

EDIT: Now help me understand the images:

The first zero is the frame, the next numbers I don't know what they are.

EDIT 2: nvm...
__________________
~XxMoNsTeR

Last edited by XxMoNsTeRXM; Apr 9, 2015 at 01:05 AM.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,691

Violet CLM has disabled reputation

Apr 8, 2015, 11:57 PM
Violet CLM is offline
Reply With Quote
Yay! That's both of you... now I've exhausted the market and don't need to worry about making a proper executable ever. /s
__________________
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

Apr 9, 2015, 01:06 AM
XxMoNsTeRXM is offline
Reply With Quote
Quote:
Originally Posted by Violet CLM View Post
Yay! That's both of you... now I've exhausted the market and don't need to worry about making a proper executable ever. /s
Too many errors... ugh...
BTW... this is on j2a-import.py:
__________________
~XxMoNsTeR

Last edited by XxMoNsTeRXM; Feb 26, 2017 at 02:30 AM.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,691

Violet CLM has disabled reputation

Apr 9, 2015, 10:25 AM
Violet CLM is offline
Reply With Quote
That'll happen if you have one or more improperly formatted image filenames.
__________________
FawFul FawFul's Avatar

JCF Member

Joined: Jun 2007

Posts: 493

FawFul is a forum legendFawFul is a forum legendFawFul is a forum legend

Apr 9, 2015, 10:55 AM
FawFul is offline
Reply With Quote
I used this script:

#pragma require "Mario.j2a"
#pragma name "Play as Mario!"

/************************************************/
/**********Play as Mario! by FawFuL**************/
/************************************************/

void onLevelLoad() {
jjAnimSets[ANIM::SPAZ].load(0, "mario.j2a");
jjAnimSets[ANIM::SPAZ2].load(1, "mario.j2a");
}

void onPlayer(jjPLAYER@ play) {
if (play.charCurr == CHAR::JAZZ || play.charCurr == CHAR::LORI) play.morphTo(CHAR::SPAZ);
}

And i ran into 2 problems:

1: Animation index
the animation indexes for 1.23 and 1.24 are different for set Anim::SPAZ. There are unused animations in 1.23 that clutter the animation order like spaz grabbing ledges, the j2a is based on 1.24. Apparently there are ways to fix this but it's really complicated. It also makes this preset stuff redundant if it doesn't takes differences in indexes into account.

2. Wrong animations on other online players
I overrided Anim::SPAZ and Anim::SPAZ2 and they look right for 1.24 users, however you get weird cluttered images on other players. (bird animations, bullets and a few of the custom animations, iirc). Vanilla jj2 draws your own sprites and others sprites right from Anim::SPAZ, why does my custom j2a make it show 2 different things on local and online players? Is this fixable?

I suggest that it's maybe useful to have a snippet that fixes these 2 problems, because i imagine more players would want to make their own custom j2a characters. afaik there were some already that ppl liked to import .. a snippet could be nice and reusable for this.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,691

Violet CLM has disabled reputation

Apr 9, 2015, 12:57 PM
Violet CLM is offline
Reply With Quote
This is what the RABBIT::Anim enum is for! Maybe once you get it working, you can be the one to write the snippet.

Additional hint.
__________________
Lark

JCF Member

Joined: Jan 2002

Posts: 1,564

Lark has disabled reputation

Apr 10, 2015, 09:07 PM
Lark is offline
Reply With Quote
eh I'm gonna play with this tomorrow when I have time to be awake late, but you're saying no support for extracting or viewing in game sfx (yet)?? bummer dude, I hope to see that soon
__________________
=D
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,691

Violet CLM has disabled reputation

Apr 10, 2015, 10:05 PM
Violet CLM is offline
Reply With Quote
SFX over here
__________________
Seren Seren's Avatar

JCF Member

Joined: Feb 2010

Posts: 823

Seren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to all

Apr 11, 2015, 02:08 AM
Seren is offline
Reply With Quote
DJazz's site also lets you download an archive with all JJ2 sounds in wav format, although they're unnamed there.
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.
FawFul FawFul's Avatar

JCF Member

Joined: Jun 2007

Posts: 493

FawFul is a forum legendFawFul is a forum legendFawFul is a forum legend

Apr 11, 2015, 08:04 AM
FawFul is offline
Reply With Quote
I made my anims script work by adding 3 additional sets for 1.23. I tried to do both 1.23 and TSF with a single set, but I didn't manage to make it work (sorry Violet!). It is probably possible with RABBIT::ANIM.

both 1.23 and TSF run the fully correct animation replacements now, however you still see other players wrong. The following explanation is what happens when seeing other online players:

For example RABBIT:: DIVE while it should be RABBIT::STAND, RABBIT::STAND while it should be RABBIT::IDLE2..... RABBIT:: DIVE while it should be RABBIT::JUMPING1. I found out that it does somewhat try to get the right frames, for example it stays stuck in the buttomp frame forever whenever a player buttstomps. It stays stuck in the airboard frame whenever someone had an airboard and whenever someone ducks it stays stuck in that frame aswell. It can even still load the latest 'normal' spaz sprite upon cycling. Is this a bug or can i do something about this in AS? all animations are loaded upon levelload so i don't understand why there is a 'refresh-rate' problem (eventhough some animations won't show at all even if you wait for a delay). when i duck, someone else will see the right animation index 3 seconds late and will only show a single frame instead of a complete animation. I'd like to add that the 'errors' are really consistent. Always the same frames where it gets stuck in and the same RABBIT::ANIM sets that will change with it. The only animation indexes that work somewhat well are RABBIT::AIRBOARD and RABBIT::CORPSE.

Maybe unimportant to say, but this was not the case if you shared custom j2a files back in the day.

Last edited by FawFul; Apr 11, 2015 at 08:17 AM.
DennisKainz DennisKainz's Avatar

JCF Member

Joined: Dec 2005

Posts: 407

DennisKainz is notorious for his worthless posts

Apr 26, 2015, 03:20 PM
DennisKainz is offline
Reply With Quote
There's a problem. Whether I use Python 2 or Python 3, when I write "C:\", Python highlights the ":" in "C:\" as invalid syntax
Stijn Stijn's Avatar

Administrator

Joined: Mar 2001

Posts: 6,936

Stijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to behold

Apr 26, 2015, 03:23 PM
Stijn is offline
Reply With Quote
Try putting it between "quotes".
DennisKainz DennisKainz's Avatar

JCF Member

Joined: Dec 2005

Posts: 407

DennisKainz is notorious for his worthless posts

Apr 26, 2015, 11:56 PM
DennisKainz is offline
Reply With Quote


I don't want to give up! I really need that custom j2a file!
Stijn Stijn's Avatar

Administrator

Joined: Mar 2001

Posts: 6,936

Stijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to behold

Apr 27, 2015, 02:06 AM
Stijn is offline
Reply With Quote
...you're not supposed to run things inside the python interpreter.

Open the terminal, go to the right folder, then run "python j2a-extract.py plus.j2a". That's all.
DennisKainz DennisKainz's Avatar

JCF Member

Joined: Dec 2005

Posts: 407

DennisKainz is notorious for his worthless posts

Apr 27, 2015, 02:45 AM
DennisKainz is offline
Reply With Quote
By terminal you mean cmd.exe in System 32, right?
Because there seems to be yet another problem ...

When I write the line "C:\Games\Jazz2>python j2a-extract.py" I get "Access Denied"
Stijn Stijn's Avatar

Administrator

Joined: Mar 2001

Posts: 6,936

Stijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to behold

Apr 27, 2015, 03:04 AM
Stijn is offline
Reply With Quote
https://technet.microsoft.com/en-us/...=ws.10%29.aspx
Old Apr 27, 2015, 03:32 AM
DennisKainz
This message has been deleted by DennisKainz. Reason: Solved on my own
DennisKainz DennisKainz's Avatar

JCF Member

Joined: Dec 2005

Posts: 407

DennisKainz is notorious for his worthless posts

Apr 27, 2015, 04:07 AM
DennisKainz is offline
Reply With Quote

EDIT: Solved.
If you get this message, it is because your PNGs aren't color-indexed.

P.S. Thanks for your help, admin! Now I can create my own j2a files!

Last edited by DennisKainz; Apr 27, 2015 at 09:38 AM.
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

May 2, 2015, 01:04 AM
XxMoNsTeRXM is offline
Reply With Quote
Quote:
Originally Posted by DennisKainz View Post

If you get this message, it is because your PNGs aren't color-indexed.
What do you mean aren't colored-index? (I got this error too)
__________________
~XxMoNsTeR
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,691

Violet CLM has disabled reputation

May 2, 2015, 01:19 AM
Violet CLM is offline
Reply With Quote
You need to use 8-bit PNGs, not 24/32.
__________________
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

May 2, 2015, 04:13 AM
XxMoNsTeRXM is offline
Reply With Quote
Quote:
Originally Posted by Violet CLM View Post
You need to use 8-bit PNGs, not 24/32.
Still doesn't work, I made them 23x31, same error.
__________________
~XxMoNsTeR
cooba cooba's Avatar

JCF Veteran

Joined: Jan 2004

Posts: 7,793

cooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of light

May 2, 2015, 04:27 AM
cooba is offline
Reply With Quote
Quote:
Originally Posted by XxMoNsTeRXM View Post
Still doesn't work, I made them 23x31, same error.
No offense but LOL.

8-bit means they need to be 256 colors and use the JJ2 palette.
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

May 2, 2015, 04:32 AM
XxMoNsTeRXM is offline
Reply With Quote
Quote:
Originally Posted by cooba View Post
No offense but LOL.

8-bit means they need to be 256 colors and use the JJ2 palette.
AH ok. Thx
EDIT: Where can I get the jj2 palette?
__________________
~XxMoNsTeR

Last edited by XxMoNsTeRXM; May 2, 2015 at 04:57 AM.
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

All times are GMT -8. The time now is 06:11 AM.