1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

bow:: mouse_fire_mode

This commit is contained in:
Zeno Rogue 2023-12-02 11:30:51 +01:00
parent 9bebbd8f4e
commit 176ea28a24
3 changed files with 46 additions and 0 deletions

View File

@ -1562,6 +1562,11 @@ EX void initConfig() {
-> set_need_confirm()
-> set_value_to = [] (bow::eCrossbowStyle s) { bool b = game_active; if(s != bow::style) stop_game(); bow::style = s; if(b) start_game(); };
param_b(bow::bump_to_shoot, "bump_to_shoot", true)->editable("bump to shoot", 'b');
param_enum(bow::mouse_fire_mode, "mouse_fire_mode", "mouse_fire_mode", bow::mfmPriority)
->editable({{"explicit", "You need to click crossbow or be close to fire."},
{"priority", "Click on a faraway monster to fire if possible, or move if not."},
{"always", "Clicking on a faraway monster always means an attempt to fire."}},
"mouse auto-fire mode", 'm');
param_enum(vid.msgleft, "message_style", "message style", 2)
-> editable({{"centered", ""}, {"left-aligned", ""}, {"line-broken", ""}}, "message style", 'a');

View File

@ -621,6 +621,7 @@ EX void handleKeyNormal(int sym, int uni) {
else if(mouseover &&
targetclick && (shmup::on ? numplayers() == 1 && !shmup::pc[0]->dead : true) && targetRangedOrb(mouseover, forcetarget ? roMouseForce : roMouse)) {
}
else if(bow::fire_on_mouse(mouseover)) ;
else if(forcetarget)
;
else if(rug::rugged && rug::renderonce)

View File

@ -325,6 +325,45 @@ EX void add_fire(cell *c) {
}
}
#if HDR
enum eMouseFireMode { mfmNone, mfmPriority, mfmAlways };
#endif
EX eMouseFireMode mouse_fire_mode = mfmPriority;
EX bool fire_on_mouse(cell *c) {
if(mouse_fire_mode == mfmNone) return false;
if(!mouseover) return false;
if(!mouseover->monst) return false;
if(items[itCrossbow]) {
if(mouse_fire_mode == mfmAlways) {
addMessage(XLAT("Cannot fire again yet. Turns to reload: %1.", its(items[itCrossbow])));
return true;
}
return false;
}
target_at = {};
target_at[mouseover->cpdist] = mouseover;
int res = create_path();
if(res <= 0) {
if(mouse_fire_mode == mfmAlways) {
addMessage(XLAT("Shooting impossible."));
return true;
}
return false;
}
gen_bowpath_map();
checked_move_issue = miVALID;
pcmove pcm;
pcm.checkonly = false;
changes.init(false);
addMessage(XLAT("Fire!"));
bool b = pcm.try_shooting(false);
if(!b) changes.rollback();
if(mouse_fire_mode == mfmAlways) return true;
return b;
}
EX void shoot() {
flagtype attackflags = AF_BOW;
if(items[itOrbSpeed]&1) attackflags |= AF_FAST;
@ -440,6 +479,7 @@ EX void showMenu() {
if(crossbow_mode()) {
add_edit(style);
add_edit(bump_to_shoot);
add_edit(bow::mouse_fire_mode);
}
else dialog::addBreak(200);
dialog::addBack();