-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add enums for event command parameters #245
Comments
I did some research on this: Ghabry Suggested checking R48's commands descriptions, from @20kdc repos: There are also some interesting references from Destiny Patch sourcecode (thanks to Kotatsu Akira and @drxgb) The Destiny Patch one also has lots of name suggestions for some parameters outputs, It may complicate stuff in cases where maniacs patch is used, due to its alien bitsmask parameters... |
just so you know, some commands are... complicated, and can't be directly dumped from r48's CMDB due to this |
Hey @20kdc! It would help us a lot, since we are stuck with this issue since 2018 Meanwhile I extracted all the commented |
This isn't absolutely all data in the system (it gets increasingly complicated to do that going further into the details) but it should have an entry for every command. |
Oh, right, I should probably note:
|
Thanks! and in order to match with our IDs, it can be get through: I thought about replacing all |
The js do get it was: // Determine the maximum number of parameters among all commands
let maxParams = 0;
jsonFile.cmdbs.event.knownCommands.forEach((command) => {
if (command.params.length > maxParams) {
maxParams = command.params.length;
}
});
// Create CSV header
const headers = ['ParentName', 'ParentId'];
for (let i = 0; i < maxParams; i++) {
headers.push(`Param_${i}`);
}
// Create CSV rows
const csvData = [headers];
jsonFile.cmdbs.event.knownCommands.forEach((command) => {
const row = [command.name, command.commandId];
for (let i = 0; i < maxParams; i++) {
if (i < command.params.length) {
row.push(command.params[i].name);
} else {
row.push(''); // Empty cell if no parameter at this index
}
}
csvData.push(row);
});
// Convert the data to CSV format
const csvContent = csvData.map((row) => row.join(',')).join('\n');
console.log('CSV data as a string:');
console.log(csvContent); |
That script isn't handling parameters with dynamic types (i.e. 10310 has |
hm... right. Though that kind of detection is already inside the Player's source code. It should indeed have inside it something like |
if you look at the JSON, you can get at least a first pass just by taking the default branch of "dynamic" parameters EDIT: Example: {
"arrayDI" : 2,
"contents" : {
"0" : {
"name" : "gold",
"se" : 285,
"type" : "static"
}
},
"def" : {
"name" : "goldVar",
"se" : 50,
"type" : "static"
},
"type" : "dynamic"
} |
...oh, right, also, something I forgot to mention: The sdbNodes stuff was included for a reason! you can use it to find and retrieve enums |
// Determine the maximum number of parameters among all commands
let maxParams = 0;
jsonFile.cmdbs.event.knownCommands.forEach((command) => {
if (command.params.length > maxParams) {
maxParams = command.params.length;
}
});
// Create CSV header
const headers = ['ParentName', 'ParentId'];
for (let i = 0; i < maxParams; i++) {
headers.push(`Param_${i}`);
}
// Create CSV rows
const csvData = [headers];
jsonFile.cmdbs.event.knownCommands.forEach((command) => {
const row = [command.name, command.commandId];
for (let i = 0; i < maxParams; i++) {
if (i < command.params.length) {
const param = command.params[i];
if (param.type === 'dynamic' && param.contents && param.contents[0]) {
row.push(param.contents[0].name);
} else {
row.push(param.name);
}
} else {
row.push(''); // Empty cell if no parameter at this index
}
}
csvData.push(row);
});
// Convert the data to CSV format
const csvContent = csvData.map((row) => row.join(',')).join('\n');
console.log('CSV data as a string:');
console.log(csvContent); |
I'd still advise checking the |
You mean, checking if def exists instead of param.type === 'dynamic' ? I gotta leave right now, later I'll take a better look at still needs to be done and what sdbNodes does. |
Well, for when you get back, I'll just explain the fine details: Param is an abstract class in R48, with two implementations: Static and Dynamic. These are represented as the "static" and "dynamic" types. If
For static params, it's "name" (name) and "se" (index into "sdbNodes") as usual. "sdbNodes" is an array because a lot of SDB nodes are just completely unnamed, and some have two names, etc. That said, a name will only ever refer to one SDB node. The SDB data in the JSON is... incomplete. But it has things like enumerations, so you can use this to get, say, window position enumerations and such. The "se" value in parameters connects those enumerations to parameters. The "specialSchema" value is for commands which don't fit the Param system; depending on how much or little effort you want to put into really squeezing every last bit of data out of the JSON, you may be better off just ignoring this. |
Now it has the same command Names from easyRPG sourcecode. I received some feedback about more entries: @20kdc do you have any info on those? The source code of the JS extractor (included both jsonFile and BetterName templates, to show where goes r48 json and easyRPG commandNames) // Replace this with your JSON data
const jsonFile = {
cmdbs: {
event: {
knownCommands: [
{
name: 'Command1',
commandId: 'ID1',
params: [
{ name: 'Param_0_Value', type: 'static' },
{ name: 'Param_1_Value', type: 'dynamic', contents: [{ name: 'Dynamic_Param_1' }] },
],
},
{
name: 'Command2',
commandId: 'ID2',
params: [
{ name: 'Param_0_Value', type: 'dynamic', contents: [{ name: 'Dynamic_Param_0' }] },
{ name: 'Param_1_Value', type: 'static' },
{ name: 'Param_2_Value', type: 'dynamic', contents: [{ name: 'Dynamic_Param_2' }] },
],
},
],
},
},
};
const betterNames = {
"ID1": "BetterCommand1",
"ID2": "BetterCommand2",
// Add more mappings as needed
};
// Determine the maximum number of parameters among all commands
let maxParams = 0;
jsonFile.cmdbs.event.knownCommands.forEach((command) => {
if (command.params.length > maxParams) {
maxParams = command.params.length;
}
});
// Create CSV header
const headers = ['ParentName', 'ParentId'];
for (let i = 0; i < maxParams; i++) {
headers.push(`Param_${i}`);
}
// Create CSV rows
const csvData = [headers];
jsonFile.cmdbs.event.knownCommands.forEach((command) => {
const row = [betterNames[command.commandId] || command.name, command.commandId];
for (let i = 0; i < maxParams; i++) {
if (i < command.params.length) {
const param = command.params[i];
if (param.type === 'dynamic' && param.contents && param.contents[0]) {
row.push(param.contents[0].name);
} else {
row.push(param.name);
}
} else {
row.push(''); // Empty cell if no parameter at this index
}
}
csvData.push(row);
});
// Convert the data to CSV format
const csvContent = csvData.map((row) => row.join(',')).join('\n');
console.log('CSV data as a string:');
console.log(csvContent); |
The relation between the "value" and "type of value" parameter is, as I have previously explained, in the "dynamic" param structure. "arrayDI" is the index of the "type of value" parameter. |
ok, put more information inside it. Let me know if something else is missing: jsonFile = {} //R48 json file
easyrpgNames = {} //easyRPG list of commands names
// Determine the maximum number of parameters among all commands
let maxParams = 0;
jsonFile.cmdbs.event.knownCommands.forEach((command) => {
if (command.params.length > maxParams) {
maxParams = command.params.length;
}
});
// Create CSV header
const headers = ['Command', 'ID']; // this instead of ParentName and ParentId
for (let i = 0; i < maxParams; i++) {
if (i === 0) {
headers.push('String'); // Rename Param_0 to String
} else {
headers.push(`Param_${i}`);
}
}
// Create CSV rows
const csvData = [headers];
jsonFile.cmdbs.event.knownCommands.forEach((command) => {
const row = [easyrpgNames[command.commandId] || command.name.replace(/[^a-zA-Z0-9_]/g, ''), command.commandId];
for (let i = 0; i < maxParams; i++) {
if (i < command.params.length) {
const param = command.params[i];
if (param.type === 'dynamic') {
// Construct the Param_n cell based on additional rules
let paramCell = param.def && param.def.name ? param.def.name : 'undefined'; // Default parameter name
if (param.contents) {
const contentsNames = Object.keys(param.contents).map((o) => param.contents[o].name);
if (contentsNames.length > 0) {
paramCell += ' || ' + contentsNames.join(' || '); // Contents names
}
}
if (param.arrayDI != null) {
paramCell += ` (ParentParam: ${param.arrayDI})`; // ParentName is used here now.
}
row.push(paramCell);
} else {
const paramName = param.name
row.push(paramName);
}
} else {
row.push(''); // Empty cell if no parameter at this index
}
}
csvData.push(row);
});
// Convert the data to CSV format
const csvContent = csvData.map((row) => row.join(',')).join('\n');
console.log('CSV data as a string:');
//console.log(csvContent);
csvContent; |
cases like set variable and timer operation doesn't have parameters described on it. example from timer operation: specialSchemaEssential: true
specialSchema: 423` |
Yes; this is because it's hard or impossible to describe those cases using the CMDB syntax. Same goes for Conditional Branch. In fact, there's probably argument to be made against converting them period, at least at first; they're mazes and mistakes will result in awkward Player bugs. |
ok, just to keep things fresh: List of Event Commands: List of named Parameters: @Ghabry let me know what else is missing in those files. |
I extracted all the I'm trying to discover if there's a painless way to customize the csv list with new commands supported by easyRPG, using these snippets of code. |
Another motivation for this is shown here:
When you look at the assembler output you can see that both functions compile to the exact same code. Compilers are smart :). |
Currently Player uses dozens of magic numbers for event command parameters. For more readable code, mostly in game interpreter and shared and better support for game editors, liblcf might provide some generated code from CSV with these enumerations.
Number of hits of
com.parameters
in code:game_interpreter.cpp
: 529game_interpreter_map.cpp
: 52game_interpreter_battle.cpp
: 42The text was updated successfully, but these errors were encountered: