1872{
1874
1876
1878
1885
1886
1887
1893
1899
1901
1905
1906
1908 {
1910
1911
1912 RegisterNetSyncVariableInt( "m_SyncParts01" );
1913 RegisterNetSyncVariableInt( "m_SyncParts02" );
1914 RegisterNetSyncVariableInt( "m_SyncParts03" );
1915 RegisterNetSyncVariableInt( "m_InteractedPartId" );
1916 RegisterNetSyncVariableInt( "m_PerformedActionId" );
1917 RegisterNetSyncVariableBool( "m_HasBase" );
1918
1919
1920 ConstructionInit();
1921
1922 if (ConfigIsExisting("hybridAttachments"))
1923 {
1926 }
1927 if (ConfigIsExisting("mountables"))
1928 {
1931 }
1932
1934 SetAllowDamage(true);
1935 }
1936
1938 {
1939 return "disableBaseDamage";
1940 }
1941
1943 {
1944 return true;
1945 }
1946
1948 {
1949 return EInventoryIconVisibility.HIDE_VICINITY;
1950 }
1951
1953 {
1954 super.InitItemSounds();
1955
1959
1964 }
1965
1967 {
1968 return "putDown_FenceKit_SoundSet";
1969 }
1970
1972 {
1973 return "Shelter_Site_Build_Loop_SoundSet";
1974 }
1975
1976
1978 {
1980 {
1981 SetSynchDirty();
1982 }
1983 }
1984
1986 {
1988 super.OnVariablesSynchronized();
1989
1991 }
1992
1994 {
1995
1997
1998
2000
2001
2003 }
2004
2005
2007 {
2008
2009 int offset;
2010 int mask;
2011
2012 if ( part_id >= 1 && part_id <= 31 )
2013 {
2014 offset = part_id - 1;
2015 mask = 1 << offset;
2016
2018 }
2019 else if ( part_id >= 32 && part_id <= 62 )
2020 {
2021 offset = ( part_id % 32 );
2022 mask = 1 << offset;
2023
2025 }
2026 else if ( part_id >= 63 && part_id <= 93 )
2027 {
2028 offset = ( part_id % 63 );
2029 mask = 1 << offset;
2030
2032 }
2033 }
2034
2036 {
2037
2038 int offset;
2039 int mask;
2040
2041 if ( part_id >= 1 && part_id <= 31 )
2042 {
2043 offset = part_id - 1;
2044 mask = 1 << offset;
2045
2047 }
2048 else if ( part_id >= 32 && part_id <= 62 )
2049 {
2050 offset = ( part_id % 32 );
2051 mask = 1 << offset;
2052
2054 }
2055 else if ( part_id >= 63 && part_id <= 93 )
2056 {
2057 offset = ( part_id % 63 );
2058 mask = 1 << offset;
2059
2061 }
2062 }
2063
2065 {
2066
2067 int offset;
2068 int mask;
2069
2070 if ( part_id >= 1 && part_id <= 31 )
2071 {
2072 offset = part_id - 1;
2073 mask = 1 << offset;
2074
2076 {
2077 return true;
2078 }
2079 }
2080 else if ( part_id >= 32 && part_id <= 62 )
2081 {
2082 offset = ( part_id % 32 );
2083 mask = 1 << offset;
2084
2086 {
2087 return true;
2088 }
2089 }
2090 else if ( part_id >= 63 && part_id <= 93 )
2091 {
2092 offset = ( part_id % 63 );
2093 mask = 1 << offset;
2094
2096 {
2097 return true;
2098 }
2099 }
2100
2101 return false;
2102 }
2103
2105 {
2108 }
2109
2111 {
2112
2115 }
2116
2118 {
2120 {
2123
2124 switch( build_action_id )
2125 {
2129 }
2130 }
2131 }
2132
2133
2135 {
2137 bool is_base = part.
IsBase();
2140 if ( is_part_built_sync )
2141 {
2143 {
2147
2148 if (is_base)
2149 {
2152 }
2153 }
2154 }
2155 else
2156 {
2158 {
2162
2163 if (is_base)
2164 {
2167 }
2168 }
2169 }
2170
2171
2173 }
2174
2175
2177 {
2180
2181 for ( int i = 0; i < construction_parts.Count(); ++i )
2182 {
2183 string key = construction_parts.GetKey( i );
2186 }
2187
2188
2190 }
2191
2193 {
2196
2197 for ( int i = 0; i < construction_parts.Count(); ++i )
2198 {
2199 string key = construction_parts.GetKey( i );
2201
2202 if ( value.
GetId() ==
id )
2203 {
2204 return value;
2205 }
2206 }
2207
2208 return NULL;
2209 }
2210
2211
2212
2214 {
2216 }
2217
2219 {
2221 }
2222
2224 {
2225 return true;
2226 }
2227
2229 {
2230 return false;
2231 }
2232
2233
2235 {
2238 {
2240 }
2241
2242 return construction_kit;
2243 }
2244
2246 {
2249 {
2251 }
2252 }
2253
2255 {
2257 }
2258
2260 {
2261 return "";
2262 }
2263
2265 {
2267 g_Game.ObjectDelete( construction_kit );
2268 }
2269
2270
2272 {
2274 g_Game.ObjectDelete(
this );
2275 }
2276
2277
2279 {
2280 super.EEDelete(parent);
2281
2283 {
2284 areaDamage.Destroy();
2285 }
2286
2287 }
2288
2290 {
2291 super.OnStoreSave( ctx );
2292
2293
2297
2299 }
2300
2302 {
2303 if ( !super.OnStoreLoad( ctx, version ) )
2304 return false;
2305
2306
2307
2309 {
2311 return false;
2312 }
2314 {
2316 return false;
2317 }
2319 {
2321 return false;
2322 }
2323
2324
2326 {
2328 return false;
2329 }
2330
2331
2332 return true;
2333 }
2334
2336 {
2337 super.AfterStoreLoad();
2338
2340 {
2342 }
2343 }
2344
2346 {
2347
2349
2350
2353
2354
2356 }
2357
2359 {
2360 super.OnCreatePhysics();
2361
2362 ConstructionInit();
2364 }
2365
2367 {
2369 return;
2370
2371 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
2372 }
2373
2375 {
2377 {
2379 }
2380
2381 super.EEOnAfterLoad();
2382 }
2383
2385 {
2386 super.EEItemAttached( item, slot_name );
2387
2391 }
2392
2394 {
2395 super.EEItemDetached( item, slot_name );
2396
2399 }
2400
2401 protected void OnSetSlotLock(
int slotId,
bool locked,
bool was_locked )
2402 {
2405
2408 }
2409
2410
2412 {
2413 return true;
2414 }
2415
2416
2417
2419 {
2421
2422
2423 if (construtionPart.
IsBase())
2424 {
2426
2427
2429 }
2430
2431
2433
2434
2436
2437
2439
2441
2443
2444
2446
2447
2449 }
2450
2452 {
2453
2455 }
2456
2457
2459 {
2462
2463
2465
2466
2468
2469
2471
2472
2474
2476
2477
2479
2480
2482
2483
2484 if (construtionPart.
IsBase())
2485 {
2486
2488 }
2489 }
2490
2492 {
2493
2495 }
2496
2497
2498 void OnPartDestroyedServer(Man player,
string part_name,
int action_id,
bool destroyed_by_connected_part =
false)
2499 {
2502
2503
2505
2506
2508
2509
2511
2512
2514
2516
2517
2519
2520
2522
2523
2524 if (construtionPart.
IsBase())
2525 {
2526
2528 }
2529 }
2530
2532 {
2533
2535 }
2536
2537
2539 {
2541
2544 }
2545
2547 {
2549
2551 {
2553 }
2554 else
2555 {
2557 }
2558
2560 }
2561
2563 {
2565
2567 foreach (
string slotName : attachmentSlots)
2568 {
2570 }
2571
2572
2575 else
2577
2579 }
2580
2582 {
2583 string slotNameMounted = slot_name + "_Mounted";
2584 EntityAI attachment = FindAttachmentBySlotName(slot_name);
2585
2586 if (attachment)
2587 {
2588 BarbedWire barbedWire = BarbedWire.Cast(attachment);
2589 if (barbedWire && barbedWire.IsMounted())
2591 else
2593
2594 if (is_locked)
2595 {
2596 SetAnimationPhase(slotNameMounted, 0);
2597 SetAnimationPhase(slot_name, 1);
2598 }
2599 else
2600 {
2601 SetAnimationPhase(slotNameMounted, 1);
2602 SetAnimationPhase(slot_name, 0);
2603 }
2604 }
2605 else
2606 {
2607 SetAnimationPhase(slotNameMounted, 1);
2608 SetAnimationPhase(slot_name, 1);
2609
2611 }
2612 }
2613
2614
2616 {
2619
2622
2625
2626 foreach (
string slotName : attachmentSlots)
2627 {
2629 }
2630
2631
2633 {
2636
2638 }
2639 else
2640 {
2643
2645 }
2646
2649 }
2650
2652 {
2653
2655 return;
2656
2657 string slot_name_mounted = slot_name + "_Mounted";
2658 EntityAI attachment = FindAttachmentBySlotName( slot_name );
2659
2660
2662 RemoveProxyPhysics( slot_name_mounted );
2663 RemoveProxyPhysics( slot_name );
2664
2665 if ( attachment )
2666 {
2668 if ( is_locked )
2669 {
2671 AddProxyPhysics( slot_name_mounted );
2672 }
2673 else
2674 {
2676 AddProxyPhysics( slot_name );
2677 }
2678 }
2679 }
2680
2682 {
2683 SetAffectPathgraph( true, false );
2685 }
2686
2688 {
2689 return true;
2690 }
2691
2693 {
2694 return true;
2695 }
2696
2698 {
2699 if ( attachment )
2700 {
2702 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
2703
2704 return GetInventory().GetSlotLock( inventory_location.
GetSlot() );
2705 }
2706
2707 return false;
2708 }
2709
2711 {
2713 }
2714
2715
2717 {
2718 string config_path = "CfgVehicles" + " " + entity.GetType() + " " + "attachments";
2719 if (
g_Game.ConfigIsExisting( config_path ) )
2720 {
2721 g_Game.ConfigGetTextArray( config_path, attachment_slots );
2722 }
2723 }
2724
2726 {
2727 return true;
2728 }
2729
2731 {
2732 return true;
2733 }
2734
2736 {
2737 return true;
2738 }
2739
2740
2742 {
2745 }
2746
2748 {
2750 }
2751
2753 {
2755 }
2756
2758 {
2759 int attachment_count = GetInventory().AttachmentCount();
2760 if ( attachment_count > 0 )
2761 {
2762 if (
HasBase() && attachment_count == 1 )
2763 {
2764 return false;
2765 }
2766
2767 return true;
2768 }
2769
2770 return false;
2771 }
2772
2774 {
2775 return true;
2776 }
2777
2779 {
2780 return false;
2781 }
2782
2783
2785 {
2786 return false;
2787 }
2788
2790 {
2791 return false;
2792 }
2793
2794
2796 {
2797 return false;
2798 }
2799
2800
2801
2803 {
2804 return true;
2805 }
2806
2808 {
2809 return true;
2810 }
2811
2814 {
2815 return false;
2816 }
2817
2818
2820 {
2821 return false;
2822 }
2823
2824
2826 {
2827 return true;
2828 }
2829
2830
2832 {
2833 if (
HasBase() || GetInventory().AttachmentCount() > 0 )
2834 {
2835 return false;
2836 }
2837
2838 return true;
2839 }
2840
2842 {
2845
2846 return item;
2847 }
2848
2849
2851 {
2853 {
2854
2856
2857
2860
2862 if ( MemoryPointExists( slot_name + "_min" ) )
2863 {
2864 min_max[0] = GetMemoryPointPos( slot_name + "_min" );
2865 }
2866 if ( MemoryPointExists( slot_name + "_max" ) )
2867 {
2868 min_max[1] = GetMemoryPointPos( slot_name + "_max" );
2869 }
2870
2871
2874
2875
2878 center = ModelToWorld( center );
2879
2880
2883
2884 areaDamage.SetExtents( extents[0], extents[1] );
2885 areaDamage.SetAreaPosition( center );
2889 areaDamage.SetHitZones( { "Torso","LeftHand","LeftLeg","LeftFoot","RightHand","RightLeg","RightFoot" } );
2890 areaDamage.SetAmmoName( "BarbedWireHit" );
2891 areaDamage.Spawn();
2892
2894 }
2895 }
2896
2898 {
2899 if ( angle_deg != 0 )
2900 {
2901
2903
2904
2906 if ( MemoryPointExists( "rotate_axis" ) )
2907 {
2908 rotate_axis = ModelToWorld( GetMemoryPointPos( "rotate_axis" ) );
2909 }
2910 float r_center_x = (
Math.
Cos( angle_deg *
Math.
DEG2RAD ) * ( center[0] - rotate_axis[0] ) ) - (
Math.
Sin( angle_deg *
Math.
DEG2RAD ) * ( center[2] - rotate_axis[2] ) ) + rotate_axis[0];
2911 float r_center_z = (
Math.
Sin( angle_deg *
Math.
DEG2RAD ) * ( center[0] - rotate_axis[0] ) ) + (
Math.
Cos( angle_deg *
Math.
DEG2RAD ) * ( center[2] - rotate_axis[2] ) ) + rotate_axis[2];
2912 center[0] = r_center_x;
2913 center[2] = r_center_z;
2914 }
2915 }
2916
2918 {
2920 {
2923 {
2924 if (areaDamage)
2925 {
2926 areaDamage.Destroy();
2927 }
2928
2930 }
2931 }
2932 }
2933
2935 {
2936 return true;
2937 }
2938
2939
2940
2941
2943 {
2945 }
2946
2948 {
2950 }
2951
2953 {
2955 }
2956
2958 {
2960
2961 switch ( material_type )
2962 {
2968 }
2969
2970 return "";
2971 }
2972
2974 {
2976
2977 switch ( material_type )
2978 {
2984 }
2985
2986 return "";
2987 }
2988
2989
2991 {
2993 {
2994
2996 {
2997 SetHealth(slot_name,"Health",item.GetHealth());
2998 }
2999 }
3000 }
3001
3003 {
3004 return 111;
3005 }
3006
3008 {
3009 super.SetActions();
3010
3014 }
3015
3017 {
3019 if (!construction)
3020 return;
3021
3023 for ( int i = constructionParts.Count() - 1; i >= 0; --i )
3024 {
3027 {
3029 }
3030 }
3031 }
3032
3034 {
3036 if (!construction)
3037 return;
3038
3040 for ( int i = constructionParts.Count() - 1; i >= 0; --i )
3041 {
3044 {
3045 construction.HandleEntityFalling(part.
GetPartName());
3046 }
3047 }
3048 }
3049
3052 {
3054 return;
3055
3058
3059 if (DestroyOnFall())
3060 {
3062 {
3064 }
3065 else
3066 {
3068 {
3070 }
3072 }
3073 }
3074 }
3075
3077 {
3078 if (HasAnyAttachmentsOrCargo())
3079 {
3082 }
3083 }
3084
3085
3086
3087
3088
3091 {
3092 return null;
3093 }
3094
3096 {
3098 }
3099
3101 {
3104
3105 Man p;
3106
3107 #ifdef SERVER
3109 g_Game.GetWorld().GetPlayerList(players);
3110 if (players.Count())
3111 p = players[0];
3112 #else
3114 #endif
3115
3117 {
3118 bool excluded = false;
3120 if (excludes)
3121 {
3122 foreach (string exclude : excludes)
3123 {
3125 {
3126 excluded = true;
3127 break;
3128 }
3129 }
3130 }
3131
3132 if (!excluded)
3133 {
3135 }
3136 }
3137
3139 }
3140
3142
3144 [
Obsolete(
"handled in the Construction component directly")]
3146 {
3147 }
3148
3149 [
Obsolete(
"handled in the Construction component directly")]
3151 {
3152 }
3153
3154 [
Obsolete(
"obsolete debug method")]
3156 {
3157 }
3158}
3159
3161{
3162#ifdef BSB_DEBUG
3164#else
3165
3166#endif
3167}
3169{
3170#ifdef BSB_DEBUG_SPAM
3172#else
3173
3174#endif
3175}
const int AT_DISMANTLE_PART
const int AT_DESTROY_PART
ref ConstructionBasic m_Construction
void AddAction(typename actionName)
void RemoveAction(typename actionName)
void AreaDamageManager(EntityAI parent)
void OnPartDismantledClient(string part_name, int action_id)
const string ANIMATION_DEPLOYED
override int GetHideIconMask()
override void OnStoreSave(ParamsWriteContext ctx)
void SetActionFromSyncData()
bool CheckMemoryPointVerticalDistance(float max_dist, string selection, PlayerBase player)
override void OnDebugSpawn()
array< string > OnDebugSpawnBuildExcludes()
Excludes certain parts from being built by OnDebugSpawn, uses Contains to compare.
void DropAttachmentAndCargoItems()
void SoundDestroyStart(string part_name)
const string SOUND_BUILD_WOOD_LOG
void SoundBuildStart(string part_name)
void UpdateAttachmentVisuals(string slot_name, bool is_locked)
void CalcDamageAreaRotation(float angle_deg, out vector center, out vector orientation)
override bool CanObstruct()
bool HasAttachmentsBesidesBase()
override void InitItemSounds()
void RegisterPartForSync(int part_id)
ConstructionBasic CreateConstructionComponent()
const string SOUND_DISMANTLE_METAL
void SetPartsAfterStoreLoad()
void DestroyConstruction()
ref array< string > m_HybridAttachments
override string GetFoldSoundset()
string GetDismantleSoundByMaterial(string part_name)
bool IsAttachmentSlotLocked(EntityAI attachment)
override bool IsFacingPlayer(PlayerBase player, string selection)
void OnPartBuiltClient(string part_name, int action_id)
bool HasProperDistance(string selection, PlayerBase player)
override void OnCreatePhysics()
void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
void RegisterActionForSync(int part_id, int action_id)
const string SOUND_BUILD_WOOD_PLANK
void SetPartsFromSyncData()
ref array< string > m_Mountables
const string SOUND_BUILD_WIRE
void ResetActionSyncData()
override string GetInvulnerabilityTypeString()
void OnPartDismantledServer(notnull Man player, string part_name, int action_id)
void CheckForHybridAttachments(EntityAI item, string slot_name)
override void EEOnAfterLoad()
override void EEItemDetached(EntityAI item, string slot_name)
vector GetKitSpawnPosition()
override void OnItemFallRebuilding()
@Note for modders: This method and is subject to change!
bool CheckSlotVerticalDistance(int slot_id, PlayerBase player)
void GetAttachmentSlots(EntityAI entity, out array< string > attachment_slots)
override bool IsDeployable()
void OnPartDestroyedClient(string part_name, int action_id)
void UnregisterPartForSync(int part_id)
void bsbDebugSpam(string s)
override void OnVariablesSynchronized()
bool PerformRoofCheckForBase(string partName, PlayerBase player, out bool result)
Construction GetConstruction()
void SoundDismantleStart(string part_name)
ConstructionPart GetConstructionPartById(int id)
string GetConstructionKitType()
bool CheckLevelVerticalDistance(float max_dist, string selection, PlayerBase player)
void OnPartDestroyedServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
bool CanFoldBaseBuildingObject()
override int GetDamageSystemVersionChange()
const string SOUND_DISMANTLE_WOOD_PLANK
override void EEItemAttached(EntityAI item, string slot_name)
const string SOUND_DISMANTLE_WOOD_LOG
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
const string SOUND_BUILD_WOOD_STAIRS
ItemBase FoldBaseBuildingObject()
override ConstructionBasic GetConstructionBasic()
override bool CanPutInCargo(EntityAI parent)
override bool CanUseConstruction()
override void AfterStoreLoad()
void SetPartFromSyncData(ConstructionPart part)
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
override bool IgnoreOutOfReachCondition()
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override bool ShowZonesHealth()
void UpdateAttachmentPhysics(string slot_name, bool is_locked)
void HandleFallingForConstructedParts()
override bool IsPlayerInside(PlayerBase player, string selection)
string GetBuildSoundByMaterial(string part_name)
ItemBase CreateConstructionKit()
const string SOUND_DISMANTLE_WIRE
bool MustBeBuiltFromOutside()
Some buildings can only be built from outside.
override bool IsTakeable()
float m_ConstructionKitHealth
override void EEDelete(EntityAI parent)
override void SetActions()
void HandleItemFalling(ConstructionPart part)
void DestroyConstructionKit(ItemBase construction_kit)
void CreateConstructionKitInHands(notnull PlayerBase player)
void ItemFall(vector min, vector max)
override bool CanUseConstructionBuild()
void OnSynchronizedClient()
void SynchronizeBaseState()
override bool IsIgnoredByConstruction()
ref map< string, ref AreaDamageManager > m_DamageTriggers
void SetBaseState(bool has_base)
const string SOUND_BUILD_METAL
override string GetLoopFoldSoundset()
void OnSetSlotLock(int slotId, bool locked, bool was_locked)
override bool CanPutIntoHands(EntityAI parent)
bool IsPartBuildInSyncData(int part_id)
override bool CanRemoveFromCargo(EntityAI parent)
void DestroyConstructedParts()
const string SOUND_DISMANTLE_WOOD_STAIRS
const int ECE_PLACE_ON_SURFACE
PlayerSpawnPreset slotName
ConstructionMaterialType
used to guide action sound selection, mostly. Could be also used for particles and stuff,...
string GetLoopFoldSoundset()
ItemSoundHandler GetItemSoundHandler()
bool m_FixDamageSystemInit
void ItemSoundHandler(ItemBase parent)
override void SetLoopInterval(float time)
A particular version of the deferred loop used to not damage players inside vehicles.
override void SetDeferDuration(float time)
static bool GetDisableRefundMaterialsOnFall()
static bool GetDisableDropAttachmentsOnFall()
static bool GetDisableItemFalling()
override void DestroyPartServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
just declared for module 3 use
Instanced construction part data classes for dynamic data, statics now stored on EntityType level in ...
Wrapper class for managing sound through SEffectManager.
proto native int GetSlot()
returns slot id if current type is Attachment
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
static bool IsBaseBuildingLogEnable()
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override string GetDebugName()
Serializer ParamsReadContext
Serializer ParamsWriteContext
proto void PrintToRPT(void var)
Prints content of variable to RPT file (performance warning - each write means fflush!...
void Obsolete(string msg="")
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static const float DEG2RAD
vector GetPosition()
Get the world position of the Effect.
bool Contains(string sample)
Returns true if sample is substring of string.