For having a reference to Hitchhiker’s Guide to the Galaxy, the towel has remarkably few uses, I decided to make it wearable like a bandana/scarf.
The stats I’ve used are entirely impulsive but I figured I’d post the changes I made to get it to work here if anybody wanted to do a PR for a more realistic version.
I’ve not yet done anything in Github at all and I’ve sort of polluted my personal version with a ton of random changes, so I’ve posted this here for lack of knowing what else to do with it.
EDIT: I’ve changed it so the towel has a menu, you can use it to dry off, wear it on the head, mouth, or torso, the values are still a bit arbitrary at the moment if anybody has some suggestions.
A quick test after compiling it seems to have no issues, but I didn’t really do any rigorous testing.
I’ll look into making it work as improvised bedding and see if I can figure out how to do a PR on github, some advice in that direction would be helpful.
[spoiler=player.cpp]Starting at line 6413 I replaced the code with this:
if(it->type->id == “towel_wet”)
it->make(itypes[“towel”]);
if(it->type->id == “towel_wet_head”)
it->make(itypes[“towel_head”]);
if(it->type->id == “towel_wet_torso”)
it->make(itypes[“towel_torso”]);
Inserted the following into a newline at 8775:
used->type->use == &iuse::towel ||
[/spoiler]
int iuse::towel(player *p, item *it, bool)
{
bool towelUsed = false;
int choice = -1;
int pos = p->get_item_position(it);
item& ait = p->i_at(pos);
choice = menu(true, _(“Do what with the towel?:”), _(“Dry Off”), _(“Wear on Head”), _(“Wear over Mouth”), _(“Wear on Torso”), _(“Use as bedding”), _(“Cancel”), NULL);
if( choice < 0 || choice == 6){
g->add_msg_if_player(p, _("Never mind."));
return 0;
}
else if(choice == 1)
// can't use an already wet towel!
if( it->has_flag("WET") ) {
g->add_msg_if_player(p,_("That %s is too wet to soak up any more liquid!"), it->name.c_str());
}
// dry off from being wet
else if( abs(p->has_morale(MORALE_WET)) ){
p->rem_morale(MORALE_WET);
g->add_msg_if_player(p,_("You use the %s to dry off, saturating it with water!"), it->name.c_str());
towelUsed = true;
it->item_counter = 300;
}
// clean off slime
else if( p->has_disease("slimed") ){
p->rem_disease("slimed");
g->add_msg_if_player(p,_("You use the %s to clean yourself off, saturating it with slime!"), it->name.c_str());
towelUsed = true;
it->item_counter = 450; // slime takes a bit longer to dry
}
// default message
else {
g->add_msg_if_player(p,_("You are already dry, the %s does nothing."), it->name.c_str());
}
else if(choice == 2){
if(it->type->id == "towel" || "towel_torso"){
it->make(itypes["towel_head"]);
p->inv.assign_empty_invlet(ait,true);
if(!(p->is_wearing("towel_head"))){
p->wear(pos);
}
towelUsed = true;
}
else if(it->type->id == "towel_wet" || "towel_torso_wet"){
it->make(itypes["towel_head_wet"]);
p->inv.assign_empty_invlet(ait,true);
if(!(p->is_wearing("towel_head"))){
p->wear(pos);
}
towelUsed = true;
}
else if(it->type->id == "towel_head" || "towel_wet_head"){
p->inv.assign_empty_invlet(ait,true);
if(!(p->is_wearing("towel_head") || p->is_wearing("towel_wet_head"))){
p->wear(pos);
}
towelUsed = true;
}
else
return 0;
}
else if(choice == 3){
if(it->type->id == "towel_head" || "towel_torso"){
it->make(itypes["towel"]);
p->inv.assign_empty_invlet(ait,true);
if(!(p->is_wearing("towel"))){
p->wear(pos);
}
towelUsed = true;
}
else if(it->type->id == "towel_wet_head" || "towel_wet_torso"){
it->make(itypes["towel_wet"]);
p->inv.assign_empty_invlet(ait,true);
if(!(p->is_wearing("towel_wet"))){
p->wear(pos);
}
towelUsed = true;
}
else if(it->type->id == "towel" || "towel_wet"){
p->inv.assign_empty_invlet(ait,true);
if(!(p->is_wearing("towel") || p->is_wearing("towel_wet"))){
p->wear(pos);
}
towelUsed = true;
}
else
return 0;
}
else if(choice == 4){
if(it->type->id == "towel" || "towel_head"){
it->make(itypes["towel_torso"]);
p->inv.assign_empty_invlet(ait,true);
if(!(p->is_wearing("towel_torso"))){
p->wear(pos);
}
towelUsed = true;
}
else if(it->type->id == "towel_wet" || "towel_wet_head"){
it->make(itypes["towel_wet_torso"]);
p->inv.assign_empty_invlet(ait,true);
if(!(p->is_wearing("towel_torso") || p->is_wearing("towel_wet_torso"))){
p->wear(pos);
}
towelUsed = true;
}
else if(it->type->id == "towel_torso" || "towel_wet_torso"){
p->inv.assign_empty_invlet(ait,true);
if(!(p->is_wearing("towel_torso"))){
p->wear(pos);
}
towelUsed = true;
}
else
return 0;
}
else if(choice == 5){
g->add_msg_if_player(p,_("Not Yet Available"));
return 0;
}
else
g->add_msg_if_player(p,_("What have you done??"));
// towel was used
if(towelUsed)
{
p->moves -= 50;
// change "towel" to a "towel_wet" (different flavor text/color)
if(it->type->id == "towel")
it->make(itypes["towel_wet"]);
else if(it->type->id == "towel_head")
it->make(itypes["towel_wet_head"]);
else if(it->type->id == "towel_torso")
it->make(itypes["towel_wet_torso"]);
// WET, active items have their timer decremented every turn
it->item_tags.erase("ABSORBENT");
it->item_tags.insert("WET");
it->active = true;
}
return it->type->charges_to_use();
}
In data/json/items/, I removed the towel from tools.json and added the following to tool_armor.json:
{
“type” : “ARMOR”,
“id” : “towel”,
“name” : “towel”,
“weight” : 370,
“volume” : 2,
“price” : 4500,
“symbol” : “,”,
“color” : “cyan”,
“description” : “This is a fluffy and large towel. It could be used to dry yourself. Any person that can travel the length and breadth of the apocalypse, rough it, slum it, struggle against terrible odds, win through and still know where their towel is, is clearly a force to be reckoned with.”,
“to_hit” : -1,
“storage” : 0,
“material” : “cotton”,
“covers” : [“MOUTH”],
“coverage” : 95,
“enviromental_protection” : 2,
“cutting” : 0,
“bashing” : 0,
“warmth” : 10,
“phase” : “solid”,
“encumbrance” : 1,
“material_thickness” : 1,
“flags” : [“ABSORBENT”],
“max_charge” : 0,
“charges_per_use” : 0,
“turns_per_charge” : 5,
“ammo” : “NULL”,
“revert_to” : “NULL”,
“use_action” : “TOWEL”
},
{
“type” : “ARMOR”,
“id” : “towel_head”,
“name” : “towel”,
“weight” : 370,
“volume” : 2,
“price” : 4500,
“symbol” : “,”,
“color” : “cyan”,
“description” : “This is a fluffy and large towel. It could be used to dry yourself. Any person that can travel the length and breadth of the apocalypse, rough it, slum it, struggle against terrible odds, win through and still know where their towel is, is clearly a force to be reckoned with.”,
“to_hit” : -1,
“storage” : 0,
“material” : “cotton”,
“covers” : [“HEAD”],
“coverage” : 80,
“enviromental_protection” : 0,
“cutting” : 0,
“bashing” : 0,
“warmth” : 10,
“phase” : “solid”,
“encumbrance” : 1,
“material_thickness” : 1,
“flags” : [“ABSORBENT”],
“max_charge” : 0,
“charges_per_use” : 0,
“turns_per_charge” : 5,
“ammo” : “NULL”,
“revert_to” : “NULL”,
“use_action” : “TOWEL”
},
{
“type” : “ARMOR”,
“id” : “towel_torso”,
“name” : “towel”,
“weight” : 370,
“volume” : 2,
“price” : 4500,
“symbol” : “,”,
“color” : “cyan”,
“description” : “This is a fluffy and large towel. It could be used to dry yourself. Any person that can travel the length and breadth of the apocalypse, rough it, slum it, struggle against terrible odds, win through and still know where their towel is, is clearly a force to be reckoned with.”,
“to_hit” : -1,
“storage” : 0,
“material” : “cotton”,
“covers” : [“TORSO”],
“coverage” : 55,
“enviromental_protection” : 0,
“cutting” : 0,
“bashing” : 0,
“warmth” : 10,
“phase” : “solid”,
“encumbrance” : 1,
“material_thickness” : 1,
“flags” : [“ABSORBENT”],
“max_charge” : 0,
“charges_per_use” : 0,
“turns_per_charge” : 5,
“ammo” : “NULL”,
“revert_to” : “NULL”,
“use_action” : “TOWEL”
},
{
“type” : “ARMOR”,
“id” : “towel_wet”,
“name” : “towel”,
“weight” : 400,
“volume” : 2,
“price” : 4500,
“symbol” : “,”,
“color” : “blue”,
“description” : “This is a large, sopping wet towel. If you wait a little bit, it should dry out. Don’t panic.”,
“to_hit” : 1,
“storage” : 0,
“material” : “cotton”,
“covers” : [“MOUTH”],
“coverage” : 95,
“enviromental_protection” : 0,
“cutting” : 0,
“bashing” : 0,
“warmth” : 0,
“phase” : “solid”,
“encumbrance” : 1,
“material_thickness” : 1,
“flags” : [“WET”],
“max_charge” : 0,
“charges_per_use” : 0,
“turns_per_charge” : 5,
“ammo” : “NULL”,
“revert_to” : “NULL”,
“use_action” : “TOWEL”
},
{
“type” : “ARMOR”,
“id” : “towel_wet_head”,
“name” : “towel”,
“weight” : 400,
“volume” : 2,
“price” : 4500,
“symbol” : “,”,
“color” : “blue”,
“description” : “This is a large, sopping wet towel. If you wait a little bit, it should dry out. Don’t panic.”,
“to_hit” : 1,
“storage” : 0,
“material” : “cotton”,
“covers” : [“HEAD”],
“coverage” : 80,
“enviromental_protection” : 0,
“cutting” : 0,
“bashing” : 0,
“warmth” : 0,
“phase” : “solid”,
“encumbrance” : 1,
“material_thickness” : 1,
“flags” : [“WET”],
“max_charge” : 0,
“charges_per_use” : 0,
“turns_per_charge” : 5,
“ammo” : “NULL”,
“revert_to” : “NULL”,
“use_action” : “TOWEL”
},
{
“type” : “ARMOR”,
“id” : “towel_wet_torso”,
“name” : “towel”,
“weight” : 400,
“volume” : 2,
“price” : 4500,
“symbol” : “,”,
“color” : “blue”,
“description” : “This is a large, sopping wet towel. If you wait a little bit, it should dry out. Don’t panic.”,
“to_hit” : 1,
“storage” : 0,
“material” : “cotton”,
“covers” : [“TORSO”],
“coverage” : 55,
“enviromental_protection” : 0,
“cutting” : 0,
“bashing” : 0,
“warmth” : 0,
“phase” : “solid”,
“encumbrance” : 1,
“material_thickness” : 1,
“flags” : [“WET”],
“max_charge” : 0,
“charges_per_use” : 0,
“turns_per_charge” : 5,
“ammo” : “NULL”,
“revert_to” : “NULL”,
“use_action” : “TOWEL”
},