PDA

View Full Version : JJM-Script


Sfaizst
Dec 24, 2010, 03:36 PM
Hello,

paralell to the Thread about JJM itself (LINK (http://www.jazz2online.com/jcf/showthread.php?t=19043)) I want you to talk here about the JJM-Script language that is really useful for adding extra functions to your levels, theoreticly it's possible to crate a rpg (i hope someone finish this step) with the Script.

How the script is working in Gerneral can be found in the subfolder "JJM-Script", there is a graphic that shows you how the scripting is working in gerneral and a ReadMe how the language is structed, there are some examples and Ideas too...

If a good programmer want to translate the script into an other languege (atm it's "Delphi-like") just write it here...

In future i want to add more features like a free configurateable map or some things for the JJM Action Center (possible a single tab for the script) too.

A help for the Scripting can be this page:
List of JJ2 Adresses (http://www.jazz2online.com/wiki/?List_of_Jazz_Jackrabbit_2_Memory_Addresses)

and programs like TSearch or CheatEngine...

So, if you have any problems / need help / have any ideas just post them here.

Sfaizst

Foly
Dec 25, 2010, 01:09 AM
Edit: Nvm, I should first read and then comment :)

Edit2: This is amazing, from now on I'll be using jjm.

Sfaizst
Dec 27, 2010, 07:56 AM
Made a Video about the example Level (JJMDance) and uploaded it on youtube, then it's easyer to see what can be possible with the script...

LINK (http://www.youtube.com/watch?v=GrgqFNCsZoo)

(The camera movement is possible the most interesting part...)

Violet CLM
Dec 27, 2010, 12:48 PM
The video got me to download and look at the readme, but in general, it's not the best practice to tell people they have to download your program before you'll tell them what it does. This looks incredibly promising, even if it seems pretty incomplete right now. Main stuff that I'd like to see added or changed:
The handling of the actual memory reading/writing could be improved, particularly since the addresses differ between JJ2 versions. I would much rather that health, xpos, etc., were constantly named variables, or keys in an associative array, than look up every time what their addresses might or might not be.
No for, while, or else? Sad panda. Heck, more datatypes, even.
The list of addresses you link to seems quite limited. In terms of <a href="http://www.jazz2online.com/jcf/showpost.php?p=459827&postcount=164">save files</a>, it seems to cover only the second block, but not the dictionary or event map or even triggers, which would seem vital to any detailed scripting work. Are these impenetrable to the current tools?

Sfaizst
Dec 28, 2010, 02:51 AM
I know that the script is quite not finished at the moment, but I made for the basic the most importand functions and operations, thats reading and writing out / in JJ memory, "If" and the mathematic operations of the variables.

I planned to expand the script a lot and to hold it compatible down to this versoin. The File you creating with the "Compiler" program is so wide expandable, that i can easylie add functions and more complex operations every time (only the types of the variables are limited to bool, byte, word, integer and string, and the count of variables for each type are limited to 65535).

I think I will release every Update of JJM some new things for the script, so that it gets better and better.

Intresting that you are interested so mutch in a script for JJ2.

DoubleGJ
Dec 28, 2010, 03:44 AM
So...
If I make an entrance into the boss arena, say, with a sucker tube, put an Activate Boss event there, and right after it a script that changes the music, I can have whatever boss music I want without having to change the .j2b file?

Awesome, and just what I need.

GoldRabbit
Dec 30, 2010, 03:38 AM
This looks incredible, and even quite revolutionary. (I myself didn't even dream of something like this ever happening.)

I wish you good luck in expanding the possibilities, and keep up the great work!

This being on top of JJ2+ instead of being a conflicting add-on is also a great plus (haha c wut i did thar)

This would be SO useful for my city, even to the point of getting my enthusiasm back on track. The music change and camera control featured look VERY tasty.

Again, great job.

EDIT: I have run a few tests, seeing as there previously was no way to change the max health in single player (I think so at least), so I attempted to save with around 20 hearts. I was surprised that everything was okay, including the external script. So far, it looks stable.

[GpW]Urbs
Jan 4, 2011, 08:45 AM
haha i saw wat u did thar:)

Violet CLM
Jan 4, 2011, 01:24 PM
Okay, I did some poking, and <a href="http://www.jazz2online.com/wiki/?List_of_Jazz_Jackrabbit_2_Memory_Addresses">that list</a> is not conclusive. For instance, I found trigger ID 0 (in 1.23) at 5C68E0 ( the other thirty-one are right after it in a row) and the beginning of the dictionary at 29759B0. Does anyone have a better list of memory addresses, or is it time for a lot of trial and error?

ETA: Realtime palette editing looks... potentially possible, I guess? I can find the palette in the memory, but the actual colors used for display only read it (update) when you change the color depth or resolution or something like that. If there's a flag in the memory that gets turned on briefly when one of those options is selected which causes the palette to update, and that flag could be found, palette editing is a go; otherwise, asking the player to reselect their resolution at various intervals doesn't seem like the best idea.

ETA2: I can't get convert() to work at all, and I notice it's not in any of the examples. :( And it turns out that the dictionary (didn't recheck triggers) is not at the same memory location every time you run the game, which is a powerful argument for this getting a little smarter and providing the user with the addresses, rather than him/her going hunting every time. JJM should have some way of figuring out where the dictionary is; the user does not.

Sfaizst
Jan 6, 2011, 04:32 AM
About the convert function, i not really like to use this function, but sometimes it can be importent (atm i only see it relevant for converting a integer to a string, so that it is possible to send echos related to something).

I tested it, and i have to say SORRY, i documentated it completly wrong :D
the first parameter is the variable that you want to convert to an other, the second parameter is the other one...

here a little example script (tested and working):


var
InVar : Integer = 1
OutVar, T1 : Byte = 0
T2 : Byte = 1
Echo : String=Convert is working very well...
begin
If (OutVar = T1)
Convert(InVar,OutVar)
end
If (OutVar = T2)
Outvar := 2
jjecho(Echo)
end
end.


Have fun, working now on more functions i try to add somethinglike Goto (some know this from basic) to the script language, with this can be for, while,... possible

Edit: Booleans are Bytes in fact, you can read Booleans like Bytes in JJ's ram too but JJM will handle them only as boolean so 0 = false and 1-255 = True, so you can read the triggers themselfs as boolean

Violet CLM
Jan 6, 2011, 01:04 PM
I was trying to use convert() for turning a byte into a short, actually, since I wanted to read bytes from one location and write them as shorts elsewhere, and that seemed simpler than writing the byte and then writing another byte as 0 every single time. Ultimately, though, without reliable dictionary access it's all moot.

Sfaizst
Jan 6, 2011, 01:44 PM
I'm currently working on "for" with this it should be easyer to handle these problems (after this i want to add the support for arrays, but this will take a longer time as "for" and I'm not finished with it... + the array will be static, I hope this wont be a problem)

how for and the array can look like (dunno if i make it so, but it should be similar):


var
IntArray : Array(10,Integer) //Create a Array of Integer with 10 Values
Count : Integer = 0
CountTo : Integer = 10
TmpStr, SendStr : String
begin
for (Count,Countto)
IntArray[Count] := Count+CountTo //Only as example :D
Convert(Count,TmpStr)
SendStr :=Currently at Position
SendStr := SendStr+TmpStr
jjecho(SendStr)
end
end.


Edit1 (15.01.11):
Got "for" working and fixed the bug in Convert, have to say sorry, there was really one, convert only worked for some times (so the bug will be fixed in the next official version of JJM) Convert will be looking like i written in the ReadMe Convert(OutVar,InVar)

Working now on the arrays and several bug fixes, i got a lot stuff in the other Thread :D

Sfaizst
Jan 23, 2011, 09:21 AM
Hey, sorry for the doublepost, but i want to say a lot new related to the script:

I finished today the support for arrays (they are working generally at all functions only at "for" as parameters not), added the new functions "Valloc" (VirtualAllocEx), "CRT" (CreateRemoteThread) and "VFree" (VirtualFreeEx) to the script, so that you can call functions in the game.

And I edited the Compiler itself a bit, so that it's easyer to debug it if you made a mistake ;)

Here a example script for sending a echo with CRT:

var
//General Variables
VFalse : Boolean = false
StartLevel : Boolean = True

//Send Echo with CRT:
EchoStr, EmptyStr : String
EchoPtr : Integer=$483060
EchoStrSize : Integer = 68
THandle, ParamP : Integer
begin

//On Level Start;
If (StartLevel <> VFalse)
EchoStr :=I wanted to say hello man!
StartLevel := VFalse
end

//Send Echo with CRT:
If (EchoStr <> EmptyStr)
Valloc(ParamP,EchoStrSize)
jjwrite(ParamP,EchoStr)
CRT(THandle,EchoPtr,ParamP)
VFree(THandle,ParamP)
EchoStr:= EmptyStr
end
end.

I know there is jjecho() for sending an echo, but this is only a example to show how CRT is working...

Here alittle Picture about the Compiler and it's new little helper:
http://jj2.ath.cx/Programme/JJM/JJMCompiler.png

Now I try to fix the bugs you guys said in the other tread and then i will release the new version (normally take about 3 or 4 days, I'm not all the time there, i have to work sometimes :D)

Sfaizst
Feb 4, 2011, 03:39 PM
Next Plans / Ideas I have for the future (/nextversions of the script):

the next time (until next version):
- Adding a function to call Plus / JJM commands
- Adding more pointers (atm there are: "jjmplusbase" and "jjmeventbase" ; all pointers have a "jjm" in the name to differ from normal variables)

long-time-plans:
- Adding in JJM-ACP a tab for the script (I dont know, how I will make it, but I think it will have some tabs (for a map, for a shop and possible 2 or 3 where you can set the buttons / labels).
- Adding a external Ini file to save settings with the script,... (can be good in bigger projects)
- Adding the possibility to get access to a mysql database on the net (I made this once in an other project, but this will take a while, would be interesting to build rpg's like karrotshire that communicate with a server)

If you have any ideas what you need to make your script perfect, please say a word or if you have a problem understanding some thing... (it possible take a while until I answer)

Violet CLM
Feb 5, 2011, 10:34 AM
The things I want remain the same from my earlier posts, particularly better multiversion support and actual access to the dictionary.