DayZ Enforce
Script API
Private Member Functions | Private Attributes | List of all members
ItemBase Class Reference

#include <ItemBase.h>

Inheritance diagram for ItemBase:
InventoryItem BaseBuildingBase BatteryCharger CableReel Clothing Consumable_Paper Crafting_WoodenStick EN5C_Book_Base EN5C_BurlapSackCover EN5C_CarBattery EN5C_Container_Base EN5C_Defibrillator EN5C_DiggedSoil EN5C_Edible_Base EN5C_FenceLight EN5C_FireplaceBase EN5C_Firewood EN5C_FishingRod_Base EN5C_Flashlight EN5C_Grenade_Base EN5C_HescoBox EN5C_PlantBase EN5C_Powered_Base EN5C_Rag EN5C_SeedPackBase EN5C_Stone EN5C_Trap_Base EN5C_Tripod EN5C_WoodenStick EN5C_WorldContainer_Base EnergyItem_Base GardenBase ItemBook ItemCompass ItemGPS ItemGrenade ItemMap ItemMegaphone ItemOptics ItemSuppressor ItemTransmitter ItemWatch KnifeBase Magazine PileOfWoodenPlanks PowerGenerator Spotlight TentBase TrapBase TrapSpawnBase Weapon

Private Member Functions

void  ItemBase ()
 
void  ~ItemBase ()
 
void  EOnInit (_entity other, int extra)
 
void  TransferModifiers (PlayerBase reciever)
 
void  CalculateNutritions (PlayerBase reciever, float consumedquantity)
 
bool  IsItemBase ()
 
bool  KindOf (string tag)
 
void  AddQuantity (float quantity, bool auto_destroy=false)
  Add quantity. More...
 
void  OnGetActions (ActionMenuContext ctx, Man player)
 
void  SetQuantity (float quantity, bool auto_destroy=false)
  Set quantity. More...
 
float  GetQuantity ()
  Returns current quantity. More...
 
void  SetQuantityMax (float quantity_max)
  Set maximum of quantity, quantity cant be more. More...
 
float  GetQuantityMax ()
  Returns maximum of quantity. More...
 
bool  CanQuantityCombine (ItemBase other_item)
  Returns bool by whether that item can be put together with other item. More...
 
bool  QuantityCombine (ItemBase other_item)
  Quantity of this item will be moved to other_item, but only to maximum quantity of other_item. More...
 
bool  CanQuantitySplit ()
  Returns bool by whether that item can be split to two items by quantity. If quantity is 1 or 0, item can not be split. More...
 
ItemBase  QuantitySplit ()
  Half of quantity from this item will be moved to new item object. New item object will be copy of this. Extends damamge. More...
 
void  MessageToOwnerStatus (string text)
  Send message to owner player in grey color. More...
 
void  MessageToOwnerAction (string text)
  Send message to owner player in yellow color. More...
 
void  MessageToOwnerFriendly (string text)
  Send message to owner player in green color. More...
 
void  MessageToOwnerImportant (string text)
  Send message to owner player in red color. More...
 
bool  OnAction (int action_id, Man player, ParamsReadContext ctx)
 
bool  CanRepair (ItemBase item_repair_kit)
 
bool  Repair (PlayerBase player, ItemBase item_repair_kit)
 
bool  IsRuined ()
  Returns whether the object is ruined (damage 1). More...
 
int  GetItemSize ()
 
void  Explode ()
  Creates a explosion by ammoType in config of object. If object dont have this parameter ("ammoType" like grenade) explsotion is default "G_GrenadeHand". More...
 
bool  CanEat ()
 
bool  AddAction (int action_id, ActionMenuContext ctx, Man player, int action_type)
 
void  OnRPC (int rpc_type, ParamsReadContext ctx)
 
int  NameToID (string name)
 
string  IDToName (int id)
 
void  SyncRequest ()
 
void  SyncDelayed ()
 
void  ConfigVariableSet (string name, float value)
 
void  ConfigVariableSetInt (string name, int value)
 
float  ConfigVariableGet (string name)
 
int  ConfigVariableGetInt (string name)
 
void  ConfigVariableAdd (string name, float value)
 
float  ConfigVariableGetMax (string name)
 
float  ConfigVariableGetMin (string name)
 
void  ConfigVariableSetMax (string name)
 
void  ConfigVariableSetMin (string name)
 
void  OnStoreSave (ParamsWriteContext ctx)
 
void  OnStoreLoad (ParamsReadContext ctx)
 
void  CreateVariableMap ()
 
bool  IsVariableMap ()
 
void  LoadVariables (ParamsReadContext ctx)
 
void  SaveVariables (ParamsWriteContext ctx)
 
void  PrintVariables ()
 
void  OnSynchronize (ParamsWriteContext ctx)
 
void  OnSynchronized (ParamsReadContext ctx)
 
void  SyncVariables (ParamsWriteContext ctx)
 
void  OnSyncVariables (ParamsReadContext ctx)
 
void  SetQuantity2 (float value, bool dummy=false)
 
void  SetQuantityDestroy2 (float value)
 
void  AddQuantity2 (float value)
 
void  SetQuantityMax2 ()
 
float  GetQuantityMax2 ()
 
float  GetQuantity2 ()
 
void  SetEnergy2 (float value)
 
void  AddEnergy2 (float value)
 
void  SetEnergyMax2 ()
 
float  GetEnergy2 ()
 
void  SetTemperature (float value)
 
void  AddTemperature (float value)
 
float  GetTemperature ()
 
void  SetTemperature2 (float value)
 
void  AddTemperature2 (float value)
 
void  SetTemperatureMax2 ()
 
float  GetTemperature2 ()
 
void  SetWet (float value)
 
void  AddWet (float value)
 
float  GetWet ()
 
void  SetWet2 (float value)
 
void  AddWet2 (float value)
 
void  SetWetMax2 ()
 
float  GetWet2 ()
 
void  SetBloodType2 (int value)
 
int  GetBloodType2 ()
 
void  SetLiquidType2 (int value)
 
int  GetLiquidType2 ()
 
void  Open ()
 
void  Close ()
 
bool  IsOpen ()
 
array< int >  GetAgents ()
 
void  SaveAgents (ParamsWriteContext ctx)
 
void  LoadAgents (ParamsReadContext ctx)
 
void  InsertAgent (int agent, int count=1)
 
void  PrintAgents ()
 
void  TransmitAgentsIn (Man player)
 
void  TransmitAgentsOut (Man player)
 
void  EEItemLocationChanged (EntityAI old_owner, EntityAI new_owner)
 
void  OnInventoryExit (Man player)
  Event called on item when it is removed from the player(Man) inventory, passes the old owner as a parameter. More...
 
void  OnInventoryEnter (Man player)
  Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter. More...
 
void  OnHologramItemCreated ()
 
void  OnPlacementFinished (PlayerBase player)
 
bool  CanManipulateAsCargo ()
 
bool  CanBePlaced (PlayerBase player, vector position)
  This method is called as condition when placing item with advanced placement system can be placed at given position. More...
 
string  CanBePlacedFailMessage (PlayerBase player, vector position)
  Method which returns message why object can't be placed at given position. More...
 

Private Attributes

private float  m_Quantity
 
private float  m_QuantityMax
 
private bool  m_QuantityCanCombine
 
private bool  m_QuantityCanSplit
 
autoptr map< string, float >  m_ItemVars
 
autoptr Timer  myTimer1
 
int  m_LastSyncTime
 
bool  m_Opened = true
 
autoptr array< int >  m_Agents
 

Constructor & Destructor Documentation

void ItemBase::ItemBase ( )
private
void ItemBase::~ItemBase ( )
private

Member Function Documentation

void ItemBase::EOnInit ( _entity  other,
int  extra 
)
private
void ItemBase::TransferModifiers ( PlayerBase  reciever )
private
void ItemBase::CalculateNutritions ( PlayerBase  reciever,
float  consumedquantity 
)
private
bool ItemBase::IsItemBase ( )
private
bool ItemBase::KindOf ( string  tag )
private
void ItemBase::AddQuantity ( float  quantity,
bool  auto_destroy = false 
)
private

Add quantity.

Parameters
quantity float How many quantity add
[auto_destroy]=false bool true => Auto delete this object when result quantity is 0 or less
Returns
void
item.AddQuantity(5); // Add quantity
item.AddQuantity(-3, true); // Add quantity, if result quantity is 0 or less, item will be deleted
item.AddQuantity(-8, false);// Add quantity, if result quantity is 0 or less, item will NOT be deleted

References AddQuantity2(), GetDayZGame(), EntityAI::GetVariableFloat(), m_QuantityMax, and SetQuantity().

Referenced by EN5C_FireplaceBase::BoilWater(), ActionSplintTarget::OnComplete(), ActionCollectBloodTarget::OnComplete(), ActionCollectSampleTarget::OnComplete(), ActionBandageTarget::OnComplete(), ActionIgniteFireplaceByMatch::OnComplete(), ActionCollectSampleSelf::OnComplete(), ActionSplintSelf::OnComplete(), ActionBandageSelf::OnComplete(), ActionCollectBloodSelf::OnComplete(), ActionExtinguishFireplace::OnComplete(), QuantityCombine(), QuantitySplit(), PileOfWoodenPlanks::RemovePlanks(), and BaseBuildingBase::TakeRequiredMaterials().

void ItemBase::OnGetActions ( ActionMenuContext  ctx,
Man  player 
)
private
void ItemBase::SetQuantity ( float  quantity,
bool  auto_destroy = false 
)
private

Set quantity.

Parameters
quantity float New quantity value
[auto_destroy]=false bool true => Auto delete this object when result quantity is 0 or less
Returns
void
item.SetQuantity(5); // Set quantity
item.SetQuantity(-5, true); // Set quantity, if new quantity value is 0 or less, item will be deleted

References EntityAI::Delete(), GetDayZGame(), SetQuantity2(), SetQuantityDestroy2(), and EntityAI::SetVariable().

Referenced by AddQuantity(), PlayerBase::CopyInventoryItem(), TempCrafting::CraftFireplace(), ModuleHorticulture::GiveWormsToPlayer(), PileOfWoodenPlanks::OnAction(), ActionTurnOnTorch::OnComplete(), PileOfWoodenPlanks::PileOfWoodenPlanks(), QuantityCombine(), QuantitySplit(), BaseBuildingBase::ReceiveRemainingMaterials(), ModuleSkinning::SkinComplete(), TrapSpawnBase::SpawnCatch(), and PlayerBase::SpawnItem().

float ItemBase::GetQuantity ( )
private
void ItemBase::SetQuantityMax ( float  quantity_max )
private

Set maximum of quantity, quantity cant be more.

Returns
void
item.SetQuantity(10);
float qunatity = item.GetQuantity();
Print(qunatity);
>> qunatity = 5

References m_QuantityMax.

float ItemBase::GetQuantityMax ( )
private

Returns maximum of quantity.

Returns
float Maximum of quantity
item.SetQuantity(3);
float qunatity_max = item.GetQuantityMax();
Print(qunatity_max);
>> qunatity_max = 5

References m_QuantityMax.

Referenced by CanQuantitySplit(), PileOfWoodenPlanks::PileOfWoodenPlanks(), QuantityCombine(), PlayerBase::SpawnItem(), and PileOfWoodenPlanks::UpdateSelections().

bool ItemBase::CanQuantityCombine ( ItemBase  other_item )
private

Returns bool by whether that item can be put together with other item.

Parameters
other_item ItemBase for check to combine
Returns
bool Can combined with other_item
item_stone.CanQuantityCombine(item_rags); // returns false
item_stone.CanQuantityCombine(item_stone); // returns true

References Object::GetType(), and m_QuantityCanCombine.

Referenced by InventoryManager::GetCombinationFlags(), and QuantityCombine().

bool ItemBase::QuantityCombine ( ItemBase  other_item )
private

Quantity of this item will be moved to other_item, but only to maximum quantity of other_item.

Returns
bool from CanQuantityCombine()
item_shovel.CanQuantitySplit(); // returns false, becouse shovel has quantity 1
item_stone.CanQuantityCombine(item_stone); // returns true, becouse stone has quantity 5

References AddQuantity(), CanQuantityCombine(), GetQuantity(), GetQuantityMax(), MessageToOwnerAction(), and SetQuantity().

Referenced by InventoryManager::OnPerformCombination().

bool ItemBase::CanQuantitySplit ( )
private

Returns bool by whether that item can be split to two items by quantity. If quantity is 1 or 0, item can not be split.

