Skip to content

Commit

Permalink
Melee weapons now give audiovisual feedback when they miss a target. (#…
Browse files Browse the repository at this point in the history
…19734)

title

also adds relevant info to logs

Co-authored-by: Matt Atlas <[email protected]>
  • Loading branch information
NonQueueingMatt and Matt Atlas authored Aug 2, 2024
1 parent 06ac02d commit 1ed9d50
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 16 deletions.
37 changes: 21 additions & 16 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -103,32 +103,37 @@ avoid code duplication. This includes items that may sometimes act as a standard
to_chat(user, SPAN_WARNING("You don't want to harm other living beings!"))
return 0

if(!force)
playsound(loc, 'sound/weapons/tap.ogg', get_clamped_volume(), 1, -1)
else if(hitsound)
playsound(loc, hitsound, get_clamped_volume(), 1, -1)

/////////////////////////
user.lastattacked = M
M.lastattacker = user

if(!no_attack_log)
user.attack_log += "\[[time_stamp()]\]<span class='warning'> Attacked [M.name] ([M.ckey]) with [name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(damtype)])</span>"
M.attack_log += "\[[time_stamp()]\]<font color='orange'> Attacked by [user.name] ([user.ckey]) with [name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(damtype)])</font>"
msg_admin_attack("[key_name(user, highlight_special = 1)] attacked [key_name(M, highlight_special = 1)] with [name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(damtype)]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)",ckey=key_name(user),ckey_target=key_name(M) )
/////////////////////////

user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
user.do_attack_animation(M, src)
if(!user.aura_check(AURA_TYPE_WEAPON, src, user))
return FALSE

var/mob/living/victim = M.get_attack_victim(src, user, target_zone)
var/hit_zone
if(victim)
var/hit_zone = victim.resolve_item_attack(src, user, target_zone)
hit_zone = victim.resolve_item_attack(src, user, target_zone)
if(hit_zone)
apply_hit_effect(victim, user, hit_zone)

// Null hitzone means a miss.
if(hit_zone)
if(!force)
playsound(loc, 'sound/weapons/tap.ogg', get_clamped_volume(), 1, -1)
else if(hitsound)
playsound(loc, hitsound, get_clamped_volume(), 1, -1)
else
playsound(loc, 'sound/weapons/punchmiss2.ogg', get_clamped_volume(), 1, -1)

/////////////////////////
user.lastattacked = M
M.lastattacker = user

if(!no_attack_log)
user.attack_log += "\[[time_stamp()]\]<span class='warning'> [hit_zone ? "Attacked" : "Missed"] [M.name] ([M.ckey]) with [name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(damtype)])</span>"
M.attack_log += "\[[time_stamp()]\]<font color='orange'> [hit_zone ? "Attacked" : "Missed"] by [user.name] ([user.ckey]) with [name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(damtype)])</font>"
msg_admin_attack("[key_name(user, highlight_special = 1)] [hit_zone ? "attacked" : "missed"] [key_name(M, highlight_special = 1)] with [name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(damtype)]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)",ckey=key_name(user),ckey_target=key_name(M) )
/////////////////////////

return 1

//Called when a weapon is used to make a successful melee attack on a mob. Returns whether damage was dealt.
Expand Down
58 changes: 58 additions & 0 deletions html/changelogs/mattatlas-missedopportunity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# - (fixes bugs)
# wip
# - (work in progress)
# qol
# - (quality of life)
# soundadd
# - (adds a sound)
# sounddel
# - (removes a sound)
# rscadd
# - (adds a feature)
# rscdel
# - (removes a feature)
# imageadd
# - (adds an image or sprite)
# imagedel
# - (removes an image or sprite)
# spellcheck
# - (fixes spelling or grammar)
# experiment
# - (experimental change)
# balance
# - (balance changes)
# code_imp
# - (misc internal code change)
# refactor
# - (refactors code)
# config
# - (makes a change to the config files)
# admin
# - (makes changes to administrator tools)
# server
# - (miscellaneous changes to server)
#################################

# Your name.
author: MattAtlas

# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True

# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit.
# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog.
changes:
- rscadd: "Melee weapons now give audiovisual feedback when they miss a target."

0 comments on commit 1ed9d50

Please sign in to comment.