I want to set an item's durability so that when it breaks it can only be repaired one time. Anyone have an idea of how to achieve this?
Set item to only be repairable once?Solved
The OnItemRepair hook. Cancel the repair if the item has been repaired before.
Remember to store the item ID in a data file to make sure it is only done once though*
ZugzwangThe OnItemRepair hook. Cancel the repair if the item has been repaired before.
I was hoping for a way to set the repair state so that it's mostly red with just one repair attempt left. Is there not a way to do this?
Simplest algorithm without tracking the ID of every item repaired:
OnItemRepair:
- If Item.maxCondition isn't full, cancel repair.
- Otherwise, repair item, and manually reduce Item.maxCondition, even if Item.maintainMaxCondition is true.
ZugzwangSimplest algorithm without tracking the ID of every item repaired:
OnItemRepair:
- If Item.maxCondition isn't full, cancel repair.
- Otherwise, repair item, and manually reduce Item.maxCondition, even if Item.maintainMaxCondition is true.
Thanks. That's an interesting approach. I'd prefer to adjust the condition when the item is dropped from the NPC. I currently adjust the durability and set it between two values so that it breaks quickly after use, but they can go repair it and I only want that to happen once. If I could set the red repair bar to the last value (https://rust.fandom.com/wiki/Mechanics#Durability) 20% or 40%? that would be ideal. This way I wouldn't have to deal with any OnRepair actions. In my experiements I can ge the bar to be all red, but then you can't equip the item. I'm still searching for how to make the bar only a % red as stated above.
Could set the maxCondition to 50% and only allow repairs if it is exactly at that amount. Or whatever percentage is good for your purposes.
ZugzwangCould set the maxCondition to 50% and only allow repairs if it is exactly at that amount. Or whatever percentage is good for your purposes.
Thanks for the help guys. I solved it. It displays the almost full red bar. I was using the wrong value for _maxCondition.
Locked automatically