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

Marine Body Spray AKA: Reworks Marine Orders #3782

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions code/game/jobs/job/marine/squads.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
var/num_specialists = 0
var/num_tl = 0
var/count = 0 //Current # in the squad
var/list/ftl_list = list() // list of marines with the actual FTL role
var/list/marines_list = list() // list of mobs (or name, not always a mob ref) in that squad.

var/mob/living/carbon/human/overwatch_officer = null //Who's overwatching this squad?
Expand Down Expand Up @@ -409,6 +410,7 @@
assignment = JOB_SQUAD_TEAM_LEADER
num_tl++
M.important_radio_channels += radio_freq
ftl_list += M
if(JOB_SQUAD_SMARTGUN)
assignment = JOB_SQUAD_SMARTGUN
num_smartgun++
Expand Down Expand Up @@ -523,6 +525,7 @@
num_smartgun--
if(JOB_SQUAD_TEAM_LEADER)
num_tl--
ftl_list -= M
if(JOB_SQUAD_LEADER)
num_leaders--

Expand Down
14 changes: 7 additions & 7 deletions code/modules/defenses/planted_flag.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
QDEL_NULL(range_bounds)

/obj/structure/machinery/defenses/planted_flag/proc/apply_buff_to_player(mob/living/carbon/human/H)
H.activate_order_buff(COMMAND_ORDER_HOLD, buff_intensity, 1.5 SECONDS)
H.activate_order_buff(COMMAND_ORDER_FOCUS, buff_intensity, 1.5 SECONDS)
H.affected_by_orders(COMMAND_ORDER_HOLD, buff_intensity)
H.affected_by_orders(COMMAND_ORDER_FOCUS, buff_intensity)

/obj/structure/machinery/defenses/planted_flag/range
name = "extended JIMA planted flag"
Expand All @@ -111,9 +111,9 @@
defense_type = "Warbanner"

/obj/structure/machinery/defenses/planted_flag/warbanner/apply_buff_to_player(mob/living/carbon/human/H)
H.activate_order_buff(COMMAND_ORDER_HOLD, buff_intensity, 5 SECONDS)
H.activate_order_buff(COMMAND_ORDER_FOCUS, buff_intensity, 5 SECONDS)
H.activate_order_buff(COMMAND_ORDER_MOVE, buff_intensity, 5 SECONDS)
H.affected_by_orders(COMMAND_ORDER_HOLD, buff_intensity)
H.affected_by_orders(COMMAND_ORDER_FOCUS, buff_intensity)
H.affected_by_orders(COMMAND_ORDER_MOVE, buff_intensity)

/obj/item/storage/backpack/jima
name = "JIMA frame mount"
Expand Down Expand Up @@ -153,8 +153,8 @@
if(!(H.get_target_lock(M.faction_group)))
continue

H.activate_order_buff(COMMAND_ORDER_MOVE, buff_intensity, 3 SECONDS)
H.activate_order_buff(COMMAND_ORDER_FOCUS, buff_intensity, 3 SECONDS)
H.affected_by_orders(COMMAND_ORDER_MOVE, buff_intensity)
H.affected_by_orders(COMMAND_ORDER_FOCUS, buff_intensity)

#undef PLANTED_FLAG_BUFF
#undef PLANTED_FLAG_RANGE
11 changes: 5 additions & 6 deletions code/modules/mob/living/carbon/human/human_abilities.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
if(!ishuman(owner))
return
var/mob/living/carbon/human/H = owner
if(H.current_aura)
for(var/datum/action/human_action/issue_order/order_button in H.actions)
order_button.button.icon_state = "template"
if(H.current_aura != order_type)
button.icon_state = "template_on"
H.issue_order(order_type)

/datum/action/human_action/issue_order/action_cooldown_check()
if(!ishuman(owner))
return FALSE
var/mob/living/carbon/human/H = owner
return !H.command_aura_available

