DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ SnapOnObject()

void SnapOnObject ( EntityAI victim)
protected

См. определение в файле TrapBase.c строка 216

217 {
218 if ( GetGame().IsServer() )
219 {
220 if ( m_Timer )
221 {
222 m_Timer.Stop();
223 }
224
225 RefreshState();
226
227 if (m_DamagePlayers > 0)
228 {
229 if (victim)
230 {
231 if ( victim.IsInherited(SurvivorBase))
232 {
233 victim.DecreaseHealth("", "", m_DamagePlayers);
234 }
235 else if (victim.IsInherited(DayZCreatureAI))
236 {
237 victim.DecreaseHealth("", "", m_DamageOthers);
238 }
239 else if (victim.IsInherited(ItemBase))
240 {
241 ItemBase victim_item = ItemBase.Cast(victim);
242 float damage_coef = 1;
243
244 if (victim_item.HasQuantity() && victim_item.GetQuantityMax() != 0 && victim_item.GetQuantity() > 0)
245 {
246 damage_coef = victim_item.GetQuantityMax() / victim_item.GetQuantity(); // Lower quantity increases damage exposure
247 }
248
249 if (damage_coef > 0)
250 {
251 int item_size_x = 1;
252 int item_size_y = 1;
253 GetGame().GetInventoryItemSize(victim_item, item_size_x, item_size_y);
254
255 float add_damage = 300 * damage_coef / Math.Clamp(item_size_x * item_size_y, 1, int.MAX);
256 victim_item.DecreaseHealth("", "", add_damage);
257 }
258 }
259 }
260 }
261
262 Synch(victim);
263 }
264
265 OnSteppedOn(victim);
266 }
ref Timer m_Timer
Определения DayZGame.c:705
const int MAX
Определения EnConvert.c:27
void Synch(EntityAI victim)
keeping "step" here for consistency only
Определения TrapBase.c:281
void RefreshState()
Определения TrapBase.c:331
void OnSteppedOn(EntityAI victim)
Определения TrapBase.c:273
float m_DamagePlayers
Определения TrapBase.c:20
float m_DamageOthers
Определения TrapBase.c:21
proto void GetInventoryItemSize(InventoryItem item, out int width, out int height)
do not process rotations !
Определения DayZAnimal.c:612
Определения InventoryItem.c:731
Определения EnMath.c:7
proto native CGame GetGame()
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

Перекрестные ссылки Math::Clamp(), GetGame(), CGame::GetInventoryItemSize(), m_DamageOthers, m_DamagePlayers, m_Timer, MAX, TrapBase::OnSteppedOn(), RefreshState() и Synch().

Используется в OnItemLocationChanged() и OnRPC().