DayZ 1.24
Loading...
Searching...
No Matches
MiscGameplayFunctions.c
Go to the documentation of this file.
2{
8
10 {
11 SetTransferParams();
12 }
13
14 void SetTransferParams(bool transfer_agents = true, bool transfer_variables = true, bool transfer_health = true, bool exclude_quantity = false, float quantity_override = -1)
15 {
16 m_TransferAgents = transfer_agents;
17 m_TransferVariables = transfer_variables;
18 m_TransferHealth = transfer_health;
19 m_ExcludeQuantity = exclude_quantity;
20 m_quantity_override = quantity_override;
21 }
22
24 {
25 super.CopyOldPropertiesToNew(old_item, new_item);
26
27 if (new_item)
28 {
29 MiscGameplayFunctions.TransferItemProperties(old_item, new_item, m_TransferAgents, m_TransferVariables, m_TransferHealth, m_ExcludeQuantity);
31
32 //quantity override
33 if (ItemBase.Cast(new_item) && m_quantity_override != -1)
34 {
35 m_quantity_override = Math.Max(m_quantity_override, 0);
36 ItemBase.Cast(new_item).SetQuantity(m_quantity_override);
37 }
38 }
39 else
40 Debug.LogError("TurnItemIntoItemLambda: failed to create new item", "static");
41 }
42
45 {
46 if (m_NewLocation.GetType() == InventoryLocationType.ATTACHMENT && m_OldItem.ConfigIsExisting("ChangeIntoOnAttach"))
47 {
48 string str;
49 int idx = -1;
53
54 m_OldItem.ConfigGetTextArray("ChangeInventorySlot", inventory_slots);
55 if (inventory_slots.Count() < 1) //is string
56 {
57 inventory_slots_idx.Insert(InventorySlots.GetSlotIdFromString(m_OldItem.ConfigGetString("ChangeInventorySlot")));
58 attach_types.Insert(m_OldItem.ConfigGetString("ChangeIntoOnAttach"));
59 }
60 else //is array
61 {
62 inventory_slots_idx.Clear();
63 for (int i = 0; i < inventory_slots.Count(); i++)
65 m_OldItem.ConfigGetTextArray("ChangeIntoOnAttach", attach_types);
66 }
67
68 idx = m_NewLocation.GetSlot();
70 if (str != "")
71 m_NewItemType = str;
72 }
73 }
74
76 {
77 super.OnSuccess(new_item);
78 if (m_Player)
79 m_Player.GetItemAccessor().OnItemInHandsChanged();
80 }
81};
82
83class TurnItemIntoItemLambdaAnimSysNotifyLambda extends TurnItemIntoItemLambda
84{
86 {
87 super.OnSuccess(new_item);
88 if (m_Player)
89 m_Player.GetItemAccessor().OnItemInHandsChanged();
90 }
91}
92
93class TurnItemIntoItemLambdaRestrainLambda extends TurnItemIntoItemLambdaAnimSysNotifyLambda
94{
95 override void OnSuccess(EntityAI new_item)
96 {
97 super.OnSuccess(new_item);
98 m_Player.SetRestrained(true);
99 }
100}
101
106{
108
113
115 {
116 super.CopyOldPropertiesToNew(old_item, new_item);
117
118 InventoryLocation understash_src = m_NewLocation; // m_NewLocation is a backup of original old_item's src before the operation started
119
121 old_item.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, children);
122 int count = children.Count();
123 for (int i = 0; i < count; i++)
124 {
125 EntityAI child = children.Get(i);
126 if (child)
127 {
129 child.GetInventory().GetCurrentInventoryLocation(child_src);
130
132 //@TODO: modify _dst with place on gnd?
133
134 vector m4[4];
136
139
140 child_dst.SetGround(child, m4);
141
142 m_Player.LocalTakeToDst(child_src, child_dst);
143
144 GetGame().RemoteObjectTreeCreate(child); // this forces server to send CreateVehicle Message to client. This is needed for preserving the appearance of network operations on client (so that DeleteObject(old) arrives before CreateVehicle(new)). @NOTE: this does not delete the object on server, only it's network representation.
145 }
146 }
147 }
148}
149
154{
157
159 {
162 if (new_item_type != string.Empty)
163 Error("MoveEquipAndDestroyRootLambda expects new_item_type to be empty");
164 }
165
166 override protected void RemoveNetworkObjectInfo()
167 {
168 super.RemoveNetworkObjectInfo();
169 GetGame().RemoteObjectTreeDelete(m_NewItem);
170 }
171 override protected void UndoRemoveNetworkObjectInfo()
172 {
173 super.UndoRemoveNetworkObjectInfo();
174 GetGame().RemoteObjectTreeCreate(m_NewItem);
175 }
176
178 {
179 // @NOTE: new_item is NULL, this lambda does not create new entity
180 super.CopyOldPropertiesToNew(old_item, new_item);
181
183 }
184
186 {
187 super.CreateNetworkObjectInfo(new_item);
188 GetGame().RemoteObjectTreeCreate(m_NewItem);
189 }
190};
191
196
198{
199 NONE = 0,
200 SPLIT = 1, //< Splits the item when it has quantity, recommended to use when called on an attachment
201}
202
204{
206 static float Truncate(float value, int decimals = 2)
209 return Math.Clamp(Math.Floor(value * multiplier), float.LOWEST, float.MAX) / multiplier;
210 }
212 static string TruncateToS(float value, int decimals = 2)
213 {
214 return Truncate(value, decimals).ToString();
215 }
218 {
219 int multiplier = Math.Pow(10, decimals);
220 float v1 = Math.Clamp(Math.Floor(value[0] * multiplier), float.LOWEST, float.MAX) / multiplier;
221 float v2 = Math.Clamp(Math.Floor(value[1] * multiplier), float.LOWEST, float.MAX) / multiplier;
222 float v3 = Math.Clamp(Math.Floor(value[2] * multiplier), float.LOWEST, float.MAX) / multiplier;
223 return Vector(v1, v2, v3);
224 }
225
226 static string TruncateVecToS(vector value, int decimals = 2, string delimiter = " ")
227 {
228 return MiscGameplayFunctions.TruncateToS(value[0], decimals) + delimiter + MiscGameplayFunctions.TruncateToS(value[1], decimals) + delimiter + MiscGameplayFunctions.TruncateToS(value[2], decimals));
229 }
230
231 static string GetColorString(float r, float g, float b, float a)
232 {
233 return string.Format("#(argb,8,8,3)color(%1,CO)", string.Format("%1,%2,%3,%4", r, g, b, a));
234 }
235
237 static string ValueToBar(float value, string bar = "[----------]", string mark = "x")
238 {
239 int length = bar.Length() - 2;
240 float index = Math.Lerp(0, length, value);
242 index = Math.Clamp(index, 0, length);
243
244 return InsertAtPos(bar, mark, index);
245 }
246
248 static string InsertAtPos(string base, string insert, int pos)
249 {
250 int length_first = pos + 1;
251 int length_base = base.Length();
253 string first = base.Substring(0, length_first);
254 string second = base.Substring(pos + 1, length_second);
255 return first + insert + second;
256 }
257
260 {
263
264 if (transfer_agents) target_ib.TransferAgents(source.GetAgents());
265
268
269 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
270 {
271 if (transfer_health)
272 target_ib.SetHealth01("", "", source.GetHealth01("", ""));
273 }
274 }
275
277 {
278 target.TransferVariablesFloat(source.GetVariablesFloat());
279 //target.TransferVariablesString( source.GetVariablesString() );
281 target.RemoveItemVariable(VARIABLE_QUANTITY);
282 else if (source.IsMagazine() && target.IsMagazine())
283 {
286
287 target_mag.ServerSetAmmoCount(source_mag.GetAmmoCount());
288 }
289
290 if (source.IsWeapon() && target.IsWeapon())
291 {
294
295 target_wpn.CopyWeaponStateFrom(source_wpn);
296 }
297 else if (source.HasEnergyManager() && target.HasEnergyManager())
298 {
299 ComponentEnergyManager ems = source.GetCompEM();
300 ComponentEnergyManager emt = target.GetCompEM();
301
302 emt.SetEnergy(ems.GetEnergy());
303
304 if (ems.IsSwitchedOn())
305 emt.SwitchOn();
306 }
307 else if (source.CanDecay() && target.CanDecay())
308 {
311
312 target_edb.TransferFoodStage(source_edb);
313 }
314 }
315
317 {
319
321 sourceItem.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, children);
322 int count = children.Count();
323 for (int i = 0; i < count; i++)
324 {
325 EntityAI child = children.Get(i);
326 if (child)
327 {
329 child.GetInventory().GetCurrentInventoryLocation(child_src);
330
332 child_dst.Copy(child_src);
333 child_dst.SetParent(targetItem);
334
335 bool drop = false;
336
338 {
339 // try to move it to the same exact place in dst
340 targetItem.GetInventory().TakeToDst(InventoryMode.LOCAL, child_src, child_dst);
341 }
342 else
343 {
344 drop = true; // or drop otherwise
345 }
346
347 if (drop)
348 {
349 player.LocalDropEntity(child);
350 GetGame().RemoteObjectTreeCreate(child);
351 result = TransferInventoryResult.DroppedSome;
352 }
353 }
354 }
355 return result;
356 }
357
359 {
360 if (ItemBase.GetDebugActionsMask() & DebugActionType.UNLIMITED_AMMO)
361 {
363 if (GetGame().IsServer())
364 {
365 magazine = weapon.GetMagazine(weapon.GetCurrentMuzzle());
366
367 if (magazine)
368 {
369 if (magazine.GetAmmoCount() <= 5)
370 magazine.ServerSetAmmoMax();
371 }
372 }
373 else
374 {
375 magazine = weapon.GetMagazine(weapon.GetCurrentMuzzle());
376
377 if (magazine)
378 {
379 if (magazine.GetAmmoCount() <= 5)
380 magazine.LocalSetAmmoMax();
381 }
382
383 }
384 }
385 }
386
387
392
394 {
395 player.ServerReplaceItemWithNew(lambda);
396 }
397
402
404 {
405 player.ServerReplaceItemInHandsWithNew(lambda);
406 }
407
410 {
412 float max_stack_size;
414
416 max_stack_size = g_Game.ConfigGetInt("cfgVehicles " + item_name + " varStackMax");
417 if (max_stack_size < 1)
418 max_stack_size = g_Game.ConfigGetInt("cfgVehicles " + item_name + " varQuantityMax");
419 if (max_stack_size < 1)
420 max_stack_size = 1;
421
424
425 for (int i = 0; i < full_piles_count; i++)
426 {
427 if (floaty_spawn)
429 else
431 pile.SetQuantity(max_stack_size);
432 pile.SetHealth(health);
433 item_piles.Insert(pile);
434 }
435 if (rest > 0)
436 {
437 if (floaty_spawn)
439 else
441 pile.SetQuantity(rest);
442 pile.SetHealth(health);
443 item_piles.Insert(pile);
444 }
445 return item_piles;
446 }
447
449 {
451 float stack_size;
453
455 stack_size = g_Game.ConfigGetInt("cfgMagazines " + item_name + " count");
456
459
460 for (int i = 0; i < piles_count; i++)
461 {
463 pile.ServerSetAmmoCount(stack_size);
464 items.Insert(pile);
465 }
466 if (rest > 0)
467 {
469 pile.ServerSetAmmoCount(rest);
470 items.Insert(pile);
471 }
472 return items;
473 }
474
476 {
479 float stack_size;
481 string item_name;
482 if (!g_Game.ConfigGetText("cfgAmmo " + bullet_type + " spawnPileType", item_name))
483 return items;
484
485 stack_size = g_Game.ConfigGetInt("cfgMagazines " + item_name + " count");
486
487 if (stack_size > 0)
488 {
491
492 for (int i = 0; i < piles_count; i++)
493 {
495 pile.ServerSetAmmoCount(stack_size);
496 items.Insert(pile);
497 }
498 if (rest > 0)
499 {
501 pile.ServerSetAmmoCount(rest);
502 items.Insert(pile);
503 }
504 }
505 return items;
506 }
507
508 static int GetHealthLevelForAmmo(string class_name, float health)
509 {
510 float health_normalized = health / 100;
511 string config_path = CFG_WEAPONSPATH + " " + class_name + " DamageSystem" + " GlobalHealth" + " healthLabels";
513 GetGame().ConfigGetFloatArray(config_path, CachedObjectsArrays.ARRAY_FLOAT);
514 for (int i = 0; i < CachedObjectsArrays.ARRAY_FLOAT.Count(); i++)
515 {
517 return i;
518 }
519 return -1;
520 }
521
522 static float GetTypeMaxGlobalHealth(string class_name, string health_type = "Health")
523 {
524 float max_health;
525 string cfg_path;
526
527 if (GetGame().ConfigIsExisting(CFG_VEHICLESPATH + " " + class_name))
529 else if (GetGame().ConfigIsExisting(CFG_WEAPONSPATH + " " + class_name))
531 else if (GetGame().ConfigIsExisting(CFG_MAGAZINESPATH + " " + class_name))
533 cfg_path = cfg_path + " " + class_name + " DamageSystem GlobalHealth " + health_type + " hitpoints";
534 max_health = GetGame().ConfigGetFloat(cfg_path);
535
536 return max_health;
537 }
538
540 {
541 vector usti_hlavne_position = weapon.GetSelectionPositionMS("usti hlavne");
542 vector konec_hlavne_position = weapon.GetSelectionPositionMS("konec hlavne");
547
551
553 return true;
554 return false;
555 }
556
558 {
559 // Get position of head for starting trace pos, otherwise use sane default
560 int headBoneIdx = player.GetBoneIndexByName("Head");
561 if (headBoneIdx == -1)
562 pos = player.GetPosition()[1] + 1.6;
563 else
564 pos = player.GetBonePositionWS(headBoneIdx);
565 }
566
568 {
569 vector dir = vector.Zero;
571 dir[0] = Math.Cos(headingAngle + Math.PI_HALF);
572 dir[2] = Math.Sin(headingAngle + Math.PI_HALF);
573
574 return dir.Normalized();
575 }
576
578 {
579 HumanInputController hic = player.GetInputController();
580 float headingAngle = hic.GetHeadingAngle();
581
582 return headingAngle;
583 }
584
586 {
587 float speed;
588 switch (movement_speed)
589 {
590 case DayZPlayerConstants.MOVEMENTIDX_WALK:
592 break;
593 case DayZPlayerConstants.MOVEMENTIDX_RUN:
595 break;
596 case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
598 break;
599 default:
600 speed = 0;
601 break;
602 }
603
605 return speed;
606 }
607
609 {
610 float speed;
611 switch (movement_speed)
612 {
613 case DayZPlayerConstants.MOVEMENTIDX_WALK:
615 break;
616 case DayZPlayerConstants.MOVEMENTIDX_RUN:
618 break;
619 case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
621 break;
622 default:
623 speed = 0;
624 break;
625 }
626
628 return speed;
629 }
630
632 {
633 return entity.ConfigGetString("OnRestrainChange");
634 }
635
637 {
638 bool type;
639
640 if (tool)
641 {
642 //is unrestrain and not struggle
643 type = tool.ConfigGetBool("RestrainUnlockType");
644 }
645 string new_item_name = current_item.ConfigGetString("OnRestrainChange");
646
647 if (new_item_name != "")
648 {
649 if (player_target)
650 {
651 if (player_target.IsAlive())
653 else
655 }
656 else
658 }
659 else
660 Error("current_item:" + current_item + ", tool:" + tool + ". No value for 'OnRestrainChange' config parameter");
661 }
662
663 static bool IsValueInRange(float value, float from, float to)
664 {
665 return (value >= from) && (value <= to);
666 }
667
670 {
671 if (player)
672 {
673 vector player_dir = player.GetDirection();
674 vector to_target_dir = target_pos - player.GetPosition();
675
676 player_dir[1] = 0;
677 to_target_dir[1] = 0;
678
679 player_dir.Normalize();
680 to_target_dir.Normalize();
681
684
685 int dir = Math.Acos(cos_fi) * Math.RAD2DEG;
686
687 if (cross[1] < 0)
688 dir = -dir;
689
692 return true;
693 }
694
695 return false;
696 }
697
698 //TODO
699 static string SanitizeString(string input)
700 {
701 int max_length = 512;
702 string output = input;
703
704 output = output.Substring(0, Math.Clamp(max_length, 0, output.Length()));
705 return output;
706 }
707
708 // deprecated - dont use
710 {
711 return true;
712 }
713
715 {
717 if (base_building)
718 {
719 Construction construction = base_building.GetConstruction();
721 {
722 ConstructionActionData construction_action_data = player.GetConstructionActionData();
723 string partName;
724 if (item)
725 partName = construction_action_data.GetBuildPartAtIndex(constraction_index).GetPartName();
726 else
727 partName = construction_action_data.GetBuildPartNoToolAtIndex(constraction_index).GetPartName();
728 bool boo;
729 if (base_building.PerformRoofCheckForBase(partName, player, boo) && boo)
730 return false;
731 if (player.IsPlacingLocal() || player.IsPlacingServer())
732 return false;
733
734 /*float distance_root = vector.DistanceSq(target.GetCursorHitPos(), player.GetPosition());
735
736 if (!CfgGameplayHandler.GetDisableDistanceCheck() && distance_root < UAMaxDistances.BASEBUILDING_SHORT)
737 {
738 return false;
739 } */
740 return !construction.IsColliding(partName);
741 }
742 }
743 return false;
744 }
745
746 // deprecated - dont use
748 {
749 return true;
750 }
751
753 {
754 Object targetObject = target.GetObject();
755 if (targetObject && targetObject.CanUseConstruction())
756 {
758 ConstructionActionData construction_action_data = player.GetConstructionActionData();
760
762 if (item)
764 else
766
767 //Debug
768 /*
769 if ( constrution_part )
770 {
771 Construction construction = base_building.GetConstruction();
772 construction.IsColliding( constrution_part.GetPartName() );
773 }
774 */
775
777 {
778 //camera and position checks
779 bool position_check = (base_building.MustBeBuiltFromOutside() && !base_building.IsPlayerInside(player, constrution_part.GetMainPartName())) || (!base_building.MustBeBuiltFromOutside() && base_building.IsPlayerInside(player, constrution_part.GetMainPartName()));
780 if (position_check && !player.GetInputController().CameraIsFreeLook())
781 {
782 //Camera check (client-only)
783 if (camera_check)
784 {
785 if (GetGame() && (!GetGame().IsDedicatedServer()))
786 return !base_building.IsFacingCamera(constrution_part.GetMainPartName());
787 }
788
789 return true;
790 }
791 }
792 }
793
794 return false;
795 }
796
798 {
799 vector minMax[2];
800 entity.GetCollisionBox(minMax);
801
802 vector size = Vector(0, 0, 0);
803 //size[1] = minMax[1][1] - minMax[0][1];
804 float from_override = entity.HeightStartCheckOverride();
805 if (from_override > 0.0)
806 size[1] = from_override;
807 else
808 size[1] = minMax[1][1] - minMax[0][1];
809
810 from = entity.GetPosition() + size;
811 if (entity.HeightCheckOverride() > 0)
812 to = entity.GetPosition() + Vector(0, entity.HeightCheckOverride(), 0);
813 else
814 {
815 vector ceiling = "0 0 0";
816 ceiling[1] = height;
817 to = from + ceiling; //+size ??? offset to cast same distance
818 }
819 }
820
825
827 {
828 vector from;
829 vector to;
830
832
835
837 //set<Object> hit_object = new set<Object>;
838 bool boo = DayZPhysics.RaycastRV(from, to, contact_pos, contact_dir, contact_component, /*hit_object*/NULL, NULL, entity, false, false, geometry, 0.25);
839
840 /*if (boo)
841 {
842 Debug.DrawSphere(from , 0.8,Colors.YELLOW, ShapeFlags.ONCE);
843 Debug.DrawSphere(to , 0.8,Colors.RED, ShapeFlags.ONCE);
844 }
845 else
846 {
847 Debug.DrawSphere(from , 0.8,Colors.GREEN, ShapeFlags.ONCE);
848 Debug.DrawSphere(to , 0.8,Colors.RED, ShapeFlags.ONCE);
849 }*/
850
851 return boo;
852 }
853
854 // cooking equipment effects (get position for steam particle)
856 {
858 float steam_offset = 0;
859
860 if (parent)
861 {
862 particle_pos = parent.GetPosition();
863
864 if (parent.IsInherited(PortableGasStove))
865 steam_offset = 0.2;
866 else if (parent.IsInherited(FireplaceBase))
867 {
869
870 if (fireplace.IsBaseFireplace())
871 steam_offset = 0.8;
872 else if (fireplace.IsBarrelWithHoles())
873 steam_offset = 1.1;
874 else if (fireplace.IsFireplaceIndoor())
875 steam_offset = 0.45;
876 else if (fireplace.IsIndoorOven())
877 steam_offset = 0.9;
878 }
879 }
880
882
883 return particle_pos;
884 }
885
887 {
888 if (!GetGame().IsServer())
889 return;
891 ib.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, items);
892
893 vector direction = ib.GetDirection();
895
896 float angle = Math.Acos(dot);
897 if (direction[0] < 0)
898 angle = -angle;
899
900 float cos = Math.Cos(angle);
901 float sin = Math.Sin(angle);
902
904 int count = items.Count();
905 for (int i = 0; i < count; ++i)
906 {
907 item = items.Get(i);
908 if (item)
909 ib.GetInventory().DropEntityInBounds(InventoryMode.SERVER, ib, item, halfExtents, angle, cos, sin);
910 }
911 }
912
913 static void ThrowAllItemsInInventory(notnull EntityAI parent, int flags)
914 {
915 vector position = parent.GetPosition();
916 vector orientation = parent.GetOrientation();
918 float direction[4];
919
920 vector minmax[2];
921 parent.GetCollisionBox(minmax);
922
925
927 for (int i = 0; i < parent.GetInventory().AttachmentCount(); ++i)
928 {
930 position[1] + Math.RandomFloat(minmax[0][1], minmax[1][1]),
931 position[2] + Math.RandomFloat(minmax[0][2], minmax[1][2]));
932
933 ThrowEntityFromInventory(parent.GetInventory().GetAttachmentFromIndex(i), randomPos, direction, -GetVelocity(parent), ThrowEntityFlags.NONE);
934 }
935
936 for (int j = 0; j < parent.GetInventory().GetCargo().GetItemCount(); ++j)
937 {
939 position[1] + Math.RandomFloat(minmax[0][1], minmax[1][1]),
940 position[2] + Math.RandomFloat(minmax[0][2], minmax[1][2]));
941
942 ThrowEntityFromInventory(parent.GetInventory().GetCargo().GetItem(j), randomPos, direction, -GetVelocity(parent), ThrowEntityFlags.NONE);
943 }
944 }
945
947 {
949 if (!GetGame().IsMultiplayer())
950 invMode = InventoryMode.LOCAL;
951
953 if (CastTo(entityIB, entity))
954 {
956 dst.SetGroundEx(entity, position, direction);
957
958 if ((flags & ThrowEntityFlags.SPLIT) && entityIB.CanBeSplit())
959 {
960 for (int l = 0; l < entityIB.GetQuantity(); ++l)
961 {
963
964 if (new_item)
965 {
966 MiscGameplayFunctions.TransferItemProperties(entityIB, new_item);
967 entityIB.AddQuantity(-1);
968 new_item.SetQuantity(1);
969 new_item.ThrowPhysically(null, force, false);
970 }
971 }
972 }
973 else
974 {
975 float stackable = entityIB.GetTargetQuantityMax();
976 if (!(stackable == 0 || stackable >= entityIB.GetQuantity()))
977 {
978 while (entityIB.GetQuantity() > stackable)
979 {
981 position[1] = position[1] + 0.1;
982 spltDst.SetGroundEx(entity, position, direction);
983
984 ItemBase splitItem = entityIB.SplitIntoStackMaxToInventoryLocationEx(spltDst);
985 splitItem.ThrowPhysically(null, force, false);
986 }
987 }
988
990 entity.GetInventory().GetCurrentInventoryLocation(src);
991
992 entity.GetInventory().TakeToDst(invMode, src, dst);
993 entityIB.ThrowPhysically(null, force, false);
994 }
995 }
996 else
997 {
998 entity.GetInventory().DropEntity(invMode, entity.GetHierarchyRoot(), entity);
1000 }
1001 }
1002
1004 {
1005 float wetFactor;
1006 float healthFactor;
1007
1008 float heatIsolation = pItem.GetHeatIsolation();
1009 float itemHealthLabel = pItem.GetHealthLevel();
1010 float itemWetness = pItem.GetWet();
1011
1023
1025 switch (itemHealthLabel)
1026 {
1029 break;
1030
1033 break;
1034
1037 break;
1038
1041 break;
1042
1045 break;
1046 }
1047
1051
1052 return heatIsolation;
1053 }
1054
1056 {
1057 if (!obstructingObjects)
1059
1060 for (int i = 0; i < potentiallyObstructingObjects.Count(); ++i)
1061 {
1063 if (obj && (obj.CanObstruct() || obj.CanProxyObstruct()))
1064 obstructingObjects.Insert(obj);
1065 }
1066 }
1067
1069 {
1070 return obj.IsTransport() || obj.CanUseConstruction();
1071 }
1072
1075 {
1078
1079 int i = 0;
1080 int j = 0;
1081 int k = 0;
1082 int mCount = vicinityObjects.Count();
1083
1084 if (!filteredObjects)
1086
1087 // Remove objects that are too far from the player anyways
1088 if (doDistanceCheck)
1089 {
1090 for (i = vicinityObjects.Count() - 1; i >= 0; --i)
1091 {
1092 Object obj = vicinityObjects[i];
1093 if (obj && !CanIgnoreDistanceCheck(obj) && vector.DistanceSq(origin, obj.GetPosition()) > maxDist * maxDist)
1094 vicinityObjects.Remove(i);
1095 }
1096 }
1097
1098 // Sort obstructingObjects to have the furthest one first
1102 float distance, dist1, dist2;
1103
1104 for (i = 0; i < obstructingObjects.Count(); ++i)
1105 {
1106 distance = vector.DistanceSq(obstructingObjects[i].GetWorldPosition(), origin);
1107 distanceHelper.Insert(distance);
1108 }
1109
1111 distanceHelper.Sort();
1112
1113 for (i = distanceHelper.Count() - 1; i >= 0; --i)
1115
1119
1120 float cos = Math.Cos(90);
1121 float sin = Math.Sin(90);
1122
1123 // Iterate through sorted obstructingObjects
1124 for (i = 0; i < sortedObstructingObjects.Count(); ++i)
1125 {
1127 vector worldPos = obstrObj.GetWorldPosition();
1128 vector min, max;
1129 vector minMax[2];
1130 if (obstrObj.GetCollisionBox(minMax))
1131 {
1132 min = minMax[0];
1133 max = minMax[1];
1134 max = max * (obstrObj.GetOrientation() * range);
1135
1136 vector center, dx, dy, dz, half;
1137 center = (min + max) * 0.5;
1138 dz = obstrObj.GetOrientation();
1141 half = (max - min) * 0.5;
1143
1144 group = new array<Object>;
1145
1146 // Group objects within the above box
1147 for (j = vicinityObjects.Count() - 1; j >= 0; --j)
1148 {
1150 if (vicObj)
1151 {
1152 vector d = vicObj.GetWorldPosition() - worldPos + center;
1153 if (Math.AbsFloat(vector.Dot(d, dx)) <= half[0] && Math.AbsFloat(vector.Dot(d, dy)) <= half[1] && Math.AbsFloat(vector.Dot(d, dz)) <= half[2])
1154 {
1155 group.Insert(vicObj);
1156 vicinityObjects.Remove(j);
1157 }
1158 }
1159 }
1160
1161 if (group.Count() > 0)
1162 tempGroups.Insert(group);
1163 }
1164 }
1165
1166 // Go through the objects grouped by obstruction to split them by distance too
1167 for (i = 0; i < tempGroups.Count(); ++i)
1169
1170 // Split initial groups by distance
1172
1173 // Raycast accordingly to groups
1175 for (i = 0; i < objectGroups.Count(); ++i)
1176 {
1179
1181 filteredObjects.InsertAll(objectGroup);
1182
1183 cache.ClearCache();
1184 }
1185 }
1186
1188 {
1190 for (int i = 0; i < objects.Count();)
1191 {
1192 Object obj1 = objects[i];
1193 if (obj1)
1194 {
1195 group = new array<Object>;
1196 group.Insert(obj1);
1197 for (int j = objects.Count() - 1; j > i; --j)
1198 {
1199 Object obj2 = objects[j];
1200 if (obj1 && obj2)
1201 {
1202 vector start = obj1.GetWorldPosition();
1203 vector end = obj2.GetWorldPosition();
1204
1207 {
1208 group.Insert(obj2);
1209 objects.Remove(j);
1210 }
1211 }
1212 }
1213 objectGroups.Insert(group);
1214 objects.Remove(i);
1215 continue;
1216 }
1217 ++i;
1218 }
1219 }
1220
1221 static bool IsObjectObstructed(Object object, bool doDistanceCheck = false, vector distanceCheckPos = "0 0 0", float maxDist = 0)
1222 {
1224 MiscGameplayFunctions.GetHeadBonePos(PlayerBase.Cast(GetGame().GetPlayer()), rayStart);
1226
1228 }
1229
1231 {
1232 if (!object)
1233 return true;
1234
1235 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
1237 return true;
1238
1239 cache.ObjectCenterPos = object.GetCenter();
1240
1241 return IsObjectObstructedFilterEx(object, cache, player);
1242 }
1243
1245 {
1246 if (object.CanProxyObstruct())
1247 {
1248 RaycastRVParams rayInput = new RaycastRVParams(cache.RaycastStart, cache.ObjectCenterPos, player);
1249 DayZPhysics.RaycastRVProxy(rayInput, cache.HitProxyObjects);
1250 if (cache.HitProxyObjects)
1251 {
1252 if (cache.HitProxyObjects.Count() > 0)
1253 {
1254 if (cache.HitProxyObjects[0].hierLevel > 0)
1255 {
1256 // ignores attachments on player
1257 if (!cache.HitProxyObjects[0].parent.IsMan())
1258 {
1259 if (cache.HitProxyObjects[0].parent)
1260 {
1261 EntityAI proxyParent = EntityAI.Cast(cache.HitProxyObjects[0].parent);
1262 if (proxyParent.GetInventory() && proxyParent.GetInventory().GetCargo())
1263 return true;
1264 }
1265 }
1266 }
1267 }
1268 }
1269 }
1270 return false;
1271 }
1272
1274 {
1275 for (int m = 0; m < cache.HitObjects.Count(); m++)
1276 {
1277 Object hit_object = cache.HitObjects.Get(m);
1278
1279 if (hit_object.CanObstruct())
1280 return true;
1281
1282 //4.3. ignore item if items are big and heavy >= OBJECT_OBSTRUCTION_WEIGHT
1283 //EntityAI eai;
1284 //if ( Class.CastTo( eai, hit_object ) )
1285 //{
1286 // if ( eai.GetWeight() >= OBJECT_OBSTRUCTION_WEIGHT )
1287 // {
1288 // if ( eai != filtered_object && eai.GetHierarchyRoot() != filtered_object )
1289 // {
1290 // //Print("!!!!!obstacle vaha: " + hit_object);
1291 // is_obstructed = true;
1292 // }
1293 // }
1294 //}
1295 }
1296
1297 return false;
1298 }
1299
1302 {
1303 //first proxy geometries
1304 RaycastRVParams rayInput = new RaycastRVParams(cache.RaycastStart, cache.ObjectCenterPos, player);
1305 rayInput.flags = CollisionFlags.ALLOBJECTS;
1306 if (geometryTypeOverride != -1)
1307 rayInput.type = geometryTypeOverride; //default 'ObjIntersectView'
1308 DayZPhysics.RaycastRVProxy(rayInput, cache.HitProxyObjects);
1309 int count;
1310 int i;
1311
1312 if (cache.HitProxyObjects)
1313 {
1314 count = cache.HitProxyObjects.Count();
1315 Object parent;
1316 for (i = 0; i < count; i++)
1317 {
1318 if (cache.HitProxyObjects[i].hierLevel > 0) //parent has to exist, skipping nullcheck
1319 {
1320 parent = cache.HitProxyObjects[i].parent;
1321 if (parent && !parent.IsMan() && parent.CanProxyObstruct())
1322 {
1323 if (parent != object || (parent == object && object.CanProxyObstructSelf()))
1324 return true;
1325 }
1326 }
1327 }
1328 }
1329
1330 //second, regular raycast
1331 int geometry = ObjIntersectFire; //default for the RV raycast
1332 if (geometryTypeOverride != -1)
1334 DayZPhysics.RaycastRV(cache.RaycastStart, cache.ObjectCenterPos, cache.ObjectContactPos, cache.ObjectContactDir, cache.ContactComponent, cache.HitObjects, object, GetGame().GetPlayer(), false, false, geometry, 0.0, CollisionFlags.ALLOBJECTS);
1335 count = cache.HitObjects.Count();
1336 for (i = 0; i < count; i++)
1337 {
1338 if (cache.HitObjects[i].CanObstruct())
1339 return true;
1340 }
1341
1342 return false;
1343 }
1344
1345 //Inflict absolute damage to item (used on tools when completing actions)
1346 static void DealAbsoluteDmg(ItemBase item, float dmg)
1347 {
1348 item.DecreaseHealth(dmg, false);
1349 }
1350
1351 //Function used to normailze values, enter the used value and the max value (max will become 1)
1352 static float Normalize(int val, int maxVal)
1353 {
1354 if (maxVal == 0)
1355 {
1356 Debug.LogError("Division by 0 is not allowed");
1357 return 0;
1358 }
1359
1360 return val / maxVal;
1361 }
1362
1363 static float Bobbing(float period, float amplitude, float elapsedTime)
1364 {
1365 //Prevent division by 0
1366 if (period == 0)
1367 period = 1;
1368
1369 elapsedTime /= period;
1370
1371 float cycle;
1372 cycle += elapsedTime;
1373 cycle = FModulus(cycle, 360);
1375
1376 return cycle;
1377 }
1378
1379 // DEPRECATED, use Math.ModFloat directly instead
1380 static float FModulus(float x, float y)
1381 {
1382 return Math.ModFloat(x, y);
1383 }
1384
1386 {
1387 EntityAI entity = player.GetInventory().CreateInInventory("Splint");
1388 if (!entity)
1389 entity = player.SpawnEntityOnGroundOnCursorDir("Splint", 0.5);
1390
1393 Class.CastTo(attachment, player.GetItemOnSlot("Splint_Right"));
1394 if (attachment && attachment.GetType() == "Splint_Applied")
1395 {
1396 if (new_item)
1397 {
1398 MiscGameplayFunctions.TransferItemProperties(attachment, new_item);
1399
1400 if (GetGame().IsServer())
1401 {
1402 //Lower health level of splint after use
1403 if (new_item.GetHealthLevel() < 4)
1404 {
1405 int newDmgLevel = new_item.GetHealthLevel() + 1;
1406
1407 float max = new_item.GetMaxHealth("", "");
1408
1409 switch (newDmgLevel)
1410 {
1413 break;
1414
1416 new_item.SetHealth("", "", max * GameConstants.DAMAGE_DAMAGED_VALUE);
1417 break;
1418
1420 new_item.SetHealth("", "", max * GameConstants.DAMAGE_WORN_VALUE);
1421 break;
1422
1424 new_item.SetHealth("", "", max * GameConstants.DAMAGE_RUINED_VALUE);
1425 break;
1426
1427 default:
1428 break;
1429 }
1430 }
1431 }
1432 }
1433
1434 attachment.Delete();
1435 }
1436 }
1437
1440 {
1441 if (player.GetSimulationTimeStamp() < 20 && !player.IsPersistentFlag(PersistentFlag.AREA_PRESENCE))
1442 {
1443 //simulation time is bellow a threshold, which means the player has recently connected,
1444 //the player does not have the AREA_PRESENCE flag set, which means they were not inside the area when they disconnected,
1445 //that means they just spawned into a contaminated area, lets move them somewhere safe
1446 vector player_pos = player.GetPosition();
1448
1450 {
1452
1453 player.SetPosition(closest_safe_pos); //...so lets teleport them somewhere safe
1454 //DeveloperTeleport.SetPlayerPosition(player, closest_safe_pos);
1455 GetGame().RPCSingleParam(player, ERPCs.RPC_WARNING_TELEPORT, null, true, player.GetIdentity());
1456 }
1457
1458 player.SetPersistentFlag(PersistentFlag.AREA_PRESENCE, false);
1459 }
1460 }
1461
1462
1464 {
1466 float smallest_dist = float.MAX;
1467 foreach (array<float> pos: positions)
1468 {
1469 vector vpos = "0 0 0";
1470 vpos[0] = pos[0];
1471 vpos[2] = pos[1];
1472
1473 to_pos[1] = 0;
1474 float dist = vector.DistanceSq(to_pos, vpos);//2d dist sq
1475 if (dist < smallest_dist)
1476 {
1478 closest_pos = vpos;
1479 }
1480 }
1481 return closest_pos;
1482 }
1483
1485 {
1486 if (GetGame().IsServer())
1487 {
1488 NoiseSystem noise = GetGame().GetNoiseSystem();
1489 if (noise)
1490 noise.AddNoiseTarget(position, lifeTime, noiseParams);
1491 }
1492 }
1493
1495 {
1496 float minValue = 0.0;
1497 for (int i = 0; i < pArray.Count(); i++)
1498 {
1499 if (minValue == 0 || pArray.Get(i) < minValue)
1500 minValue = pArray.Get(i);
1501 }
1502
1503 return minValue;
1504 }
1505
1507 {
1508 float maxValue = 0.0;
1509 for (int i = 0; i < pArray.Count(); i++)
1510 {
1511 if (maxValue == 0 || pArray.Get(i) > maxValue)
1512 maxValue = pArray.Get(i);
1513 }
1514
1515 return maxValue;
1516 }
1517
1518 static string GetItemDisplayName(string type)
1519 {
1520 return GetGame().ConfigGetTextOut("CfgVehicles " + type + " displayName");
1521 }
1522
1524 {
1525 if (pSelection.Count() == 0 || pCompName.Length() == 0)
1526 return false;
1527
1528 for (int i = 0; i < pSelection.Count(); ++i)
1529 {
1530 pCompName.ToLower();
1531 if (pSelection[i] && pSelection[i].GetName() == pCompName)
1532 return true;
1533 }
1534
1535 return false;
1536 }
1537
1539 {
1540 if (!MiscGameplayFunctions.IsComponentInSelection(pSelection, pCompName))
1541 return INDEX_NOT_FOUND;
1542
1543 for (int i = 0; i < pSelection.Count(); ++i)
1544 {
1545 pCompName.ToLower();
1546 if (pSelection[i] && pSelection[i].GetName() == pCompName)
1547 return i;
1548 }
1549
1550 return INDEX_NOT_FOUND;
1551 }
1552
1554 {
1555 if (listOfTypenames.Count() > 0)
1556 {
1557 Object child = Object.Cast(parent.GetChildren());
1558 while (child)
1559 {
1561 child = Object.Cast(child.GetSibling());
1562
1563 if (childToRemove.IsAnyInherited(listOfTypenames))
1564 {
1565 vector pos = childToRemove.GetPosition();
1566 parent.RemoveChild(childToRemove, false);
1567
1568 vector m4[4];
1570 m4[3] = pos;
1571 childToRemove.SetTransform(m4);
1572 childToRemove.PlaceOnSurface();
1573 }
1574 }
1575 }
1576 }
1579 {
1580 IEntity child = parent.GetChildren();
1581 while (child)
1582 {
1583 outputObjects.Insert(child);
1584 child = child.GetSibling();
1585 }
1586 }
1587
1589 {
1590 if (g_Game.IsServer())
1591 {
1592 if (parent.GetLiquidType() != 0 && parent.GetQuantityNormalized() > liquidQuantityThresholdPercentage)
1593 item.SetWetMax();
1594 }
1595 }
1596}
1597
1599{
1600 // @NOTE m_Player == target player - i.e. restrained one
1602 {
1604 vector mtx[4];
1605 if (old_item)
1606 old_item.GetTransform(mtx);
1607 else
1608 player.GetTransform(mtx);
1609 gnd.SetGround(NULL, mtx);
1610 OverrideNewLocation(gnd);
1611 }
1612
1613 protected override void RemoveOldItemFromLocation()
1614 {
1615 super.RemoveOldItemFromLocation();
1616 m_Player.GetHumanInventory().OnEntityInHandsDestroyed(m_OldLocation);
1617 }
1618}
1619
1620// This was created since IsObjectObstructed is often called multiple times in one frame
1621// And apparently it seems that keeping this data in one struct seems to be more efficient than creating the variables dozens of times per frame
1622class IsObjectObstructedCache // Pretending this is a struct
1623{
1624 // Outside data
1627
1628 // Inside data
1635
1641
1642 // Only inside data
1644 {
1645 ObjectCenterPos = "0 0 0";
1646 ObjectContactPos = "0 0 0";
1647 ObjectContactDir = "0 0 0";
1648 ContactComponent = -1;
1649 HitProxyObjects.Clear();
1650 HitObjects.Clear();
1651 }
1652}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22
override void OnSuccess(EntityAI new_item)
const int ECE_NONE
const int ECE_PLACE_ON_SURFACE
const int ECE_UPDATEPATHGRAPH
const int RF_DEFAULT
const int ECE_CREATEPHYSICS
void Construction(BaseBuildingBase parent)
DayZGame g_Game
Definition DayZGame.c:3528
proto native int GetComponentIndex()
ERPCs
Definition ERPCs.c:2
DayZPlayer m_Player
Definition Hand_Events.c:42
Empty
Definition Hand_States.c:14
Icon x
Icon y
InventoryLocationType
types of Inventory Location
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Definition ItemBase.c:8415
PlayerBase m_Player
ref array< ref RaycastRVResult > HitProxyObjects
static bool CanIgnoreDistanceCheck(Object obj)
DestroyItemInCorpsesHandsAndCreateNewOnGndLambda RaycastStart
static vector TruncateVec(vector value, int decimals=2)
truncate float to specified precision
static string ObtainRestrainItemTargetClassname(notnull EntityAI entity)
TransferInventoryResult
static void GetAttachedChildren(IEntity parent, array< IEntity > outputObjects)
Fills the provided array with all children entities in hierarchy of this entity.
static void DealAbsoluteDmg(ItemBase item, float dmg)
static void TransferItemVariables(ItemBase source, ItemBase target, bool exclude_quantity=false)
static float Bobbing(float period, float amplitude, float elapsedTime)
static bool IsPlayerOrientedTowardPos(notnull DayZPlayerImplement player, vector target_pos, float cone_angle)
Check if player direction(based on cone of defined angle) is oriented to target position.
int TotalObjects
static void RemoveAllAttachedChildrenByTypename(notnull EntityAI parent, array< typename > listOfTypenames)
static bool BuildCondition(PlayerBase player, ActionTarget target, ItemBase item, bool camera_check)
static void TurnItemIntoItemEx(notnull PlayerBase player, ReplaceItemWithNewLambdaBase lambda)
static bool ComplexBuildCollideCheckClient(PlayerBase player, ActionTarget target, ItemBase item, string partName="")
static void DropAllItemsInInventoryInBounds(ItemBase ib, vector halfExtents)
static vector GetSteamPosition(EntityAI parent)
EntityAI m_NewItem
static void GenerateAINoiseAtPosition(vector position, float lifeTime, NoiseParams noiseParams)
vector ObjectContactDir
vector ObjectContactPos
enum ThrowEntityFlags Truncate(float value, int decimals=2)
truncate float to specified precision
vector ObjectCenterPos
static vector GetClosestSafePos(vector to_pos, notnull array< ref array< float > > positions)
static void FilterObstructedObjectsByGrouping(vector origin, float range, float distanceDelta, array< Object > objects, array< Object > obstructingObjects, out array< Object > filteredObjects, bool doDistanceCheck=false, bool checkIfDistanceCanBeIgnored=false, float maxDist=0)
group objects that are close to each other together
static int GetHealthLevelForAmmo(string class_name, float health)
ref set< Object > HitObjects
void MoveEquipToExistingItemAndDestroyOldRootLambda(EntityAI old_item, string new_item_type, PlayerBase player, EntityAI new_item)
static void TurnItemInHandsIntoItem(notnull ItemBase old_item, string new_item_type, notnull PlayerBase player)
void IsObjectObstructedCache(vector rayCastStart, int totalObjects)
static float GetTypeMaxGlobalHealth(string class_name, string health_type="Health")
static float Normalize(int val, int maxVal)
static string TruncateVecToS(vector value, int decimals=2, string delimiter=" ")
static string TruncateToS(float value, int decimals=2)
truncate float to specified precision, output as string
static void TurnItemInHandsIntoItemEx(notnull PlayerBase player, ReplaceItemWithNewLambdaBase lambda)
static TransferInventoryResult TransferInventory(EntityAI sourceItem, EntityAI targetItem, PlayerBase player)
static string GetItemDisplayName(string type)
static void TransformRestrainItem(EntityAI current_item, EntityAI tool, PlayerBase player_source, PlayerBase player_target, bool destroy=false)
static vector GetHeadingVector(notnull PlayerBase player)
static array< Magazine > CreateMagazinePilesFromBullet(string bullet_type, vector ground_position, float quantity, float health)
static bool IsValueInRange(float value, float from, float to)
static string SanitizeString(string input)
static bool IsComponentInSelection(array< Selection > pSelection, string pCompName)
static void GetHeadBonePos(notnull PlayerBase player, out vector pos)
static bool GetProjectedCursorPos3d(out vector position, Weapon_Base weapon)
static float GetEnergyMetabolicSpeed(int movement_speed)
static bool IsObjectObstructedFilter(Object object, IsObjectObstructedCache cache, PlayerBase player)
static void IsUnderRoofFromToCalculation(EntityAI entity, out vector from, out vector to, float height=GameConstants.ROOF_CHECK_RAYCAST_DIST)
static bool IsUnderRoof(EntityAI entity, float height=GameConstants.ROOF_CHECK_RAYCAST_DIST)
static float GetHeadingAngle(notnull DayZPlayerImplement player)
int ContactComponent
static bool IsObjectObstructed(Object object, bool doDistanceCheck=false, vector distanceCheckPos="0 0 0", float maxDist=0)
static void ThrowEntityFromInventory(notnull EntityAI entity, vector position, float direction[4], vector force, int flags)
static void RemoveSplint(PlayerBase player)
static bool IsObjectObstructedProxy(Object object, IsObjectObstructedCache cache, PlayerBase player)
static float GetWaterMetabolicSpeed(int movement_speed)
static bool IsObjectObstructedFilterEx(Object object, IsObjectObstructedCache cache, PlayerBase player, int geometryTypeOverride=-1)
groups 'RaycastRVProxy' and 'RaycastRV' approaches into one method, allowes for comprehensive geometr...
static void UnlimitedAmmoDebugCheck(Weapon_Base weapon)
static string ValueToBar(float value, string bar="[----------]", string mark="x")
Produces ACII "progress bar" based on an 0..1 'value' input.
static bool IsObjectObstructedEx(Object object, IsObjectObstructedCache cache, bool doDistanceCheck=false, vector distanceCheckPos="0 0 0", float maxDist=0)
static void SplitArrayIntoGroupsByDistance(array< Object > objects, array< ref array< Object > > objectGroups, float squaredDistanceDelta)
static string InsertAtPos(string base, string insert, int pos)
Insert 'insert' behind index 'pos' of the 'base' string.
static void TransferItemProperties(EntityAI source, notnull EntityAI target, bool transfer_agents=true, bool transfer_variables=true, bool transfer_health=true, bool exclude_quantity=false)
will transform item' variables, agents and other local scripted properties as well as any relevant no...
static float GetCurrentItemHeatIsolation(ItemBase pItem)
void ClearCache()
static float FModulus(float x, float y)
static array< Magazine > CreateMagazinePiles(string item_name, vector ground_position, float quantity, float health)
static bool IsUnderRoofEx(EntityAI entity, float height=GameConstants.ROOF_CHECK_RAYCAST_DIST, int geometry=ObjIntersectView)
static void TeleportCheck(notnull PlayerBase player, notnull array< ref array< float > > safe_positions)
checks if we should teleport the player to a safe location and if so, performs the teleportation
static void TurnItemIntoItem(notnull ItemBase old_item, string new_item_type, notnull PlayerBase player)
static void SoakItemInsideParentContainingLiquidAboveThreshold(notnull ItemBase item, notnull ItemBase parent, float liquidQuantityThresholdPercentage=0.05)
static void ThrowAllItemsInInventory(notnull EntityAI parent, int flags)
static void FilterObstructingObjects(array< Object > potentiallyObstructingObjects, out array< Object > obstructingObjects)
static array< ItemBase > CreateItemBasePiles(string item_name, vector ground_position, float quantity, float health, bool floaty_spawn=false)
Spawns multiple piles of stackable ItemBase objects on ground (intended for generic use)
PlayerBase GetPlayer()
class NoiseSystem NoiseParams()
Definition Noise.c:15
class OptionSelectorMultistate extends OptionSelector class_name
PersistentFlag
DebugActionType
float GetMinValue()
float GetMaxValue()
static ref TFloatArray ARRAY_FLOAT
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool RaycastRV(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, set< Object > results=NULL, Object with=NULL, Object ignore=NULL, bool sorted=false, bool ground_only=false, int iType=ObjIntersectView, float radius=0.0, CollisionFlags flags=CollisionFlags.NEARESTCONTACT)
Raycasts world by given parameters.
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
override void OnItemInHandsChanged()
Definition Debug.c:14
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
Definition Debug.c:341
void DestroyItemInCorpsesHandsAndCreateNewOnGndLambda(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy=false)
this one is a bit special: it drops all items and destroys the ex-root of the hierarchy
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
void DropEquipAndDestroyRootLambda(EntityAI old_item, string new_item_type, PlayerBase player)
script counterpart to engine's class Inventory
Definition Inventory.c:79
static proto native bool LocationCanAddEntity(notnull InventoryLocation inv_loc)
queries if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/....
static proto native bool PrepareDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix=false, int conflictCheckDepth=-1)
Finds a transformation for the item to be dropped to If the initial transforation overlaps with anoth...
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
InventoryLocation.
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
Definition EnMath.c:7
this one is a also bit special: it moves all items to already existing item and destroys the ex-root ...
static const float METABOLIC_SPEED_WATER_BASAL
static const float METABOLIC_SPEED_WATER_WALK
static const float METABOLIC_SPEED_ENERGY_JOG
static const float METABOLIC_SPEED_WATER_JOG
static const float METABOLIC_SPEED_ENERGY_WALK
static const float METABOLIC_SPEED_WATER_SPRINT
static const float METABOLIC_SPEED_ENERGY_SPRINT
static const float METABOLIC_SPEED_ENERGY_BASAL
base class for transformation operations (creating one item from another)
void RemoveNetworkObjectInfo()
Step C. - remove network part of the object @NOTE this operation does not delete the object,...
void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Step E. copy properties from old object to the created one.
void CreateNetworkObjectInfo(EntityAI new_item)
Step G. - create NetworkObjectInfo for new item.
adds automatic QuickBar handling
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
override void VerifyItemTypeBySlotType()
if attaching from att.slot to att.slot, skips the change to "ground" version. Allows for correct prop...
void TurnItemIntoItemLambda(EntityAI old_item, string new_item_type, PlayerBase player)
void SetTransferParams(bool transfer_agents=true, bool transfer_variables=true, bool transfer_health=true, bool exclude_quantity=false, float quantity_override=-1)
override void OnSuccess(EntityAI new_item)
override void OnSuccess(EntityAI new_item)
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static const vector Aside
Definition EnConvert.c:108
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Definition EnConvert.c:271
static const vector Forward
Definition EnConvert.c:109
static const vector Zero
Definition EnConvert.c:110
static vector RotateAroundZero(vector pos, vector axis, float cosAngle, float sinAngle)
Rotate a vector around 0,0,0.
Definition EnConvert.c:478
static const vector Up
Definition EnConvert.c:107
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
const int INDEX_NOT_FOUND
Definition gameplay.c:13
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Definition gameplay.c:6
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
CollisionFlags
Definition EnDebug.c:141
const float PROJECTED_CURSOR_DISTANCE
Definition constants.c:591
const float ROOF_CHECK_RAYCAST_DIST
Definition constants.c:867
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
array< string > TStringArray
Definition EnScript.c:666
array< int > TIntArray
Definition EnScript.c:668
proto native IEntity GetChildren()
Returns pointer to first child Entity in hierarchy.
const float ENVIRO_ISOLATION_WETFACTOR_SOAKED
Definition constants.c:712
const float ENVIRO_ISOLATION_WETFACTOR_WET
Definition constants.c:711
const float ENVIRO_ISOLATION_WETFACTOR_DAMP
Definition constants.c:710
const float ENVIRO_ISOLATION_WETFACTOR_DRENCHED
Definition constants.c:713
const float ENVIRO_ISOLATION_HEALTHFACTOR_RUINED
Definition constants.c:719
const float ENVIRO_ISOLATION_HEALTHFACTOR_DAMAGED
Definition constants.c:717
const float ENVIRO_ISOLATION_HEALTHFACTOR_WORN
Definition constants.c:716
const float ENVIRO_ISOLATION_WETFACTOR_DRY
Heat buffer static timer tick (set for 2s enviro tick, 180s to 1.0)
Definition constants.c:709
const float ENVIRO_ISOLATION_HEALTHFACTOR_PRISTINE
impact of item health (state) to the heat isolation
Definition constants.c:715
const float ENVIRO_ISOLATION_HEALTHFACTOR_B_DAMAGED
Definition constants.c:718
const float DAMAGE_BADLY_DAMAGED_VALUE
Definition constants.c:772
const float DAMAGE_RUINED_VALUE
Definition constants.c:773
const float DAMAGE_DAMAGED_VALUE
Definition constants.c:771
const float DAMAGE_WORN_VALUE
Definition constants.c:770
const int STATE_RUINED
Definition constants.c:757
const int STATE_WORN
Definition constants.c:760
const int STATE_DAMAGED
Definition constants.c:759
const int STATE_BADLY_DAMAGED
Definition constants.c:758
const int STATE_PRISTINE
Definition constants.c:761
const int VARIABLE_QUANTITY
Definition constants.c:579
const float STATE_DRY
Definition constants.c:785
const float STATE_DAMP
Definition constants.c:784
const float STATE_SOAKING_WET
Definition constants.c:782
const float STATE_DRENCHED
Definition constants.c:781
const float STATE_WET
Definition constants.c:783
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto void MatrixToQuat(vector mat[3], out float d[4])
Converts rotation matrix to quaternion.
static proto void YawPitchRollMatrix(vector ang, out vector mat[3])
Creates rotation matrix from angles.
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Definition EnMath3D.c:233
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Floor(float f)
Returns floor of value.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static const float PI_HALF
Definition EnMath.c:14
static proto float ModFloat(float x, float y)
Returns the floating-point remainder of x/y rounded towards zero.
static proto float Acos(float c)
Returns angle in radians from cosinus.
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Round(float f)
Returns mathematical round of value.
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
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'.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static proto float Pow(float v, float power)
Return power of v ^ power.
static const float RAD2DEG
Definition EnMath.c:16
static proto float AbsFloat(float f)
Returns absolute value.
const string CFG_VEHICLESPATH
Definition constants.c:209
const string CFG_WEAPONSPATH
Definition constants.c:210
const string CFG_MAGAZINESPATH
Definition constants.c:211
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin)
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
proto native owned string GetName()