const object_get_stats = (object_netscript) => {
try {
return object_netscript.getStats();
throw new Error("WARNING: Uncommented the call to `getStats`.");
}
catch (object_exception) {
object_netscript.print(`${JSON.stringify(object_exception)}\nUsing default values instead.`);
return {
hacking: object_netscript.getHackingLevel(),
strength: 1,
defense: 1,
dexterity: 1,
agility: 1,
charisma: 1,
intelligence: 1
};
}
};
export const float_get_time_hack = ({
object_netscript: n,
string_server: r,
float_server_security: c,
float_skill_hacking: h,
float_intelligence: i,
}) => {
const object_stats = object_get_stats(n),
Player = {
hacking_skill: object_stats.hacking,
intelligence: object_stats.intelligence,
hacking_speed_mult: n.getHackingMultipliers().speed,
};
function calculateHackingTime(server, float_hack, int) {
const difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
const baseDiff = 500;
const baseSkill = 50;
const diffFactor = 2.5;
const intFactor = 0.1;
if (float_hack == null) {float_hack = Player.hacking_skill;}
if (int == null) {int = Player.intelligence;}
var skillFactor = (diffFactor * difficultyMult + baseDiff);
skillFactor /= (float_hack + baseSkill + (intFactor * int));
const hackTimeMultiplier = 5;
const hackingTime = hackTimeMultiplier * skillFactor / Player.hacking_speed_mult;
return hackingTime;
}
return calculateHackingTime(
{
requiredHackingSkill: n.getServerRequiredHackingLevel(r),
hackDifficulty: c,
},
h,
i
);
};
export const float_get_time_grow = ({
object_netscript: n,
string_server: r,
float_server_security: c,
float_skill_hacking: h,
float_intelligence: i,
}) => {
const calculateHackingTime = (r, h, i) => float_get_time_hack({
object_netscript: n,
string_server: r,
float_server_security: c,
float_skill_hacking: h,
float_intelligence: i,
});
function calculateGrowTime(server, float_hack, int) {
const growTimeMultiplier = 3.2;
return growTimeMultiplier * calculateHackingTime(server, float_hack, int);
}
return calculateGrowTime(r, h, i);
};
export const float_get_time_weaken = ({
object_netscript: n,
string_server: r,
float_server_security: c,
float_skill_hacking: h,
float_intelligence: i,
}) => {
const calculateHackingTime = (r, h, i) => float_get_time_hack({
object_netscript: n,
string_server: r,
float_server_security: c,
float_skill_hacking: h,
float_intelligence: i,
});
function calculateWeakenTime(server, float_hack, int) {
const weakenTimeMultiplier = 4;
return weakenTimeMultiplier * calculateHackingTime(server, float_hack, int);
}
return calculateWeakenTime(r, h, i);
};