Class ISORGMWeapon

This serves as a wrapper between PZ’s Reloadable system and the ORGM.ReloadableWeapon.

Most functions have been moved there, as it allows for the same functions on both ISORGMWeapon objects and a HandWeapon/InventoryItem’s modData. As such method calls in here are depreciated, as they are no longer called for by anywhere else in this file, and should be removed at a later date.

Info:

  • Copyright: 2018 File: shared/3LoadOrder/ISORGMWeapon.lua
  • Release: 3.09
  • Author: Fenris_Wolf

Attacking Methods

ISORGMWeapon:isLoaded (difficulty) Called to determine if ISORGMWeapon:fireShot should be called in ISReloadManager:checkLoaded.
ISORGMWeapon:preFireShot (difficulty, playerObj, weaponItem) Called before the IsoPlayer.DoAttack in ISReloadManager:checkLoaded.
ISORGMWeapon:fireShot (weaponItem, difficulty) Called after the IsoPlayer.DoAttack in ISReloadManager:checkLoaded`.
ISORGMWeapon:fireEmpty (playerObj, weaponItem) Called when the trigger is pulled on a empty chamber in ISReloadManager:checkLoaded.

Reload Action Methods

ISORGMWeapon:canReload (playerObj) Called at the start of a reload timed action.
ISORGMWeapon:isReloadValid (playerObj, square, difficulty) Checks if the reload timed action is still valid.
ISORGMWeapon:reloadStart (playerObj, square, difficulty) Called at the start of the reload timed action.
ISORGMWeapon:reloadPerform (playerObj, square, difficulty, weaponItem) Called at completion of the reload timed action.
ISORGMWeapon:getReloadTime () Returns the time it takes to perform the reload timed action.
ISORGMWeapon:getReloadText () Gets the translated context menu text for reloading.
ISORGMWeapon:isChainReloading () Checks if a reload action should be performed immediately after this one.

Unload Action Methods

ISORGMWeapon:canUnload (playerObj) Called at the start of a unload timed action.
ISORGMWeapon:isUnloadValid (playerObj, square, difficulty) Checks if the unload timed action is still valid.
ISORGMWeapon:unloadStart (playerObj, square, difficulty) Called at the start of the unload timed action.
ISORGMWeapon:unloadPerform (playerObj, square, difficulty, weaponItem) Called at completion of the unload timed action.
ISORGMWeapon:isChainUnloading () Checks if a unload action should be performed immediately after this one.

Rack Action Methods

ISORGMWeapon:canRack (playerObj) Called at the start of a reack timed action.
ISORGMWeapon:rackingStart (playerObj, square, weaponItem) Called at the start of the rack timed action.
ISORGMWeapon:rackingPerform (playerObj, square, weaponItem) Called at completion of the rack timed action.
ISORGMWeapon:getRackTime () Returns the time it takes to perform the reload timed action.

Magazine Methods

ISORGMWeapon:ejectMagazine (playerObj[, playSound]) Ejects the current magazine and adds it to the players inventory.
ISORGMWeapon:insertMagazine (playerObj[, playSound]) Inserts the best magazine from the players inventory into the firearm.
ISORGMWeapon:setupMagazine (magItem) Sets up the ISReloadableMagazine on the InventoryItem

Depreciated Methods

ISORGMWeapon:createMagazine () DEPRECIATED.
ISORGMWeapon:loadRoundIntoMagazine (ammoType, weaponItem, position) DEPRECIATED.
ISORGMWeapon:convertAmmoGroupRound (ammoType) DEPRECIATED.
ISORGMWeapon:findBestMagazine (playerObj, ammoType) DEPRECIATED.
ISORGMWeapon:findBestAmmo (playerObj) DEPRECIATED.
ISORGMWeapon:getMagazineAtPosition (position) DEPRECIATED.
ISORGMWeapon:getMagazineAtNextPosition (wrap) DEPRECIATED.
ISORGMWeapon:emptyMagazineAtOnce (playerObj, playSound) DEPRECIATED.
ISORGMWeapon:hasEmptyCasesInMagazine () DEPRECIATED.
ISORGMWeapon:feedNextRound (playerObj, weaponItem) DEPRECIATED.
ISORGMWeapon:setCurrentRound (ammoType, weaponItem) DEPRECIATED.
ISORGMWeapon:cockHammer (playerObj, playSound, weaponItem) DEPRECIATED.
ISORGMWeapon:releaseHammer (playerObj, playSound) DEPRECIATED.
ISORGMWeapon:openSlide (playerObj, playSound, weaponItem) DEPRECIATED.
ISORGMWeapon:closeSlide (playerObj, playSound, weaponItem) DEPRECIATED.
ISORGMWeapon:rotateCylinder (count, playerObj, playSound, weaponItem) DEPRECIATED.
ISORGMWeapon:openCylinder (playerObj, playSound, weaponItem) DEPRECIATED.
ISORGMWeapon:closeCylinder (playerObj, playSound, weaponItem) DEPRECIATED.
ISORGMWeapon:openBreak (playerObj, playSound, weaponItem) DEPRECIATED.
ISORGMWeapon:closeBreak (playerObj, playSound, weaponItem) DEPRECIATED.

Setup and Sync Methods

ISORGMWeapon:syncItemToReloadable (weaponItem) Copies modData from the weaponItem to the reloadable object.
ISORGMWeapon:syncReloadableToItem (weaponItem) Copies properties of the reloadable object to the weaponItem’s modData.


Attacking Methods

These are called from ISReloadManager:checkLoaded()
ISORGMWeapon:isLoaded (difficulty)
Called to determine if ISORGMWeapon:fireShot should be called in ISReloadManager:checkLoaded.

Parameters:

  • difficulty int players reloading difficulty, not used

Returns:

    bool
ISORGMWeapon:preFireShot (difficulty, playerObj, weaponItem)
Called before the IsoPlayer.DoAttack in ISReloadManager:checkLoaded.

Parameters:

  • difficulty int players reloading difficulty, not used
  • playerObj IsoPlayer
  • weaponItem HandWeapon

Returns:

    bool true if the attack can continue.

Usage:

    local result = reloadable:preFireShot(3, playerObj, weaponItem)
ISORGMWeapon:fireShot (weaponItem, difficulty)
Called after the IsoPlayer.DoAttack in ISReloadManager:checkLoaded`.

