/* * Jam a closed door with a spike * * This command may NOT be repeated */ void do_cmd_spike(cmd_code code, cmd_arg args[]) { int y, x, dir, item = 0; dir = args[0].direction; /* Get a spike */ if (!get_spike(&item)) { /* Message */ msg_print("You have no spikes!"); /* Done */ return; } /* Get location */ y = p_ptr->py + ddy[dir]; x = p_ptr->px + ddx[dir]; /* Verify legality */ if (!do_cmd_spike_test(y, x)) return; /* Take a turn */ p_ptr->energy_use = 100; /* Confuse direction */ if (confuse_dir(&dir)) { /* Get location */ y = p_ptr->py + ddy[dir]; x = p_ptr->px + ddx[dir]; } /* Monster */ if (cave_m_idx[y][x] > 0) { if (mon_list[cave_m_idx[y][x]].align & (AL_PET_MASK)) { msg_print("There is a friendly monster in the way!"); } else { /* Message */ msg_print("There is a monster in the way!"); /* Attack */ py_attack(y, x); } } /* Go for it */ else { /* Verify legality */ if (!do_cmd_spike_test(y, x)) return; /* Successful jamming */ msg_print("You jam the door with a spike."); /* Convert "locked" to "stuck" XXX XXX XXX */ if (cave_feat[y][x] < FEAT_DOOR_HEAD + 0x08) { cave_feat[y][x] += 0x08; } /* Add one spike to the door */ if (cave_feat[y][x] < FEAT_DOOR_TAIL) { cave_feat[y][x] += 0x01; } /* Use up, and describe, a single spike, from the bottom */ inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } }
/* * Jam a closed door with a spike. Now takes only 4/10ths normal energy * if no monster is in the way. -LM- * * This command may NOT be repeated */ void do_cmd_spike(void) { int py = p_ptr->py; int px = p_ptr->px; int y, x, dir, item; /* Get a spike */ if (!get_spike(&item)) { /* Message */ msg_print("You have no spikes!"); /* Done */ return; } /* Get a direction (or abort) */ if (!get_rep_dir(&dir)) return; /* Get location */ y = py + ddy[dir]; x = px + ddx[dir]; /* Verify legality */ if (!do_cmd_spike_test(y, x)) return; /* Take a partial turn. Now jamming is more useful. */ p_ptr->energy_use = 40; /* Confuse direction */ if (confuse_dir(&dir)) { /* Get location */ y = py + ddy[dir]; x = px + ddx[dir]; } /* Monster. Make the action now take a full turn */ if (cave_m_idx[y][x] > 0) { /* Message */ msg_print("There is a monster in the way!"); p_ptr->energy_use += 60; /* Attack */ py_attack(y, x); } /* Go for it */ else { /* Verify legality */ if (!do_cmd_spike_test(y, x)) return; /* Successful jamming */ msg_print("You jam the door with a spike."); /* Convert "locked" to "stuck" XXX XXX XXX */ if (cave_feat[y][x] < FEAT_DOOR_HEAD + 0x08) { cave_feat[y][x] += 0x08; } /* Add one spike to the door */ if (cave_feat[y][x] < FEAT_DOOR_TAIL) { cave_feat[y][x] += 0x01; } /* Use up, and describe, a single spike, from the bottom */ inven_item_increase(item, -1); inven_item_describe(item); inven_item_optimize(item); } }