Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
actionforceconsume.c
Go to the documentation of this file.
2{
3 override void CreateActionComponent()
4 {
5 m_ActionData.m_ActionComponent = new CAContinuousQuantityEdible(UAQuantityConsumed.DEFAULT, UATimeSpent.DEFAULT);
6 }
7}
8
9class ActionForceConsume : ActionContinuousBase
10{
11 protected const float SOUND_REPEAT_INTERVAL = 1.5;
12
14 {
15 m_CallbackClass = ActionForceConsumeCB;
16 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_FORCEFEED;
17 m_StanceMask = DayZPlayerConstants.STANCEIDX_ERECT | DayZPlayerConstants.STANCEIDX_CROUCH;
18 m_FullBody = true;
19 m_Text = "#feed";
20 }
21
23 {
24 m_ConditionTarget = new CCTMan(UAMaxDistances.DEFAULT);
25 m_ConditionItem = new CCINonRuined();
26 }
27
28 override void OnStartServer(ActionData action_data)
29 {
30 super.OnStartServer(action_data);
31
32 PlayerBase player = PlayerBase.Cast(action_data.m_Target.GetObject());
33 if (player)
34 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(PlaySound, SOUND_REPEAT_INTERVAL * 1000, true, player);
35 }
36
37 override void OnEndServer(ActionData action_data)
38 {
39 super.OnEndServer(action_data);
40
41 if (action_data.m_MainItem && (action_data.m_MainItem.GetQuantity() <= 0.01))
42 {
43 action_data.m_MainItem.SetQuantity(0);
44 }
45
46 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Remove(PlaySound);
47 }
48
49 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
50 {
51 if (!super.ActionCondition(player, target, item))
52 return false;
53
54 PlayerBase targetPlayer = PlayerBase.Cast(target.GetObject());
55 ConsumeConditionData dta = new ConsumeConditionData(targetPlayer,item);
56 if (!targetPlayer || !targetPlayer.CanEatAndDrink() || !targetPlayer.CanConsumeFood(dta) || !item.CanBeConsumed(dta))
57 return false;
58
59 float angleDiff = Math.AbsFloat(player.GetDirection().VectorToAngles()[0] - targetPlayer.GetDirection().VectorToAngles()[0]);
60 if (angleDiff < 135 || angleDiff > 225) // not in 90 deg cone angle facing the other player
61 return false;
62
63 if (targetPlayer.GetPerformedActionID() != -1 || targetPlayer.GetActivePrimarySymptomID() == SymptomIDs.SYMPTOM_VOMIT)
64 return false;
65
66 return item.GetQuantity() > item.GetQuantityMin();
67 }
68
69 protected void PlaySound(PlayerBase player)
70 {
71 if (player)
72 player.RequestSoundEventEx(EPlayerSoundEventID.FORCE_FEED);
73 }
74}
override void CreateConditionComponents()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnEndServer(ActionData action_data)
override void OnStartServer(ActionData action_data)
int m_CommandUID
Definition actionbase.c:31
int m_StanceMask
Definition actionbase.c:33
ActionForceConsumeCB SOUND_REPEAT_INTERVAL
void ActionForceConsume()
ActionData m_ActionData
Definition cctman.c:2
Definition enmath.c:7
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
void PlaySound()