Parameters:

  • weaponItem HandWeapon
  • difficulty int players reloading difficulty, not used

Usage:

    reloadable:fireShot(weaponItem, 3)
ISORGMWeapon:fireEmpty (playerObj, weaponItem)
Called when the trigger is pulled on a empty chamber in ISReloadManager:checkLoaded.

Parameters:

  • playerObj IsoPlayer
  • weaponItem HandWeapon

Usage:

    reloadable:fireShot(playerObj, weaponItem)

Reload Action Methods

Methods relating to the reload timed action.
ISORGMWeapon:canReload (playerObj)
Called at the start of a reload timed action.

Parameters:

  • playerObj IsoPlayer

Returns:

    bool true if the timed action can start.

Usage:

    local result = reloadable:canReload(playerObj)
ISORGMWeapon:isReloadValid (playerObj, square, difficulty)
Checks if the reload timed action is still valid.

Parameters:

  • playerObj IsoPlayer
  • square IsoGridSquare
  • difficulty int players reloading difficulty, not used

Returns:

    bool true to continue, false to halt.

Usage:

    local result = reloadable:isReloadValid(playerObj, square, 3)
ISORGMWeapon:reloadStart (playerObj, square, difficulty)
Called at the start of the reload timed action.

Parameters:

  • playerObj IsoPlayer
  • square IsoGridSquare
  • difficulty int players reloading difficulty, not used

Usage:

    reloadable:reloadStart(playerObj, square, 3)
