added `killall.js` option to kill only named scripts. fixed `void_server_buy_or_upgrade` regression that prevented it from working when you don't have servers.

[?]
Apr 14, 2020, 7:26 PM
BCM3TZOSIZSGCROXIWDIZBZPMWDAPUVYVFS6LJNMLMEI5AOMHFAQC

Dependencies

  • [2] VMXI7PS4 added action cap. improved scoring system. fixed parts of security and cash predictors. made lshw loopable.
  • [3] 2BKHJI2S init
  • [4] 3TYF4BJS target only hackable servers. replace servers continually.

Change contents

  • edit in lib/lib.js at line 33
    [3.3737375]
    [3.3737375]
    // ns.tprint(JSON.stringify(error));
  • edit in lib/lib.js at line 148
    [3.3740735]
    [3.3740735]
    // ns.tprint(JSON.stringify(error));
  • replacement in lib/lib.js at line 248
    [3.2036][3.2036:2058]()
    // catch (error) {
    [3.2036]
    [3.2058]
    // catch (error) {
    // ns.tprint(JSON.stringify(error));
  • edit in lib/lib.js at line 367
    [3.3219][3.3219:3256]()
    }
    else {
    return false;
  • edit in lib/lib.js at line 373
    [2.2385][3.3495:3611](),[3.3495][3.3495:3611]()
    const float_ram_server_bought_biggest = integer_get_server_ram_total(ns, string_get_server_bought_biggest(ns));
  • replacement in lib/lib.js at line 376
    [3.3789][2.2386:2467](),[2.2467][3.3749897:3750019](),[3.3861][3.3749897:3750019](),[3.3749897][3.3749897:3750019](),[3.3750019][2.2468:2639]()
    (integer_servers_bought_amount < object_constants.PurchasedServerLimit) &&
    // you dont own a server with max ram yet, buy a server with ram greater than the ram of your biggest bought server
    (float_ram_server_bought_biggest != object_constants.PurchasedServerMaxRam) &&
    (float_ram_server_bought_biggest < integer_get_server_ram_biggest_afforded(ns))
    [3.3789]
    [3.4023]
    (integer_servers_bought_amount < object_constants.PurchasedServerLimit)
  • replacement in lib/lib.js at line 379
    [3.4031][3.4031:4087]()
    return true;
    }
    else {
    return false;
    [3.4031]
    [3.4087]
    const float_ram_server_bought_biggest = integer_get_server_ram_total(ns, string_get_server_bought_biggest(ns));
    if (
    // you dont own a server with max ram yet, buy a server with ram greater than the ram of your biggest bought server
    (float_ram_server_bought_biggest != object_constants.PurchasedServerMaxRam) &&
    (float_ram_server_bought_biggest < integer_get_server_ram_biggest_afforded(ns))
    ) {
    return true;
    }
  • replacement in lib/lib.js at line 394
    [3.4377][2.2640:2727](),[2.2727][3.4555:4636](),[3.4555][3.4555:4636](),[3.4636][3.3750307:3750398](),[3.3750307][3.3750307:3750398](),[3.3750398][3.4637:4754](),[3.4754][2.2728:2815]()
    if (// you currently own less than the maximum amount of purchased servers allowed
    (integer_servers_bought_amount < object_constants.PurchasedServerLimit) &&
    // you already bought a server with max ram, buy another server the max possible ram
    (integer_get_server_ram_total(ns, string_get_server_bought_biggest(ns)) == float_ram_server_bought_maximum) &&
    (integer_get_server_ram_biggest_afforded(ns) >= float_ram_server_bought_maximum)
    [3.4377]
    [3.4841]
    if (// you have one or more servers already
    (integer_servers_bought_amount > 0) &&
    // you currently own less than the maximum amount of purchased servers allowed
    (integer_servers_bought_amount < object_constants.PurchasedServerLimit)
  • replacement in lib/lib.js at line 399
    [3.4849][3.4849:4868]()
    return true;
    [3.4849]
    [3.3750687]
    if (// you already bought a server with max ram, buy another server the max possible ram
    (integer_get_server_ram_total(ns, string_get_server_bought_biggest(ns)) == float_ram_server_bought_maximum) &&
    (integer_get_server_ram_biggest_afforded(ns) >= float_ram_server_bought_maximum)
    ) {
    return true;
    }
  • edit in lib/lib.js at line 406
    [3.3750693][3.4869:4906]()
    else {
    return false;
    }
  • replacement in bin/killall.js at line 4
    [3.3797253][3.3797253:3797680]()
    for (let integer_indices_0 = 0; integer_indices_0 < array_servers.length; ++integer_indices_0) {
    const array_scan_results = ns.scan(array_servers[integer_indices_0]);
    for (let integer_indices_1 = 0; integer_indices_1 < array_scan_results.length; ++integer_indices_1) {
    if (array_servers.indexOf(array_scan_results[integer_indices_1]) === -1) {
    array_servers.push(array_scan_results[integer_indices_1]);
    [3.3797253]
    [3.3797680]
    for (let integer_integer_indices_0 = 0; integer_integer_indices_0 < array_servers.length; ++integer_integer_indices_0) {
    const array_scan_results = ns.scan(array_servers[integer_integer_indices_0]);
    for (let integer_integer_indices_1 = 0; integer_integer_indices_1 < array_scan_results.length; ++integer_integer_indices_1) {
    if (array_servers.indexOf(array_scan_results[integer_integer_indices_1]) === -1) {
    array_servers.push(array_scan_results[integer_integer_indices_1]);
  • replacement in bin/killall.js at line 17
    [3.3797816][3.3797816:3797862]()
    const const_string_host = ns.getHostname();
    [3.3797816]
    [3.3797862]
    const string_host = ns.getHostname();
  • edit in bin/killall.js at line 19
    [3.3797912]
    [3.3797912]
    const array_arguments = Array.from(arguments)[1];
  • replacement in bin/killall.js at line 24
    [3.3798009][3.3798009:3798333]()
    for (var indices_0 = 0; indices_0 < array_of_servers.length; indices_0++) {
    const server = array_of_servers[indices_0];
    const scripts = ns.ps(server);
    // kill each script in the server
    for (var indices_1 = 0; indices_1 < scripts.length; indices_1++) {
    ns.scriptKill(scripts[indices_1].filename, server);
    [3.3798009]
    [3.3798333]
    for (let integer_indices_0 = 0; integer_indices_0 < array_of_servers.length; ++integer_indices_0) {
    const string_server = array_of_servers[integer_indices_0];
    // if arguments exist, kill the scripts with the same name in the server, otherwise, kill all scripts in the server
    if (array_arguments.length > 0) {
    for (let integer_indices_4 = 0; integer_indices_4 < array_arguments.length; ++integer_indices_4) {
    ns.scriptKill(array_arguments[integer_indices_4], string_server);
    }
  • edit in bin/killall.js at line 33
    [3.3798339]
    [3.3798339]
    else {
    const array_scripts_in_server = ns.ps(string_server);
    for (let integer_indices_1 = 0; integer_indices_1 < array_scripts_in_server.length; ++integer_indices_1) {
    ns.scriptKill(array_scripts_in_server[integer_indices_1].filename, string_server);
    }
    }
  • replacement in bin/killall.js at line 42
    [3.3798372][3.3798372:3798682]()
    let scripts_host = ns.ps(const_string_host);
    for (var indices_2 = 0; indices_2 < scripts_host.length; indices_2++) {
    // ensure current this script is killed last
    if (scripts_host[indices_2].filename != ns.getScriptName()) {
    ns.scriptKill(scripts_host[indices_2].filename, const_string_host);
    [3.3798372]
    [3.3798682]
    if (array_arguments.length > 0) {
    for (let integer_indices_5 = 0; integer_indices_5 < array_arguments.length; ++integer_indices_5) {
    if (array_arguments[integer_indices_5] != ns.getScriptName()) {
    ns.scriptKill(array_arguments[integer_indices_5], string_host);
    }
    }
    }
    else {
    const array_scripts_in_host = ns.ps(string_host);
    for (let integer_indices_2 = 0; integer_indices_2 < array_scripts_in_host.length; ++integer_indices_2) {
    // ensure current this script is killed last
    if (array_scripts_in_host[integer_indices_2].filename != ns.getScriptName()) {
    ns.scriptKill(array_scripts_in_host[integer_indices_2].filename, string_host);
    }
  • replacement in bin/killall.js at line 61
    [3.3798737][3.3798737:3798766]()
    void_kill_all_scripts(ns);
    [3.3798737]
    [3.3798766]
    const array_arguments = ns.args;
    void_kill_all_scripts(ns, array_arguments);