123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- class ActionDigWormsCB : ActionContinuousBaseCB
- {
- override void CreateActionComponent()
- {
- float time_spent;
- time_spent = UATimeSpent.DIG_WORMS;
- if (m_ActionData.m_MainItem.KindOf("Knife"))
- time_spent = time_spent * 1.2;
-
- if (m_ActionData.m_Player.GetInColdArea())
- time_spent *= GameConstants.COLD_AREA_DIG_WORMS_MODIF;
-
- m_ActionData.m_ActionComponent = new CAContinuousTime(time_spent);
- }
- };
- class ActionDigWorms: ActionContinuousBase
- {
- void ActionDigWorms()
- {
- m_CallbackClass = ActionDigWormsCB;
- m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGGIN_WORMS;
- m_FullBody = true;
- m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
- m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_MEDIUM;
- m_Text = "#dig_up_worms";
- }
-
- override void CreateConditionComponents()
- {
- m_ConditionItem = new CCINonRuined;
- m_ConditionTarget = new CCTSurface(UAMaxDistances.DEFAULT);
- }
-
- override bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
- {
- if (!super.Can(player, target, item, condition_mask))
- return false;
-
- return player.CheckFreeSpace(vector.Forward, 0.8, false);
- }
-
- override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
- {
- if (player.IsPlacingLocal())
- return false;
-
- return IsTargetFertile(target) && IsPlayerOnGround(player);
- }
-
- override bool ActionConditionContinue(ActionData action_data)
- {
- return IsPlayerOnGround(action_data.m_Player);
- }
-
- override bool HasTarget()
- {
- return true;
- }
- override void OnFinishProgressServer(ActionData action_data)
- {
- ItemBase worms;
- int count = action_data.m_MainItem.GetOnDigWormsAmount();
- for (int i = 0; i < count; i++)
- {
- Class.CastTo(worms, GetGame().CreateObjectEx("Worm", action_data.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE));
- }
-
- MiscGameplayFunctions.DealEvinronmentAdjustedDmg(action_data.m_MainItem, action_data.m_Player, 4);
- }
-
- bool IsTargetFertile(ActionTarget target)
- {
- if (target)
- {
- string surface_type;
- vector position;
- position = target.GetCursorHitPos();
-
- GetGame().SurfaceGetType(position[0], position[2], surface_type);
-
- if (GetGame().IsSurfaceFertile(surface_type))
- {
- return true;
- }
- }
-
- return false;
- }
-
- bool IsPlayerOnGround(PlayerBase player)
- {
- vector position = player.GetPosition();
- float heightDiff = GetGame().SurfaceY(position[0], position[2]);
- heightDiff = position[1] - heightDiff;
-
- return heightDiff <= 0.4; // Player is considered on ground
- }
-
- //! DEPRECATED - See ItemBase.OverrideActionAnimation() to override commands for items
- void SetDiggignAnimation(ItemBase item);
-
- };
|