Improved Standardize Items Patch

now every item is available and can be found on the ground
This commit is contained in:
AdAstra-LD
2021-02-16 19:00:25 +01:00
parent b7182dbc0a
commit ffcc59ff61
3 changed files with 24 additions and 13 deletions

View File

@@ -276,15 +276,8 @@ namespace DSPRE {
owTrainerComboBox.Items.AddRange(trainerNames);
/* Add item list to ow item box */
int itemScriptId = RomInfo.itemScriptFileNumber;
try {
int count = new ScriptFile(itemScriptId).allScripts.Count - 1;
owItemComboBox.Items.AddRange(GetItemNames(0, count));
} catch {
MessageBox.Show("There was a problem reading Script File #" + itemScriptId + ".\n" +
"It is strongly adviced that you restore this file from a clean backup.", "Item script couldn't be loaded",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
owItemComboBox.Items.AddRange(GetItemNames(0, new TextArchive(RomInfo.itemNamesTextNumber).messages.Count-1));
/* Add ow movement list to box */
owMovementComboBox.Items.AddRange(PokeDatabase.EventEditor.Overworlds.movementsArray);

View File

@@ -20,6 +20,12 @@ namespace DSPRE.ROMFiles {
this.containerType = containerType;
commands = commandList;
}
public CommandContainer(uint newID, CommandContainer toCopy) {
manualUserID = newID;
useScript = toCopy.useScript;
containerType = toCopy.containerType;
commands = new List<ScriptCommand>(toCopy.commands); //command parameters need to be copied recursively
}
#endregion
}
public class ScriptCommand {
@@ -77,7 +83,7 @@ namespace DSPRE.ROMFiles {
}
}
public ScriptCommand(string wholeLine, int lineNumber) {
public ScriptCommand(string wholeLine, int lineNumber = 0) {
name = wholeLine;
cmdParams = new List<byte[]>();

View File

@@ -5,6 +5,7 @@ using System.Resources;
using System.Windows.Forms;
using System.Linq;
using DSPRE.ROMFiles;
using System.Collections.Generic;
namespace DSPRE {
public partial class ROMToolboxDialog : Form {
@@ -415,10 +416,21 @@ namespace DSPRE {
} else {
ScriptFile itemScript = new ScriptFile(RomInfo.itemScriptFileNumber);
for (ushort i = 0; i < itemScript.allScripts.Count - 1; i++) {
itemScript.allScripts[i].commands[0].cmdParams[1] = BitConverter.GetBytes(i); // Fix item index
itemScript.allScripts[i].commands[1].cmdParams[1] = BitConverter.GetBytes((ushort)1); // Fix item quantity
int itemCount = new TextArchive(RomInfo.itemNamesTextNumber).messages.Count;
CommandContainer executeGive = new CommandContainer((uint)itemCount, itemScript.allScripts[itemScript.allScripts.Count-1]);
itemScript.allScripts.Clear();
for (ushort i = 0; i < itemCount; i++) {
List<ScriptCommand> cmdList = new List<ScriptCommand>();
cmdList.Add(new ScriptCommand("SetVar 0x8008 " + i));
cmdList.Add(new ScriptCommand("SetVar 0x8009 0x1"));
cmdList.Add(new ScriptCommand("Jump Function_#1"));
itemScript.allScripts.Add(new CommandContainer((ushort)(i + 1), ScriptFile.containerTypes.SCRIPT, commandList: cmdList));
}
itemScript.allScripts.Add(executeGive);
//itemScript.allFunctions[1].commands[0].cmdParams[]
itemScript.SaveToFileDefaultDir(RomInfo.itemScriptFileNumber, showSuccessMessage: false);
MessageBox.Show("Operation successful.", "Process completed.", MessageBoxButtons.OK, MessageBoxIcon.Information);