Skip to content

Commit

Permalink
Merge pull request #4 from Eisendrachen/Eisenbranch
Browse files Browse the repository at this point in the history
Combat Indicator
  • Loading branch information
OctusGit authored Mar 12, 2022
2 parents 9366d4e + 8d42768 commit 363be38
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 2 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/keybinding.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//General
#define COMSIG_KB_ACTIVATED (1<<0)
#define COMSIG_KB_EMOTE "keybinding_emote_down"
#define COMSIG_KB_LIVING_COMBAT_INDICATOR "keybinding_living_combat_indicator"

//Admin
#define COMSIG_KB_ADMIN_ASAY_DOWN "keybinding_admin_asay_down"
Expand Down
4 changes: 2 additions & 2 deletions code/datums/keybinding/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
return TRUE

/datum/keybinding/mob/toggle_move_intent
hotkey_keys = list("C")
hotkey_keys = list("Alt") //PARIAH EDIT CHANGE - COMBAT_INDICATOR
name = "toggle_move_intent"
full_name = "Hold to toggle move intent"
description = "Held down to cycle to the other move intent, release to cycle back"
Expand Down Expand Up @@ -233,7 +233,7 @@
return TRUE

/datum/keybinding/mob/prevent_movement
hotkey_keys = list("Alt")
hotkey_keys = list("Unbound")
name = "block_movement"
full_name = "Block movement"
description = "Prevents you from moving"
Expand Down
57 changes: 57 additions & 0 deletions code/modules/combat_indicator/code/combat_indicator.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#define COMBAT_NOTICE_COOLDOWN 10 SECONDS
GLOBAL_VAR_INIT(combat_indicator_overlay, GenerateCombatOverlay())

/proc/GenerateCombatOverlay()
var/mutable_appearance/combat_indicator = mutable_appearance('code/modules/combat_indicator/icons/combat_indicator.dmi', "combat", FLY_LAYER)
combat_indicator.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA | KEEP_APART
return combat_indicator

/mob/living
var/combat_indicator = FALSE
var/nextcombatpopup = 0

/mob/living/proc/combat_indicator_unconscious_signal()
set_combat_indicator(FALSE)

/mob/living/proc/set_combat_indicator(state)
if(combat_indicator == state)
return

combat_indicator = state

if(combat_indicator)
if(world.time > nextcombatpopup)
nextcombatpopup = world.time + COMBAT_NOTICE_COOLDOWN
playsound(src, 'sound/machines/chime.ogg', 10)
flick_emote_popup_on_mob("combat", 20)
visible_message("<span class='boldwarning'>[src] gets ready for combat!</span>")
add_overlay(GLOB.combat_indicator_overlay)
combat_indicator = TRUE
src.log_message("<font color='red'>has turned ON the combat indicator!</font>", INDIVIDUAL_ATTACK_LOG)
RegisterSignal(src, COMSIG_LIVING_STATUS_UNCONSCIOUS, .proc/combat_indicator_unconscious_signal)
else
cut_overlay(GLOB.combat_indicator_overlay)
combat_indicator = FALSE
src.log_message("<font color='blue'>has turned OFF the combat indicator!</font>", INDIVIDUAL_ATTACK_LOG)
UnregisterSignal(src, COMSIG_LIVING_STATUS_UNCONSCIOUS)

/mob/living/proc/user_toggle_combat_indicator()
if(stat != CONSCIOUS)
return
set_combat_indicator(!combat_indicator)

#undef COMBAT_NOTICE_COOLDOWN

/datum/keybinding/living/combat_indicator
hotkey_keys = list("C")
name = "combat_indicator"
full_name = "Combat Indicator"
description = "Indicates that you're escalating to mechanics. YOU NEED TO USE THIS"
keybind_signal = COMSIG_KB_LIVING_COMBAT_INDICATOR

/datum/keybinding/living/combat_indicator/down(client/user)
. = ..()
if(.)
return
var/mob/living/L = user.mob
L.user_toggle_combat_indicator()
Binary file not shown.
1 change: 1 addition & 0 deletions code/modules/mob/living/death.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
med_hud_set_status()
stop_pulling()

set_combat_indicator(FALSE) //PARIAH EDIT ADDITION - COMBAT_INDICATOR

SEND_SIGNAL(src, COMSIG_LIVING_DEATH, gibbed)
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_MOB_DEATH, src, gibbed)
Expand Down
19 changes: 19 additions & 0 deletions code/modules/mob/living/emote_popup.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/obj/effect/overlay/emote_popup
icon = 'icons/mob/popup_flicks.dmi'
icon_state = "combat"
layer = FLY_LAYER
plane = GAME_PLANE
appearance_flags = APPEARANCE_UI_IGNORE_ALPHA | KEEP_APART
mouse_opacity = 0

/mob/living/proc/flick_emote_popup_on_mob(state, time)
var/obj/effect/overlay/emote_popup/I = new
I.icon_state = state
vis_contents += I
animate(I, alpha = 255, time = 5, easing = BOUNCE_EASING, pixel_y = 10)
addtimer(CALLBACK(src, .proc/remove_emote_popup_on_mob, I), time)

/mob/living/proc/remove_emote_popup_on_mob(obj/effect/overlay/emote_popup/I)
vis_contents -= I
qdel(I)
return
Binary file added icons/mob/popup_flicks.dmi
Binary file not shown.
2 changes: 2 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2593,6 +2593,7 @@
#include "code\modules\clothing\under\jobs\Plasmaman\engineering.dm"
#include "code\modules\clothing\under\jobs\Plasmaman\medsci.dm"
#include "code\modules\clothing\under\jobs\Plasmaman\security.dm"
#include "code\modules\combat_indicator\code\combat_indicator.dm"
#include "code\modules\detectivework\detective_work.dm"
#include "code\modules\detectivework\evidence.dm"
#include "code\modules\detectivework\footprints_and_rag.dm"
Expand Down Expand Up @@ -3078,6 +3079,7 @@
#include "code\modules\mob\living\damage_procs.dm"
#include "code\modules\mob\living\death.dm"
#include "code\modules\mob\living\emote.dm"
#include "code\modules\mob\living\emote_popup.dm"
#include "code\modules\mob\living\inhand_holder.dm"
#include "code\modules\mob\living\init_signals.dm"
#include "code\modules\mob\living\life.dm"
Expand Down

0 comments on commit 363be38

Please sign in to comment.