DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Shelter.c
Go to the documentation of this file.
1class ShelterBase extends TentBase
2{
3 static const string SITE_OBJECT_TYPE = "ShelterSite";
4
6 {
7 m_ShowAnimationsWhenPitched.Insert("Body");
8 m_ShowAnimationsWhenPacked.Insert("Body");
9
10 m_HalfExtents = Vector(0.8, 0.15, 1.3);
11 }
12
13 override void SetActions()
14 {
15 super.SetActions();
16
21
23 }
24
25 override void EEInit()
26 {
27 super.EEInit();
28
29 TryPitch(true, true);
30 }
31
33 {
35 SpawnKit();
36 Delete();
37 }
38
40 {
41 return string.Format("%1 %2 Construction site %3 Materials", CFG_VEHICLESPATH, SITE_OBJECT_TYPE, GetShelterVariant());
42 }
43
45 {
46 return "";
47 }
48
49 void SpawnKit()
50 {
51 ItemBase constructionKit = ItemBase.Cast(GetGame().CreateObjectEx("ShelterKit", GetPosition(), ECE_PLACE_ON_SURFACE));
52 constructionKit.SetHealth01("", "", GetHealth01());
53 }
54
55 override bool IsPlayerInside(PlayerBase player, string selection)
56 {
57 vector player_pos = player.GetPosition();
58 vector shelter_pos = GetPosition();
59 vector ref_dir = GetDirection();
60 ref_dir[1] = 0;
61 ref_dir.Normalize();
62
63 vector x[2];
64 vector b1,b2;
65 GetCollisionBox(x);
66 b1 = x[0];
67 b2 = x[1];
68
69 vector dir_to_shelter = shelter_pos - player_pos;
70 dir_to_shelter[1] = 0;
71 float len = dir_to_shelter.Length();
72
73 dir_to_shelter.Normalize();
74
75 vector ref_dir_angle = ref_dir.VectorToAngles();
76 vector dir_to_shelter_angle = dir_to_shelter.VectorToAngles();
77 vector test_angles = dir_to_shelter_angle - ref_dir_angle;
78
79 vector test_position = test_angles.AnglesToVector() * len;
80
81 if (test_position[0] < b1[0] || test_position[0] > b2[0] || test_position[2] < 0.2 || test_position[2] > 2.2 )
82 {
83 return false;
84 }
85 else
86 {
87 return true;
88 }
89 }
90}
91
92class ShelterFabric extends ShelterBase
93{
94 override string GetShelterVariant()
95 {
96 return "fabric";
97 }
98}
99
100class ShelterLeather extends ShelterBase
101{
102 override string GetShelterVariant()
103 {
104 return "leather";
106}
107
108class ShelterStick extends ShelterBase
109{
110 override string GetShelterVariant()
111 {
112 return "stick";
113 }
114}
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
ActionPackTentCB ActionContinuousBaseCB ActionPackTent()
void AddAction(typename actionName)
void RemoveAction(typename actionName)
const int ECE_PLACE_ON_SURFACE
Container_Base m_HalfExtents
Icon x
string GetMaterialPath()
Definition Shelter.c:131
static const string SITE_OBJECT_TYPE
Definition Shelter.c:95
void SpawnKit()
Definition Shelter.c:141
class JsonUndergroundAreaTriggerData GetPosition
override string GetShelterVariant()
Definition Shelter.c:102
static void SpawnConstructionMaterialPiles(notnull EntityAI entity, Man player, string cfg_path, string main_part_name, string damagezone_name="", bool is_base=false)
spawns material from any construction; 'player' parameter optional
string GetMaterialPath()
Definition Shelter.c:39
override void EEInit()
Definition Shelter.c:25
void Deconstruct()
Definition Shelter.c:32
override bool IsPlayerInside(PlayerBase player, string selection)
Definition Shelter.c:55
string GetShelterVariant()
Definition Shelter.c:44
void SpawnKit()
Definition Shelter.c:49
void ShelterBase()
Definition Shelter.c:5
override void SetActions()
Definition Shelter.c:13
proto float Normalize()
Normalizes vector. Returns length.
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
proto native float Length()
Returns length of vector (magnitude)
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
const string CFG_VEHICLESPATH
Definition constants.c:195
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.