Interface Gang

Gang API

Remarks

If you are not in BitNode-2, then you must have Source-File 2 in order to use this API.

interface Gang {
    ascendMember(memberName): undefined | GangMemberAscension;
    canRecruitMember(): boolean;
    createGang(faction): boolean;
    getAscensionResult(memberName): undefined | GangMemberAscension;
    getBonusTime(): number;
    getChanceToWinClash(gangName): number;
    getEquipmentCost(equipName): number;
    getEquipmentNames(): string[];
    getEquipmentStats(equipName): EquipmentStats;
    getEquipmentType(equipName): string;
    getGangInformation(): GangGenInfo;
    getInstallResult(memberName): undefined | GangMemberInstall;
    getMemberInformation(name): GangMemberInfo;
    getMemberNames(): string[];
    getOtherGangInformation(): GangOtherInfo;
    getRecruitsAvailable(): number;
    getTaskNames(): string[];
    getTaskStats(name): GangTaskStats;
    inGang(): boolean;
    nextUpdate(): Promise<number>;
    purchaseEquipment(memberName, equipName): boolean;
    recruitMember(name): boolean;
    renameMember(memberName, newName): boolean;
    respectForNextRecruit(): number;
    setMemberTask(memberName, taskName): boolean;
    setTerritoryWarfare(engage): void;
}

