mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-30 21:42:59 +00:00 
			
		
		
		
	bow:: mouse_fire_mode
This commit is contained in:
		| @@ -1562,6 +1562,11 @@ EX void initConfig() { | |||||||
|     -> set_need_confirm() |     -> 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(); }; |     -> 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_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) |   param_enum(vid.msgleft, "message_style", "message style", 2) | ||||||
|     -> editable({{"centered", ""}, {"left-aligned", ""}, {"line-broken", ""}}, "message style", 'a'); |     -> editable({{"centered", ""}, {"left-aligned", ""}, {"line-broken", ""}}, "message style", 'a'); | ||||||
|   | |||||||
| @@ -621,6 +621,7 @@ EX void handleKeyNormal(int sym, int uni) { | |||||||
|     else if(mouseover && |     else if(mouseover && | ||||||
|       targetclick && (shmup::on ? numplayers() == 1 && !shmup::pc[0]->dead : true) && targetRangedOrb(mouseover, forcetarget ? roMouseForce : roMouse)) { |       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(forcetarget) | ||||||
|       ; |       ; | ||||||
|     else if(rug::rugged && rug::renderonce) |     else if(rug::rugged && rug::renderonce) | ||||||
|   | |||||||
							
								
								
									
										40
									
								
								crossbow.cpp
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								crossbow.cpp
									
									
									
									
									
								
							| @@ -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() { | EX void shoot() { | ||||||
|   flagtype attackflags = AF_BOW; |   flagtype attackflags = AF_BOW; | ||||||
|   if(items[itOrbSpeed]&1) attackflags |= AF_FAST; |   if(items[itOrbSpeed]&1) attackflags |= AF_FAST; | ||||||
| @@ -440,6 +479,7 @@ EX void showMenu() { | |||||||
|   if(crossbow_mode()) { |   if(crossbow_mode()) { | ||||||
|     add_edit(style); |     add_edit(style); | ||||||
|     add_edit(bump_to_shoot); |     add_edit(bump_to_shoot); | ||||||
|  |     add_edit(bow::mouse_fire_mode); | ||||||
|     } |     } | ||||||
|   else dialog::addBreak(200); |   else dialog::addBreak(200); | ||||||
|   dialog::addBack(); |   dialog::addBack(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue