Files
GS13NG/code/_onclick/item_attack.dm
deathride58 1c0b13ecfb [READY FOR MERGE] The Giant Combat Reworks - Part 1: Goodbye stuns, hello staminacrit (#5463)
* part 1 - resist out of resting, move and interact with the world while resting, and stamina regen nerf

* makes beepsky check for stuns instead of knockdowns, adds message for getting up, makes gravity reduce standup time, and more

* sprinting, staminacrit, balance changes, and more

* adds stamina modifier to clickdelay, makes items deal stamina damage to the user when attacking, buffs resting stamina regen

* combat mode, ability to toggle right-click context menu on/off, basic combat mode QOL, lays groundwork for 2-handing any item

combat mode toggle sound is from Interbay.

* commits dme changes

* unarmed combat stamina, ability to right click in combat mode, balance changes

* tosses in the HUD icons for later-ish

* rolls back admin.txt

* lotsa UI stuff

* stamina checks, some balance stuff

* adds support for best ui, adds right click to flush disposals, removes aggressive grab pinning in favor of neckgrab chokeholding

* quick dogborg patch while i figure out what do do with them

* oops - fixes prefbreaking for screenshake

* trying to sprint from an elevated surface onto lower ground will now knock you down

* right click to pull fire alarm, lets you bully people by pulling chairs out form under them, makes attacking objects cost stamina

* makes accidents during slipping less likely to occur while combat mode is active, makes tripping off elevated surfaces cause accidents

* makes pumping shotguns cost a tiiiny bit of stamina

* makes eyestabbing and batoning cost stamina

* makes failing stamina checks error out properly, adds stamina check to shotgun pumping

* adds stamina check for chair pulling

* readds aggressive grab pinning

* fixes bug with being buckled preventing interaction

* adds recoveringstam check to incapacitated

* reduces stamina cost for attacking

* oh this too

* fixes bug where you can get stuck in recoveringstam if your stamina suddenly becomes 0 while you're in staminacrit

* makes monkey transformation inherit staminaloss

* adds the ability to wave or shake your fist at someone via right click

* grammar and span closing

* 99 annoying little bugs on the wall, 99 annoying little bugs. take one down, pass it around, 864 gamebreaking bugs on the wall

* more distant right-click emotes.

* buffs standing stamina regen a tiiiiiiny bit

* adds aiming down sights for guns, makes firing guns cause trace amounts of staminaloss

* crusher powercreep - gives crushers the ability to heal staminaloss

* item throwing buff

* adds 1:1 HUD layout

* hopefully fixes issue with recoveringstamcrit not updating

* giant hipfire nerf

* halves the effect of staminaloss on movement speed

* makes stamina recover faster in staminacrit, makes it easier to get disarmed out of combat mode

* get_weight(), movedelay health_deficiency tweaking, combat and resting checks for item attacking

* makes staminacrit automatically disable combat mode, it's now impossible to enter combat mode while in stamcrit

* adds stamina buffer, halves the time needed to stand up after resting, increases stam penalty for firing weapons, and more

* tweaks stamina buffer drain rate a little

* makes buffered staminaloss redirect stamina to the actual stamloss proc when empty, makes stamina buffer stat() more precise

* removes stamina modifier for clickdelays, makes stunbatons deal extra staminaloss

* makes electrodes deal a lil extra staminaloss

* drones cannot resist a rest, so now only carbons are forced to rest

* restricts aiming down sights to carbon mobs, adds stamina display to stat()

* makes gun accuracy and stamcosts more flexible, decreases base inaccuracy penalty, makes borgs immune to inaccuracy penalties

* nerfs inaccuracy penalties just a lil more, fixes blooddrunk miner eye depleting all your stamina

* getting used to tortoisegit

* readds temp dogborg buff

* stamina and stamina buffer HUD displays. Stamina sprite from hippiestation

* makes afterattack call properly again

* decreases stamina buffer regen time to 3 seconds

* Yknow what? decreases it to 2 seconds. That's 3 entire attacks worth of waiting

* makes stamina buffer influence movespeed a lil

* nerfs compiling errors

* tweaks the icons a little

* adds autostanding, adds delimiters to attempts to stand

* makes automatic standup attempts a little clearer

* rest button now toggles intent to rest, fixes perma rest

* oop - quick fixes

* Makes crushers ignore recoil stamina on lavaland, makes burstfiring weapons deal less staminaloss

* buffs highlander sword

* makes stamina have less of an impact on the health display

* fixes dogborgs shoving other borgs into infinite stuns

* You can no longer shoot over tables or shoot through windows while resting. Also buffs turrets
2018-03-11 13:32:44 -07:00

159 lines
6.5 KiB
Plaintext

/obj/item/proc/melee_attack_chain(mob/user, atom/target, params)
if(!tool_attack_chain(user, target) && pre_attackby(target, user, params))
// Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example)
var/resolved = target.attackby(src, user, params)
if(!resolved && target && !QDELETED(src))
afterattack(target, user, 1, params) // 1: clicking something Adjacent
//Checks if the item can work as a tool, calling the appropriate tool behavior on the target
/obj/item/proc/tool_attack_chain(mob/user, atom/target)
if(!tool_behaviour)
return FALSE
return target.tool_act(user, src, tool_behaviour)
// Called when the item is in the active hand, and clicked; alternately, there is an 'activate held object' verb or you can hit pagedown.
/obj/item/proc/attack_self(mob/user)
SendSignal(COMSIG_ITEM_ATTACK_SELF, user)
interact(user)
/obj/item/proc/pre_attackby(atom/A, mob/living/user, params) //do stuff before attackby!
return TRUE //return FALSE to avoid calling attackby after this proc does stuff
// No comment
/atom/proc/attackby(obj/item/W, mob/user, params)
if(SendSignal(COMSIG_PARENT_ATTACKBY, W, user, params) & COMPONENT_NO_AFTERATTACK)
return TRUE
return FALSE
/obj/attackby(obj/item/I, mob/living/user, params)
return ..() || ((obj_flags & CAN_BE_HIT) && I.attack_obj(src, user))
/mob/living/attackby(obj/item/I, mob/living/user, params)
user.changeNext_move(CLICK_CD_MELEE)
if(user.a_intent == INTENT_HARM && stat == DEAD && (butcher_results || guaranteed_butcher_results)) //can we butcher it?
GET_COMPONENT_FROM(butchering, /datum/component/butchering, I)
if(butchering && butchering.butchering_enabled)
to_chat(user, "<span class='notice'>You begin to butcher [src]...</span>")
playsound(loc, butchering.butcher_sound, 50, TRUE, -1)
if(do_mob(user, src, butchering.speed) && Adjacent(I))
butchering.Butcher(user, src)
return 1
else if(I.is_sharp() && !butchering) //give sharp objects butchering functionality, for consistency
I.AddComponent(/datum/component/butchering, 80 * I.toolspeed)
attackby(I, user, params) //call the attackby again to refresh and do the butchering check again
return
return I.attack(src, user)
/obj/item/proc/attack(mob/living/M, mob/living/user)
SendSignal(COMSIG_ITEM_ATTACK, M, user)
if(flags_1 & NOBLUDGEON_1)
return
if(user.staminaloss >= STAMINA_SOFTCRIT) // CIT CHANGE - makes it impossible to attack in stamina softcrit
to_chat(user, "<span class='warning'>You're too exhausted.</span>") // CIT CHANGE - ditto
return // CIT CHANGE - ditto
if(force && user.has_trait(TRAIT_PACIFISM))
to_chat(user, "<span class='warning'>You don't want to harm other living beings!</span>")
return
if(!force)
playsound(loc, 'sound/weapons/tap.ogg', get_clamped_volume(), 1, -1)
else if(hitsound)
playsound(loc, hitsound, get_clamped_volume(), 1, -1)
M.lastattacker = user.real_name
M.lastattackerckey = user.ckey
user.do_attack_animation(M)
M.attacked_by(src, user)
add_logs(user, M, "attacked", src.name, "(INTENT: [uppertext(user.a_intent)]) (DAMTYPE: [uppertext(damtype)])")
add_fingerprint(user)
user.adjustStaminaLossBuffered(getweight())//CIT CHANGE - makes attacking things cause stamina loss
//the equivalent of the standard version of attack() but for object targets.
/obj/item/proc/attack_obj(obj/O, mob/living/user)
SendSignal(COMSIG_ITEM_ATTACK_OBJ, O, user)
if(flags_1 & NOBLUDGEON_1)
return
if(user.staminaloss >= STAMINA_SOFTCRIT) // CIT CHANGE - makes it impossible to attack in stamina softcrit
to_chat(user, "<span class='warning'>You're too exhausted.</span>") // CIT CHANGE - ditto
return // CIT CHANGE - ditto
user.adjustStaminaLossBuffered(getweight()*1.2)//CIT CHANGE - makes attacking things cause stamina loss
user.changeNext_move(CLICK_CD_MELEE)
user.do_attack_animation(O)
O.attacked_by(src, user)
/atom/movable/proc/attacked_by()
return
/obj/attacked_by(obj/item/I, mob/living/user)
if(I.force)
visible_message("<span class='danger'>[user] has hit [src] with [I]!</span>", null, null, COMBAT_MESSAGE_RANGE)
//only witnesses close by and the victim see a hit message.
take_damage(I.force, I.damtype, "melee", 1)
/mob/living/attacked_by(obj/item/I, mob/living/user)
send_item_attack_message(I, user)
if(I.force)
//CIT CHANGES START HERE - combatmode and resting checks
var/totitemdamage = I.force
if(iscarbon(user))
var/mob/living/carbon/tempcarb = user
if(!tempcarb.combatmode)
totitemdamage *= 0.5
if(user.resting)
totitemdamage *= 0.5
//CIT CHANGES END HERE
apply_damage(totitemdamage, I.damtype) //CIT CHANGE - replaces I.force with totitemdamage
if(I.damtype == BRUTE)
if(prob(33))
I.add_mob_blood(src)
var/turf/location = get_turf(src)
add_splatter_floor(location)
if(get_dist(user, src) <= 1) //people with TK won't get smeared with blood
user.add_mob_blood(src)
return TRUE //successful attack
/mob/living/simple_animal/attacked_by(obj/item/I, mob/living/user)
if(I.force < force_threshold || I.damtype == STAMINA)
playsound(loc, 'sound/weapons/tap.ogg', I.get_clamped_volume(), 1, -1)
else
return ..()
// Proximity_flag is 1 if this afterattack was called on something adjacent, in your square, or on your person.
// Click parameters is the params string from byond Click() code, see that documentation.
/obj/item/proc/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
return
/obj/item/proc/get_clamped_volume()
if(w_class)
if(force)
return CLAMP((force + w_class) * 4, 30, 100)// Add the item's force to its weight class and multiply by 4, then clamp the value between 30 and 100
else
return CLAMP(w_class * 6, 10, 100) // Multiply the item's weight class by 6, then clamp the value between 10 and 100
/mob/living/proc/send_item_attack_message(obj/item/I, mob/living/user, hit_area)
var/message_verb = "attacked"
if(I.attack_verb && I.attack_verb.len)
message_verb = "[pick(I.attack_verb)]"
else if(!I.force)
return
var/message_hit_area = ""
if(hit_area)
message_hit_area = " in the [hit_area]"
var/attack_message = "[src] has been [message_verb][message_hit_area] with [I]."
if(user in viewers(src, null))
attack_message = "[user] has [message_verb] [src][message_hit_area] with [I]!"
visible_message("<span class='danger'>[attack_message]</span>",\
"<span class='userdanger'>[attack_message]</span>", null, COMBAT_MESSAGE_RANGE)
return 1