Skip to content

Commit

Permalink
Reading books is more user-friendly. Gun info is more explicit about …
Browse files Browse the repository at this point in the history
…what values come from ammo / the gun itself.
  • Loading branch information
Whales committed Feb 4, 2011
1 parent f71dc83 commit 84b6a3e
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 51 deletions.
44 changes: 24 additions & 20 deletions addiction.h
Expand Up @@ -64,28 +64,32 @@ void addict_effect(game *g, addiction &add)
break;

case ADD_PKILLER:
g->u.str_cur -= 1 + int(in / 7);
g->u.per_cur--;
g->u.dex_cur--;
if (g->u.pain < in * 3)
g->u.pain++;
if ((in >= 25 || g->turn % (100 - in * 4) == 0) && g->u.pkill > 0)
g->u.pkill--; // Tolerance increases!
if (in >= 40 || one_in((1200 - 30 * in)))
g->u.health--;
if (one_in(20) && dice(2, 20) < in) {
g->add_msg("Your hands start shaking... you need some painkillers.");
g->cancel_activity_query("You have an opiate craving.");
g->u.add_morale(MOR_CRAVING_OPIATE, 20, 600);
g->u.add_disease(DI_SHAKES, 20 + in * 5, g);
} else if (one_in(20) && dice(2, 30) < in) {
g->add_msg("You feel anxious. You need your painkillers!");
g->u.add_morale(MOR_CRAVING_OPIATE, 15, 600);
g->cancel_activity_query("You have a craving.");
} else if (one_in(50) && dice(3, 50) < in) {
g->add_msg("You throw up heavily!");
g->cancel_activity_query("Throwing up.");
g->u.vomit(g);
if (g->u.pkill >= 35) // No further effects if we're doped up.
add.sated = 0;
else {
g->u.str_cur -= 1 + int(in / 7);
g->u.per_cur--;
g->u.dex_cur--;
if (g->u.pain < in * 3)
g->u.pain++;
if (in >= 40 || one_in((1200 - 30 * in)))
g->u.health--;
if (one_in(20) && dice(2, 20) < in) {
g->add_msg("Your hands start shaking... you need some painkillers.");
g->cancel_activity_query("You have an opiate craving.");
g->u.add_morale(MOR_CRAVING_OPIATE, 20, 600);
g->u.add_disease(DI_SHAKES, 20 + in * 5, g);
} else if (one_in(20) && dice(2, 30) < in) {
g->add_msg("You feel anxious. You need your painkillers!");
g->u.add_morale(MOR_CRAVING_OPIATE, 15, 600);
g->cancel_activity_query("You have a craving.");
} else if (one_in(50) && dice(3, 50) < in) {
g->add_msg("You throw up heavily!");
g->cancel_activity_query("Throwing up.");
g->u.vomit(g);
}
}
break;

Expand Down
17 changes: 16 additions & 1 deletion bodypart.cpp
Expand Up @@ -9,7 +9,7 @@ std::string body_part_name (body_part bp, int side)
case bp_eyes:
return "eyes";
case bp_mouth:
return "jaw";
return "mouth";
case bp_torso:
return "torso";
case bp_arms:
Expand Down Expand Up @@ -41,6 +41,21 @@ std::string body_part_name (body_part bp, int side)
}
}

std::string encumb_text(body_part bp)
{
switch (bp) {
case bp_head: return "";
case bp_eyes: return "Ranged combat is hampered.";
case bp_mouth: return "Running is slowed.";
case bp_torso: return "Movement and melee is hampered.";
case bp_arms: return "Melee and ranged combat is hampered.";
case bp_hands: return "Manual tasks are slowed.";
case bp_legs: return "Running and swimming are slowed.";
case bp_feet: return "Running is slowed.";
default: return "It's inflammed.";
}
}

body_part random_body_part()
{
int rn = rng(0, 30);
Expand Down
2 changes: 2 additions & 0 deletions bodypart.h
Expand Up @@ -16,6 +16,8 @@ enum body_part {
};

std::string body_part_name(body_part bp, int side);
std::string encumb_text(body_part bp);

body_part random_body_part();

#endif
18 changes: 13 additions & 5 deletions game.cpp
Expand Up @@ -709,8 +709,11 @@ void game::process_activity()
u.activity.moves_left -= u.moves;
u.moves = 0;
}

