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 ( !
g_Game.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 (
g_Game.ConfigIsExisting(cfg_path) )
346 string child_slot_name;
347 for ( i = 0; i <
g_Game.ConfigGetChildrenCount( cfg_path ); i++ )
349 g_Game.ConfigGetChildName( cfg_path, i, child_name );
350 material_path =
"" + cfg_path +
" " + child_name +
" slot_name";
351 if (
g_Game.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.
override void OnDebugSpawn()
override bool CanDisplayAttachmentCategory(string category_name)
int m_FlagRefresherFrequency
const float MAX_ACTION_DETECTION_ANGLE_RAD
void HandleRefreshers()
Saves positions of active lifetime refreshers to MissionGameplay / MissionServer.
override void OnCEUpdate()
bool m_RefresherInitialized
void SetRefresherActive(bool state)
override bool IsFacingPlayer(PlayerBase player, string selection)
override void OnStoreSave(ParamsWriteContext ctx)
override bool IsFacingCamera(string selection)
override bool CanBeRepairedToPristine()
override bool HasProperDistance(string selection, PlayerBase player)
void CheckLoadedVariables(int max_duration)
override void OnPartDismantledServer(notnull Man player, string part_name, int action_id)
int m_FlagRefresherMaxDuration
override bool IsPlayerInside(PlayerBase player, string selection)
void RemoveRefresherPosition(int idx=-2)
override int GetMeleeTargetType()
override void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
override void EEItemDetached(EntityAI item, string slot_name)
override void OnPartDestroyedServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
override void AfterStoreLoad()
override bool CanPutIntoHands(EntityAI parent)
void LogAnimateFlag(float newPhase, notnull PlayerBase player)
float GetRefresherTime01()
int m_RefresherTimeRemaining
const float MAX_ACTION_DETECTION_DISTANCE
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override string GetConstructionKitType()
bool m_RefresherActiveLocal
void AnimateFlag(float delta)
override void OnVariablesSynchronized()
void AnimateFlagEx(float delta, PlayerBase player=null)
void SetRefreshTimer01(float fraction)
void InsertRefresherPosition()
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
override vector GetKitSpawnPosition()
void AddRefresherTime01(float fraction)
override void SetActions()
void SetActionInitiator(PlayerBase action_initiator)
provides access to slot configuration
static proto native owned string GetSlotName(int id)
static proto native int GetSlotIdFromString(string slot_name)
proto bool Write(void value_out)
proto bool Read(void value_in)
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto float Normalize()
Normalizes vector.
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).
bool IsPartConstructed(string part_name)
Serializer ParamsReadContext
Serializer ParamsWriteContext
const int REFRESHER_MAX_DURATION_DEFAULT
const int REFRESHER_FREQUENCY_DEFAULT
const float REFRESHER_RADIUS
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'.
vector GetPosition()
Get the world position of the Effect.
PluginBase GetPlugin(typename plugin_type)