ISORGMWeapon:reloadPerform (playerObj, square, difficulty, weaponItem)
Called at completion of the reload timed action.

Parameters:

  • playerObj IsoPlayer
  • square IsoGridSquare
  • difficulty int players reloading difficulty, not used
  • weaponItem HandWeapon

Usage:

    reloadable:reloadPerform(playerObj, square, 3, weaponItem)
ISORGMWeapon:getReloadTime ()
Returns the time it takes to perform the reload timed action.

Returns:

    integer the reload time.

Usage:

    local time = reloadable:getReloadTime()
ISORGMWeapon:getReloadText ()
Gets the translated context menu text for reloading.

Returns:

    string the translated text

Usage:

    local text = reloadable:getReloadText()
ISORGMWeapon:isChainReloading ()
Checks if a reload action should be performed immediately after this one.

Does not take into account ammunition availability.

Returns:

    bool true if the reloading should continue.

Usage:

    local result = reloadable:isChainReloading()

Unload Action Methods

Methods relating to the unload timed action.
ISORGMWeapon:canUnload (playerObj)
Called at the start of a unload timed action.

Parameters:

  • playerObj IsoPlayer

Returns:

    bool true if the timed action can start.

Usage:

    local result = reloadable:canUnload(playerObj)
ISORGMWeapon:isUnloadValid (playerObj, square, difficulty)
Checks if the unload timed action is still valid.

Parameters:

  • playerObj IsoPlayer
  • square IsoGridSquare
  • difficulty int players reloading difficulty, not used

Returns:

    bool true to continue, false to halt.

Usage:

    local result = reloadable:isUnloadValid(playerObj, square, 3)
ISORGMWeapon:unloadStart (playerObj, square, difficulty)
Called at the start of the unload timed action.

Parameters:

  • playerObj IsoPlayer
  • square IsoGridSquare
  • difficulty int players reloading difficulty, not used

Usage:

    reloadable:unloadStart(playerObj, square, 3)
ISORGMWeapon:unloadPerform (playerObj, square, difficulty, weaponItem)
Called at completion of the unload timed action.

Parameters:

  • playerObj IsoPlayer
  • square IsoGridSquare
  • difficulty int players reloading difficulty, not used
  • weaponItem HandWeapon

Usage:

    reloadable:unloadPerform(playerObj, square, 3, weaponItem)
ISORGMWeapon:isChainUnloading ()
Checks if a unload action should be performed immediately after this one.

Returns:

    bool true if the unloading should continue.

Usage:

    local result = reloadable:isChainUnloading()

Rack Action Methods

Methods relating to the racking timed action.
ISORGMWeapon:canRack (playerObj)
Called at the start of a reack timed action.

On Easy/Normal this returns false if there is already a round chambered.

Parameters:

  • playerObj IsoPlayer

Returns:

    bool true if the timed action can start.

Usage:

    local result = reloadable:canRack(playerObj)
ISORGMWeapon:rackingStart (playerObj, square, weaponItem)
Called at the start of the rack timed action.

Parameters:

  • playerObj IsoPlayer
  • square IsoGridSquare
  • weaponItem HandWeapon

Usage:

    reloadable:rackingStart(playerObj, square, weaponItem)
ISORGMWeapon:rackingPerform (playerObj, square, weaponItem)
Called at completion of the rack timed action.

Parameters:

  • playerObj IsoPlayer
  • square IsoGridSquare
  • weaponItem HandWeapon

Usage:

    reloadable:rackingPerform(playerObj, square, weaponItem)
ISORGMWeapon:getRackTime ()
Returns the time it takes to perform the reload timed action.

Returns:

    int the reload time.

Usage:

    local time = reloadable:getReloadTime()

Magazine Methods

ISORGMWeapon:ejectMagazine (playerObj[, playSound])
Ejects the current magazine and adds it to the players inventory.

Parameters:

  • playerObj IsoPlayer
  • playSound bool if true plays the ejectSound (optional)

