Skip to content

Commit

Permalink
Ports action code improvements. (#689)
Browse files Browse the repository at this point in the history
* Fix middle click pref for humans (#14990)

* Action code fixes/improvements (#16402)

* should_show

* 15414

* Update underbarrel.dm

* headset for spatial agent

---------

Co-authored-by: Lumipharon <[email protected]>
  • Loading branch information
Helg2 and Lumipharon authored Nov 29, 2024
1 parent 81f83be commit 869fb95
Show file tree
Hide file tree
Showing 32 changed files with 158 additions and 140 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/cooldowns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define COOLDOWN_RACK_BOLT "rack_bolt"
#define COOLDOWN_LIGHT "cooldown_light"
#define COOLDOWN_JETPACK "jetpack"
#define COOLDOWN_SKILL_ORDERS "skill_orders"
#define COOLDOWN_CIC_ORDERS "cic_orders"
#define COOLDOWN_HUD_ORDER "hud_order"
#define COOLDOWN_CLOAK_IMPLANT "cloak_implant"
Expand Down
6 changes: 5 additions & 1 deletion code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,11 @@

//Signals for CIC orders
#define COMSIG_ORDER_SELECTED "order_selected"
#define COMSIG_ORDER_SENT "order_updated"
#define COMSIG_CIC_ORDER_SENT "order_updated"
#define COMSIG_CIC_ORDER_OFF_CD "order_off_cd"

#define COMSIG_SKILL_ORDER_SENT "skill_order_updated"
#define COMSIG_SKILL_ORDER_OFF_CD "skill_order_off_cd"

//Signals for automatic fire at component
#define COMSIG_AUTOMATIC_SHOOTER_START_SHOOTING_AT "start_shooting_at"
Expand Down
8 changes: 5 additions & 3 deletions code/__DEFINES/overwatch.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define ORDER_DURATION 30 SECONDS
#define ORDER_COOLDOWN 30 SECONDS
#define RALLY_ORDER_DURATION 30 SECONDS
#define CIC_ORDER_DURATION 30 SECONDS
#define CIC_ORDER_COOLDOWN 30 SECONDS

#define SKILL_ORDER_DURATION 30 SECONDS
#define SKILL_ORDER_COOLDOWN 45 SECONDS
7 changes: 6 additions & 1 deletion code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,13 @@ if(selected_ability.target_flags & flagname && !istype(A, typepath)){\
/mob/living/carbon/human/ShiftClickOn(atom/A)
if(client.prefs.toggles_gameplay & MIDDLESHIFTCLICKING)
return ..()
var/obj/item/held_thing = get_active_held_item()
if(selected_ability)
A = ability_target(A)
if(selected_ability.can_use_ability(A))
selected_ability.use_ability(A)
return TRUE

var/obj/item/held_thing = get_active_held_item()
if(held_thing && SEND_SIGNAL(held_thing, COMSIG_ITEM_SHIFTCLICKON, A, src) & COMPONENT_ITEM_CLICKON_BYPASS)
return FALSE
return ..()
Expand Down
6 changes: 3 additions & 3 deletions code/_onclick/hud/screen_objects/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -796,17 +796,17 @@
/atom/movable/screen/arrow/attack_order_arrow
name = "attack order arrow"
icon_state = "Attack_arrow"
duration = ORDER_DURATION
duration = CIC_ORDER_DURATION

/atom/movable/screen/arrow/rally_order_arrow
name = "Rally order arrow"
icon_state = "Rally_arrow"
duration = RALLY_ORDER_DURATION
duration = CIC_ORDER_DURATION

/atom/movable/screen/arrow/defend_order_arrow
name = "Defend order arrow"
icon_state = "Defend_arrow"
duration = ORDER_DURATION
duration = CIC_ORDER_DURATION

/atom/movable/screen/arrow/hunter_mark_arrow
name = "hunter mark arrow"
Expand Down
9 changes: 6 additions & 3 deletions code/datums/actions/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ KEYBINDINGS
var/action_type = ACTION_CLICK
///Used for keeping track of the addition of the selected/active frames
var/toggled = FALSE
///Is this action explicitly hidden from the owner
var/hidden = FALSE

/datum/action/New(Target)
target = Target
Expand Down Expand Up @@ -66,8 +68,9 @@ KEYBINDINGS
SHOULD_CALL_PARENT(TRUE)
qdel(src)

///Whether the owner can see this action
/datum/action/proc/should_show()
return TRUE
return !hidden

///Depending on the action type , toggles the selected/active frame to show without allowing stacking multiple overlays
/datum/action/proc/set_toggle(value)
Expand Down Expand Up @@ -186,7 +189,6 @@ KEYBINDINGS
owner.actions += src
if(owner.client)
owner.client.screen += button
owner.update_action_buttons()
owner.actions_by_path[type] = src
for(var/type in keybinding_signals)
var/signal = keybinding_signals[type]
Expand All @@ -197,6 +199,7 @@ KEYBINDINGS
update_map_text(our_kb.get_keys_formatted(M.client), signal)

SEND_SIGNAL(M, ACTION_GIVEN)
owner.update_action_buttons()

/datum/action/proc/remove_action(mob/M)
for(var/type in keybinding_signals)
Expand All @@ -207,9 +210,9 @@ KEYBINDINGS
M.client.screen -= button
M.actions_by_path[type] = null
M.actions -= src
M.update_action_buttons()
owner = null
SEND_SIGNAL(M, ACTION_REMOVED)
M.update_action_buttons()

///Should a AI element occasionally see if this ability should be used?
/datum/action/proc/ai_should_start_consider()
Expand Down
6 changes: 0 additions & 6 deletions code/datums/actions/innate.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
Deactivate()
return TRUE


/datum/action/innate/give_action()
. = ..()
update_button_icon()


/datum/action/innate/proc/Activate()
return

Expand Down
5 changes: 4 additions & 1 deletion code/datums/actions/item_action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
. = ..()
set_toggle(!toggled)

/datum/action/item_action/toggle/remove_action(mob/M)
deselect()
return ..()

/datum/action/item_action/toggle/suit_toggle
keybinding_signals = list(KEYBINDING_NORMAL = COMSIG_KB_SUITLIGHT)

Expand All @@ -79,7 +83,6 @@
/datum/action/item_action/firemode/New()
. = ..()
holder_gun = holder_item
update_button_icon()


/datum/action/item_action/firemode/update_button_icon()
Expand Down
4 changes: 4 additions & 0 deletions code/datums/actions/item_toggles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@
else
visual_references[VREF_MUTABLE_LINKED_OBJ] = null
return ..()

/datum/action/ability/activable/item_toggle/remove_action(mob/M)
deselect()
return ..()
30 changes: 20 additions & 10 deletions code/datums/actions/order_action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

/datum/action/innate/order/give_action(mob/M)
. = ..()
RegisterSignal(M, COMSIG_ORDER_SENT, PROC_REF(update_button_icon))
RegisterSignals(M, list(COMSIG_CIC_ORDER_SENT, COMSIG_CIC_ORDER_OFF_CD), PROC_REF(update_button_icon))

/datum/action/innate/order/remove_action(mob/M)
. = ..()
UnregisterSignal(M, COMSIG_ORDER_SENT)
UnregisterSignal(M, list(COMSIG_CIC_ORDER_SENT, COMSIG_CIC_ORDER_OFF_CD))

/datum/action/innate/order/Activate()
active = TRUE
Expand Down Expand Up @@ -53,9 +53,9 @@
if(visual_type)
target = get_turf(target)
new visual_type(target, faction)
TIMER_COOLDOWN_START(owner, COOLDOWN_CIC_ORDERS, ORDER_COOLDOWN)
SEND_SIGNAL(owner, COMSIG_ORDER_SENT)
addtimer(CALLBACK(owner, TYPE_PROC_REF(/mob, update_all_icons_orders)), ORDER_COOLDOWN)
TIMER_COOLDOWN_START(owner, COOLDOWN_CIC_ORDERS, CIC_ORDER_COOLDOWN)
SEND_SIGNAL(owner, COMSIG_CIC_ORDER_SENT)
addtimer(CALLBACK(src, PROC_REF(on_cooldown_finish)), CIC_ORDER_COOLDOWN + 1)
if(squad)
for(var/mob/living/carbon/human/marine AS in squad.marines_list)
marine.receive_order(target, arrow_type, verb_name, faction)
Expand All @@ -65,11 +65,9 @@
human.receive_order(target, arrow_type, verb_name, faction)
return TRUE

///Update all icons of orders action of the mob
/mob/proc/update_all_icons_orders()
for(var/datum/action/action AS in actions)
if(istype(action, /datum/action/innate/order))
action.update_button_icon()
///Lets any other orders know when we're off CD
/datum/action/innate/order/proc/on_cooldown_finish()
SEND_SIGNAL(owner, COMSIG_CIC_ORDER_OFF_CD, src)

/**
* Proc to give a marine an order
Expand Down Expand Up @@ -114,6 +112,9 @@
)

/datum/action/innate/order/attack_order/personal/should_show()
. = ..()
if(!.)
return
return owner.skills.getRating(skill_name) >= skill_min

/datum/action/innate/order/attack_order/personal/action_activate()
Expand All @@ -135,6 +136,9 @@
)

/datum/action/innate/order/defend_order/personal/should_show()
. = ..()
if(!.)
return
return owner.skills.getRating(skill_name) >= skill_min

/datum/action/innate/order/defend_order/personal/action_activate()
Expand All @@ -155,6 +159,9 @@
)

/datum/action/innate/order/retreat_order/personal/should_show()
. = ..()
if(!.)
return
return owner.skills.getRating(skill_name) >= skill_min

/datum/action/innate/order/retreat_order/personal/action_activate()
Expand All @@ -176,6 +183,9 @@
)

/datum/action/innate/order/rally_order/personal/should_show()
. = ..()
if(!.)
return
return owner.skills.getRating(skill_name) >= skill_min

/datum/action/innate/order/rally_order/personal/action_activate()
Expand Down
5 changes: 4 additions & 1 deletion code/datums/actions/skill.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
var/skill_min

/datum/action/skill/should_show()
return can_use_action()
. = ..()
if(!.)
return
return owner.skills.getRating(skill_name) >= skill_min

/datum/action/skill/can_use_action()
return owner.skills.getRating(skill_name) >= skill_min
Expand Down
38 changes: 25 additions & 13 deletions code/datums/jobs/job/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,18 @@ GLOBAL_PROTECT(exp_specialmap)
/datum/outfit/job/proc/handle_id(mob/living/carbon/human/H, client/override_client)
var/datum/job/job = H.job ? H.job : SSjob.GetJobType(jobtype)
var/obj/item/card/id/id = H.wear_id
if(istype(id))
id.access = job.get_access()
id.iff_signal = GLOB.faction_to_iff[job.faction]
shuffle_inplace(id.access) // Shuffle access list to make NTNet passkeys less predictable
id.registered_name = H.real_name
id.assignment = job.title
id.rank = job.title
id.paygrade = job.paygrade
id.update_label()
if(H.mind?.initial_account) // In most cases they won't have a mind at this point.
id.associated_account_number = H.mind.initial_account.account_number
H.update_action_buttons()
if(!istype(id))
return
id.access = job.get_access()
id.iff_signal = GLOB.faction_to_iff[job.faction]
shuffle_inplace(id.access) // Shuffle access list to make NTNet passkeys less predictable
id.registered_name = H.real_name
id.assignment = job.title
id.rank = job.title
id.paygrade = job.paygrade
id.update_label()
if(H.mind?.initial_account) // In most cases they won't have a mind at this point.
id.associated_account_number = H.mind.initial_account.account_number

/datum/job/proc/get_special_name(client/preference_source)
return
Expand Down Expand Up @@ -222,8 +222,9 @@ GLOBAL_PROTECT(exp_specialmap)
var/datum/job/scaled_job = SSjob.GetJobType(index)
if(!(scaled_job in SSjob.active_joinable_occupations))
continue
scaled_job.add_job_points(-jobworth[index])
scaled_job.remove_job_points(jobworth[index])

///Adds to job points, adding a new slot if threshold reached
/datum/job/proc/add_job_points(amount)
job_points += amount
if(total_positions >= max_positions)
Expand All @@ -232,6 +233,17 @@ GLOBAL_PROTECT(exp_specialmap)
job_points -= job_points_needed
add_job_positions(1)

///Removes job points, and if needed, job positions
/datum/job/proc/remove_job_points(amount)
if(job_points_needed == INFINITY || total_positions == -1)
return
if(job_points >= amount)
job_points -= amount
return
var/job_slots_removed = ROUND_UP((amount - job_points) / job_points_needed)
remove_job_positions(job_slots_removed)
job_points += (job_slots_removed * job_points_needed) - amount

/datum/job/proc/add_job_positions(amount)
if(!(job_flags & (JOB_FLAG_LATEJOINABLE|JOB_FLAG_ROUNDSTARTJOINABLE)))
CRASH("add_job_positions called for a non-joinable job")
Expand Down
6 changes: 0 additions & 6 deletions code/datums/jobs/job/militarypolice.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ In addition, you are tasked with the security of high-ranking personnel, includi
wear_suit = /obj/item/clothing/suit/armor/bulletproof/mp
suit_store = /obj/item/weapon/gun/energy/taser

/obj/item/radio/headset/mainship/mp
icon = 'icons/obj/items/radio.dmi'
name = "security radio headset"
icon_state = "mp_headset"
keyslot = /obj/item/encryptionkey/mcom

/obj/item/storage/pouch/pistol/laserpistol/Initialize()
. = ..()
new /obj/item/weapon/gun/energy/lasgun/lasrifle/standard_marine_pistol/tactical(src)
Expand Down
1 change: 1 addition & 0 deletions code/datums/jobs/job/other.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
gloves = /obj/item/clothing/gloves/marine/officer/chief/sa
glasses = /obj/item/clothing/glasses/sunglasses/sa/nodrop
back = /obj/item/storage/backpack/marine/satchel
ears = /obj/item/radio/headset/mainship/spatial

/datum/job/spatial_agent/galaxy_red
outfit = /datum/outfit/job/other/spatial_agent/galaxy_red
Expand Down
6 changes: 1 addition & 5 deletions code/datums/jobs/squads.dm
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
CRASH("attempted to insert marine [new_squaddie] into squad while already having one")

if(!(new_squaddie.job.title in current_positions))
CRASH("Attempted to insert [new_squaddie.job.title] into squad [name]")
return FALSE

current_positions[new_squaddie.job.title]++

Expand Down Expand Up @@ -144,7 +144,6 @@
marines_list += new_squaddie
new_squaddie.assigned_squad = src
new_squaddie.hud_set_job(faction)
new_squaddie.update_action_buttons()
new_squaddie.update_inv_head()
new_squaddie.update_inv_wear_suit()
return TRUE
Expand Down Expand Up @@ -192,7 +191,6 @@

leaving_squaddie.assigned_squad = null
leaving_squaddie.hud_set_job(faction)
leaving_squaddie.update_action_buttons()
leaving_squaddie.update_inv_head()
leaving_squaddie.update_inv_wear_suit()
return TRUE
Expand Down Expand Up @@ -222,7 +220,6 @@
to_chat(squad_leader, "<font size='3' color='blue'>You're no longer the Squad Leader for [src]!</font>")
var/mob/living/carbon/human/H = squad_leader
squad_leader = null
H.update_action_buttons()
H.hud_set_job(faction)
H.update_inv_head()
H.update_inv_wear_suit()
Expand Down Expand Up @@ -251,7 +248,6 @@
R.use_command = TRUE

squad_leader.hud_set_job(faction)
squad_leader.update_action_buttons()
squad_leader.update_inv_head()
squad_leader.update_inv_wear_suit()
to_chat(squad_leader, "<font size='3' color='blue'>You're now the Squad Leader for [src]!</font>")
Expand Down
1 change: 0 additions & 1 deletion code/datums/outfit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
H.update_body()
return TRUE


/datum/outfit/proc/get_json_data()
. = list()
.["outfit_type"] = type
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/effects/temporary_visuals/miscellaneous.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ GLOBAL_LIST_EMPTY(blood_particles)
icon = 'icons/Marine/marine-items.dmi'
var/icon_state_on
hud_possible = list(SQUAD_HUD_TERRAGOV, SQUAD_HUD_SOM)
duration = ORDER_DURATION
duration = CIC_ORDER_DURATION
layer = TURF_LAYER

/obj/effect/temp_visual/order/Initialize(mapload, faction)
Expand Down Expand Up @@ -186,7 +186,7 @@ GLOBAL_LIST_EMPTY(blood_particles)
/obj/effect/temp_visual/order/rally_order
name = "rally order"
icon_state_on = "rally"
duration = RALLY_ORDER_DURATION
duration = CIC_ORDER_DURATION

///Set visuals for the hud
/obj/effect/temp_visual/order/proc/set_visuals(faction)
Expand Down
Loading

0 comments on commit 869fb95

Please sign in to comment.