DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ShelterSite.c
См. документацию.
1class ShelterSite extends BaseBuildingBase
2{
3 const float MAX_ACTION_DETECTION_ANGLE_RAD = 1.3; //1.3 RAD = ~75 DEG
4 const float MAX_ACTION_DETECTION_DISTANCE = 2.0; //meters
5
7 {
8 }
9
10 override string GetConstructionKitType()
11 {
12 return "ShelterKit";
13 }
14
15 override int GetMeleeTargetType()
16 {
17 return EMeleeTargetType.NONALIGNABLE;
18 }
19
20 //--- CONSTRUCTION KIT
22 {
23 if ( MemoryPointExists( "kit_spawn_position" ) )
24 {
25 vector position;
26 position = GetMemoryPointPos( "kit_spawn_position" );
27
28 return ModelToWorld( position );
29 }
30
31 return GetPosition();
32 }
33
34 //--- BUILD EVENTS
35 //CONSTRUCTION EVENTS
36 override void OnPartBuiltServer( notnull Man player, string part_name, int action_id )
37 {
38 ConstructionPart constrution_part = GetConstruction().GetConstructionPart( part_name );
39
40 string shelter_type = "";
41 switch (part_name)
42 {
43 case "leather":
44 shelter_type = "ShelterLeather";
45 break;
46
47 case "fabric":
48 shelter_type = "ShelterFabric";
49 break;
50
51 case "stick":
52 shelter_type = "ShelterStick";
53 break;
54
55 default: {};
56 }
57
58 if (shelter_type != "")
59 {
60 GetConstruction().DropNonUsableMaterialsServer( player, part_name );
61 MiscGameplayFunctions.TurnItemIntoItem(this, shelter_type, PlayerBase.Cast(player));
62
63 PluginAdminLog admin_log = PluginAdminLog.Cast( GetPlugin(PluginAdminLog) );
64 if (admin_log)
65 {
66 string playerPrefix = admin_log.GetPlayerPrefix(PlayerBase.Cast(player), player.GetIdentity());
67 admin_log.DirectAdminLogPrint(playerPrefix +" built " + shelter_type + " with Hands ");
68 }
69 }
70 //super.OnPartBuiltServer( part_name, action_id );
71 }
72
73 override bool CanPutIntoHands( EntityAI parent )
74 {
75 return false;
76 }
77
79 {
80 return true;
81 }
82
83 override bool CanUseHandConstruction()
84 {
85 return true;
86 }
87
88 override bool MustBeBuiltFromOutside()
89 {
90 return true;
91 }
92
93 override bool IsFacingCamera( string selection )
94 {
95 vector ref_dir = GetDirection();
97
98 //ref_dir = GetGame().GetCurrentCameraPosition() - GetPosition();
99 ref_dir.Normalize();
100 ref_dir[1] = 0; //ignore height
101
102 cam_dir.Normalize();
103 cam_dir[1] = 0; //ignore height
104
105 if ( ref_dir.Length() != 0 )
106 {
107 float angle = Math.Acos( cam_dir * ref_dir );
108
109 if ( angle >= MAX_ACTION_DETECTION_ANGLE_RAD )
110 {
111 return true;
112 }
113 }
114
115 return false;
116 }
117
118 override bool IsPlayerInside( PlayerBase player, string selection )
119 {
120 vector player_pos = player.GetPosition();
121 vector object_pos = GetPosition();
122 vector ref_dir = GetDirection();
123 ref_dir[1] = 0;
124 ref_dir.Normalize();
125
126 vector min,max;
127 min = -GetMemoryPointPos( "BoundingBox_min" );
128 max = -GetMemoryPointPos( "BoundingBox_max" );
129
130 vector dir_to_object = object_pos - player_pos;
131 dir_to_object[1] = 0;
132 float len = dir_to_object.Length();
133
134 dir_to_object.Normalize();
135
136 vector ref_dir_angle = ref_dir.VectorToAngles();
137 vector dir_to_object_angle = dir_to_object.VectorToAngles();
138 vector test_angles = dir_to_object_angle - ref_dir_angle;
139
140 vector test_position = test_angles.AnglesToVector() * len;
141
142 if(test_position[0] > max[0] || test_position[0] < min[0] || test_position[2] > max[2] || test_position[2] < min[2] )
143 {
144 return false;
145 }
146
147 return true;
148 }
149
150 override bool HasProperDistance( string selection, PlayerBase player )
151 {
152 if ( MemoryPointExists( selection ) )
153 {
154 vector selection_pos = ModelToWorld( GetMemoryPointPos( selection ) );
155 float distance = vector.Distance( selection_pos, player.GetPosition() );
156 if ( distance >= MAX_ACTION_DETECTION_DISTANCE )
157 {
158 return false;
159 }
160 }
161
162 return true;
163 }
164
174}
ActionFoldBaseBuildingObjectCB ActionContinuousBaseCB ActionFoldBaseBuildingObject()
Определения ActionFoldBaseBuildingObject.c:11
ActionPlaceObjectCB ActiondeployObjectCB ActionPlaceObject()
Определения ActionPlaceObject.c:11
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
Construction GetConstruction()
Определения BaseBuildingBase.c:2244
EMeleeTargetType
Определения EMeleeTargetType.c:2
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
override bool IsPlayerInside(PlayerBase player, string selection)
Определения ShelterSite.c:118
override string GetConstructionKitType()
Определения ShelterSite.c:10
override bool CanPutIntoHands(EntityAI parent)
Определения ShelterSite.c:73
override void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
Определения ShelterSite.c:36
override bool CanUseHandConstruction()
Определения ShelterSite.c:83
override void SetActions()
Определения ShelterSite.c:165
override bool MustBeBuiltFromOutside()
Определения ShelterSite.c:88
void ShelterSite()
Определения ShelterSite.c:6
const float MAX_ACTION_DETECTION_ANGLE_RAD
Определения Fence.c:16
override bool IsFacingCamera(string selection)
Определения ShelterSite.c:93
const float MAX_ACTION_DETECTION_DISTANCE
Определения Fence.c:17
override int GetMeleeTargetType()
Определения ShelterSite.c:15
override bool HasProperDistance(string selection, PlayerBase player)
Определения ShelterSite.c:150
override vector GetKitSpawnPosition()
Определения ShelterSite.c:21
override bool CanBeRepairedToPristine()
Определения ShelterSite.c:78
Определения Fence.c:2
proto native vector GetCurrentCameraDirection()
Определения Building.c:6
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
proto native float Length()
Returns length of vector (magnitude)
proto float Normalize()
Normalizes vector. Returns length.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.
Определения EnConvert.c:106
proto native CGame GetGame()
static proto float Acos(float c)
Returns angle in radians from cosinus.
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9