8 if( item_tool.ConfigIsExisting(
"OpenItemSpillRange") )
10 item_tool.ConfigGetIntArray(
"OpenItemSpillRange", spill_range );
14 Debug.LogError(
"OpenItemSpillRange config parameter missing, default values used ! ");
15 Error(
"OpenItemSpillRange config parameter missing, default values used !");
16 spill_range.Insert(0);
17 spill_range.Insert(100);
19 float spill_modificator =
Math.RandomIntInclusive( spill_range.Get(0),spill_range.Get(1) ) / 100;
21 OpenItem.SwitchItems(item_target, player, spill_modificator, specialty_weight);
25 static void SwitchItems (
EntityAI old_item,
PlayerBase player,
float spill_modificator,
float specialty_weight)
27 string old_name = old_item.GetType();
28 string new_name = old_name +
"_Opened";
30 l.SetTransferParams(
true,
true,
true,
true);
31 MiscGameplayFunctions.TurnItemIntoItemEx(player, l);
38 float m_SpillModifier;
39 float m_SpecialtyWeight;
42 override void CopyOldPropertiesToNew (notnull
EntityAI old_item,
EntityAI new_item)
44 super.CopyOldPropertiesToNew(old_item, new_item);
47 override void OnSuccess (
EntityAI new_item)
49 super.OnSuccess(new_item);
54 float quantity_old = ib.GetQuantity();
55 float spill_amount = quantity_old * m_SpillModifier;
57 float quantity_new = quantity_old - spill_amount;
59 Debug.Log(
"quantity before spill: "+quantity_old.ToString());
60 Debug.Log(
"spill_amount: "+spill_amount.ToString());
61 Debug.Log(
"quantity_new: "+quantity_new.ToString());
63 ib.SetQuantity(quantity_new);