3 const float MAX_ACTION_DETECTION_ANGLE_RAD = 1.3;
4 const float MAX_ACTION_DETECTION_DISTANCE = 2.0;
26 RegisterNetSyncVariableBool(
"m_RefresherActive");
36 int frequency =
GetCEApi().GetCEGlobalInt(
"FlagRefreshFrequency");
37 int max_duration =
GetCEApi().GetCEGlobalInt(
"FlagRefreshMaxDuration");
43 if ( max_duration > 0 )
52 return "TerritoryFlagKit";
74 if ( MemoryPointExists(
"kit_spawn_position" ) )
77 position = GetMemoryPointPos(
"kit_spawn_position" );
79 return ModelToWorld( position );
87 if ( category_name ==
"Base" && !
HasBase() )
103 super.OnStoreSave( ctx );
113 if ( !super.OnStoreLoad( ctx, version ) )
117 int loaded_max_duration;
129 if ( !ctx.
Read( loaded_max_duration ) )
147 super.AfterStoreLoad();
161 int time_elapsed_rounded =
Math.
Round(m_ElapsedSinceLastUpdate);
182 if (!
mission.m_ActiveRefresherLocations)
233 mission.m_ActiveRefresherLocations.Remove(idx);
239 super.OnVariablesSynchronized();
254 super.OnPartBuiltServer( player, part_name, action_id );
264 super.OnPartDismantledServer( player, part_name, action_id );
270 override void OnPartDestroyedServer( Man player,
string part_name,
int action_id,
bool destroyed_by_connected_part =
false )
272 super.OnPartDestroyedServer( player, part_name, action_id );
281 super.EEItemDetached( item, slot_name );
285 float state = GetAnimationPhase(
"flag_mast");
296 if ( !super.CanReceiveAttachment(attachment, slotId) )
300 if ( !
GetGame().IsDedicatedServer() )
315 if ( slot_name ==
"Material_FPole_Flag" )
326 for (
int i = 0; i <
GetConstruction().GetConstructionParts().Count(); i++)
331 if (part_id == -1 || part_id > part.
GetId())
334 part_id = part.
GetId();
342 string material_path;
343 if (
GetGame().ConfigIsExisting(cfg_path) )
346 string child_slot_name;
350 material_path =
"" + cfg_path +
" " + child_name +
" slot_name";
351 if (
GetGame().ConfigGetText(material_path,child_slot_name) && child_slot_name == slot_name )
378 vector player_pos = player.GetPosition();
380 vector ref_dir = GetDirection();
390 vector dir_to_fence = fence_pos - player_pos;
392 float len = dir_to_fence.
Length();
398 vector test_angles = dir_to_fence_angle - ref_dir_angle;
402 if(test_position[0] < b1[0] || test_position[0] > b2[0] || test_position[2] < 0.2 || test_position[2] > 2.2 )
417 vector player_pos = player.GetPosition();
418 vector ref_dir = GetDirection();
421 vector fence_player_dir = player.GetDirection();
423 fence_player_dir[1] = 0;
428 if ( ref_dir.
Length() != 0 )
430 float angle =
Math.
Acos( fence_player_dir * ref_dir );
445 vector ref_dir = GetDirection();
455 if ( ref_dir.
Length() != 0 )
457 float angle =
Math.
Acos( cam_dir * ref_dir );
471 if ( MemoryPointExists( selection ) )
473 vector selection_pos = ModelToWorld( GetMemoryPointPos( selection ) );
474 float distance =
vector.
Distance( selection_pos, player.GetPosition() );
510 if (temp < 0.01 || temp > 0.99)
517 SetAnimationPhase(
"flag_mast",phase_new);
533 PluginAdminLog logs = PluginAdminLog.Cast(
GetPlugin(PluginAdminLog));
537 logs.TotemFlagChange(
true, player,
this);
539 else if (newPhase == 1)
542 logs.TotemFlagChange(
false, player,
this);
599 super.OnDebugSpawn();
601 GetInventory().CreateInInventory(
"Flag_DayZ");
eBleedingSourceType GetType()
ActionFoldBaseBuildingObjectCB ActionContinuousBaseCB ActionFoldBaseBuildingObject()
void AddAction(typename actionName)
Construction GetConstruction()
proto native CEApi GetCEApi()
Get the CE API.
bool IsPartConstructed(string part_name)
PluginBase GetPlugin(typename plugin_type)
override bool CanDisplayAttachmentCategory(string category_name)
override void OnDebugSpawn()
override bool IsPlayerInside(PlayerBase player, string selection)
bool m_RefresherInitialized
override void OnVariablesSynchronized()
void SetRefreshTimer01(float fraction)
void RemoveRefresherPosition(int idx=-2)
override string GetConstructionKitType()
float GetRefresherTime01()
int m_FlagRefresherFrequency
override void EEItemDetached(EntityAI item, string slot_name)
override bool CanPutIntoHands(EntityAI parent)
int m_RefresherTimeRemaining
override void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
override void SetActions()
void AddRefresherTime01(float fraction)
void SetRefresherActive(bool state)
int m_FlagRefresherMaxDuration
const float MAX_ACTION_DETECTION_ANGLE_RAD
override bool IsFacingCamera(string selection)
override bool IsFacingPlayer(PlayerBase player, string selection)
const float MAX_ACTION_DETECTION_DISTANCE
override void OnCEUpdate()
override void AfterStoreLoad()
override bool OnStoreLoad(ParamsReadContext ctx, int version)
void LogAnimateFlag(float newPhase, notnull PlayerBase player)
override int GetMeleeTargetType()
override bool HasProperDistance(string selection, PlayerBase player)
void HandleRefreshers()
Saves positions of active lifetime refreshers to MissionGameplay / MissionServer.
override void OnPartDestroyedServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
void CheckLoadedVariables(int max_duration)
override void OnStoreSave(ParamsWriteContext ctx)
void InsertRefresherPosition()
override vector GetKitSpawnPosition()
override bool CanBeRepairedToPristine()
void AnimateFlagEx(float delta, PlayerBase player=null)
void AnimateFlag(float delta)
bool m_RefresherActiveLocal
override void OnPartDismantledServer(notnull Man player, string part_name, int action_id)
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native vector GetCurrentCameraDirection()
proto native Mission GetMission()
void SetActionInitiator(PlayerBase action_initiator)
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
proto bool Write(void value_out)
proto bool Read(void value_in)
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.
Serializer ParamsReadContext
proto native CGame GetGame()
Serializer ParamsWriteContext
const float REFRESHER_RADIUS
const int REFRESHER_MAX_DURATION_DEFAULT
const int REFRESHER_FREQUENCY_DEFAULT
static proto float Acos(float c)
Returns angle in radians from cosinus.
static proto float Round(float f)
Returns mathematical round of value.
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'.
class JsonUndergroundAreaTriggerData GetPosition