Module m_durability

Documentation for the modules-m_durability module in /std/modules/m_durability.c.

Module Information

This module provides durability functionality for objects. It allows objects to have a durability value that can be set, reset, and modified. It also provides functions to check the durability percentage, missing durability, and to increase or decrease the durability.

Functions

int has_durability()

Returns 1 if the object has durability, 0 otherwise.

void set_max_durability(int md)

Sets the maximum durability of the object. If md is 0, it does nothing.

nomask int original_max_durability()

Returns the original maximum durability of the object. If it has not been set, it is set to the current maximum durability. This is used to ensure that the original maximum durability is preserved even if the current maximum durability changes. This is useful for repairing objects, where the maximum durability may decrease.

nomask int max_durability()

Returns the current maximum durability of the object. If it has not been set, it is set to the original maximum durability.

void set_damaged_durability()

Sets the durability to a random value between 1 and 10% of the current maximum durability. This is used when the object is damaged.

void reset_durability()

Resets the durability to the current maximum durability. This is used when the object is repaired or when it is first created.

void durability_after_repair()

This function is called after the object has been repaired. It decreases the current maximum durability by a random percentage between 0 and 5%. This simulates the wear and tear that occurs during repairs.

int query_durability()

Returns the current durability of the object. If it has not been set, it is set to the current maximum durability.

int direct_repair_obj()

Returns 1 if the object can be repaired, i.e., if its durability is less than the current maximum durability. This is used to determine if the object can be repaired.

int durability_percent()

Returns the percentage of durability remaining. This is calculated as (current durability / maximum durability) * 100.

int missing_durability()

Returns the amount of durability missing from the object. This is calculated as the difference between the current maximum durability and the current durability.

string durability_extra_long()

Returns a string representation of the current durability percentage. This is used to display the durability of the object in a long format.

void decrease_durability(int d)

Decreases the durability by the specified amount. If the durability is -1, it resets the durability to the current maximum durability first.

void increase_durability(int d)

Increases the durability by the specified amount. If the durability is -1, it resets the durability to the current maximum durability first. It ensures that the durability does not exceed the current maximum durability.

File generated by Lima 1.1a4 reStructured Text daemon.