if (u.activity.moves_left <= 0) { // We finished our activity!

switch (u.activity.type) {

case ACT_RELOAD:
u.weapon.reload(u, u.activity.index);
if (u.weapon.is_gun())
Expand Down Expand Up @@ -738,6 +741,7 @@ void game::process_activity()
}
}
break;

case ACT_READ:
if (u.activity.index == -2)
reading = dynamic_cast<it_book*>(u.weapon.type);
Expand All @@ -751,15 +755,23 @@ void game::process_activity()

if (u.sklevel[reading->type] < reading->level) {
add_msg("You learn a little about %s!", skill_name(reading->type).c_str());
u.skexercise[reading->type] += rng(reading->time, reading->time * 2);
int min_ex = reading->time + u.int_cur,
max_ex = reading->time * 2 + u.int_cur * 4;
u.skexercise[reading->type] += rng(min_ex, max_ex);
if (u.sklevel[reading->type] +
(u.skexercise[reading->type] >= 100 ? 1 : 0) >= reading->level)
add_msg("You can no longer learn from this %d.", reading->name.c_str());
}
break;

case ACT_WAIT:
add_msg("You finish waiting.");
break;

case ACT_CRAFT:
complete_craft();
break;

case ACT_BUTCHER:
complete_butcher(u.activity.index);
break;
Expand Down Expand Up @@ -3979,10 +3991,6 @@ void game::wield()

void game::read()
{
if (u.morale_level() < MIN_MORALE_READ) { // See morale.h
add_msg("What's the point of reading? (Your morale is too low!)");
return;
}
char ch = inv("Read:");
u.read(this, ch);
}
Expand Down
59 changes: 49 additions & 10 deletions item.cpp
Expand Up @@ -192,36 +192,67 @@ std::string item::info(bool showtext)
int(type->melee_cut) << " To-hit bonus: " <<
(type->m_to_hit > 0 ? "+" : "" ) << int(type->m_to_hit) << "\n" <<
" Moves per attack: " << attack_time() << "\n";

