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

JJ2 Source Code (partial)

Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Sep 29, 2020, 12:09 PM
Violet CLM is offline
Reply With Quote
JJ2 Source Code (partial)

Download here

The full JJ2 source code has never been released, but we do have access to a few files, even though we don't know where they came from. These are the files most useful to someone for AngelScript-writing purposes, dealing mostly with object (i.e. jjOBJ) setup, behavior, and interactions. If you want to slightly modify the behavior of some enemy, for example, it's helpful to know how it works already so you can change only the relevant bits.

Keep in mind that these source files are for 1.22 or 1.23. They don't reflect any minor changes in 1.24 and they definitely don't reflect any changes in JJ2+: for example, the raven function in g_Ai.c still includes the bug where sometimes raven enemies would lock in place forever after returning from an attack.

JJ2's original internal variable names are generally similar to what you're used to from JJ2+'s AngelScript API but do differ a bit. Here are some key points:
  • For "Omonster" or "Tgameobj" read "jjOBJ." For "Obullets" also read "jjOBJ," but note that some properties will have different names.
  • For "phase" read "frameID"
  • For "tileattr" read "jjEventAtLastMaskedPixel"
  • For "RandFac(#)," where "#" is any number (usually a power of two minus one), read "jjRandom() & #"
  • For "gameobj" and "loadobj" read "jjObjects" and "jjObjectPresets"
  • For "sintable" and "costable" read "jjSin" and "jjCos"
  • For "var1" read "var[0]," for "var2" read "var[1]," etc.: JJ2 uses 1-indexed names for these properties but the AS API uses a 0-indexed array
Most importantly, JJ2 does not use floats. Places you're used to seeing floats in the AS API, such as xPos, xAcc, xSpeed, xOrg, and their y* equivalents, are internally fixed-point numbers, where the top sixteen bits store the number to the left of the decimal point and the bottom sixteen bits store the number to the right of the decimal point. For example, in g_aisetup.c the following lines set how fast unpowered blaster bullets move:
obj->xspeed=6*65536;
obj->xacc=8192;

This is equivalent to the following in AngelScript:
obj.xSpeed=6;
obj.xAcc=0.125;

Keep this in mind when reviewing JJ2 code. Be prepared to divide various numbers by 65536 (0x10000 in hex) in your head to get numbers that look more like what you're expecting.
__________________
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 02:03 AM.