MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / BattleItem

Method BattleItem

src/Savegame/BattleItem.cpp:33–52  ·  view source on GitHub ↗

* Initializes a item of the specified type. * @param rules Pointer to ruleset. * @param id The id of the item. */

Source from the content-addressed store, hash-verified

31 * @param id The id of the item.
32 */
33BattleItem::BattleItem(RuleItem *rules, int *id) : _id(*id), _rules(rules), _owner(0), _previousOwner(0), _unit(0), _tile(0), _inventorySlot(0), _inventoryX(0), _inventoryY(0), _ammoItem(0), _fuseTimer(-1), _ammoQuantity(0), _painKiller(0), _heal(0), _stimulant(0), _XCOMProperty(false), _droppedOnAlienTurn(false)
34{
35 if (_rules && _rules->getBattleType() == BT_AMMO)
36 {
37 setAmmoQuantity(_rules->getClipSize());
38 } else if (_rules && _rules->getBattleType() == BT_MEDIKIT)
39 {
40 setHealQuantity (_rules->getHealQuantity ());
41 setPainKillerQuantity (_rules->getPainKillerQuantity ());
42 setStimulantQuantity (_rules->getStimulantQuantity ());
43 }
44 (*id)++;
45
46 // weapon does not need ammo, ammo item points to weapon
47 if (_rules && (_rules->getBattleType() == BT_FIREARM || _rules->getBattleType() == BT_MELEE) && _rules->getCompatibleAmmo()->empty())
48 {
49 setAmmoQuantity(_rules->getClipSize());
50 _ammoItem = this;
51 }
52}
53
54/**
55 *

Callers

nothing calls this directly

Calls 7

getBattleTypeMethod · 0.80
getClipSizeMethod · 0.80
getCompatibleAmmoMethod · 0.80
getHealQuantityMethod · 0.45
getPainKillerQuantityMethod · 0.45
getStimulantQuantityMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected