Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
seedpackbase.c
Go to the documentation of this file.
1 class SeedPackBase extends Inventory_Base
2 {
3  private static const float PACK_DAMAGE_TOLERANCE = 0.5;
4 
5  void SeedPackBase()
6  {
7  }
8 
9  void EmptySeedPack( PlayerBase player )
10  {
11 
12  string pack_type = GetType();
13  string seeds_type = "";
14 
15  GetGame().ConfigGetText( "cfgVehicles " + pack_type + " Horticulture ContainsSeedsType", seeds_type );
16 
17  int seeds_quantity_max = GetGame().ConfigGetInt( "cfgVehicles " + pack_type + " Horticulture ContainsSeedsQuantity" );
18  int seeds_quantity = seeds_quantity_max;
19 
20  seeds_quantity = Math.Round( seeds_quantity_max * GetHealth01("","") );
21 
22  if ( seeds_quantity < 1 )
23  {
24  seeds_quantity = 1;
25  }
26 
27  if (player)
28  {
29  EmptySeedsPackLambda lambda = new EmptySeedsPackLambda(this, seeds_type, player, seeds_quantity);
30  player.ServerReplaceItemInHandsWithNew(lambda);
31  }
32  else
33  {
34  vector pos = GetPosition();
35  GetGame().CreateObjectEx(seeds_type, pos, ECE_PLACE_ON_SURFACE);
36  GetGame().ObjectDelete( this );
37  }
38  }
39 
40  override void SetActions()
41  {
42  super.SetActions();
43 
45  }
46 }
47 
49 {
50  int m_ItemCount;
51 
52  void EmptySeedsPackLambda (EntityAI old_item, string new_item_type, PlayerBase player, int count)
53  {
54  m_ItemCount = count;
55  }
56 
57  override void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
58  {
59  super.CopyOldPropertiesToNew(old_item, new_item);
60 
61  ItemBase unboxed;
62  Class.CastTo(unboxed, new_item);
63  unboxed.SetQuantity(m_ItemCount);
64  }
65 
66  override void OnSuccess(EntityAI new_item)
67  {
68  super.OnSuccess(new_item);
69 
70  //spawns wrapping Paper
71  ItemBase paper = ItemBase.Cast( GetGame().CreateObjectEx("Paper", new_item.GetHierarchyRoot().GetPosition(), ECE_PLACE_ON_SURFACE) );
72  }
73 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
SeedPackBase
Definition: cannabisseedspack.c:1
ActionEmptySeedsPack
Definition: actionemptyseedspack.c:6
CopyOldPropertiesToNew
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Definition: seedpackbase.c:57
OnSuccess
override void OnSuccess(EntityAI new_item)
Definition: seedpackbase.c:66
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
m_ItemCount
class SeedPackBase extends Inventory_Base m_ItemCount
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
SetActions
void SetActions()
Definition: advancedcommunication.c:79
ReplaceItemWithNewLambdaBase
base class for transformation operations (creating one item from another)
Definition: replaceitemwithnewlambdabase.c:4
Inventory_Base
Definition: barbedbaseballbat.c:1
Math
Definition: enmath.c:6
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
EntityAI
Definition: building.c:5
GetType
override int GetType()
Definition: huddebugwincharagents.c:49
EmptySeedsPackLambda
void EmptySeedsPackLambda(EntityAI old_item, string new_item_type, PlayerBase player, int count)
Definition: seedpackbase.c:52