if (is_food()) {

it_comest* food = dynamic_cast<it_comest*>(type);
dump << " Nutrituion: " << int(food->nutr) << "\n Quench: " <<
int(food->quench) << "\n Enjoyability: " << int(food->fun);

} else if (is_food_container()) {

it_comest* food = dynamic_cast<it_comest*>(contents[0].type);
dump << " Nutrituion: " << int(food->nutr) << "\n Quench: " <<
int(food->quench) << "\n Enjoyability: " << int(food->fun);

} else if (is_ammo()) {

it_ammo* ammo = dynamic_cast<it_ammo*>(type);
dump << " Type: " << ammo_name(ammo->type) << "\n Damage: " <<
int(ammo->damage) << "\n Armor-pierce: " << int(ammo->pierce) <<
"\n Range: " << int(ammo->range) << "\n Accuracy: " <<
int(100 - ammo->accuracy) << "\n Recoil: " << int(ammo->recoil);

} else if (is_gun()) {

it_gun* gun = dynamic_cast<it_gun*>(type);
int ammo_dam = 0, ammo_recoil = 0;
bool has_ammo = (curammo != NULL && charges > 0);
if (has_ammo) {
ammo_dam = curammo->damage;
ammo_recoil = curammo->recoil;
}

dump << " Skill used: " << skill_name(gun->skill_used) << "\n Ammunition: " <<
clip_size() << " rounds of " << ammo_name(ammo()) <<
"\n Damage bonus: " << (gun_damage() > 0 ? "+" : "" ) <<
gun_damage() << "\n Accuracy: " << int(100 - accuracy()) <<
"\n Recoil: " << recoil() << "\n";
clip_size() << " rounds of " << ammo_name(ammo());

dump << "\n Damage: ";
if (has_ammo)
dump << ammo_dam;
dump << (gun_damage(false) >= 0 ? "+" : "" ) << gun_damage(false);
if (has_ammo)
dump << " = " << gun_damage();

dump << "\n Accuracy: " << int(100 - accuracy());

dump << "\n Recoil: ";
if (has_ammo)
dump << ammo_recoil;
dump << (recoil(false) >= 0 ? "+" : "" ) << recoil(false);
if (has_ammo)
dump << " = " << recoil();

if (burst_size() == 0)
dump << " Semi-automatic.";
dump << "\n Semi-automatic.";
else
dump << " Burst size: " << burst_size();
dump << "\n Burst size: " << burst_size();
if (contents.size() > 0)
dump << "\n";
for (int i = 0; i < contents.size(); i++)
dump << "\n+" << contents[i].tname();

} else if (is_gunmod()) {

it_gunmod* mod = dynamic_cast<it_gunmod*>(type);
if (mod->accuracy != 0)
dump << " Accuracy: " << (mod->accuracy > 0 ? "+" : "") <<
Expand All @@ -245,7 +276,9 @@ std::string item::info(bool showtext)
dump << "SMGs. ";
if (mod->used_on_rifle)
dump << "Rifles.";

} else if (is_armor()) {

it_armor* armor = dynamic_cast<it_armor*>(type);
dump << " Covers: ";
if (armor->covers & mfb(bp_head))
Expand All @@ -268,7 +301,9 @@ std::string item::info(bool showtext)
"\n Environmental protection: " << int(armor->env_resist) <<
"\n Warmth: " << int(armor->warmth) <<
"\n Storage: " << int(armor->storage);

} else if (is_book()) {

it_book* book = dynamic_cast<it_book*>(type);
if (book->type == sk_null)
dump << " Just for fun.\n";
Expand All @@ -286,14 +321,17 @@ std::string item::info(bool showtext)
dump << " Reading this book affects your morale by " <<
(book->fun > 0 ? "+" : "") << int(book->fun) << std::endl;
dump << " This book takes " << int(book->time) << " minutes to read.";

} else if (is_tool()) {

it_tool* tool = dynamic_cast<it_tool*>(type);
dump << " Maximum " << tool->max_charges << " charges";
if (tool->ammo == AT_NULL)
dump << ".";
else
dump << " of " << ammo_name(tool->ammo) << ".";
}

if (showtext) {
dump << "\n\n " << type->description << "\n";
if (contents.size() > 0) {
Expand Down Expand Up @@ -656,6 +694,7 @@ int item::reload_time(player &u)
ret = 100 + volume() + weight();
if (type->id == itm_crossbow) // Crossbows are special, they take longer
ret += 150 - u.str_cur * 10;
ret += u.encumb(bp_hands) * 30;
return ret;
}

Expand Down Expand Up @@ -688,13 +727,13 @@ int item::accuracy()
return ret;
}

int item::gun_damage()
int item::gun_damage(bool with_ammo)
{
if (!is_gun())
return 0;
it_gun* gun = dynamic_cast<it_gun*>(type);
int ret = gun->dmg_bonus;
if (curammo != NULL)
if (with_ammo && curammo != NULL)
ret += curammo->damage;
for (int i = 0; i < contents.size(); i++) {
if (contents[i].is_gunmod())
Expand Down Expand Up @@ -735,13 +774,13 @@ int item::burst_size()
return ret;
}

int item::recoil()
int item::recoil(bool with_ammo)
{
if (!is_gun())
return 0;
it_gun* gun = dynamic_cast<it_gun*>(type);
int ret = gun->recoil;
if (curammo != NULL)
if (with_ammo && curammo != NULL)
ret += curammo->recoil;
for (int i = 0; i < contents.size(); i++) {
if (contents[i].is_gunmod())
Expand Down
4 changes: 2 additions & 2 deletions item.h
Expand Up @@ -30,10 +30,10 @@ class item
int reload_time(player &u);
int clip_size();
int accuracy();
int gun_damage();
int gun_damage(bool with_ammo = true);
int noise();
int burst_size();
int recoil();
int recoil(bool with_ammo = true);
ammotype ammo();
int pick_reload_ammo(player &u, bool interactive);
bool reload(player &u, int index);
Expand Down

0 comments on commit 84b6a3e

Please sign in to comment.