Returns
bool ItemBase can be split to two items
item_shovel.CanQuantitySplit(); // returns false, becouse shovel has quantity 1
item_stone.CanQuantitySplit(); // returns true, becouse stone has quantity 5

References GetQuantity(), GetQuantityMax(), and m_QuantityCanSplit.

Referenced by QuantitySplit().

ItemBase ItemBase::QuantitySplit ( )
private

Half of quantity from this item will be moved to new item object. New item object will be copy of this. Extends damamge.

Returns
ItemBase Instance of this object with half quantity
ItemBase item_stone_new = item_stone.QuantitySplit(); // If this item has 2 or more quantity, will be splitted

References AddQuantity(), CanQuantitySplit(), PlayerBase::CopyInventoryItem(), floor(), GetGame(), CGame::GetPlayer(), GetQuantity(), and SetQuantity().

void ItemBase::MessageToOwnerStatus ( string  text )
private

Send message to owner player in grey color.

Returns
void
item_stone.MessageToOwnerStatus("Some Status Message");

References EntityAI::GetOwnerPlayer(), and PlayerBase::MessageStatus().

void ItemBase::MessageToOwnerAction ( string  text )
private

Send message to owner player in yellow color.

Returns
void
item_stone.MessageToOwnerAction("Some Action Message");

References EntityAI::GetOwnerPlayer(), and PlayerBase::MessageAction().

Referenced by QuantityCombine().

void ItemBase::MessageToOwnerFriendly ( string  text )
private

Send message to owner player in green color.

Returns
void
item_stone.MessageToOwnerFriendly("Some Friendly Message");

References EntityAI::GetOwnerPlayer(), and PlayerBase::MessageFriendly().

void ItemBase::MessageToOwnerImportant ( string  text )
private

Send message to owner player in red color.

Returns
void
item_stone.MessageToOwnerImportant("Some Important Message");

References EntityAI::GetOwnerPlayer(), and PlayerBase::MessageImportant().

bool ItemBase::OnAction ( int  action_id,
Man  player,
ParamsReadContext  ctx 
)
private
bool ItemBase::CanRepair ( ItemBase  item_repair_kit )
private
bool ItemBase::Repair ( PlayerBase  player,
ItemBase  item_repair_kit 
)
private
bool ItemBase::IsRuined ( )
private

Returns whether the object is ruined (damage 1).

Returns
bool true = item have damage 1
if ( item.IsRuined() )
{
Print("Object is ruined!");
}

References Object::GetDamage().

Referenced by ModuleRepairing::Repair().

int ItemBase::GetItemSize ( )
private
void ItemBase::Explode ( )
private

Creates a explosion by ammoType in config of object. If object dont have this parameter ("ammoType" like grenade) explsotion is default "G_GrenadeHand".

Returns
void
ItemBase item = GetGame().GetPlayer().CreateInInventory("GrenadeRGD5");
item.Explode();

References Object::ConfigGetString(), CGame::CreateObject(), EntityAI::Delete(), GetGame(), and Object::GetPosition().

Referenced by Trap_LandMine::MakeExplosion(), and Trap_TripWire::MakeExplosion().

bool ItemBase::CanEat ( )
private
bool ItemBase::AddAction ( int  action_id,
ActionMenuContext  ctx,
Man  player,
int  action_type 
)
private
void ItemBase::OnRPC ( int  rpc_type,
ParamsReadContext  ctx 
)
private
int ItemBase::NameToID ( string  name )
private

References ModuleVariables::GetID(), GetModule(), and Type().

Referenced by SyncVariables().

string ItemBase::IDToName ( int  id )
private
void ItemBase::SyncRequest ( )
private
void ItemBase::SyncDelayed ( )
private
void ItemBase::ConfigVariableSet ( string  name,
float  value 
)
private
void ItemBase::ConfigVariableSetInt ( string  name,
int  value 
)
private
float ItemBase::ConfigVariableGet ( string  name )
private
int ItemBase::ConfigVariableGetInt ( string  name )
private
void ItemBase::ConfigVariableAdd ( string  name,
float  value 
)
private
float ItemBase::ConfigVariableGetMax ( string  name )
private
float ItemBase::ConfigVariableGetMin ( string  name )
private
void ItemBase::ConfigVariableSetMax ( string  name )
private
void ItemBase::ConfigVariableSetMin ( string  name )
private
void ItemBase::OnStoreSave ( ParamsWriteContext  ctx )
private
void ItemBase::OnStoreLoad ( ParamsReadContext  ctx )
private
void ItemBase::CreateVariableMap ( )
private
bool ItemBase::IsVariableMap ( )
private
void ItemBase::LoadVariables ( ParamsReadContext  ctx )
private
void ItemBase::SaveVariables ( ParamsWriteContext  ctx )
private
void ItemBase::PrintVariables ( )
private

