123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- class ActionCraftBoltsFeatherCB : ActionContinuousBaseCB
- {
- private const float TIME_TO_CRAFT = 3.0;
-
- override void CreateActionComponent()
- {
- m_ActionData.m_ActionComponent = new CAContinuousRepeat(TIME_TO_CRAFT);
- }
- };
- class ActionCraftBoltsFeather: ActionContinuousBase
- {
- protected bool m_IsFeatherInHands;
- protected Ammunition_Base m_ResultEntity;
-
- void ActionCraftBoltsFeather()
- {
- m_CallbackClass = ActionCraftBoltsFeatherCB;
- m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
- m_FullBody = true;
- m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
- m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_HIGH;
- m_Text = "#STR_CraftBolt1";
- }
-
- override void CreateConditionComponents()
- {
- m_ConditionItem = new CCINonRuined();
- m_ConditionTarget = new CCTNonRuined();
- }
-
- protected bool IsFeatherType(string itemInHandsType)
- {
- return itemInHandsType == "ChickenFeather";
- }
-
- override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
- {
- if (IsFeatherType(item.ClassName()))
- {
- //feather in hands
- if (target.GetObject())
- return (target.GetObject().ClassName() == "Ammo_ImprovisedBolt_1");
- }
- else if (target.GetObject())
- {
- // bolt in hands
- return IsFeatherType(target.GetObject().ClassName());
- }
- return false;
- }
- override void OnStartServer(ActionData action_data)
- {
- super.OnStartServer(action_data);
-
- m_IsFeatherInHands = IsFeatherType(action_data.m_MainItem.ClassName());
- m_ResultEntity = null;
- }
-
- override void OnFinishProgressServer(ActionData action_data)
- {
- ItemBase feather;
- Ammunition_Base bolt;
- bool added = false;
-
- if (m_IsFeatherInHands)
- {
- //feather in hands
- feather = action_data.m_MainItem;
- bolt = Ammunition_Base.Cast(action_data.m_Target.GetObject());
- }
- else
- {
- // bolt in hands
- bolt = Ammunition_Base.Cast(action_data.m_MainItem);
- feather = ItemBase.Cast(action_data.m_Target.GetObject());
- }
-
- if (!bolt || !feather)
- return;
-
- float dmg;
- string type;
-
- bolt.ServerAcquireCartridge(dmg, type);
-
- if (m_ResultEntity)
- {
- type = m_ResultEntity.ConfigGetString("Ammo");
- if (m_ResultEntity.GetAmmoCount() < m_ResultEntity.GetAmmoMax())
- {
- m_ResultEntity.ServerStoreCartridge(dmg, type);
- added = true;
- }
- }
-
- if (!added)
- {
- m_ResultEntity = Ammunition_Base.Cast(action_data.m_Player.SpawnEntityOnGroundRaycastDispersed("Ammo_ImprovisedBolt_2"));
- type = m_ResultEntity.ConfigGetString("Ammo");
- m_ResultEntity.ServerSetAmmoCount(0);
- m_ResultEntity.ServerStoreCartridge(dmg, type);
- m_ResultEntity.SetHealth01("", "", bolt.GetHealth01("", ""));
- }
- feather.AddQuantity(-1);
- }
- };
|