DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
AreaExposure.c
Go to the documentation of this file.
2{
3 const int EVENT_1_INTERVAL_MIN = 3;
4 const int EVENT_1_INTERVAL_MAX = 5;
5
6 const float AGENTS_PER_SEC = 5;
7 protected float m_NextEvent1;
8 protected float m_Time1;
9
10 const int EVENT_2_INTERVAL_MIN = 13;
11 const int EVENT_2_INTERVAL_MAX = 18;
12
13
14 const float AGENT_DOSE_PER_BS_SEC = 0.33;//how many agents will be injected in one sec per a single bleeding source
15
16 protected float m_NextEvent2;
17 protected float m_Time2;
18
19
20
21 override void Init()
22 {
24 m_ID = eModifiers.MDF_AREAEXPOSURE;
27 m_SyncID = eModifierSyncIDs.MODIFIER_SYNC_ZONE_EXPOSURE;
30
31 }
32
33 override bool ActivateCondition(PlayerBase player)
34 {
35 return false;
36 }
37
38 override void OnActivate(PlayerBase player)
39 {
40
42 if (data)
43 {
44 MiscGameplayFunctions.TeleportCheck(player, data.SafePositions);
45 }
46
47 //make the player cough immediately
48 float transmitted = TransmitAgents(player, 1);
49 if(transmitted)
50 player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_COUGH);
51
53 }
54
55 override void OnDeactivate(PlayerBase player)
56 {
57 }
58
59 override bool DeactivateCondition(PlayerBase player)
60 {
61 return false;
62 }
63
64 override void OnTick(PlayerBase player, float deltaT)
65 {
66 #ifdef DEVELOPER
67 if(!player.GetCanBeDestroyed())
68 return;
69 #endif
70
71 float transmitted = TransmitAgents(player, AGENTS_PER_SEC * deltaT);
72
73 m_Time2 += deltaT;
74
75 if (transmitted)
76 {
77 m_Time1 += deltaT;
78 if (m_Time1 >= m_NextEvent1 )
79 {
80 player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_COUGH);
81
82 if(Math.RandomFloat01() < 0.25)//creates a cough cooldown once in a while
83 {
85 }
86 else
87 {
89 }
90
91 m_Time1 = 0;
92 }
93 }
94
95 if ( m_Time2 >= m_NextEvent2 )
96 {
98 m_Time2 = 0;
100 }
101
102 ApplyAgentsToBleedingSources(player, deltaT);
103
104 }
105
106 void ApplyAgentsToBleedingSources(PlayerBase player, float deltaT)
107 {
108
109 int count = player.GetBleedingSourceCount();
110 float agent_dose = count * AGENT_DOSE_PER_BS_SEC * deltaT;
111 player.InsertAgent(eAgents.CHEMICAL_POISON, agent_dose);
112
113 }
114
116 {
117 int free_bs_locations = 0;//bitmask where each bit set to 1 represents available bleeding source location
118 set<int> list = player.GetBleedingManagerServer().GetBleedingSourcesLocations();
119
120 foreach(int location: list)
121 {
122 float prot_level = PluginTransmissionAgents.GetProtectionLevelEx(DEF_CHEMICAL, location, player, true);
123 float dice_throw = Math.RandomFloat01();
124 if(dice_throw > prot_level)
125 {
126 free_bs_locations = player.GetBleedingManagerServer().GetFreeBleedingSourceBitsByInvLocation(location) | free_bs_locations;
127 }
128 }
129
130 int num_of_free_bs = Math.GetNumberOfSetBits(free_bs_locations);//gets us the number of bits set to 1, where each represents a free bleeding source location
131
132 if ( num_of_free_bs > 0 )
133 {
134 int random_bs_index = Math.RandomIntInclusive(0, num_of_free_bs - 1 );// - 1 on the max to convert count to index
135 int random_bs_bit = Math.Pow(2, Math.GetNthBitSet(free_bs_locations,random_bs_index));
136 player.GetBleedingManagerServer().AttemptAddBleedingSourceDirectly(random_bs_bit, eBleedingSourceType.CONTAMINATED);
137 }
138 }
139
140 float TransmitAgents(PlayerBase player, float count)
141 {
142 PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
143 return plugin.TransmitAgentsEx(null, player, AGT_AIRBOURNE_CHEMICAL, count, eAgents.CHEMICAL_POISON);
144 }
145
146
147};
eBleedingSourceType
eAgents
Definition EAgents.c:3
protected int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition Effect.c:49
bool m_TrackActivatedTime
void DisableDeactivateCheck()
void DisableActivateCheck()
eModifierSyncIDs m_SyncID
float m_TickIntervalActive
float m_TickIntervalInactive
eModifierSyncIDs
const int DEFAULT_TICK_TIME_ACTIVE_SHORT
const int DEFAULT_TICK_TIME_INACTIVE_LONG
PluginBase GetPlugin(typename plugin_type)
override bool DeactivateCondition(PlayerBase player)
override void OnActivate(PlayerBase player)
protected float m_Time2
void ApplyAgentsToBleedingSources(PlayerBase player, float deltaT)
float TransmitAgents(PlayerBase player, float count)
void BleedingSourceCreateCheck(PlayerBase player)
const int EVENT_2_INTERVAL_MIN
const int EVENT_1_INTERVAL_MAX
Definition AreaExposure.c:4
protected float m_NextEvent2
protected float m_NextEvent1
Definition AreaExposure.c:7
override void OnTick(PlayerBase player, float deltaT)
override void Init()
override bool ActivateCondition(PlayerBase player)
const int EVENT_2_INTERVAL_MAX
override void OnDeactivate(PlayerBase player)
const int EVENT_1_INTERVAL_MIN
Definition AreaExposure.c:3
const float AGENT_DOSE_PER_BS_SEC
protected float m_Time1
Definition AreaExposure.c:8
const float AGENTS_PER_SEC
Definition AreaExposure.c:6
static JsonDataContaminatedAreas GetData()
ref array< ref array< float > > SafePositions
Definition EnMath.c:7
eModifiers
Definition eModifiers.c:2
const int DEF_CHEMICAL
Definition constants.c:463
const int AGT_AIRBOURNE_CHEMICAL
Definition constants.c:460
static proto float Pow(float v, float power)
Return power of v ^ power.
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:86
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:53
static proto int GetNthBitSet(int value, int n)
returns the the index of n-th bit set in a bit mask counting from the right, for instance,...
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:106
static proto int GetNumberOfSetBits(int i)
returns the number of bits set in a bitmask i