Skip to content

Commit

Permalink
full auto fire tg edition (#13479)
Browse files Browse the repository at this point in the history
* bbra

* l6 saw

* smg crate

* Update fullauto.dm

* del musor

* be

* small fix

* 321

* rnd plasma cutter fix
  • Loading branch information
simb11 committed Sep 22, 2024
1 parent b5b41b6 commit 5a82681
Show file tree
Hide file tree
Showing 30 changed files with 566 additions and 42 deletions.
15 changes: 15 additions & 0 deletions code/__DEFINES/combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,23 @@
#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)

//Painkiller effectiveness (for get_painkiller_effect() comparison)
#define PAINKILLERS_EFFECT_SLIGHT 0.95 //all painkillers.
#define PAINKILLERS_EFFECT_MEDIUM 0.75 //weak painkillers, allow you to ignore minor pain and not see pain() messages.
#define PAINKILLERS_EFFECT_HEAVY 0.6 //powerful painkillers, allow you to not see custom_pain() messages.
#define PAINKILLERS_EFFECT_VERY_HEAVY 0.5 //very powerful painkillers that does not allow the user to determine the location of the injury.

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
1 change: 1 addition & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
#define TRAIT_MIMING "miming"
#define TRAIT_WILLPOWER_IMPLANT "willpower_implant"
#define TRAIT_CAN_LEAP "can_leap"
#define TRAIT_AUTOFIRE_SHOOTS "autofire_shoots"

/*
* Used for movables that need to be updated, via COMSIG_ENTER_AREA and COMSIG_EXIT_AREA, when transitioning areas.
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
17 changes: 17 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,18 @@
else
RangedAttack(A, params)

/client/MouseDown(datum/object, location, control, params)
SEND_SIGNAL(src, COMSIG_CLIENT_MOUSEDOWN, object, location, control, params)
..()

/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

/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)
..()

// 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

0 comments on commit 5a82681

Please sign in to comment.