Methods

  • Ascend a gang member.

    Parameters

    • memberName: string

      Name of member to ascend.

    Returns undefined | GangMemberAscension

    Object with info about the ascension results, or undefined if ascension did not occur.

    Remarks

    RAM cost: 4 GB

    Ascend the specified Gang Member.

  • Check if you can recruit a new gang member.

    Returns boolean

    True if a member can currently be recruited, false otherwise.

    Remarks

    RAM cost: 1 GB

    Returns a boolean indicating whether a member can currently be recruited.

    Once you have successfully created a gang by using the function createGang, you can immediately recruit a small number of members to your gang. After you have recruited the founding members, to recruit another member you must increase your respect. The more members you want to recruit, the more respect you require. If your gang has the maximum number of members, then this function would return false.

  • Create a gang.

    Parameters

    • faction: string

    Returns boolean

    True if the gang was created, false otherwise.

    Remarks

    RAM cost: 1GB

    Create a gang with the specified faction.

  • Get the result of an ascension without ascending.

    Parameters

    • memberName: string

      Name of member.

    Returns undefined | GangMemberAscension

    Object with info about the ascension results, or undefined if ascension is not possible.

    Remarks

    RAM cost: 2 GB

    Get a GangMemberAscension result for ascending a gang member without performing the ascension.

  • Get bonus time.

    Returns number

    Bonus time for the Gang mechanic in milliseconds.

    Remarks

    RAM cost: 0 GB

    Returns the amount of accumulated “bonus time” (milliseconds) for the Gang mechanic.

    “Bonus time” is accumulated when the game is offline or if the game is inactive in the browser.

    “Bonus time” makes the game progress faster, up to 25x the normal speed.

  • Get chance to win clash with other gang.

    Parameters

    • gangName: string

      Target gang

    Returns number

    Chance you have to win a clash with the specified gang.

    Remarks

    RAM cost: 4 GB

    Returns the chance you have to win a clash with the specified gang. The chance is returned in decimal form, not percentage

  • Get cost of equipment.

    Parameters

    • equipName: string

      Name of equipment.

    Returns number

    Cost to purchase the specified Equipment/Augmentation (number). Infinity for invalid arguments

    Remarks

    RAM cost: 2 GB

    Get the amount of money it takes to purchase a piece of Equipment or an Augmentation. If an invalid Equipment/Augmentation is specified, this function will return Infinity.

  • List equipment names.

    Returns string[]

    Names of all Equipments/Augmentations.

    Remarks

    RAM cost: 1 GB

    Get the name of all possible equipment/upgrades you can purchase for your Gang Members. This includes Augmentations.

  • Get type of an equipment.

    Parameters

    • equipName: string

      Name of equipment.

    Returns string

    Type of the equipment.

    Remarks

    RAM cost: 2 GB

    Get the specified equipment type.

  • Get the effect of an install on ascension multipliers without installing.

    Parameters

    • memberName: string

      Name of member.

    Returns undefined | GangMemberInstall

    Object with info about the install results on ascension multipliers, or undefined if ascension is not possible.

    Remarks

    RAM cost: 2 GB

    Get GangMemberInstall effects on ascension multipliers for a gang member after installing without performing the install.

  • Get information about a specific gang member.

    Parameters

    • name: string

      Name of member.

    Returns GangMemberInfo

    Object containing stat and equipment-related information about a Gang Member.

    Remarks

    RAM cost: 2 GB

    Get stat and equipment-related information about a Gang Member

  • List all gang members.

    Returns string[]

    Names of all Gang members.

    Remarks

    RAM cost: 1 GB

    Get the names of all Gang members

  • Get information about the other gangs.

    Returns GangOtherInfo

    Object containing territory and power information about all gangs.

    Remarks

    RAM cost: 2 GB

    Get territory and power information about all gangs.

  • Check how many gang members you can currently recruit.

    Returns number

    Number indicating how many members can be recruited, considering current reputation and gang size.

    Remarks

    RAM cost: 1 GB

  • List member task names.

    Returns string[]

    All valid tasks that Gang members can be assigned to.

    Remarks

    RAM cost: 1 GB

    Get the name of all valid tasks that Gang members can be assigned to.

  • Get stats of a task.

    Parameters

    • name: string

      Name of the task.

    Returns GangTaskStats

    Detailed stats of a task.

    Remarks

    RAM cost: 1 GB

    Get the stats of a gang task stats. This is typically used to evaluate which action should be executed next.

  • Check if you're in a gang.

    Returns boolean

    True if you're in a gang, false otherwise.

    Remarks

    RAM cost: 1GB

  • Sleeps until the next Gang update has happened.

    Returns Promise<number>

    Promise that resolves to the number of milliseconds of Gang time that were processed in the previous update (2000 - 5000 ms).

    Remarks

    RAM cost: 1 GB

    The amount of real time spent asleep between updates can vary due to "bonus time".

    Example

    while (true) {
    const duration = await ns.gang.nextUpdate();
    ns.print(`Gang completed ${ns.tFormat(duration)} of activity.`);
    ns.print(`Bonus time remaining: ${ns.tFormat(ns.gang.getBonusTime())}`);
    // Manage the Gang
    }
  • Purchase an equipment for a gang member.

    Parameters

    • memberName: string

      Name of Gang member to purchase the equipment for.

    • equipName: string

      Name of Equipment/Augmentation to purchase.

    Returns boolean

    True if the equipment was successfully purchased. False otherwise

    Remarks

    RAM cost: 4 GB

    Attempt to purchase the specified Equipment/Augmentation for the specified Gang member.

  • Recruit a new gang member.

    Parameters

    • name: string

      Name of member to recruit.

    Returns boolean

    True if the member was successfully recruited, false otherwise.

    Remarks

    RAM cost: 2 GB

    Attempt to recruit a new gang member.

    Possible reasons for failure:

    • Cannot currently recruit a new member
    • There already exists a member with the specified name
  • Rename a Gang member to a new unique name.

    Parameters

    • memberName: string

      Name of the member to change.

    • newName: string

      New name for that gang member.

    Returns boolean

    True if successful, and false if not.

    Remarks

    RAM cost: 0 GB

    Rename a Gang Member if none already has the new name.

  • Check the amount of Respect needed for your next gang recruit.

    Returns number

    The static number value of Respect needed for the next recruit, with consideration to your current gang size. Returns Infinity if you have reached the gang size limit.

    Remarks

    RAM cost: 1 GB

  • Set gang member to task.

    Parameters

    • memberName: string

      Name of Gang member to assign.

    • taskName: string

      Task to assign.

    Returns boolean

    True if the Gang Member was successfully assigned to the task, false otherwise.

    Remarks

    RAM cost: 2 GB

    Attempts to assign the specified Gang Member to the specified task. If an invalid task is specified, the Gang member will be set to idle (“Unassigned”).

  • Enable/Disable territory clashes.

    Parameters

    • engage: boolean

      Whether or not to engage in territory clashes.

    Returns void

    Remarks

    RAM cost: 2 GB

    Set whether or not the gang should engage in territory clashes