/datum/action/human_action/issue_order/move
name = "Issue Order - Move"
action_icon_state = "order_move"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ This function restores all limbs.
permanent_kill = FALSE, mob/firer = null, force = FALSE
)
if(protection_aura && damage > 0)
damage = round(damage * ((ORDER_HOLD_CALC_LEVEL - protection_aura) / ORDER_HOLD_CALC_LEVEL))
damage = round(damage * ((ORDER_HOLD_CALC_LEVEL - protection_aura * 0.5) / ORDER_HOLD_CALC_LEVEL))
Copy link
Contributor

Choose a reason for hiding this comment

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

are you certain this is doing what you want with PEMDAS?


//Handle other types of damage
if(damage < 0 || (damagetype != BRUTE) && (damagetype != BURN))
Expand Down
10 changes: 6 additions & 4 deletions code/modules/mob/living/carbon/human/human_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@
var/chem_effect_flags = 0
var/chem_effect_reset_time = 8

var/command_aura_available = TRUE // Whether or not you can issue an order
//var/command_aura_available = TRUE // Whether or not you can issue an order
Copy link
Contributor

Choose a reason for hiding this comment

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

don't comment out variables, remove them

var/current_aura = null //The aura we're currently emitting
var/aura_strength = 0 //Strenght of the aura we're emitting

var/mobility_aura_count = 0 //Used to track how many auras are affecting the human
var/protection_aura_count = 0
var/marksman_aura_count = 0
var/mobility_aura_new = 0 //Used to track how many auras are affecting the human
var/protection_aura_new = 0
var/marksman_aura_new = 0
Comment on lines +97 to +102
Copy link
Contributor

Choose a reason for hiding this comment

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

code doc these 5 (or more, if you want)

var/mobility_aura = 0
var/protection_aura = 0
var/marksman_aura = 0
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
. += max(0, G.slowdown - wear_slowdown_reduction)

if(mobility_aura && . >= 1.5)
. = max(. - (0.1 + 0.1 * mobility_aura), 1.5)
. = max(. - (0.1 + 0.05 * mobility_aura), 1.5)

if(superslowed)
. += HUMAN_SUPERSLOWED_AMOUNT
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/carbon/human/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
handle_organs()
handle_blood()

//Orders
handle_orders()

//Random events (vomiting etc)
if(!stat && getToxLoss() >= 45 && nutrition > 20)
vomit()
Expand Down
38 changes: 38 additions & 0 deletions code/modules/mob/living/carbon/human/life/handle_orders.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/mob/living/carbon/human/proc/handle_orders()

var/aura_center = null
if(current_aura)
aura_center = src

if((src.job == JOB_SQUAD_LEADER || HAS_TRAIT(src, TRAIT_SOURCE_SQUAD_LEADER)) && src.assigned_squad && src.assigned_squad.num_tl) //If the guy giving orders is leading a squad with FTLs we need them to act as beacons
for(var/mob/living/carbon/human/marine in src.assigned_squad.ftl_list)
marine.handle_ftl_orders(marine)

if(aura_strength > 0)
for(var/mob/living/carbon/human/H as anything in GLOB.alive_human_list)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is really expensive to call on every human every life() tick

it's more acceptable for xenoes bc they're rarely dealing with 30+ xenoes, but humans regularly breach 100, along with a not-exactly-free get_dist check

if(H.faction != faction || H.z != z || get_dist(aura_center, H) > COMMAND_ORDER_RANGE)
continue
H.affected_by_orders(current_aura, aura_strength)

if(mobility_aura != mobility_aura_new || protection_aura != protection_aura_new || marksman_aura != marksman_aura_new)
mobility_aura = mobility_aura_new
protection_aura = protection_aura_new
marksman_aura = marksman_aura_new
hud_set_order()

mobility_aura_new = 0
protection_aura_new = 0
marksman_aura_new = 0

