Skip to content
Permalink
Browse files

Merge branch 'wearable-items' of https://github.com/BevapDin/Cataclys…

…m-DDA into merge
  • Loading branch information...
KA101 committed Nov 25, 2014
2 parents cf6a055 + 5e2a07c commit d9ef1b0a67e5b0a4d9f70d508c31806ce3c11e6c
@@ -25,6 +25,31 @@
"mod_targets": ["pistol", "smg"],
"acceptable_ammo": ["9mm", "38", "40", "44"]
},
{
"id":"shoulder_strap",
"type": "GUNMOD",
"symbol": ":",
"color": "green",
"name":"shoulder strap",
"description":"A shoulder strap allows the rifle to be worn over your shoulders like a piece of cloth. However, it offers no protection.",
"location": "accessories",
"price": 480,
"material": "veggy",
"weight": 100,
"volume": 1,
"bashing": 1,
"cutting": 0,
"to_hit": -2,
"flags": [ "IS_ARMOR" ],
"dispersion_modifier": 0,
"damage_modifier": 0,
"loudness_modifier": 0,
"ammo_modifier": "NULL",
"recoil_modifier": 0,
"burst_modifier": 0,
"clip_size_modifier": 0,
"mod_targets": ["rifle"]
},
{
"type" : "GUNMOD",
"id" : "suppressor",
@@ -111,14 +111,7 @@ enum item_place_type {
static void stash_on_pet( item *item_to_stash, monster *pet )
{
item *it = &pet->inv[0];
it_armor *armor = nullptr;
if( it ) {
armor = dynamic_cast<it_armor *>(it->type);
}
int max_cap = 0;
if( armor ) {
max_cap = armor->storage;
}
int max_cap = it->get_storage();
int max_weight = pet->weight_capacity();

for (auto &i : pet->inv) {
@@ -6,8 +6,6 @@

void player::sort_armor()
{
it_armor *each_armor = 0;

/* Define required height of the right pane:
* + 3 - horizontal lines;
* + 1 - caption line;
@@ -134,20 +132,19 @@ void player::sort_armor()
// Left list
for (int drawindex = 0; drawindex < leftListSize; drawindex++) {
int itemindex = leftListOffset + drawindex;
each_armor = dynamic_cast<it_armor *>(tmp_worn[itemindex]->type);

if (itemindex == leftListIndex) {
mvwprintz(w_sort_left, drawindex + 1, 0, c_yellow, ">>");
}

if (itemindex == selected) {
mvwprintz(w_sort_left, drawindex + 1, 3, dam_color[int(tmp_worn[itemindex]->damage + 1)],
each_armor->nname(1).c_str());
tmp_worn[itemindex]->type_name(1).c_str());
} else {
mvwprintz(w_sort_left, drawindex + 1, 2, dam_color[int(tmp_worn[itemindex]->damage + 1)],
each_armor->nname(1).c_str());
tmp_worn[itemindex]->type_name(1).c_str());
}
mvwprintz(w_sort_left, drawindex + 1, left_w - 3, c_ltgray, "%3d", int(each_armor->storage));
mvwprintz(w_sort_left, drawindex + 1, left_w - 3, c_ltgray, "%3d", tmp_worn[itemindex]->get_storage());
}

// Left footer
@@ -203,15 +200,14 @@ void player::sort_armor()
}
rightListSize++;
for( auto &elem : worn ) {
each_armor = dynamic_cast<it_armor *>( elem.type );
if( elem.covers.test( cover ) ) {
if (rightListSize >= rightListOffset && pos <= cont_h - 2) {
mvwprintz( w_sort_right, pos, 2, dam_color[int( elem.damage + 1 )],
each_armor->nname( 1 ).c_str() );
elem.type_name( 1 ).c_str() );
mvwprintz( w_sort_right, pos, right_w - 2, c_ltgray, "%d",
( elem.has_flag( "FIT" ) ) ?
std::max( 0, int( each_armor->encumber ) - 1 ) :
int( each_armor->encumber ) );
std::max( 0, elem.get_encumber() - 1 ) :
elem.get_encumber() );
pos++;
}
rightListSize++;
@@ -356,8 +352,7 @@ The sum of these values is the effective encumbrance value your character has fo

void draw_mid_pane(WINDOW *w_sort_middle, item *worn_item)
{
it_armor *each_armor = dynamic_cast<it_armor *>(worn_item->type);
mvwprintz(w_sort_middle, 0, 1, c_white, each_armor->nname(1).c_str());
mvwprintz(w_sort_middle, 0, 1, c_white, worn_item->type_name(1).c_str());
int middle_w = getmaxx(w_sort_middle);
std::vector<std::string> props = clothing_properties(worn_item, middle_w - 3);
size_t i;
@@ -395,21 +390,20 @@ std::string clothing_layer(item *worn_item)

std::vector<std::string> clothing_properties(item *worn_item, int width)
{
it_armor *each_armor = dynamic_cast<it_armor *>(worn_item->type);
std::vector<std::string> props;
props.push_back(name_and_value(_("Coverage:"),
string_format("%3d", int(each_armor->coverage)), width));
string_format("%3d", worn_item->get_coverage()), width));
props.push_back(name_and_value(_("Encumbrance:"), string_format("%3d",
(worn_item->has_flag("FIT")) ? std::max(0, int(each_armor->encumber) - 1) :
int(each_armor->encumber)), width));
(worn_item->has_flag("FIT")) ? std::max(0, worn_item->get_encumber() - 1) :
worn_item->get_encumber()), width));
props.push_back(name_and_value(_("Bash Protection:"),
string_format("%3d", int(worn_item->bash_resist())), width));
props.push_back(name_and_value(_("Cut Protection:"),
string_format("%3d", int(worn_item->cut_resist())), width));
props.push_back(name_and_value(_("Warmth:"),
string_format("%3d", int(each_armor->warmth)), width));
string_format("%3d", worn_item->get_warmth()), width));
props.push_back(name_and_value(_("Storage:"),
string_format("%3d", int(each_armor->storage)), width));
string_format("%3d", worn_item->get_storage()), width));

return props;
}
@@ -199,7 +199,7 @@ struct artifact_armor_form_datum {
int warmth;
int storage;
int melee_bash, melee_cut, melee_hit;
std::bitset<13> covers;
std::bitset<num_bp> covers;
bool plural;
artifact_armor_mod available_mods[5];
};
@@ -386,7 +386,7 @@ static int game_item_type(lua_State *L)
lua_createtable(L, 0, 2); // Preallocate enough space for all type properties.

lua_pushstring(L, "name");
lua_pushstring(L, (*item_instance)->type->nname(1).c_str());
lua_pushstring(L, (*item_instance)->type_name( 1 ).c_str());
lua_rawset(L, -3);

lua_pushstring(L, "id");
@@ -744,7 +744,7 @@ const recipe *select_crafting_recipe( int &batch_size )
item_info_text = tmp.info( true );
}
mvwprintz(w_data, 0, FULL_SCREEN_WIDTH + 1, col, "%s",
utf8_truncate(tmp.type->nname(1), iInfoWidth).c_str());
utf8_truncate(tmp.type_name( 1 ), iInfoWidth).c_str());

fold_and_print( w_data, 1, FULL_SCREEN_WIDTH + 1, iInfoWidth, col, item_info_text );
}
@@ -792,7 +792,7 @@ const recipe *select_crafting_recipe( int &batch_size )
} else if (action == "HELP_RECIPE") {
tmp = current[line]->create_result();

full_screen_popup("%s\n%s", tmp.type->nname(1).c_str(), tmp.info(true).c_str());
full_screen_popup("%s\n%s", tmp.type_name( 1 ).c_str(), tmp.info(true).c_str());
redraw = true;
keepline = true;
} else if (action == "FILTER") {
@@ -1299,7 +1299,7 @@ void player::make_all_craft(const std::string &id_to_make, int batch_size)
lastrecipe = id_to_make;
}

item recipe::create_result(int handed) const
item recipe::create_result(handedness handed) const
{
item newit(result, calendar::turn, false, handed);
if (result_mult != 1) {
@@ -1314,7 +1314,7 @@ item recipe::create_result(int handed) const
return newit;
}

std::vector<item> recipe::create_results(int batch, int handed) const
std::vector<item> recipe::create_results(int batch, handedness handed) const
{
std::vector<item> items;

@@ -1379,9 +1379,16 @@ void player::complete_craft()
return;
}

int handed = 0;
handedness handed = NONE;
if (making->paired) {
handed = menu(true, ("Handedness?:"), _("Left-handed"), _("Right-handed"), NULL);
switch( menu(true, ("Handedness?:"), _("Left-handed"), _("Right-handed"), NULL) ) {
case 1:
handed = LEFT;
break;
case 2:
handed = RIGHT;
break;
}
}

// # of dice is 75% primary skill, 25% secondary (unless secondary is null)
@@ -1475,9 +1482,9 @@ void player::complete_craft()
if (first) {
first = false;
if( knows_recipe(making) ) {
add_msg(_("You craft %s from memory."), newit.type->nname(1).c_str());
add_msg(_("You craft %s from memory."), newit.type_name( 1 ).c_str());
} else {
add_msg(_("You craft %s using a book as a reference."), newit.type->nname(1).c_str());
add_msg(_("You craft %s using a book as a reference."), newit.type_name( 1 ).c_str());
// If we made it, but we don't know it,
// we're making it from a book and have a chance to learn it.
// Base expected time to learn is 1000*(difficulty^4)/skill/int moves.
@@ -1490,7 +1497,7 @@ void player::complete_craft()
(get_skill_level( making->skill_used ) * get_int() ) ) ) {
learn_recipe( (recipe *)making );
add_msg(m_good, _("You memorized the recipe for %s!"),
newit.type->nname(1).c_str());
newit.type_name( 1 ).c_str());
}
}

@@ -9,6 +9,7 @@
#include "skill.h"
#include "rng.h"
#include "json.h"
#include "bodypart.h"
#include "requirements.h"

#define MAX_DISPLAYED_RECIPES 18
@@ -83,8 +84,8 @@ struct recipe {

// Create an item instance as if the recipe was just finished,
// Contain charges multiplier
item create_result(int handed = NONE) const;
std::vector<item> create_results(int batch = 1, int handed = NONE) const;
item create_result(handedness handed = NONE) const;
std::vector<item> create_results(int batch = 1, handedness handed = NONE) const;

// Create byproduct instances as if the recipe was just finished
std::vector<item> create_byproducts(int batch = 1) const;
@@ -8545,8 +8545,7 @@ bool pet_menu(monster *z)
return true;
}

it_armor *armor = dynamic_cast<it_armor *>(it->type);
if (armor->storage <= 0) {
if( it->get_storage() <= 0 ) {
add_msg(_("This is not a bag!"));
return true;
}
@@ -8595,10 +8594,8 @@ bool pet_menu(monster *z)
return true;
}

it_armor *armor = dynamic_cast<it_armor *>(it->type);

int max_cap = armor->storage;
int max_weight = z->weight_capacity() - armor->weight;
int max_cap = it->get_storage();
int max_weight = z->weight_capacity() - it->weight();

if (z->inv.size() > 1) {
for (auto &i : z->inv) {
@@ -11180,7 +11177,7 @@ void game::plfire(bool burst, int default_target_x, int default_target_y)
std::ostringstream ss;
ss << string_format(_("%s from %s (%d)"),
i->contents[0].tname().c_str(),
i->type->nname(1).c_str(),
i->type_name(1).c_str(),
i->contents[0].charges);
choices.push_back(ss.str());
}
@@ -11190,7 +11187,7 @@ void game::plfire(bool burst, int default_target_x, int default_target_y)
if (choice > -1) {
u.wield_contents(holsters[choice], true, _("pistol"), 13);
u.add_msg_if_player(_("You pull your %s from its %s and ready it to fire."),
u.weapon.tname().c_str(), holsters[choice]->type->nname(1).c_str());
u.weapon.tname().c_str(), holsters[choice]->type_name(1).c_str());
if (u.weapon.charges <= 0) {
u.add_msg_if_player(_("... but it's empty!"));
return;
@@ -11264,7 +11261,7 @@ void game::plfire(bool burst, int default_target_x, int default_target_y)
std::ostringstream ss;
ss << string_format(_("%s from %s (%d)"),
i->contents[0].tname().c_str(),
i->type->nname(1).c_str(),
i->type_name(1).c_str(),
i->contents[0].charges);
choices.push_back(ss.str());
}
@@ -11280,11 +11277,11 @@ void game::plfire(bool burst, int default_target_x, int default_target_y)
if (archery <= 2 && one_in(10)) {
u.moves -= 30;
u.add_msg_if_player(_("You try to pull a %s from your %s, but fail!"),
arrows.tname().c_str(), worn->type->nname(1).c_str());
arrows.tname().c_str(), worn->type_name(1).c_str());
return;
}
u.add_msg_if_player(_("You pull a %s from your %s and nock it."),
arrows.tname().c_str(), worn->type->nname(1).c_str());
arrows.tname().c_str(), worn->type_name(1).c_str());
reload_pos = u.get_item_position(worn);
}
}
@@ -12322,10 +12319,6 @@ void game::wield(int pos)
bool success = false;
if (pos == -1) {
success = u.wield(NULL);
} else if (pos < -1) {
add_msg(m_info, _("You have to take off your %s before you can wield it."),
u.i_at(pos).tname().c_str());
return;
} else {
success = u.wield(&(u.i_at(pos)));
}
@@ -31,7 +31,7 @@ void iexamine::gaspump(player *p, map *m, int examx, int examy)
item *liq = &(m->i_at(examx, examy)[i]);

if (one_in(10 + p->dex_cur)) {
add_msg(m_bad, _("You accidentally spill the %s."), liq->type->nname(1).c_str());
add_msg(m_bad, _("You accidentally spill the %s."), liq->type_name(1).c_str());
item spill(liq->type->id, calendar::turn);
spill.charges = rng(dynamic_cast<it_ammo *>(liq->type)->count,
dynamic_cast<it_ammo *>(liq->type)->count * (float)(8 / p->dex_cur));
@@ -43,7 +43,7 @@ void iexamine::gaspump(player *p, map *m, int examx, int examy)
} else {
p->moves -= 300;
if (g->handle_liquid(*liq, true, false)) {
add_msg(_("With a clang and a shudder, the %s pump goes silent."), liq->type->nname(1).c_str());
add_msg(_("With a clang and a shudder, the %s pump goes silent."), liq->type_name(1).c_str());
m->i_at(examx, examy).erase(m->i_at(examx, examy).begin() + i);
}
}
@@ -943,9 +943,7 @@ bool inventory::has_items_with_quality(std::string id, int level, int amount) co
if( !elem_stack_iter.contents.empty() && elem_stack_iter.is_container() ) {
continue;
}
auto quality_iter = elem_stack_iter.type->qualities.find( id );
if( quality_iter != elem_stack_iter.type->qualities.end() &&
level <= quality_iter->second ) {
if( elem_stack_iter.has_quality( id, level ) ) {
found++;
}
}

0 comments on commit d9ef1b0

Please sign in to comment.
You can’t perform that action at this time.