Usage:

    reloadable:ejectMagazine(playerObj, true)
ISORGMWeapon:insertMagazine (playerObj[, playSound])
Inserts the best magazine from the players inventory into the firearm.

Parameters:

  • playerObj IsoPlayer
  • playSound bool if true plays the insertSound (optional)

Usage:

    reloadable:insertMagazine(playerObj, true)
ISORGMWeapon:setupMagazine (magItem)
Sets up the ISReloadableMagazine on the InventoryItem

Parameters:

  • magItem InventoryItem to add ISReloadableMagazine to.

Depreciated Methods

ISORGMWeapon:createMagazine ()
DEPRECIATED. Creates a new magazine for this weapon type and transfers some modData

Usage:

    local magItem = reloadable:createMagazine()
ISORGMWeapon:loadRoundIntoMagazine (ammoType, weaponItem, position)
DEPRECIATED. Loads a round into a internal magazine or cylinder.

Parameters:

  • ammoType a string name of a registered ORGM ammo
  • weaponItem a HandWeapon/InventoryItem
  • position integer (or nil) of position to insert the round at. If nil it is appended to the list.

Usage:

    reloadable:loadRoundIntoMagazine('Ammo_9x19mm_FMJ', weaponItem, nil)
ISORGMWeapon:convertAmmoGroupRound (ammoType)
DEPRECIATED. Converts a AmmoGroup round to a real round if required.

Parameters:

  • ammoType a string name of a AmmoGroup or registered ORGM ammo

Returns:

    string, the name of the first ammo in the group or ammoType if a real ammo was already passed in.

Usage:

    local result = reloadable:convertAmmoGroupRound('Ammo_9x19mm')
ISORGMWeapon:findBestMagazine (playerObj, ammoType)
DEPRECIATED. Finds and returns the best magazine available in the players inventory.

Parameters:

  • playerObj a IsoPlayer object
  • ammoType nil (auto detected), or string name of a registered ORGM magazine

Returns:

    InventoryItem, the best suited magazine, or nil.

Usage:

    local magItem = reloadable:findBestMagazine(playerObj, nil)
ISORGMWeapon:findBestAmmo (playerObj)
DEPRECIATED. Finds and returns the best ammo available in the players inventory.

Parameters:

  • playerObj a IsoPlayer object

Returns:

    InventoryItem, the best suited ammo, or nil.

Usage:

    local magItem = reloadable:findBestAmmo(playerObj)
ISORGMWeapon:getMagazineAtPosition (position)
DEPRECIATED. Gets the ammo at specified position.

Parameters:

  • position integer, the index position to get.

Returns:

    string, the ammo (or case) name at the position, or nil.

Usage:

    local ammoType = reloadable:getMagazineAtPosition(position)
ISORGMWeapon:getMagazineAtNextPosition (wrap)
DEPRECIATED. Gets the ammo at the next position.

Parameters:

  • wrap boolean, if we should wrap around back to the begining past maxCapacity. true for rotary actions.

Returns:

    string, the ammo (or case) name at the next position, or nil.

Usage:

    local ammoType = reloadable:getMagazineAtNextPosition(true)
ISORGMWeapon:emptyMagazineAtOnce (playerObj, playSound)
DEPRECIATED. Ejects all shells (live and spent) onto the ground.

Used primarly with revolvers and break barrels on opening.

Parameters:

  • playerObj a IsoPlayer object
  • playSound boolean, plays the ejectSound if true

Usage:

    reloadable:emptyMagazineAtOnce(playerObj, true)
ISORGMWeapon:hasEmptyCasesInMagazine ()
DEPRECIATED. Gets the number of empty cases in the magazine/cylinder.

Returns:

    integer, number of spent cases

Usage:

    local count = reloadabe:hasEmptyCasesInMagazine()
ISORGMWeapon:feedNextRound (playerObj, weaponItem)
DEPRECIATED. Loads the next round into the chamber

