Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiongivebloodself.c
Go to the documentation of this file.
2 {
3  int m_ItemBloodType;
4  float m_BloodAmount;
5  int m_Agents;
6 }
7 
8 class ActionGiveBloodSelfCB : ActionContinuousBaseCB
9 {
10  override void CreateActionComponent()
11  {
12  m_ActionData.m_ActionComponent = new CAContinuousQuantityBloodTransfer(UAQuantityConsumed.BLOOD, UATimeSpent.BLOOD);
13  }
14 };
15 
17 {
18  const float CHEM_AGENT_BLOOD_REMOVAL_MODIFIER = 0.25;
19  void ActionGiveBloodSelf()
20  {
21  m_CallbackClass = ActionGiveBloodSelfCB;
23 
24  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_SALINEBLOODBAG;
25  m_FullBody = true;
26  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
27  m_Text = "#give_blood";
28  }
29 
30  override void CreateConditionComponents()
31  {
34  }
35 
36  override bool HasTarget()
37  {
38  return false;
39  }
40 
41  override ActionData CreateActionData()
42  {
43  ActionGiveBloodData action_data = new ActionGiveBloodData;
44  return action_data;
45  }
46 
47  override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL )
48  {
49  if ( super.SetupAction(player, target, item, action_data, extra_data ) )
50  {
51  ActionGiveBloodData action_data_b = ActionGiveBloodData.Cast( action_data );
52  action_data_b.m_ItemBloodType = action_data.m_MainItem.GetLiquidType();
53  action_data_b.m_BloodAmount = action_data.m_MainItem.GetQuantity();
54  action_data_b.m_Agents = action_data.m_MainItem.GetAgents();
55  return true;
56  }
57  return false;
58  }
59 
60  override void OnEndAnimationLoopServer( ActionData action_data )
61  {
62  //OnFinishProgressServer(action_data);
63 
64  if ( action_data.m_MainItem.IsKindOf("BloodSyringe") )
65  {
66  SyringeLambda lambda = new SyringeLambda(action_data.m_MainItem, "Syringe", action_data.m_Player);
67  lambda.SetTransferParams(true, true, true);
68  MiscGameplayFunctions.TurnItemIntoItemEx(action_data.m_Player, lambda);
69  }
70 
71  action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
72  }
73 
74  override void OnEndServer(ActionData action_data)
75  {
76 
77  ActionGiveBloodData action_data_b = ActionGiveBloodData.Cast( action_data );
78  float blood_obtained = action_data_b.m_BloodAmount - action_data_b.m_MainItem.GetQuantity();
79 
80  PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
81  plugin.TransmitAgentsEx(action_data.m_MainItem, action_data.m_Player, AGT_UACTION_TO_PLAYER,blood_obtained ,action_data_b.m_Agents);
82 
83 
84  int bloodtypetarget = action_data_b.m_Player.GetStatBloodType().Get();
85  bool bloodmatch = BloodTypes.MatchBloodCompatibility(action_data_b.m_ItemBloodType, bloodtypetarget);
86 
87  if ( !bloodmatch )
88  {
89 
90 
91  if (blood_obtained > PlayerConstants.HEMOLYTIC_RISK_SHOCK_THRESHOLD)
92  {
93  action_data_b.m_Player.m_UnconsciousEndTime = -60;
94  action_data_b.m_Player.SetHealth("","Shock",0);
95 
96  if (blood_obtained > PlayerConstants.HEMOLYTIC_REACTION_THRESHOLD)
97  {
98  action_data_b.m_Player.m_ModifiersManager.ActivateModifier(eModifiers.MDF_HEMOLYTIC_REACTION);
99  }
100  }
101  }
102 
103  if ( action_data_b.m_MainItem && action_data_b.m_MainItem.GetQuantity() <= 0.01 )
104  {
105  action_data_b.m_MainItem.SetQuantity(0);
106  }
107 
108  if (!(action_data_b.m_Agents & eAgents.CHEMICAL_POISON))//does bloodbag NOT contain nerve agent ?
109  {
110  float remove_count_agents = blood_obtained * CHEM_AGENT_BLOOD_REMOVAL_MODIFIER;
111  action_data.m_Player.InsertAgent(eAgents.CHEMICAL_POISON, -remove_count_agents);
112 
113  }
114  }
115 };
116 
118 {
119  void SyringeLambda (EntityAI old_item, string new_item_type, PlayerBase player) { }
120 };
ItemBase
Definition: inventoryitem.c:730
AGT_UACTION_TO_PLAYER
const int AGT_UACTION_TO_PLAYER
Definition: constants.c:473
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
ActionGiveBloodSelf
Definition: actiongivebloodself.c:16
UASoftSkillsWeight
Definition: actionconstants.c:118
UAQuantityConsumed
Definition: actionconstants.c:3
ActionGiveBloodData
Definition: actiongivebloodself.c:1
SyringeLambda
Definition: actiongivebloodself.c:117
CreateActionComponent
ActionGiveBloodSelf CreateActionComponent
Definition: actiongivebloodself.c:10
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
eAgents
eAgents
Definition: eagents.c:2
PlayerConstants
Definition: playerconstants.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
BloodTypes
Definition: bloodtype.c:1
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CCTSelf
Definition: cctself.c:1
eModifiers
eModifiers
Definition: emodifiers.c:1
UATimeSpent
Definition: actionconstants.c:26
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
CCINotRuinedAndEmpty
Definition: ccinotruinedandempty.c:1
CAContinuousQuantityBloodTransfer
Definition: cacontinuousquantitybloodtransfer.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionContinuousBase
Definition: actioncontinuousbase.c:132
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
TurnItemIntoItemLambda
Definition: miscgameplayfunctions.c:91
EntityAI
Definition: building.c:5