References ClassName(), Debug::Log(), m_ItemVars, and ToString().

Referenced by LoadVariables(), and OnAction().

void ItemBase::OnSynchronize ( ParamsWriteContext  ctx )
private

References Debug::Log(), and SyncVariables().

void ItemBase::OnSynchronized ( ParamsReadContext  ctx )
private

References Debug::Log(), and OnSyncVariables().

void ItemBase::SyncVariables ( ParamsWriteContext  ctx )
private
void ItemBase::OnSyncVariables ( ParamsReadContext  ctx )
private
void ItemBase::SetQuantity2 ( float  value,
bool  dummy = false 
)
private
void ItemBase::SetQuantityDestroy2 ( float  value )
private
void ItemBase::AddQuantity2 ( float  value )
private
void ItemBase::SetQuantityMax2 ( )
private
float ItemBase::GetQuantityMax2 ( )
private
float ItemBase::GetQuantity2 ( )
private

References ConfigVariableGet().

Referenced by EN5C_Fireplace::CanAttachItem(), EN5C_Fireplace::CanDetachItem(), ActionBandageSelf::CanDo(), ActionBandageTarget::CanDo(), ActionCollectSampleSelf::CanDo(), ActionIgniteFireplaceByMatch::CanDo(), ActionCollectBloodSelf::CanDo(), ActionSplintSelf::CanDo(), ActionFertilizeSoil::CanDo(), ActionDisinfectPlant::CanDo(), ActionWaterPlant::CanDo(), ActionFillBottleBase::CanDo(), ActionDisinfectPlantBit::CanDo(), ActionFertilizeSoilBit::CanDo(), ActionPlantSeed::CanDo(), ActionWaterPlantBit::CanDo(), EN5C_DiggedSoil::Fertilize(), Cooking::GetCookingMethod(), GetQuantity(), EN5C_FireplaceBase::IsItemAttachedQuantity(), ActionOnTargetContinuousQuantity::OnCancel(), ActionFillBottleBase::OnCancel(), ActionOnSelfContinuousQuantity::OnCancel(), ActionGiveSalineSelf::OnComplete(), ActionConsume::OnComplete(), ActionForceConsumeSingle::OnComplete(), ActionDisinfectTarget::OnComplete(), ActionConsumeSingle::OnComplete(), ActionExtinguishFireplace::OnComplete(), ActionFillBottleBase::OnComplete(), ActionWaterPlantBit::OnComplete(), ActionDisinfectPlantBit::OnComplete(), ActionOnTargetContinuousQuantity::OnStart(), ActionOnSelfContinuousQuantity::OnStart(), ActionFillBottleBase::OnStart(), ActionOnTargetContinuousQuantity::OnTick(), ActionFillBottleBase::OnTick(), ActionOnSelfContinuousQuantity::OnTick(), GardenBase::PlantSeed(), EN5C_FireplaceBase::RefreshFireplaceVisual(), SetQuantityDestroy2(), EN5C_FireplaceBase::SpendFireConsumable(), and Cooking::UpdateCookingState().

void ItemBase::SetEnergy2 ( float  value )
private

References ConfigVariableSet().

void ItemBase::AddEnergy2 ( float  value )
private

References ConfigVariableAdd().

Referenced by EnergyItem_Base::Tick().

void ItemBase::SetEnergyMax2 ( )
private
float ItemBase::GetEnergy2 ( )
private
void ItemBase::SetTemperature ( float  value )
private
void ItemBase::AddTemperature ( float  value )
private
float ItemBase::GetTemperature ( )
private
void ItemBase::SetTemperature2 ( float  value )
private
void ItemBase::AddTemperature2 ( float  value )
private

References ConfigVariableAdd().

