DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ DropNonUsableMaterialsServer()

void DropNonUsableMaterialsServer ( Man player,
string part_name )
protected

См. определение в файле Construction.c строка 788

789 {
790 ConstructionPart construction_part = GetConstructionPart( part_name );
791
792 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "platform_support";
793 string platform_support;
794
795 if ( g_Game.ConfigIsExisting( cfg_path ) )
796 {
797 g_Game.ConfigGetText( cfg_path, platform_support );
798 }
799
800 if ( platform_support.Length() > 0 || construction_part.IsBase() )
801 {
802 string at_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "GUIInventoryAttachmentsProps";
803
804 if ( g_Game.ConfigIsExisting( at_cfg_path ) )
805 {
806 int child_count = g_Game.ConfigGetChildrenCount( at_cfg_path );
807
808 for ( int i = 0; i < child_count; i++ )
809 {
810 string child_name;
811 g_Game.ConfigGetChildName( at_cfg_path, i, child_name );
812 child_name.ToLower();
813
814 if ( child_name.Contains( platform_support ) )
815 {
816 ref array<string> attachment_slots = new array<string>;
817 g_Game.ConfigGetTextArray( at_cfg_path + " " + child_name + " " + "attachmentSlots", attachment_slots );
818
819 for ( int j = 0; j < attachment_slots.Count(); ++j )
820 {
821 //get material
822 ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( attachment_slots.Get( j ) ) );
823
824 //material still attached
825 if ( attachment )
826 {
827 InventoryLocation inventory_location = new InventoryLocation;
828 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
829 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(GetParent()) + " DropNonUsableMaterials UNlocking slot=" + inventory_location.GetSlot());
830
831 //unlock slot
832 GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot() , false );
833
834 EntityAI parent = GetParent();
835 if (!parent)
836 parent = player;
837
838 int quantity_max = attachment.GetTargetQuantityMax(-1);
840 vector mat[4];
841 attachment.GetTransform(mat);
842 //TODO: why are we spawning and deleting here, instead of moving to location??
843 if ( parent.MemoryPointExists("" + part_name + "_materials") )
844 {
845 vector destination = parent.GetMemoryPointPos("" + part_name + "_materials");
846 destination = g_Game.ObjectModelToWorld(parent,destination);
847 float health = attachment.GetHealth("","Health");
848 float quantity = attachment.GetQuantity() - 1;
849 if (quantity < 1.0)
850 quantity = 1.0;
851 float dir[4];
852 inventory_location.GetDir(dir);
853 dst.SetGroundEx(attachment,destination,dir);
854
855 if (player)
856 {
857 vector posHead;
858 MiscGameplayFunctions.GetHeadBonePos(PlayerBase.Cast(player),posHead);
859 MiscGameplayFunctions.CreateItemBasePilesDispersed(attachment.GetType(),posHead,destination,UAItemsSpreadRadius.NARROW,quantity,health,player);
860 }
861 else
862 {
863 MiscGameplayFunctions.CreateItemBasePiles(attachment.GetType(),destination,quantity,health,true);
864 }
865 attachment.AddQuantity( -quantity );
866 }
867 else
868 {
869 dst.SetGround(attachment,mat);
870
871 for ( int k = attachment.GetQuantity(); k > quantity_max; )
872 {
873 Object o = parent.GetInventory().LocationCreateEntity( dst, attachment.GetType(), ECE_PLACE_ON_SURFACE, RF_DEFAULT );
874 ItemBase new_item = ItemBase.Cast( o );
875
876 if( new_item )
877 {
878 MiscGameplayFunctions.TransferItemProperties( attachment, new_item );
879 attachment.AddQuantity( -quantity_max );
880 new_item.SetQuantity( quantity_max );
881 }
882 k -= quantity_max;
883 }
884 }
885
886 //drop
887 if (attachment.GetQuantity() > 0)
888 {
889 if ( g_Game.IsMultiplayer() )
890 {
891 parent.ServerTakeToDst( inventory_location, dst );
892 }
893 else
894 {
895 parent.LocalTakeToDst( inventory_location, dst );
896 }
897 }
898 else
899 {
900 attachment.Delete();
901 }
902 }
903 }
904 }
905 }
906 }
907 }
908 }
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
Определения BaseBuildingBase.c:1312
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
const int RF_DEFAULT
Определения CentralEconomy.c:65
ConstructionPart GetConstructionPart(string part_name)
Определения Construction.c:280
DayZGame g_Game
Определения DayZGame.c:3942
string GetPartName()
Определения ConstructionPart.c:30
bool IsBase()
Определения ConstructionPart.c:65
string GetMainPartName()
Определения ConstructionPart.c:35
override bool LocalTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Определения 3_Game/DayZ/Entities/Man.c:858
override bool ServerTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Определения 3_Game/DayZ/Entities/Man.c:863
proto native void GetDir(out float dir[4])
returns direction of item in world if type is Ground
proto native int GetSlot()
returns slot id if current type is Attachment
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
proto native void SetGroundEx(EntityAI e, vector pos, float dir[4])
sets current inventory location type to Ground with transformation mat
InventoryLocation.
Определения InventoryLocation.c:30
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
static bool IsBaseBuildingLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:796
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
const float NARROW
Определения ActionConstants.c:127
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:119
proto native int Length()
Returns length of string.
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286
proto int ToLower()
Changes string to lowercase. Returns length.
BaseBuildingBase GetParent()
Get parent of the Effect.
Определения Construction.c:40

Перекрестные ссылки bsbDebugPrint(), string::Contains(), ECE_PLACE_ON_SURFACE, g_Game, GetConstructionPart(), InventoryLocation::GetDir(), ConstructionPart::GetMainPartName(), GetParent(), ConstructionPart::GetPartName(), InventoryLocation::GetSlot(), ConstructionPart::IsBase(), LogManager::IsBaseBuildingLogEnable(), string::Length(), EntityAI::LocalTakeToDst(), UAItemsSpreadRadius::NARROW, RF_DEFAULT, EntityAI::ServerTakeToDst(), InventoryLocation::SetGround(), InventoryLocation::SetGroundEx(), ItemBase::SetQuantity() и string::ToLower().

Используется в DestroyPartServer() и DismantlePartServer().