/mob/living/carbon/human/proc/affected_by_orders(order, strength)
switch(order)
if(COMMAND_ORDER_MOVE)
if(strength > mobility_aura_new)
mobility_aura_new = Clamp(mobility_aura, strength, ORDER_MOVE_MAX_LEVEL)
if(COMMAND_ORDER_HOLD)
if(strength > protection_aura_new)
protection_aura_new = Clamp(protection_aura, strength, ORDER_HOLD_MAX_LEVEL)
pain.apply_pain_reduction(protection_aura * PAIN_REDUCTION_AURA)
if(COMMAND_ORDER_FOCUS)
if(strength > marksman_aura_new)
marksman_aura_new = Clamp(marksman_aura, strength, ORDER_FOCUS_MAX_LEVEL)
126 changes: 47 additions & 79 deletions code/modules/mob/living/carbon/human/powers/issue_order.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,58 @@
to_chat(src, SPAN_WARNING("You cannot give an order in your current state."))
return

if(!command_aura_available)
to_chat(src, SPAN_WARNING("You have recently given an order. Calm down."))
return

if(!skills)
return FALSE
var/order_level = skills.get_skill_level(SKILL_LEADERSHIP)
if(!order_level)
order_level = SKILL_LEAD_TRAINED

if(!order)
order = tgui_input_list(src, "Choose an order", "Order to send", list(COMMAND_ORDER_MOVE, COMMAND_ORDER_HOLD, COMMAND_ORDER_FOCUS, "help", "cancel"))
if(order == "help")
to_chat(src, SPAN_NOTICE("<br>Orders give a buff to nearby soldiers for a short period of time, followed by a cooldown, as follows:<br><B>Move</B> - Increased mobility and chance to dodge projectiles.<br><B>Hold</B> - Increased resistance to pain and combat wounds.<br><B>Focus</B> - Increased gun accuracy and effective range.<br>"))
if(current_aura)
deactivate_order_buff(current_aura)
current_aura = null
visible_message(SPAN_WARNING("\The [src] stops issueing orders."), \
Copy link
Contributor

Choose a reason for hiding this comment

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

issuing

SPAN_WARNING("You stop issueing orders."), null, 5)
return
if(order == "cancel")
return

if(!command_aura_available)
to_chat(src, SPAN_WARNING("You have recently given an order. Calm down."))
return

command_aura_available = FALSE
var/command_aura_strength = order_level
var/command_aura_duration = (order_level + 1) * 10 SECONDS

var/turf/T = get_turf(src)
for(var/mob/living/carbon/human/H in range(COMMAND_ORDER_RANGE, T))
if(H.stat == DEAD)
continue
H.activate_order_buff(order, command_aura_strength, command_aura_duration)

if(loc != T) //if we were inside something, the range() missed us.
activate_order_buff(order, command_aura_strength, command_aura_duration)

for(var/datum/action/A in actions)
A.update_button_icon()

// 1min cooldown on orders
addtimer(CALLBACK(src, PROC_REF(make_aura_available)), COMMAND_ORDER_COOLDOWN)

visible_message(SPAN_BOLDNOTICE("[src] gives an order to [order]!"), SPAN_BOLDNOTICE("You give an order to [order]!"))

/mob/living/carbon/human/proc/make_aura_available()
to_chat(src, SPAN_NOTICE("You can issue an order again."))
command_aura_available = TRUE
for(var/datum/action/A in actions)
A.update_button_icon()
else
order = tgui_input_list(src, "Choose an order", "Order to send", list(COMMAND_ORDER_MOVE, COMMAND_ORDER_HOLD, COMMAND_ORDER_FOCUS, "help", "cancel"))
if(order == "help")
to_chat(src, SPAN_NOTICE("<br>Orders give a buff to nearby soldiers for a short period of time, followed by a cooldown, as follows:<br><B>Move</B> - Increased mobility and chance to dodge projectiles.<br><B>Hold</B> - Increased resistance to pain and combat wounds.<br><B>Focus</B> - Increased gun accuracy and effective range.<br>"))
return
if(order == "cancel")
return

