Module ORGM.Ammo

Functions for dealing with ammo.

Info:

  • Copyright: 2018 File: shared/2LoadOrder/ORGMAmmo.lua
  • Release: 3.09
  • Author: Fenris_Wolf

Functions

register (name, ammoData) Registers a ammo type with ORGM.
deregister (name) Deregisters Ammo from ORGM.
random ([thisTable]) Returns the name of a random ammo item.
getTable () Gets the table of registered ammo.
getData (itemType[, moduleName]) Gets a value from the AmmoTable, supports module checking.
isAmmo (itemType[, moduleName]) Checks if a item is ORGM ammo.
isCase (itemType) Checks if a item is ORGM spent casing.
getGroupTable () Gets the table of ammo groups.
getGroup (groupName) Returns the ammo group table for the specified groupName.
itemGroup (item[, asTable]) Gets the ammoGroup string name or table of valid ammo for this item.
findIn (ammoGroup, ammoType, container[, mode]) Finds the best matching ammo (bullets only) in a container.
findAllIn (ammoGroup, containerItem) Finds and returns all ammo for the ammoGroup in the container, including boxes and canisters.
convertAllIn (groupName, containerItem) Converts all AmmoGroup rounds of the given name to real ammo.
boxType (item) Returns the type of ammo opening a box (or can) will yeild.
unbox (item) Unboxes a box (or canister), placing all rounds in the container.


Functions

Methods
register (name, ammoData)
Registers a ammo type with ORGM.

This must be called before any registerMagazine or registerFirearm that plans to use that ammo.

NOTE: this should only be called with real ammo (ie: Ammo_9x19mm_FMJ) and not AmmoGroup (ie: Ammo_9x19mm)

Parameters:

  • name string name without module prefix.
  • ammoData table

    Valid table keys/value pairs for the ammoData are:

    • moduleName = string, module name this item is from. If nil, ORGM is used

    • MinDamage = float, (>= 0) the min damage of the bullet. This overrides the firearm item MinDamage

    • MaxDamage = float, (>= MinDamage) the max damage of the bullet. This overrides the firearm item MaxDamage

    • Penetration = bool|int, (% chance) This overrides the firearm item PiercingBullets

    • PiercingBullets = bool|int, (% chance) This overrides the firearm item PiercingBullets (DEPRECIATED, use Penetration)

    • MaxHitCount = nil|int, This overrides the firearm item MaxHitCount. Only valid for firearms with multiple projectiles (ie: shotguns)

    • Case = nil|string, the empty case to eject

    • UseWith = nil|table, the AmmoGroup names this ammo can be used for. if nil, the name parameter is used

    • BoxCount = int, the number of rounds that come in a box.

    • CanCount = int, the number of rounds that come in a canister.

    • OptimalBarrel = int, the length of the barrel required to reach ‘full powder burn’. This should generally be 30 for pistol calibers, 80 for rifle rounds, and 60 for shotguns.

    • Recoil = int, the recoil factor applied to this round. Increased by shorter barrels.

    • Range = int, the max effective range for this round, Reduced from shorter barrels.

Returns:

    bool true on success.
deregister (name)
Deregisters Ammo from ORGM.

WARNING: Incomplete code, do not use.

Parameters:

  • name string name without module prefix

Returns:

    bool true on success
random ([thisTable])
Returns the name of a random ammo item.

Parameters:

  • thisTable table table to select from. (optional)

Returns:

    string the random ammo name.
getTable ()
Gets the table of registered ammo.

Returns:

    table all registered ammo setup by ORGM.Ammo.register
getData (itemType[, moduleName])
Gets a value from the AmmoTable, supports module checking.

Parameters:

  • itemType string or InventoryItem
  • moduleName string module to compare (optional)

Returns:

    table data of a registered ammo setup by ORGM.Ammo.register
isAmmo (itemType[, moduleName])
Checks if a item is ORGM ammo.

Parameters:

  • itemType string or InventoryItem
  • moduleName string module to compare (optional)

Returns:

    bool true if registered ammo setup by ORGM.Ammo.register
isCase (itemType)
Checks if a item is ORGM spent casing.

Parameters:

  • itemType string or InventoryItem

Returns:

    bool
getGroupTable ()
Gets the table of ammo groups.

Returns:

    table keys are group names, values are table arrays of ammo names.
getGroup (groupName)
Returns the ammo group table for the specified groupName.

The table contains all the ammo types that can be used for this group.

Parameters:

  • groupName string name of a ammo group

Returns:

    nil or table list of real ammo names
itemGroup (item[, asTable])
Gets the ammoGroup string name or table of valid ammo for this item.

Parameters:

  • item string or InventoryItem
  • asTable nil or bool true if the results returned should be a table (optional)

Returns:

    string or table ammo group name, or a table list of strings
findIn (ammoGroup, ammoType, container[, mode])
Finds the best matching ammo (bullets only) in a container.

Finds loose bullets, boxes and canisters of ammo. Search is based on the given ammoGroup name and preferred type. (can be specific round name, nil/any, or mixed)

This is called when reloading some guns and all magazines.

Note ammoGroup and ammoType should NOT have the “ORGM.” prefix.

Parameters:

  • ammoGroup string name of a AmmoGroup.
  • ammoType nil or string ‘any’, ‘mixed’ or a specific ammo name
  • container ItemContainer
  • mode nil or int 0 = rounds, 1 = box, 2 = can (optional)

Returns:

    nil or InventoryItem
findAllIn (ammoGroup, containerItem)
Finds and returns all ammo for the ammoGroup in the container, including boxes and canisters.

Parameters:

  • ammoGroup string the name of a AmmoGroup
  • containerItem ItemContainer

Returns:

    table keys are ‘rounds’, ‘boxes’ and ‘cans’, values are java ArrayList objects of InventoryItem objects
convertAllIn (groupName, containerItem)
Converts all AmmoGroup rounds of the given name to real ammo.

The first entry in the AmmoGroupTable for this name will be used Note groupName and preferredType should NOT have the “ORGM.” prefix.

Parameters:

  • groupName string the name of a AmmoGroup
  • containerItem ItemContainer

Returns:

    nil or int number of rounds converted (nil on error)
boxType (item)
Returns the type of ammo opening a box (or can) will yeild.

This assumes a strict naming convention was used for the ammo and Unboxes.

ie: ORGM standard names: Ammo_9x19mm_FMJ and Ammo_9x19mm_FMJ_Box

Parameters:

  • item string or InventoryItem the box or canister.

Returns:

    nil or string name of ammo inside the container.
unbox (item)
Unboxes a box (or canister), placing all rounds in the container.

Parameters:

  • item InventoryItem the item to be unboxed.
generated by LDoc 1.4.3 Last updated 2019-04-11 18:37:45