DayZ 1.27
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 ( GetGame().ConfigIsExisting( cfg_path ) )
796 {
797 GetGame().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 ( GetGame().ConfigIsExisting( at_cfg_path ) )
805 {
806 int child_count = GetGame().ConfigGetChildrenCount( at_cfg_path );
807
808 for ( int i = 0; i < child_count; i++ )
809 {
810 string child_name;
811 GetGame().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 GetGame().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 = GetGame().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 ( GetGame().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:1292
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
const int RF_DEFAULT
Определения CentralEconomy.c:65
ConstructionPart GetConstructionPart(string part_name)
Определения Construction.c:280
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native vector ObjectModelToWorld(Object obj, vector modelPos)
string GetPartName()
Определения ConstructionPart.c:30
bool IsBase()
Определения ConstructionPart.c:65
string GetMainPartName()
Определения ConstructionPart.c:35
override bool LocalTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Определения Man.c:825
override bool ServerTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Определения Man.c:830
Определения Building.c:6
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:29
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
Определения InventoryItem.c:731
static bool IsBaseBuildingLogEnable()
Определения Debug.c:698
Определения Debug.c:594
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
const float NARROW
Определения ActionConstants.c:127
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
proto native CGame GetGame()
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(), CGame::ConfigGetChildName(), CGame::ConfigGetChildrenCount(), CGame::ConfigGetText(), CGame::ConfigGetTextArray(), string::Contains(), ECE_PLACE_ON_SURFACE, GetConstructionPart(), InventoryLocation::GetDir(), GetGame(), ConstructionPart::GetMainPartName(), GetParent(), ConstructionPart::GetPartName(), InventoryLocation::GetSlot(), ConstructionPart::IsBase(), LogManager::IsBaseBuildingLogEnable(), string::Length(), EntityAI::LocalTakeToDst(), UAItemsSpreadRadius::NARROW, CGame::ObjectModelToWorld(), RF_DEFAULT, EntityAI::ServerTakeToDst(), InventoryLocation::SetGround(), InventoryLocation::SetGroundEx(), ItemBase::SetQuantity() и string::ToLower().

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