if(order)
if(current_aura == order)
visible_message(SPAN_BOLDNOTICE("[src] whitdraws their order to [order]!"), SPAN_BOLDNOTICE("You withdraw your order to [order]!"))
Copy link
Contributor

Choose a reason for hiding this comment

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

withdraws

deactivate_order_buff(current_aura)
current_aura = null
order = null
else
deactivate_order_buff(current_aura)
visible_message(SPAN_BOLDNOTICE("[src] gives an order to [order]!"), SPAN_BOLDNOTICE("You give an order to [order]!"))
aura_strength = order_level
current_aura = order

handle_orders(current_aura, aura_strength)

/mob/living/carbon/human/proc/handle_ftl_orders()
if(!assigned_squad)
return

var/mob/living/carbon/human/squad_lead = assigned_squad.squad_leader
if(!squad_lead || !squad_lead.current_aura || squad_lead.loc.z != loc.z)
if(current_aura && !squad_lead.current_aura)
to_chat(src, SPAN_BOLDNOTICE("Your radio goes quiet. The Squad Leader is no longer giving orders."))
aura_strength = 0
current_aura = null
else
if(current_aura != squad_lead.current_aura)
to_chat(src, SPAN_BOLDNOTICE("Your orders have changed. The Squad Leader has other plans."))
aura_strength = squad_lead.aura_strength
current_aura = squad_lead.current_aura
handle_orders(current_aura, aura_strength)
hud_set_order()

/mob/living/carbon/human/verb/issue_order_verb()
set name = "Issue Order"
Expand All @@ -64,49 +67,14 @@

issue_order()


/mob/living/carbon/human/proc/activate_order_buff(order, strength, duration)
if(!order || !strength)
return

switch(order)
if(COMMAND_ORDER_MOVE)
mobility_aura_count++
mobility_aura = Clamp(mobility_aura, strength, ORDER_MOVE_MAX_LEVEL)
if(COMMAND_ORDER_HOLD)
protection_aura_count++
protection_aura = Clamp(protection_aura, strength, ORDER_HOLD_MAX_LEVEL)
pain.apply_pain_reduction(protection_aura * PAIN_REDUCTION_AURA)
if(COMMAND_ORDER_FOCUS)
marksman_aura_count++
marksman_aura = Clamp(marksman_aura, strength, ORDER_FOCUS_MAX_LEVEL)

hud_set_order()

if(duration)
addtimer(CALLBACK(src, PROC_REF(deactivate_order_buff), order), duration)


/mob/living/carbon/human/proc/deactivate_order_buff(order)
switch(order)
if(COMMAND_ORDER_MOVE)
if(mobility_aura_count > 1)
mobility_aura_count--
else
mobility_aura_count = 0
mobility_aura = 0
mobility_aura_new = 0
if(COMMAND_ORDER_HOLD)
if(protection_aura_count > 1)
protection_aura_count--
else
pain.reset_pain_reduction()
protection_aura_count = 0
protection_aura = 0
pain.reset_pain_reduction()
protection_aura_new = 0
if(COMMAND_ORDER_FOCUS)
if(marksman_aura_count > 1)
marksman_aura_count--
else
marksman_aura_count = 0
marksman_aura = 0
marksman_aura_new = 0

hud_set_order()
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,7 @@
#include "code\modules\mob\living\carbon\human\life\handle_environment.dm"
#include "code\modules\mob\living\carbon\human\life\handle_fire.dm"
#include "code\modules\mob\living\carbon\human\life\handle_grabbed.dm"
#include "code\modules\mob\living\carbon\human\life\handle_orders.dm"
#include "code\modules\mob\living\carbon\human\life\handle_organs.dm"
#include "code\modules\mob\living\carbon\human\life\handle_pulse.dm"
#include "code\modules\mob\living\carbon\human\life\handle_regular_hud_updates.dm"
Expand Down
Binary file modified icons/mob/hud/actions.dmi
Binary file not shown.