Skip to content

Commit

Permalink
add: combo counter (#3881)
Browse files Browse the repository at this point in the history
  • Loading branch information
ROdenFL authored Nov 24, 2023
1 parent 2cbfcff commit 2e6a58a
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 3 deletions.
1 change: 1 addition & 0 deletions code/_onclick/hud/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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
Expand Down
1 change: 1 addition & 0 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
var/obj/screen/zone_select
var/obj/screen/move_intent
var/obj/screen/module_store_icon
var/obj/screen/combo/combo_display

var/obj/screen/devil/soul_counter/devilsouldisplay

Expand Down
4 changes: 4 additions & 0 deletions code/_onclick/hud/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@

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
Expand Down
57 changes: 54 additions & 3 deletions code/modules/martial_arts/martial.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
/datum/martial_art
var/name = "Martial Art"
var/streak = ""
var/max_streak_length = 6
// 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.
Expand Down Expand Up @@ -33,7 +34,9 @@
/// What combos are currently (possibly) being performed.
var/list/datum/martial_art/current_combos = list()
/// When the last hit happened.
var/last_hit = 0
// 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

Expand All @@ -59,16 +62,26 @@
/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)
return FALSE

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

Expand Down Expand Up @@ -174,6 +187,7 @@
base = H.mind.martial_art.base
else
base = src
owner_UID = H.UID()
H.mind.martial_art = src

/datum/martial_art/proc/remove(var/mob/living/carbon/human/H)
Expand Down Expand Up @@ -234,6 +248,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"

//ITEMS

/obj/item/clothing/gloves/boxing
Expand Down Expand Up @@ -507,5 +532,31 @@
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
icon_state = ""
if(!streak)
clear_streak()
return
icon_state = "combo"
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)
overlays += intent_icon
return ..()

#undef HAS_COMBOS
#undef COMBO_ALIVE_TIME
Binary file modified icons/mob/screen_gen.dmi
Binary file not shown.

0 comments on commit 2e6a58a

Please sign in to comment.