-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Directional attacks 2, probably better implementation edition (#15089)
- Loading branch information
Showing
8 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/*! | ||
* This element allows the mob its attached to the ability to click an adjacent mob by clicking a distant atom | ||
* that is in the general direction relative to the parent. | ||
*/ | ||
/datum/element/directional_attack/Attach(datum/target) | ||
. = ..() | ||
if(!ismob(target)) | ||
return ELEMENT_INCOMPATIBLE | ||
|
||
RegisterSignal(target, COMSIG_MOB_ATTACK_RANGED, PROC_REF(on_ranged_attack)) | ||
|
||
/datum/element/directional_attack/Detach(datum/source, ...) | ||
. = ..() | ||
UnregisterSignal(source, COMSIG_MOB_ATTACK_RANGED) | ||
|
||
/** | ||
* This proc handles clicks on tiles that aren't adjacent to the source mob | ||
* In addition to clicking the distant tile, it checks the tile in the direction and clicks the mob in the tile if there is one | ||
* Arguments: | ||
* * source - The mob clicking | ||
* * clicked_atom - The atom being clicked (should be a distant one) | ||
* * click_params - Miscellaneous click parameters, passed from Click itself | ||
*/ | ||
/datum/element/directional_attack/proc/on_ranged_attack(mob/source, atom/clicked_atom, click_params) | ||
SIGNAL_HANDLER | ||
|
||
if(!(source?.client?.prefs?.toggles_gameplay & DIRECTIONAL_ATTACKS)) | ||
return | ||
|
||
if(QDELETED(clicked_atom)) | ||
return | ||
|
||
var/turf/turf_to_check = get_step(source, angle_to_dir(Get_Angle(source, clicked_atom))) | ||
if(!turf_to_check) | ||
return | ||
|
||
var/mob/target_mob = locate() in turf_to_check | ||
if(!target_mob) | ||
return | ||
|
||
//This is here to undo the +1 the click on the distant turf adds so we can click the mob near us | ||
source.next_click = world.time - 1 | ||
INVOKE_ASYNC(source, TYPE_PROC_REF(/mob, ClickOn), target_mob, turf_to_check, click_params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters