Skip to content
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

bladeburner.setActionLevel does not throw an error when an invalid level is passed and allows any level to be set #3963

Closed
MPJ-K opened this issue Aug 7, 2022 · 8 comments · Fixed by #4049

Comments

@MPJ-K
Copy link
Contributor

MPJ-K commented Aug 7, 2022

The title pretty much says it all. Game version is v1.7.0 (cfcdc25). EDIT: Issue still exists in v2.0.2 (3067703c).
The bladeburner.setActionLevel() function will allow any level to be set, even if it is above the maximum level. This allows the player to cheat in bladeburner, because actions will work at the set level. I have not tried setting negative levels, because I fear it will break the game.

I do not sufficiently understand the source code to suggest an exact fix. However, I did notice that in this file, (line 253) ctx.helper.MakeRuntimeErrorMsg() is used, while every other call to this function uses ctx.MakeRuntimeErrorMsg(). Perhaps that is where the problem lies.

@phyzical
Copy link
Contributor

phyzical commented Aug 9, 2022

hmm looking at the source it should be enforcing the maxlevel

const action = getBladeburnerActionObject("setActionLevel", type, name);
      if (level < 1 || level > action.maxLevel) {
        throw helper.makeRuntimeErrorMsg(
          "bladeburner.setActionLevel",
          `Level must be between 1 and ${action.maxLevel}, is ${level}`,
        );
      }
      action.level = level;

@MPJ-K
Copy link
Contributor Author

MPJ-K commented Aug 9, 2022

Not sure what file that is from, but I was looking in bitburner/src/NetscriptFunctions/Bladeburner.ts. Like I mentioned before, every call to makeRuntimeErrorMsg() in that file uses the ctx. prefix, while for setActionLevel() the prefix is ctx.helper.. Maybe the ".helper" needs to be removed.

I also tried validating my game files and the problem did not go away.

@MPJ-K
Copy link
Contributor Author

MPJ-K commented Aug 11, 2022

I am doing Bladeburner again so I took this image showing an action's level exceeding the maximum after running ns.bladeburner.setActionLevel("Contract", "Tracking", 20);.

BitburnerSetActionLevelBug

@phyzical
Copy link
Contributor

@MPJ-K hmm yeah its clearly not working as intended thanks for the image confirmation.

the code above is where you have linked. const level = ctx.helper.number("level", _level); all this will do is convert strings or whatever to a number, i guess its possible something has gone wrong but even if it was a string still js would handle that correctly

so all i can think is that the object itself is not holding the correct "maxLevel" to what is seen in the ui 🤔

@MPJ-K
Copy link
Contributor Author

MPJ-K commented Aug 12, 2022

@phyzical I tested the action object in-game using a small test script:

ns.tprint(ns.bladeburner.getActionMaxLevel("Contract", "Tracking"));
ns.bladeburner.setActionLevel("Contract", "Tracking", 20);
ns.tprint(ns.bladeburner.getActionMaxLevel("Contract", "Tracking"));

The maxLevel is correctly returned both before and after setting the invalid level.

What I find curious is that in the code block you commented earlier there is a throw before the error, while there is no throw in the file I linked. If the error was not being thrown that would explain why maxLevel is correct and invalid levels can be set. I also tested setting the level to -100, which works (see image). This further confirms that maxLevel is not the problem.

BitburnerSetActionLevelBug2

@phyzical
Copy link
Contributor

Ah! good spot, well that just means its fixed in 2.0 already :)

@MPJ-K
Copy link
Contributor Author

MPJ-K commented Aug 17, 2022

@phyzical I just tested the issue again in v2.0.1 (69934257) and it has NOT been fixed. Perhaps the fix is in an unmerged branch?

@phyzical
Copy link
Contributor

hmmmm ill give it a test myself tonight 👍

hydroflame added a commit that referenced this issue Aug 29, 2022
NETSCRIPT: FIX #3963 Prevent bladeburner.setActionLevel from setting invalid action levels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants