modded class ActionUnpackBox
{
override void OnFinishProgressServer( ActionData action_data )
{
if ( action_data.m_MainItem && action_data.m_MainItem.GetHierarchyRootPlayer() == action_data.m_Player )
{
string path = "CfgVehicles " + action_data.m_MainItem.GetType();
string box = action_data.m_MainItem.GetType();
string child_name = "";
int count;
array<string> resources = new array<string>;
if( GetGame().ConfigIsExisting( path ) && GetGame().ConfigIsExisting( path + " Resources") )
{
path = path + " Resources";
count = GetGame().ConfigGetChildrenCount ( path );
for (int i = 0; i < count; i++)
{
GetGame().ConfigGetChildName ( path, i, child_name );
if ( GetGame().ConfigGetInt( path + " " + child_name + " value" ) )
{
resources.Insert( child_name );
}
}
//GetGame().ObjectDelete(action_data.m_Player.GetItemInHands());
//TODO modify to allow for multiple ammo types spawning (if needed??)
string itemType = resources.Get(0);
int itemCount = GetGame().ConfigGetInt( path + " " + itemType + " value" );
UnboxLambda lambda = new UnboxLambda(action_data.m_MainItem, itemType, action_data.m_Player, itemCount);
action_data.m_Player.ServerReplaceItemInHandsWithNew(lambda);
//string message = itemType;
//SendGlobalChatMessage(box);
//COTCreateLocalAdminNotification( new StringLocaliser( message ) );
for (int j=1;j<resources.Count();j++)
{
itemType = resources.Get(j);
//SendGlobalChatMessage(itemType);
//COTCreateLocalAdminNotification( new StringLocaliser( itemType ) );
itemCount = GetGame().ConfigGetInt( path + " " + itemType + " value" );
// else
// {
ItemBase itm2 = ItemBase.Cast(GetGame().CreateObject(itemType,action_data.m_Player.GetPosition(),false));
if (itemCount)
itm2.SetQuantity(itemCount);
//spawns wrapping Paper
//ItemBase paper = ItemBase.Cast( GetGame().CreateObject("Paper", action_data.m_Player.GetPosition(), false) );
// }
}
if (box.IndexOf("SU_AmmoBox") > -1)
{
for (int y = 0; y < 10; y++)
{
ItemBase itm = ItemBase.Cast(GetGame().CreateObject(itemType,action_data.m_Player.GetPosition(),false));
if (itemCount)
itm.SetQuantity(itemCount);
}
ItemBase itemsukapadla = ItemBase.Cast( GetGame().CreateObject("AmmoBox", action_data.m_Player.GetPosition(), false) );
}
else
{
//spawns wrapping Paper
ItemBase paper = ItemBase.Cast( GetGame().CreateObject("Paper", action_data.m_Player.GetPosition(), false) );
}
action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
}
}
}
}