DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionTakeFireplaceFromBarrel.c
Go to the documentation of this file.
2{
4 {
5 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
6 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
7 m_Text = "#take_fireplace";
8 }
9
10 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
11 {
12 Object target_object = target.GetObject();
13
14 if ( target_object && target_object.IsFireplace() )
15 {
16 BarrelHoles_ColorBase fireplace_barrel = BarrelHoles_ColorBase.Cast( target_object );
17
18 //check barrel fireplace state
19 if ( fireplace_barrel && fireplace_barrel.IsOpen() && !fireplace_barrel.HasAshes() && !fireplace_barrel.IsBurning() )
20 {
21 //check cargo and attachments
22 if ( fireplace_barrel.IsCargoEmpty() && fireplace_barrel.GetInventory().AttachmentCount() > 0 )
23 {
24 return true;
25 }
26 }
27 }
28
29 return false;
30 }
31
32 override void OnExecuteServer( ActionData action_data )
33 {
34 Object target_object = action_data.m_Target.GetObject();
35 BarrelHoles_ColorBase fireplace_barrel = BarrelHoles_ColorBase.Cast( target_object );
36
37 string newTypeName = "Fireplace";
39 bool found = action_data.m_Player.GetInventory().FindFirstFreeLocationForNewEntity( newTypeName, FindInventoryLocationType.ANY, targetIL );
40 if ( found )
41 {
42 // allow action only if there is place in inventory
43 auto lambda = TakeFireplaceFromBarrelLambda( fireplace_barrel, newTypeName, action_data.m_Player );
44 lambda.OverrideNewLocation( targetIL );
45 action_data.m_Player.ServerReplaceItemWithNew( lambda );
46 }
47 }
48}
49
51{
53
54 void TakeFireplaceFromBarrelLambda ( EntityAI old_item, string new_item_type, PlayerBase player )
55 {
56 m_Player = player;
57 }
58
59 override protected void RemoveOldItemFromLocation ()
60 {
61 // intentional no-operation
62 m_RemoveFromLocationPassed = true; // but indicate the operation to be success
63 }
64 override protected void UndoRemoveOldItemFromLocation ()
65 {
66 // undo nothing
67 }
68
69 override void CopyOldPropertiesToNew( notnull EntityAI old_item, EntityAI new_item )
70 {
71 super.CopyOldPropertiesToNew( old_item, new_item );
72
73 MiscGameplayFunctions.TransferInventory(old_item, new_item, m_Player);
74 }
75
76 override protected void DeleteOldEntity ()
77 {
78 // intentional no-operation
79 }
80
81 override protected void CreateNetworkObjectInfo (EntityAI new_item)
82 {
83 super.CreateNetworkObjectInfo(new_item);
84 GetGame().RemoteObjectTreeCreate(m_OldItem); // re-create network for old item
85 }
86}
protected string m_Text
Definition ActionBase.c:49
protected int m_StanceMask
Definition ActionBase.c:53
void TakeFireplaceFromBarrelLambda(EntityAI old_item, string new_item_type, PlayerBase player)
class ActionTargets ActionTarget
DayZPlayer m_Player
Definition Hand_Events.c:42
FindInventoryLocationType
flags for searching locations in inventory
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionTarget m_Target
Definition ActionBase.c:32
override void OnExecuteServer(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
proto native void RemoteObjectTreeCreate(Object obj)
RemoteObjectCreate - postponed registration of network object (and creation of remote object)....
InventoryLocation.
base class for transformation operations (creating one item from another)
protected void DeleteOldEntity()
Step F. - deletes physically old item.
protected void CreateNetworkObjectInfo(EntityAI new_item)
Step G. - create NetworkObjectInfo for new item.
void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Step E. copy properties from old object to the created one.
protected void RemoveOldItemFromLocation()
Step B. - free location for new item @NOTE this operation does not delete the object,...
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()