DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ CalculateHealth()

void PluginBase::CalculateHealth ( PlayerBase player,
ItemBase kit,
Object item,
float specialty_weight,
string damage_zone = "",
bool use_kit_qty = true )
inlineprivate

См. определение в файле PluginRepairing.c строка 29

30 {
31 EntityAI entity;
32 Class.CastTo(entity,item);
33
34 if (entity != null)
35 {
36 entity.SetAllowDamage(true);
37 }
38
39 int health_levels_count = item.GetNumberOfHealthLevels(damage_zone);
40 float kit_repair_cost_adjusted; //used with specialty_weight, disconnected
41 float new_quantity;
42
43 int target_level = Math.Clamp(item.GetHealthLevel(damage_zone) - 1, 0, health_levels_count - 1);
44 float health_coef;
45 if (!CanRepairToPristine(player) && !CanBeRepairedToPristine(item))
46 {
47 target_level = Math.Clamp(target_level, GameConstants.STATE_WORN, health_levels_count - 1);
48 }
49 health_coef = item.GetHealthLevelValue(target_level,damage_zone);
50
51 //handles kit depletion; TODO: move to separate method.
52 if (kit && kit.ConfigGetInt("repairKitType"))
53 {
54 bool kit_has_quantity = kit.HasQuantity();
55 float cur_kit_quantity = kit.GetQuantity();
56 float kit_repair_cost_per_level = GetKitRepairCost(kit, item);
57
58 if (cur_kit_quantity > kit_repair_cost_per_level)
59 {
60 kit_repair_cost_adjusted = kit_repair_cost_per_level; //TODO: removed speciality weight for now, it should affect speed only (?).
61 //kit_repair_cost_adjusted = player.GetSoftSkillsManager().SubtractSpecialtyBonus(kit_repair_cost_per_level, specialty_weight);
62 kit_repair_cost_adjusted = Math.Clamp(kit_repair_cost_adjusted, 0, 100);
63 if (use_kit_qty)
64 {
65 new_quantity = kit.GetQuantity() - kit_repair_cost_adjusted;
66 kit.SetQuantity(new_quantity);
67 }
68 }
69 else if (!kit_has_quantity) //"kit" without quantity (hammers and such) for your every day repairing needs
70 {
71 }
72 else
73 {
74 if (use_kit_qty)
75 {
76 kit.SetQuantity(0);
77 }
78 }
79 }
80
81 if (item.GetHealth01(damage_zone,"Health") < health_coef)
82 {
83 item.SetHealth01(damage_zone,"Health",health_coef);
84 }
85
86 if (entity != null)
87 {
88 entity.ProcessInvulnerabilityCheck(entity.GetInvulnerabilityTypeString());
89 }
90 }
class LogManager EntityAI
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
bool CanRepairToPristine(PlayerBase player)
Player can repair items to 100%; currently unused.
Определения PluginRepairing.c:132
float GetKitRepairCost(ItemBase repair_kit, Object item)
Определения PluginRepairing.c:143
bool CanBeRepairedToPristine(Object item)
Item can be repaired to 100%.
Определения PluginRepairing.c:138

Перекрестные ссылки CanBeRepairedToPristine(), CanRepairToPristine(), Class::CastTo(), Math::Clamp(), GetKitRepairCost(), ItemBase::SetQuantity() и GameConstants::STATE_WORN.

Используется в Repair().