Skip to content
Permalink
Browse files

Greatly simplify net escapes

Only ever try to destroy nets, and remove all of the amazingly complicated
handling for how much damage is dealt each attempt, instead just making it
random. Also remove can_cut_meat in the process.
  • Loading branch information...
semitonal committed Jun 18, 2016
1 parent 8fa7b83 commit d622f133501d2de153cb4222a7e0a54ef3ab7f7e
@@ -2372,11 +2372,6 @@ int food_turns(const item_def &item)
return Food_prop[Food_index[item.sub_type]].turns;
}

bool can_cut_meat(const item_def &item)
{
return _does_damage_type(item, DAM_SLICE);
}

bool is_fruit(const item_def & item)
{
return item.is_type(OBJ_FOOD, FOOD_FRUIT);
@@ -201,7 +201,6 @@ bool food_is_veggie(int food_type) PURE;
bool food_is_veggie(const item_def &item) PURE;
int food_value(const item_def &item) PURE;
int food_turns(const item_def &item) PURE;
bool can_cut_meat(const item_def &item) PURE;
bool is_fruit(const item_def &item) PURE;

// generic item property functions:
@@ -539,16 +539,6 @@ IDEF(is_melded)
return 1;
}

IDEF(can_cut_meat)
{
if (!item || !item->defined())
return 0;

lua_pushboolean(ls, can_cut_meat(*item));

return 1;
}

IDEF(is_corpse)
{
if (!item || !item->defined())
@@ -1306,7 +1296,6 @@ static ItemAccessor item_attrs[] =
{ "is_throwable", l_item_is_throwable },
{ "dropped", l_item_dropped },
{ "is_melded", l_item_is_melded },
{ "can_cut_meat", l_item_can_cut_meat },
{ "is_skeleton", l_item_is_skeleton },
{ "is_corpse", l_item_is_corpse },
{ "has_skeleton", l_item_has_skeleton },
@@ -752,7 +752,7 @@ void swap_with_monster(monster* mon_to_swap)
}
else
{
you.attribute[ATTR_HELD] = 10;
you.attribute[ATTR_HELD] = 1;
if (get_trapping_net(you.pos()) != NON_ITEM)
mpr("You become entangled in the net!");
else
@@ -2361,107 +2361,38 @@ void monster::struggle_against_net()
return;
}

// The more corroded the net gets, the more easily it will break.
const int hold = mitm[net].net_durability; // This will usually be negative.
const int mon_size = body_size(PSIZE_BODY);

// Smaller monsters can escape more quickly.
if (mon_size < random2(SIZE_BIG) // BIG = 5
&& !berserk_or_insane() && type != MONS_DANCING_WEAPON)
if (you.see_cell(pos()))
{
if (you.see_cell(pos()))
{
if (!visible_to(&you))
mpr("Something wriggles in the net.");
else
simple_monster_message(this, " struggles to escape the net.");
}

// Confused monsters have trouble finding the exit.
if (has_ench(ENCH_CONFUSION) && !one_chance_in(5))
return;

decay_enchantment(ENCH_HELD, 2*(NUM_SIZE_LEVELS - mon_size) - hold);

// Frayed nets are easier to escape.
if (mon_size <= -(hold-1)/2)
decay_enchantment(ENCH_HELD, (NUM_SIZE_LEVELS - mon_size));
if (!visible_to(&you))
mpr("Something wriggles in the net.");
else
simple_monster_message(this, " struggles against the net.");
}
else // Large (and above) monsters always thrash the net and destroy it
{ // e.g. ogre, large zombie (large); centaur, naga, hydra (big).

if (you.see_cell(pos()))
{
if (!visible_to(&you))
mpr("Something wriggles in the net.");
else
simple_monster_message(this, " struggles against the net.");
}

// Confused monsters more likely to struggle without result.
if (has_ench(ENCH_CONFUSION) && one_chance_in(3))
return;

// Nets get destroyed more quickly for larger monsters
// and if already strongly frayed.
int damage = 0;
int damage = 1 + random2(2);

// tiny: 1/6, little: 2/5, small: 3/4, medium and above: always
if (x_chance_in_y(mon_size + 1, SIZE_GIANT - mon_size))
damage++;
// Faster monsters can damage the net more often per
// time period.
if (speed != 0)
damage = div_rand_round(damage * speed, 10);

// Handled specially to make up for its small size.
if (type == MONS_DANCING_WEAPON)
{
damage += one_chance_in(3);

if (can_cut_meat(mitm[inv[MSLOT_WEAPON]]))
damage++;
}

// Extra damage for large (50%) and big (always).
if (mon_size == SIZE_BIG || mon_size == SIZE_LARGE && coinflip())
damage++;

// overall damage per struggle:
// tiny -> 1/6
// little -> 2/5
// small -> 3/4
// medium -> 1
// large -> 1,5
// big -> 2

// extra damage if already damaged
if (random2(body_size(PSIZE_BODY) - hold + 1) >= 4)
damage++;

// Berserking doubles damage dealt.
if (berserk())
damage *= 2;

// Faster monsters can damage the net more often per
// time period.
if (speed != 0)
damage = div_rand_round(damage * speed, 10);

mitm[net].net_durability -= damage;
mitm[net].net_durability -= damage;

if (mitm[net].net_durability < -7)
if (mitm[net].net_durability < NET_MIN_DURABILITY)
{
if (you.see_cell(pos()))
{
if (you.see_cell(pos()))
if (visible_to(&you))
{
if (visible_to(&you))
{
mprf("The net rips apart, and %s comes free!",
name(DESC_THE).c_str());
}
else
mpr("All of a sudden the net rips apart!");
mprf("The net rips apart, and %s comes free!",
name(DESC_THE).c_str());
}
destroy_item(net);

del_ench(ENCH_HELD, true);
else
mpr("All of a sudden the net rips apart!");
}
destroy_item(net);

del_ench(ENCH_HELD, true);
}
}

0 comments on commit d622f13

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