Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full auto fire tg edition #13479

Merged
merged 11 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions code/__DEFINES/combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,16 @@
#define MOVESET_TYPE "moveset_type"
#define MOVESET_ROLES "moveset_role"
#define MOVESET_QUALITY "moveset_quality"

//Autofire component
/// Compatible firemode is in the gun. Wait until it's held in the user hands.
#define AUTOFIRE_STAT_IDLE (1<<0)
/// Gun is active and in the user hands. Wait until user does a valid click.
#define AUTOFIRE_STAT_ALERT (1<<1)
/// Gun is shooting.
#define AUTOFIRE_STAT_FIRING (1<<2)

#define COMSIG_AUTOFIRE_ONMOUSEDOWN "autofire_onmousedown"
#define COMPONENT_AUTOFIRE_ONMOUSEDOWN_BYPASS (1<<0)
#define COMSIG_AUTOFIRE_SHOT "autofire_shot"
#define COMPONENT_AUTOFIRE_SHOT_SUCCESS (1<<0)
8 changes: 8 additions & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,11 @@
#define COMSIG_REMOVE_GENE_DISABILITY "remove_gene_disability"
// send this signal to handle disabilities in life for mob/living/carbon/human
#define COMSIG_HANDLE_DISABILITIES "handle_disabilities"

//from base of client/MouseDown(): (/client, object, location, control, params)
#define COMSIG_CLIENT_MOUSEDOWN "client_mousedown"
//from base of client/MouseUp(): (/client, object, location, control, params)
#define COMSIG_CLIENT_MOUSEUP "client_mouseup"
#define COMPONENT_CLIENT_MOUSEUP_INTERCEPT (1<<0)
//from base of client/MouseUp(): (/client, object, location, control, params)
#define COMSIG_CLIENT_MOUSEDRAG "client_mousedrag"
1 change: 1 addition & 0 deletions code/__DEFINES/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
#define SS_PRIORITY_LOW 1


#define SS_WAIT_FULLAUTO 1
#define SS_WAIT_EXPLOSION 1
#define SS_WAIT_INPUT 1
#define SS_WAIT_DEMO 1
Expand Down
20 changes: 20 additions & 0 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1662,3 +1662,23 @@ var/global/list/WALLITEMS = typecacheof(list(
location = location.loc
if(location && include_turf) //At this point, only the turf is left, provided it exists.
. += location

/proc/parse_caught_click_modifiers(list/modifiers, turf/origin, client/viewing_client)
if(!modifiers)
return null

var/screen_loc = splittext(LAZYACCESS(modifiers, SCREEN_LOC), ",")
var/list/actual_view = getviewsize(viewing_client ? viewing_client.view : world.view)
var/click_turf_x = splittext(screen_loc[1], ":")
var/click_turf_y = splittext(screen_loc[2], ":")
var/click_turf_z = origin.z

var/click_turf_px = text2num(click_turf_x[2])
var/click_turf_py = text2num(click_turf_y[2])
click_turf_x = origin.x + text2num(click_turf_x[1]) - round(actual_view[1] / 2) - 1
click_turf_y = origin.y + text2num(click_turf_y[1]) - round(actual_view[2] / 2) - 1

var/turf/click_turf = locate(clamp(click_turf_x, 1, world.maxx), clamp(click_turf_y, 1, world.maxy), click_turf_z)
LAZYSET(modifiers, ICON_X, "[(click_turf_px - click_turf.pixel_x) + ((click_turf_x - click_turf.x) * world.icon_size)]")
LAZYSET(modifiers, ICON_Y, "[(click_turf_py - click_turf.pixel_y) + ((click_turf_y - click_turf.y) * world.icon_size)]")
return click_turf
2 changes: 2 additions & 0 deletions code/__HELPERS/view.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
viewX = text2num(viewrangelist[1])
viewY = text2num(viewrangelist[2])
return list(viewX, viewY)

#define CAN_THEY_SEE(target, source) ((source in viewers(7, target)) || in_range(target, source))
simb11 marked this conversation as resolved.
Show resolved Hide resolved
21 changes: 21 additions & 0 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
* mob/RangedAttack(atom,params) - used only ranged, only used for tk and laser eyes but could be changed
*/
/mob/proc/ClickOn( atom/A, params )
if(client.click_intercept_time)
if(client.click_intercept_time >= world.time)
client.click_intercept_time = 0 //Reset and return. Next click should work, but not this one.
return
client.click_intercept_time = 0 //Just reset. Let's not keep re-checking forever.
if(world.time <= next_click)
return
next_click = world.time + 1
Expand Down Expand Up @@ -160,6 +165,22 @@
else
RangedAttack(A, params)

/client/MouseDown(datum/object, location, control, params)
SEND_SIGNAL(src, COMSIG_CLIENT_MOUSEDOWN, object, location, control, params)
if(mouse_down_icon)
mouse_pointer_icon = mouse_down_icon
..()

/client/MouseUp(object, location, control, params)
if(SEND_SIGNAL(src, COMSIG_CLIENT_MOUSEUP, object, location, control, params) & COMPONENT_CLIENT_MOUSEUP_INTERCEPT)
click_intercept_time = world.time
if(mouse_up_icon)
mouse_pointer_icon = mouse_up_icon

/client/MouseDrag(src_object,atom/over_object,src_location,over_location,src_control,over_control,params)
SEND_SIGNAL(src, COMSIG_CLIENT_MOUSEDRAG, src_object, over_object, src_location, over_location, src_control, over_control, params)
..()
Comment on lines +176 to +178
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Единственный момент, MouseDrag раньше старались избегать, так как

Don't define this unless you need it, because it generates extra communication that is otherwise avoided. Most operations can be done through Click(), DblClick(), and MouseDrop(). The other procedures are simply available for completeness.

https://www.byond.com/docs/ref/#/client/proc/MouseDrag

А тут еще и вызов сигнала на каждый дрег. Но видимо необходимые жертвы.


// Default behavior: ignore double clicks (don't add normal clicks, as it will do three clicks instead of two with double).
/mob/proc/DblClickOn(atom/A, params)
return
Expand Down
5 changes: 5 additions & 0 deletions code/controllers/subsystem/fullauto.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PROCESSING_SUBSYSTEM_DEF(fullauto)
name = "Fullauto"
flags = SS_NO_INIT | SS_BACKGROUND
priority = SS_PRIORITY_LOW
wait = SS_WAIT_FULLAUTO
4 changes: 4 additions & 0 deletions code/datums/components/_component.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
if(!length(signal_procs[target]))
signal_procs -= target

/datum/proc/RegisterSignals(datum/target, list/signal_types, proctype, override = FALSE)
for (var/signal_type in signal_types)
RegisterSignal(target, signal_type, proctype, override)

/datum/component/proc/InheritComponent(datum/component/C, i_am_original)
return

Expand Down
Loading
Loading