123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- class ActionSawPlanksCB : ActionContinuousBaseCB
- {
- static const float TIME_SAW_HANDSAW = 1.5;
- static const float TIME_SAW_HACKSAW = 3.0;
- static const float TIME_AXES = 1.2;
-
- override void CreateActionComponent()
- {
- m_ActionData.m_ActionComponent = new CAContinuousRepeat(GetDefaultTime());
- }
-
- float GetDefaultTime()
- {
- string item_type = m_ActionData.m_MainItem.GetType();
-
- switch(item_type)
- {
- case "Hacksaw":
- return TIME_SAW_HACKSAW;
- break;
-
- case "HandSaw":
- return TIME_SAW_HANDSAW;
- break;
-
- default: // axes
- return TIME_AXES;
- break
- }
- Print("ActionSawPlanksCB | Item detection error, assigning negative time");
- return -1;
- }
- };
- class ActionSawPlanks: ActionContinuousBase
- {
- static const int DECREASE_HEALTH_OF_TOOL_DEFAULT = 10; // this constant is not use anymore see ActionConstants.c UADamageApplied
- //static const int DECREASE_HEALTH_OF_TOOL_AXE = 20; // axes
- //static const int DECREASE_FUEL_OF_CHAINSAW = 20; // chainsaw fuel in ml
-
- static const int YIELD = 3;
- ItemBase m_Planks;
- ref InventoryLocation m_PlanksLocation = new InventoryLocation;
-
- void ActionSawPlanks()
- {
- m_CallbackClass = ActionSawPlanksCB;
- m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DISASSEMBLE;
- m_FullBody = true;
- m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
- m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_MEDIUM;
- m_Text = "#saw_planks";
- m_LockTargetOnUse = false;
- }
-
- override void CreateConditionComponents()
- {
- m_ConditionTarget = new CCTNonRuined(UAMaxDistances.DEFAULT);
- m_ConditionItem = new CCINonRuined;
- }
-
- override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
- {
- Object target_O = target.GetObject();
-
- if ( item && target_O.IsInherited(PileOfWoodenPlanks))
- {
- string item_type = item.GetType();
-
- switch(item_type)
- {
- case "Chainsaw":
- if ( item.HasEnergyManager() && item.GetCompEM().CanWork() )
- {
- return true;
- }
- else
- {
- return false;
- }
- break;
- }
-
- return true;
- }
-
- return false;
- }
-
- override void OnFinishProgressServer( ActionData action_data )
- {
- PileOfWoodenPlanks item_POWP = PileOfWoodenPlanks.Cast( action_data.m_Target.GetObject() );
- item_POWP.RemovePlanks(YIELD);
-
- vector pos = action_data.m_Player.GetPosition();
-
- InventoryLocation currentLoc = new InventoryLocation;
- if (m_Planks)
- m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
-
- if (!m_Planks || !currentLoc.CompareLocationOnly(m_PlanksLocation))
- {
- m_Planks = ItemBase.Cast( GetGame().CreateObjectEx("WoodenPlank", pos, ECE_PLACE_ON_SURFACE) );
- m_Planks.SetQuantity(YIELD);
-
- m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
- m_PlanksLocation.Copy(currentLoc);
- }
- else if ((m_Planks.GetQuantity() + YIELD) >= m_Planks.GetQuantityMax())
- {
- int remnant = m_Planks.GetQuantity() + YIELD - m_Planks.GetQuantityMax();
- m_Planks.SetQuantity(m_Planks.GetQuantityMax());
- if (remnant > 0)
- {
- m_Planks = ItemBase.Cast( GetGame().CreateObjectEx("WoodenPlank", pos, ECE_PLACE_ON_SURFACE) );
- m_Planks.SetQuantity(remnant);
- m_Planks.GetInventory().GetCurrentInventoryLocation(currentLoc);
- m_PlanksLocation.Copy(currentLoc);
- }
- }
- else
- {
- m_Planks.AddQuantity(YIELD);
- }
-
- ItemBase item = action_data.m_MainItem;
-
- string item_type = item.GetType();
-
- item.DecreaseHealth("", "", UADamageApplied.SAW_PLANKS);
- /*switch(item_type)
- {
- case "WoodAxe":
- item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
- break;
-
- case "FirefighterAxe":
- item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
- break;
-
- case "FirefighterAxe_Black":
- item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
- break;
-
- case "FirefighterAxe_Green":
- item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
- break;
-
- case "Hatchet":
- item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( DECREASE_HEALTH_OF_TOOL_AXE, GetSpecialtyWeight() ));
- break;
-
- case "Chainsaw":
- if ( item.HasEnergyManager() )
- {
- item.GetCompEM().ConsumeEnergy(DECREASE_FUEL_OF_CHAINSAW);
- }
- break;
-
- default: // Hacksaw and other
- item.DecreaseHealth( "", "", action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( UADamageApplied.SAW_PLANKS, GetSpecialtyWeight() ));
- break;
- }*/
- }
- };
|