3 const float MAX_ACTION_DETECTION_ANGLE_RAD = 1.3;
4 const float MAX_ACTION_DETECTION_DISTANCE = 2.0;
23 if ( MemoryPointExists(
"kit_spawn_position" ) )
26 position = GetMemoryPointPos(
"kit_spawn_position" );
28 return ModelToWorld( position );
40 string shelter_type =
"";
44 shelter_type =
"ShelterLeather";
48 shelter_type =
"ShelterFabric";
52 shelter_type =
"ShelterStick";
58 if (shelter_type !=
"")
61 MiscGameplayFunctions.TurnItemIntoItem(
this, shelter_type,
PlayerBase.Cast(player));
63 PluginAdminLog admin_log = PluginAdminLog.Cast(
GetPlugin(PluginAdminLog) );
66 string playerPrefix = admin_log.GetPlayerPrefix(
PlayerBase.Cast(player), player.GetIdentity());
67 admin_log.DirectAdminLogPrint(playerPrefix +
" built " + shelter_type +
" with Hands ");
95 vector ref_dir = GetDirection();
105 if ( ref_dir.
Length() != 0 )
107 float angle =
Math.
Acos( cam_dir * ref_dir );
109 if ( angle >= MAX_ACTION_DETECTION_ANGLE_RAD )
120 vector player_pos = player.GetPosition();
122 vector ref_dir = GetDirection();
127 min = -GetMemoryPointPos(
"BoundingBox_min" );
128 max = -GetMemoryPointPos(
"BoundingBox_max" );
130 vector dir_to_object = object_pos - player_pos;
131 dir_to_object[1] = 0;
132 float len = dir_to_object.
Length();
138 vector test_angles = dir_to_object_angle - ref_dir_angle;
142 if(test_position[0] > max[0] || test_position[0] < min[0] || test_position[2] > max[2] || test_position[2] < min[2] )
152 if ( MemoryPointExists( selection ) )
154 vector selection_pos = ModelToWorld( GetMemoryPointPos( selection ) );
155 float distance =
vector.
Distance( selection_pos, player.GetPosition() );
156 if ( distance >= MAX_ACTION_DETECTION_DISTANCE )
ActionFoldBaseBuildingObjectCB ActionContinuousBaseCB ActionFoldBaseBuildingObject()
void AddAction(typename actionName)
Construction GetConstruction()
PluginBase GetPlugin(typename plugin_type)
class JsonUndergroundAreaTriggerData GetPosition
override bool MustBeBuiltFromOutside()
override bool CanUseHandConstruction()
override bool IsFacingCamera(string selection)
override bool CanBeRepairedToPristine()
override bool HasProperDistance(string selection, PlayerBase player)
override bool IsPlayerInside(PlayerBase player, string selection)
override int GetMeleeTargetType()
override void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
override bool CanPutIntoHands(EntityAI parent)
override string GetConstructionKitType()
override vector GetKitSpawnPosition()
override void SetActions()
proto native vector GetCurrentCameraDirection()
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
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()
static proto float Acos(float c)
Returns angle in radians from cosinus.