DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
OpenItem.c
См. документацию.
2{
4 static void OpenAndSwitch(ItemBase item_tool, ItemBase item_target, PlayerBase player, float specialty_weight = 0)
5 {
6 array<int> spill_range = new array<int>;
7
8 if( item_tool.ConfigIsExisting("OpenItemSpillRange") )
9 {
10 item_tool.ConfigGetIntArray("OpenItemSpillRange", spill_range );
11 }
12 else
13 {
14 Debug.LogError("OpenItemSpillRange config parameter missing, default values used ! ");
15 Error("OpenItemSpillRange config parameter missing, default values used !");
16 spill_range.Insert(0);
17 spill_range.Insert(100);
18 }
19 float spill_modificator = Math.RandomIntInclusive( spill_range.Get(0),spill_range.Get(1) ) / 100;
20
21 OpenItem.SwitchItems(item_target, player, spill_modificator, specialty_weight);
22 }
23
25 static void SwitchItems (EntityAI old_item, PlayerBase player, float spill_modificator, float specialty_weight)
26 {
27 string old_name = old_item.GetType();
28 string new_name = old_name + "_Opened";
29 OpenAndSwitchLambda l = new OpenAndSwitchLambda(old_item, new_name, player, spill_modificator, specialty_weight);
30 l.SetTransferParams(true, true, true, true);
31 MiscGameplayFunctions.TurnItemIntoItemEx(player, l);
32 }
33};
34
35
37{
40 void OpenAndSwitchLambda (EntityAI old_item, string new_item_type, PlayerBase player, float spill_modificator, float specialty_weight) { m_SpillModifier = spill_modificator; m_SpecialtyWeight = specialty_weight; }
41
42 override void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
43 {
44 super.CopyOldPropertiesToNew(old_item, new_item);
45 }
46
47 override void OnSuccess (EntityAI new_item)
48 {
49 super.OnSuccess(new_item);
50
51 ItemBase ib = ItemBase.Cast(new_item);
52 if ( new_item )
53 {
54 float quantity_old = ib.GetQuantity();
55 float spill_amount = quantity_old * m_SpillModifier;
56 float quantity_new = quantity_old - spill_amount;
57
58 Debug.Log("quantity before spill: "+quantity_old.ToString());
59 Debug.Log("spill_amount: "+spill_amount.ToString());
60 Debug.Log("quantity_new: "+quantity_new.ToString());
61
62 ib.SetQuantity(quantity_new);
63 }
64 }
65};
66
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
Определения Debug.c:245
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Определения Debug.c:122
Определения Debug.c:2
Определения Building.c:6
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
Определения InventoryItem.c:731
Определения EnMath.c:7
void OpenAndSwitchLambda(EntityAI old_item, string new_item_type, PlayerBase player, float spill_modificator, float specialty_weight)
Определения OpenItem.c:40
float m_SpecialtyWeight
Определения OpenItem.c:39
override void OnSuccess(EntityAI new_item)
Определения OpenItem.c:47
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Определения OpenItem.c:42
float m_SpillModifier
Определения OpenItem.c:38
Определения OpenItem.c:37
static void SwitchItems(EntityAI old_item, PlayerBase player, float spill_modificator, float specialty_weight)
Will switch the 'item' for a new game entity, the new entity's classname will be formed by adding the...
Определения OpenItem.c:25
static void OpenAndSwitch(ItemBase item_tool, ItemBase item_target, PlayerBase player, float specialty_weight=0)
WIll open the 'item_target' by spawning a new entity and transferring item variables to the new one.
Определения OpenItem.c:4
Определения OpenItem.c:2
Определения PlayerBaseClient.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto string ToString(bool simple=true)
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54