diff --git a/code/__DEFINES/hud_locations.dm b/code/__DEFINES/hud_locations.dm index 2d9ffa6b2d9..d14a51d3593 100644 --- a/code/__DEFINES/hud_locations.dm +++ b/code/__DEFINES/hud_locations.dm @@ -36,6 +36,7 @@ #define ui_storage1 "CENTER+1:18,SOUTH:5" #define ui_storage2 "CENTER+2:20,SOUTH:5" #define ui_pda "CENTER+3:22,SOUTH:5" +#define ui_combo "CENTER+4:24,SOUTH+1:7" //combo meter for martial arts #define ui_alien_head "4:12,1:5" //aliens #define ui_alien_oclothing "5:14,1:5" //aliens diff --git a/code/_onclick/hud/hud_datum.dm b/code/_onclick/hud/hud_datum.dm index e3dbaf78b26..9abe854bea1 100644 --- a/code/_onclick/hud/hud_datum.dm +++ b/code/_onclick/hud/hud_datum.dm @@ -26,6 +26,7 @@ var/obj/screen/zone_select var/obj/screen/move_intent var/obj/screen/module_store_icon + var/obj/screen/combo/combo_display var/list/static_inventory = list() //the screen objects which are static var/list/toggleable_inventory = list() //the screen objects which can be hidden diff --git a/code/_onclick/hud/human_hud.dm b/code/_onclick/hud/human_hud.dm index b95569e3909..6c1b25c05bd 100644 --- a/code/_onclick/hud/human_hud.dm +++ b/code/_onclick/hud/human_hud.dm @@ -354,6 +354,9 @@ inventory_shown = FALSE + combo_display = new() + infodisplay += combo_display + for(var/obj/screen/inventory/inv in (static_inventory + toggleable_inventory)) if(inv.slot_id) inv.hud = src diff --git a/code/modules/martial_arts/martial.dm b/code/modules/martial_arts/martial.dm index b23a82911e2..17d92661b1b 100644 --- a/code/modules/martial_arts/martial.dm +++ b/code/modules/martial_arts/martial.dm @@ -4,8 +4,8 @@ /datum/martial_art var/name = "Martial Art" var/streak = "" - var/max_streak_length = 6 var/temporary = FALSE + var/owner_UID /// The permanent style. var/datum/martial_art/base = null /// Chance to deflect projectiles while on throw mode. @@ -27,8 +27,8 @@ var/list/combos = list() /// What combos are currently (possibly) being performed. var/list/datum/martial_art/current_combos = list() - /// When the last hit happened. - var/last_hit = 0 + /// Stores the timer_id for the combo timeout timer + var/combo_timer /// If the user is preparing a martial arts stance. var/in_stance = FALSE /// If the martial art allows parrying. @@ -62,9 +62,16 @@ /datum/martial_art/proc/act(step, mob/living/carbon/human/user, mob/living/carbon/human/target) if(!can_use(user)) return MARTIAL_ARTS_CANNOT_USE + if(combo_timer) + deltimer(combo_timer) +/* if(last_hit + COMBO_ALIVE_TIME < world.time) reset_combos() - last_hit = world.time +*/ + combo_timer = addtimer(CALLBACK(src, PROC_REF(reset_combos)), COMBO_ALIVE_TIME, TIMER_UNIQUE | TIMER_STOPPABLE) + streak += intent_to_streak(step) + var/mob/living/carbon/human/owner = locateUID(owner_UID) + owner?.hud_used.combo_display.update_icon(ALL, streak) if(HAS_COMBOS) return check_combos(step, user, target) @@ -72,6 +79,9 @@ /datum/martial_art/proc/reset_combos() current_combos.Cut() + streak = "" + var/mob/living/carbon/human/owner = locateUID(owner_UID) + owner?.hud_used.combo_display.update_icon(ALL, streak) for(var/combo_type in combos) current_combos.Add(new combo_type()) @@ -147,6 +157,7 @@ return if(has_explaination_verb) H.verbs |= /mob/living/carbon/human/proc/martial_arts_help + owner_UID = H.UID() H.mind.known_martial_arts.Add(src) H.mind.martial_art = get_highest_weight(H) @@ -210,6 +221,17 @@ /datum/martial_art/proc/try_deflect(mob/user) return prob(deflection_chance) +/datum/martial_art/proc/intent_to_streak(intent) + switch(intent) + if(MARTIAL_COMBO_STEP_HARM) + return "E" // these hands are rated E for everyone + if(MARTIAL_COMBO_STEP_DISARM) + return "D" + if(MARTIAL_COMBO_STEP_GRAB) + return "G" + if(MARTIAL_COMBO_STEP_HELP) + return "H" + /datum/action/defensive_stance name = "Defensive Stance - Ready yourself to be attacked, allowing you to parry incoming melee hits." button_icon_state = "block" @@ -428,5 +450,36 @@ return ..() return 0 +/obj/screen/combo + icon_state = "" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + screen_loc = ui_combo + layer = ABOVE_HUD_LAYER + var/streak + +/obj/screen/combo/proc/clear_streak() + cut_overlays() + streak = "" + icon_state = "" + +/obj/screen/combo/update_icon(updates, _streak) + streak = _streak + return ..() + +/obj/screen/combo/update_overlays() + . = list() + for(var/i in 1 to length(streak)) + var/intent_text = copytext(streak, i, i + 1) + var/image/intent_icon = image(icon, src, "combo_[intent_text]") + intent_icon.pixel_x = 16 * (i - 1) - 8 * length(streak) + . += intent_icon + +/obj/screen/combo/update_icon_state() + icon_state = "" + if(!streak) + return + icon_state = "combo" + + #undef HAS_COMBOS #undef COMBO_ALIVE_TIME diff --git a/icons/mob/screen_gen.dmi b/icons/mob/screen_gen.dmi index 6de70193270..27c2bde8ddf 100644 Binary files a/icons/mob/screen_gen.dmi and b/icons/mob/screen_gen.dmi differ