Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
seedpackbase.c
Go to the documentation of this file.
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 string pack_type = GetType();
12 string seeds_type = "";
13
14 GetGame().ConfigGetText("cfgVehicles " + pack_type + " Horticulture ContainsSeedsType", seeds_type);
15
16 int seeds_quantity_max = GetGame().ConfigGetInt("cfgVehicles " + pack_type + " Horticulture ContainsSeedsQuantity");
17 int seeds_quantity = seeds_quantity_max;
18
19 seeds_quantity = Math.Round(seeds_quantity_max * GetHealth01("",""));
20
21 if (seeds_quantity < 1)
22 {
23 seeds_quantity = 1;
24 }
25
26 if (player)
27 {
28 EmptySeedsPackLambda lambda = new EmptySeedsPackLambda(this, seeds_type, player, seeds_quantity);
29 player.ServerReplaceItemInHandsWithNew(lambda);
30 }
31 else
32 {
33 vector pos = GetPosition();
34 GetGame().CreateObjectEx(seeds_type, pos, ECE_PLACE_ON_SURFACE);
35 GetGame().ObjectDelete(this);
36 }
37 }
38
39 override void SetActions()
40 {
41 super.SetActions();
42
44 }
45}
46
48{
51
52 void EmptySeedsPackLambda(EntityAI old_item, string new_item_type, PlayerBase player, int count)
53 {
54 m_ItemCount = count;
55 m_Player = player;
56 }
57
58 override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
59 {
60 super.CopyOldPropertiesToNew(old_item, new_item);
61
62 ItemBase unboxed;
63 Class.CastTo(unboxed, new_item);
64 unboxed.SetQuantity(m_ItemCount);
65 }
66
67 override void OnSuccess(EntityAI new_item)
68 {
69 super.OnSuccess(new_item);
70
71 //spawns wrapping Paper
72 if (m_Player)
73 {
74 m_Player.SpawnEntityOnGroundRaycastDispersed("Paper",DEFAULT_SPAWN_DISTANCE,UAItemsSpreadRadius.NARROW);
75 }
76 else
77 {
78 GetGame().CreateObjectEx("Paper", new_item.GetHierarchyRoot().GetPosition(), ECE_PLACE_ON_SURFACE);
79 }
80 }
81};
eBleedingSourceType GetType()
void AddAction(typename actionName)
void SetActions()
const int ECE_PLACE_ON_SURFACE
Super root of all classes in Enforce script.
Definition enscript.c:11
Definition enmath.c:7
base class for transformation operations (creating one item from another)
void OnSuccess(EntityAI new_item)
Step H. - notification on finish.
void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Step E. copy properties from old object to the created one.
proto native CGame GetGame()
class JsonUndergroundAreaTriggerData GetPosition
DayZPlayer m_Player
Definition hand_events.c:42
const float DEFAULT_SPAWN_DISTANCE
Definition recipebase.c:3
class SeedPackBase extends Inventory_Base m_ItemCount
void EmptySeedsPackLambda(EntityAI old_item, string new_item_type, PlayerBase player, int count)