5 switch (item.GetHealthLevel(damage_zone))
11 Debug.
Log(
"repairing from GameConstants.STATE_RUINED");
13 CalculateHealth(player, repair_kit, item, specialty_weight, damage_zone, use_kit_qty);
18 CalculateHealth(player, repair_kit, item, specialty_weight, damage_zone, use_kit_qty);
22 CalculateHealth(player, repair_kit, item, specialty_weight, damage_zone, use_kit_qty);
36 entity.SetAllowDamage(
true);
39 int health_levels_count = item.GetNumberOfHealthLevels(damage_zone);
40 float kit_repair_cost_adjusted;
43 int target_level =
Math.
Clamp(item.GetHealthLevel(damage_zone) - 1, 0, health_levels_count - 1);
49 health_coef = item.GetHealthLevelValue(target_level,damage_zone);
52 if (kit && kit.ConfigGetInt(
"repairKitType"))
54 bool kit_has_quantity = kit.HasQuantity();
55 float cur_kit_quantity = kit.GetQuantity();
58 if (cur_kit_quantity > kit_repair_cost_per_level)
60 kit_repair_cost_adjusted = kit_repair_cost_per_level;
62 kit_repair_cost_adjusted =
Math.
Clamp(kit_repair_cost_adjusted, 0, 100);
65 new_quantity = kit.GetQuantity() - kit_repair_cost_adjusted;
69 else if (!kit_has_quantity)
81 if (item.GetHealth01(damage_zone,
"Health") < health_coef)
83 item.SetHealth01(damage_zone,
"Health",health_coef);
88 entity.ProcessInvulnerabilityCheck(entity.GetInvulnerabilityTypeString());
94 int state = item.GetHealthLevel(damage_zone);
98 int repair_kit_type = repair_kit.ConfigGetInt(
"repairKitType");
105 item.ConfigGetIntArray(
"repairableWithKits", repairable_with_types);
107 for (
int i = 0; i < repairable_with_types.Count(); i++)
109 int repairable_with_type = repairable_with_types.Get(i);
123 if (repair_kit_type > 0 && repairable_with_type > 0)
125 return repair_kit_type == repairable_with_type;
140 return item.CanBeRepairedToPristine();
148 item.ConfigGetIntArray(
"repairableWithKits", allowedRepairKitTypes);
149 item.ConfigGetFloatArray(
"repairCosts", repairKitCosts);
151 int repairKitType = repair_kit.ConfigGetInt(
"repairKitType");
153 foreach (
int i,
int allowedKitType : allowedRepairKitTypes)
155 if (allowedKitType == repairKitType)
157 return repairKitCosts.Get(i);
Super root of all classes in Enforce script.
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
bool CanRepairToPristine(PlayerBase player)
Player can repair items to 100%; currently unused.
void CalculateHealth(PlayerBase player, ItemBase kit, Object item, float specialty_weight, string damage_zone="", bool use_kit_qty=true)
float GetKitRepairCost(ItemBase repair_kit, Object item)
bool CanRepair(ItemBase repair_kit, Object item, string damage_zone="")
bool Repair(PlayerBase player, ItemBase repair_kit, Object item, float specialty_weight, string damage_zone="", bool use_kit_qty=true)
bool CanBeRepairedToPristine(Object item)
Item can be repaired to 100%.
bool IsRepairValid(int repair_kit_type, int repairable_with_type)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.