Skip to content

External Mod API

Sninctbur edited this page Mar 6, 2021 · 9 revisions

Want to make addons that play with Bio-Annihilation II? Here are some internals of BA2 that could help:

Variables

Shared:

BA2_MODVERSION: A string containing the current version and edition (Workshop/Git) of Bio-Annihilation II being run.

DMG_BIOVIRUS: To be used with CTakeDamageInfo:SetDamageCustom(). If an entity is killed by damage with this custom damage type, they will become a zombie. An alternative way to raise zombies through damage if you don't want to change the inflictor. It's recommended to use the latter method when possible, because this might not work if the damage is too high. (Release Update 0+)

Server:

ent.BA2Infection: Accesses an entity ent's current infection quantity.

Networked:

These variables must be retrieved with a corresponding function, such as GetNWInt for integers.

int "BA2GasmaskFilterPct": The player's current gas mask filter percentage. Despite being a networked integer, it can be a decimal. Just don't question it.

int "BA2GasmaskFilters": The number of filters a player is currently carrying.

bool "BA2GasmaskOn": Returns true if a player is currently wearing a gas mask.

bool "BA2GasmaskOwned": Returns true if a player has a gas mask, whether they're wearing it or not.

Functions

In order to use the below functions, you MUST add this line to the top of your code:

include("ba2/methods.lua")

Server:

BA2_AddInfection(Entity ent,int amnt): Adds amnt infection to ent. amnt must be positive.

BA2_InfectionManager(): Returns the Infection Manager entity, and creates one if it doesn't exist. DamageInfo with the Infection Manager as the INFLICTOR will raise zombies if it kills.

BA2_RaiseZombie(Entity ent): Raises ent as a zombie, keeping its skin and bodygroups. ent can techincally be anything with a model, but it is designed to use an NPC, player, or ragdoll.

Zombie Struct

If you manually create nb_ba2_infected, you can set these properties before you initialize it:

Color ColorOverride: If set, the zombie will spawn with this color.

String/table InfBody: The model the zombie will use. Can be a single model path or a table of model paths. If a table is used, the zombie will use a random entry in the table as its model. Must be set manually.

table InfBodyGroups: The bodygroups the zombie will use. Bodygroups can be obtained from an existing entity with ent:GetBodyGroups(). If unset, all bodygroups will be randomized.

int InfSkin: The skin number the zombie will use. If unset, a random skin will be used.

int InfVoice: The voice the zombie will use:

  • 0: Male
  • 1: Female
  • 2: Combine
  • 3: Soldier

If unset, the voice will be automatically set based on its model path.

bool noRise: If set to true, the zombie won't play its "getting up" animation when it spawns in.

Clone this wiki locally