Parameters:

  • playerObj a IsoPlayer object
  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadabe:feedNextRound(playerObj, weaponItem)
ISORGMWeapon:setCurrentRound (ammoType, weaponItem)
DEPRECIATED. Triggers a recalcuation of firearm stats on ammo changes.

Parameters:

  • ammoType a string, the name of the ammo
  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:setCurrentRound(ammoType, weaponItem)
ISORGMWeapon:cockHammer (playerObj, playSound, weaponItem)
DEPRECIATED. Cocks the hammer and rotates the cylinder for Rotary actionType.

Parameters:

  • playerObj a IsoPlayer object
  • playSound boolean, plays the cockSound if true
  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:cockHammer(playerObj, true, weaponItem)
ISORGMWeapon:releaseHammer (playerObj, playSound)
DEPRECIATED. Releases a cocked hammer.

Parameters:

  • playerObj a IsoPlayer object
  • playSound boolean, not used

Usage:

    reloadable:releaseHammer(playerObj, true)
ISORGMWeapon:openSlide (playerObj, playSound, weaponItem)
DEPRECIATED. Opens the bolt, ejecting whatever is currently in the chamber onto the ground.

Parameters:

  • playerObj a IsoPlayer object
  • playSound boolean, plays the openSound if true
  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:openSlide(playerObj, true, weaponItem)
ISORGMWeapon:closeSlide (playerObj, playSound, weaponItem)
DEPRECIATED. Closes the bolt and chambers the next round.

Single and Double actions this also cocks the hammer.

Parameters:

  • playerObj a IsoPlayer object
  • playSound boolean, plays the openSound if true
  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:closeSlide(playerObj, true, weaponItem)
ISORGMWeapon:rotateCylinder (count, playerObj, playSound, weaponItem)
DEPRECIATED. Rotates the cylinder by the specified amount.

Parameters:

  • count a integer, the number of positions to rotate. If nil or 0, randomly selects (chamber spin)
  • playerObj a IsoPlayer object
  • playSound boolean, plays the openSound if true
  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:rotateCylinder(1, playerObj, true, weaponItem)
ISORGMWeapon:openCylinder (playerObj, playSound, weaponItem)
DEPRECIATED. Opens the cylinder.

Parameters:

  • playerObj a IsoPlayer object
  • playSound boolean, plays the openSound if true
  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:openCylinder(playerObj, true, weaponItem)
ISORGMWeapon:closeCylinder (playerObj, playSound, weaponItem)
DEPRECIATED. Closes the cylinder and sets the current round.

Parameters:

  • playerObj a IsoPlayer object
  • playSound boolean, plays the openSound if true
  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:closeCylinder(playerObj, true, weaponItem)
ISORGMWeapon:openBreak (playerObj, playSound, weaponItem)
DEPRECIATED. Opens the breech and ejects any shells.

Parameters:

  • playerObj a IsoPlayer object
  • playSound boolean, plays the openSound if true
  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:openBreak(playerObj, true, weaponItem)
ISORGMWeapon:closeBreak (playerObj, playSound, weaponItem)
DEPRECIATED. Closes the breech and sets the current round.

Parameters:

  • playerObj a IsoPlayer object
  • playSound boolean, plays the openSound if true
  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:closeBreak(playerObj, true, weaponItem)

Setup and Sync Methods

These are used in intial setup of the reloadable, and keeping data synced between the HandWeapon’s mod data and the reloadable object.
ISORGMWeapon:syncItemToReloadable (weaponItem)
Copies modData from the weaponItem to the reloadable object.

Parameters:

  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:syncItemToReloadable(weaponItem)
ISORGMWeapon:syncReloadableToItem (weaponItem)
Copies properties of the reloadable object to the weaponItem’s modData.

Parameters:

  • weaponItem a HandWeapon/InventoryItem

Usage:

    reloadable:syncItemToReloadable(weaponItem)
generated by LDoc 1.4.3 Last updated 2018-10-07 13:48:49