void ItemBase::SetTemperatureMax2 ( )
private
float ItemBase::GetTemperature2 ( )
private
void ItemBase::SetWet ( float  value )
private
void ItemBase::AddWet ( float  value )
private

References GetWet(), and SetWet().

float ItemBase::GetWet ( )
private
void ItemBase::SetWet2 ( float  value )
private

References ConfigVariableSet().

void ItemBase::AddWet2 ( float  value )
private
void ItemBase::SetWetMax2 ( )
private
float ItemBase::GetWet2 ( )
private
void ItemBase::SetBloodType2 ( int  value )
private

References ConfigVariableSet().

int ItemBase::GetBloodType2 ( )
private

References ConfigVariableGet().

void ItemBase::SetLiquidType2 ( int  value )
private

References ConfigVariableSet().

int ItemBase::GetLiquidType2 ( )
private

References ConfigVariableGet().

void ItemBase::Open ( )
private

References m_Opened.

Referenced by ActionOpen::OnComplete().

void ItemBase::Close ( )
private

References m_Opened.

Referenced by ActionClose::OnComplete().

bool ItemBase::IsOpen ( )
private

References m_Opened.

Referenced by ActionClose::CanDo(), and ActionOpen::CanDo().

array< int > ItemBase::GetAgents ( )
private

References m_Agents.

Referenced by OnInventoryEnter().

void ItemBase::SaveAgents ( ParamsWriteContext  ctx )
private

References m_Agents, and ParamsWriteContext::Write().

Referenced by OnStoreSave().

void ItemBase::LoadAgents ( ParamsReadContext  ctx )
private

References InsertAgent(), and ParamsReadContext::Read().

Referenced by OnStoreLoad().

void ItemBase::InsertAgent ( int  agent,
int  count = 1 
)
private

References Debug::Log(), m_Agents, and ToString().

Referenced by LoadAgents(), and OnAction().

void ItemBase::PrintAgents ( )
private

References Debug::Log(), m_Agents, and ToString().

Referenced by OnAction().

void ItemBase::TransmitAgentsIn ( Man  player )
private
void ItemBase::TransmitAgentsOut ( Man  player )
private
void ItemBase::EEItemLocationChanged ( EntityAI  old_owner,
EntityAI  new_owner 
)
private
void ItemBase::OnInventoryExit ( Man  player )
private

Event called on item when it is removed from the player(Man) inventory, passes the old owner as a parameter.

References AGT_INV_OUT, PlayerBase::ChangePlayerLoad(), GetDayZGame(), GetGame(), IsInherited(), and PlayerBase::TransmitAgents().

Referenced by EEItemLocationChanged().

void ItemBase::OnInventoryEnter ( Man  player )
private

Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter.

References AGT_INV_IN, PlayerBase::ChangePlayerLoad(), GetAgents(), GetDayZGame(), GetGame(), IsInherited(), and PlayerBase::TransmitAgents().

Referenced by EEItemLocationChanged().

void ItemBase::OnHologramItemCreated ( )
private

Referenced by Hologram::Setup().

void ItemBase::OnPlacementFinished ( PlayerBase  player )
private
bool ItemBase::CanManipulateAsCargo ( )
private
bool ItemBase::CanBePlaced ( PlayerBase  player,
vector  position 
)
private

This method is called as condition when placing item with advanced placement system can be placed at given position.

Referenced by ActionPlaceObject::OnComplete().

string ItemBase::CanBePlacedFailMessage ( PlayerBase  player,
vector  position 
)
private

Method which returns message why object can't be placed at given position.

Referenced by ActionPlaceObject::OnComplete().

Member Data Documentation

private float ItemBase::m_Quantity
private
private float ItemBase::m_QuantityMax
private
private bool ItemBase::m_QuantityCanCombine
private

Referenced by CanQuantityCombine(), and ItemBase().

private bool ItemBase::m_QuantityCanSplit
private

Referenced by CanQuantitySplit(), and ItemBase().

autoptr map<string,float> ItemBase::m_ItemVars
private
autoptr Timer ItemBase::myTimer1
private
int ItemBase::m_LastSyncTime
private
bool ItemBase::m_Opened = true
private
autoptr array<int> ItemBase::m_Agents
private

The documentation for this class was generated from the following files:
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)