Author Topic: Saving armor conditions  (Read 602 times)

Offline Lash

  • Acquaintance
  • *
  • Posts: 42
    • View Profile
Saving armor conditions
« on: February 24, 2016, 02:02:24 PM »
I noticed in the default 3.8.6 base mudlib that armor conditions (wear and tear on armor after comabat, for example) were not being saved. A player could quit, log back in, and have all new untainted armor.

Two files were changed so armor conditions are retained:

As pointed out by Quixadhal on dschat the DamagePoints variable in lib/lib/props/deterioration.c was not initialized and thus not being saved:
Code: [Select]
private int DamagePoints;

changed to

private int DamagePoints    = 0;


In /lib/lib/std/base_armor.c the variable Protection was added to the my_save variable like so:
Code: [Select]
my_save = equip::GetSave() + value::GetSave() + mass::GetSave() +
        poison::GetSave() + deterioration::GetSave();

changed to:

my_save = equip::GetSave() + value::GetSave() + mass::GetSave() +
        poison::GetSave() + deterioration::GetSave() + ( ({"Protection"}) );

So far as I can tell, the armor objects are being saved with the correct values for deterioration, DamagePoints, and "cuts" and "dents" values as defined in the GetItemCondition() function in the base_armor.c file after character logout/login.

As a check I added the following bit of code to deterioration.c to make sure the "current" DamagePoints was being reported vs the MaxDamagePoints assigned to the specific armor object:

Code: [Select]
int GetMaxDamagePoints(){
    return MaxDamagePoints;
}

Here's some example output for armor worn by a test character that has been damaged after being attacked by an npc with a "blade" type weapon. The test character quit and logged back in. The admin character evaluated the armor object as follows:

Code: [Select]
call leggings->GetDamagePoints()
OBJ(iron leggings /domains/diku-alfa/room/30.zon/armor/3092_leggings_iron#101)
-> GetDamagePoints() = 22

call leggings->GetMaxDamagePoints()
OBJ(iron leggings /domains/diku-alfa/room/30.zon/armor/3092_leggings_iron#101)
-> GetMaxDamagePoints() = 81

call leggings->GetItemCondition()

IN GETITEM CONDITION
cuts is 80
dents is 100
cuts is 80
OBJ(iron leggings /domains/diku-alfa/room/30.zon/armor/3092_leggings_iron#101)
-> GetItemCondition() = "Its surface is scratched and unmarred."

Without making the two changes as described above none of the above values were being saved.

*note - added some output code to base_armor.c to make sure the "cuts" and "dents" variables were being reported accurately.
« Last Edit: February 24, 2016, 02:04:24 PM by Lash »

Offline Nilrin

  • Friend
  • **
  • Posts: 85
    • View Profile
Re: Saving armor conditions
« Reply #1 on: March 04, 2016, 12:57:27 PM »
Nice catch! On the list of my stuff to do for my MUD was to check why everyone had perfect armor all the time. That explains it.  ::)