Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
openitem.c
Go to the documentation of this file.
1
class
OpenItem
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
36
class
OpenAndSwitchLambda
:
TurnItemIntoItemLambda
37
{
38
float
m_SpillModifier
;
39
float
m_SpecialtyWeight
;
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
Debug
Definition
debug.c:2
Debug::LogError
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.
Definition
debug.c:305
Debug::Log
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.
Definition
debug.c:182
EntityAI
Definition
inventoryitem.c:2
ItemBase
Definition
inventoryitem.c:742
ItemBase::SetQuantity
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Definition
pileofwoodenplanks.c:88
Math
Definition
enmath.c:7
OpenAndSwitchLambda
Definition
openitem.c:37
OpenAndSwitchLambda::CopyOldPropertiesToNew
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Definition
openitem.c:42
OpenAndSwitchLambda::OnSuccess
override void OnSuccess(EntityAI new_item)
Definition
openitem.c:47
OpenAndSwitchLambda::m_SpillModifier
float m_SpillModifier
Definition
openitem.c:38
OpenAndSwitchLambda::OpenAndSwitchLambda
void OpenAndSwitchLambda(EntityAI old_item, string new_item_type, PlayerBase player, float spill_modificator, float specialty_weight)
Definition
openitem.c:40
OpenAndSwitchLambda::m_SpecialtyWeight
float m_SpecialtyWeight
Definition
openitem.c:39
OpenItem
Definition
openitem.c:2
OpenItem::OpenAndSwitch
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.
Definition
openitem.c:4
OpenItem::SwitchItems
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...
Definition
openitem.c:25
PlayerBase
Definition
playerbaseclient.c:2
TurnItemIntoItemLambda
Definition
miscgameplayfunctions.c:92
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
float::ToString
proto string ToString(bool simple=true)
Error
void Error(string err)
Messagebox with error message.
Definition
endebug.c:90
Math::RandomIntInclusive
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition
enmath.c:54
Games
Dayz
scripts
4_world
static
openitem.c
Generated by
1.17.0