Merge pull request #12834 from silicons/clickcd_experimental

Experimental hybrid clickdelay system (No seriously I'm trying my best to not call it Minecraft attack delays)
This commit is contained in:
Lin
2020-07-28 21:51:10 -05:00
committed by GitHub
350 changed files with 1127 additions and 1207 deletions
@@ -16,7 +16,8 @@
var/variance = 0 //Variance for inaccuracy fundamental to the casing
var/randomspread = 0 //Randomspread for automatics
var/delay = 0 //Delay for energy weapons
var/click_cooldown_override = 0 //Override this to make your gun have a faster fire rate, in tenths of a second. 4 is the default gun cooldown.
/// Override this to make the gun check for a different cooldown rather than CLICK_CD_RANGE, which is 4 deciseconds.
var/click_cooldown_override
var/firing_effect_type = /obj/effect/temp_visual/dir_setting/firing_effect //the visual effect appearing when the ammo is fired.
var/heavy_metal = TRUE
var/harmful = TRUE //pacifism check for boolet, set to FALSE if bullet is non-lethal
@@ -16,10 +16,7 @@
AddComponent(/datum/component/pellet_cloud, projectile_type, pellets)
SEND_SIGNAL(src, COMSIG_PELLET_CLOUD_INIT, target, user, fired_from, randomspread, spread, zone_override, params, distro)
if(click_cooldown_override)
user.changeNext_move(click_cooldown_override)
else
user.changeNext_move(CLICK_CD_RANGE)
user.DelayNextAction(considered_action = TRUE, immediate = FALSE)
user.newtonian_move(get_dir(target, user))
update_icon()
return 1
+17 -7
View File
@@ -17,6 +17,7 @@
force = 5
item_flags = NEEDS_PERMIT
attack_verb = list("struck", "hit", "bashed")
attack_speed = CLICK_CD_RANGE
var/fire_sound = "gunshot"
var/suppressed = null //whether or not a message is displayed when fired
@@ -166,6 +167,8 @@
/obj/item/gun/afterattack(atom/target, mob/living/user, flag, params)
. = ..()
if(!CheckAttackCooldown(user, target))
return
process_afterattack(target, user, flag, params)
/obj/item/gun/proc/process_afterattack(atom/target, mob/living/user, flag, params)
@@ -174,9 +177,6 @@
if(firing)
return
var/stamloss = user.getStaminaLoss()
if(stamloss >= STAMINA_NEAR_SOFTCRIT) //The more tired you are, the less damage you do.
var/penalty = (stamloss - STAMINA_NEAR_SOFTCRIT)/(STAMINA_NEAR_CRIT - STAMINA_NEAR_SOFTCRIT)*STAM_CRIT_GUN_DELAY
user.changeNext_move(CLICK_CD_RANGE+(CLICK_CD_RANGE*penalty))
if(flag) //It's adjacent, is the user, or is on the user's person
if(target in user.contents) //can't shoot stuff inside us.
return
@@ -218,6 +218,8 @@
to_chat(user, "<span class='userdanger'>You need both hands free to fire \the [src]!</span>")
return
user.DelayNextAction()
//DUAL (or more!) WIELDING
var/bonus_spread = 0
var/loop_counter = 0
@@ -248,6 +250,17 @@
to_chat(user, "<span class='notice'> [src] is lethally chambered! You don't want to risk harming anyone...</span>")
return FALSE
/obj/item/gun/CheckAttackCooldown(mob/user, atom/target)
if((user.a_intent == INTENT_HARM) && user.Adjacent(target)) //melee
return user.CheckActionCooldown(CLICK_CD_MELEE)
return user.CheckActionCooldown(get_clickcd())
/obj/item/gun/proc/get_clickcd()
return isnull(chambered?.click_cooldown_override)? CLICK_CD_RANGE : chambered.click_cooldown_override
/obj/item/gun/GetEstimatedAttackSpeed()
return get_clickcd()
/obj/item/gun/proc/handle_pins(mob/living/user)
if(no_pin_required)
return TRUE
@@ -362,17 +375,14 @@
if(user.a_intent == INTENT_HARM) //Flogging
if(bayonet)
M.attackby(bayonet, user)
attack_delay_done = TRUE
return
else
return ..()
attack_delay_done = TRUE //we are firing the gun, not bashing people with its butt.
/obj/item/gun/attack_obj(obj/O, mob/user)
if(user.a_intent == INTENT_HARM)
if(bayonet)
O.attackby(bayonet, user)
return TRUE
return O.attackby(bayonet, user)
return ..()
/obj/item/gun/attackby(obj/item/I, mob/user, params)
+2 -5
View File
@@ -97,8 +97,7 @@
w_class += S.w_class //so pistols do not fit in pockets when suppressed
update_icon()
//ATTACK HAND IGNORING PARENT RETURN VALUE
/obj/item/gun/ballistic/attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags)
/obj/item/gun/ballistic/on_attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags)
if(loc == user)
if(suppressed && can_unsuppress)
var/obj/item/suppressor/S = suppressed
@@ -180,13 +179,11 @@
#undef BRAINS_BLOWN_THROW_SPEED
#undef BRAINS_BLOWN_THROW_RANGE
/obj/item/gun/ballistic/proc/sawoff(mob/user)
if(sawn_off)
to_chat(user, "<span class='warning'>\The [src] is already shortened!</span>")
return
user.changeNext_move(CLICK_CD_MELEE)
user.DelayNextAction(CLICK_CD_MELEE)
user.visible_message("[user] begins to shorten \the [src].", "<span class='notice'>You begin to shorten \the [src]...</span>")
//if there's any live ammo inside the gun, makes it go off
@@ -327,8 +327,7 @@
. = ..()
update_icon()
//ATTACK HAND IGNORING PARENT RETURN VALUE
/obj/item/gun/ballistic/automatic/l6_saw/attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags)
/obj/item/gun/ballistic/automatic/l6_saw/on_attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags)
if(loc != user)
..()
return //let them pick it up
@@ -29,8 +29,7 @@
/obj/item/minigunpack/process()
overheat = max(0, overheat - heat_diffusion)
//ATTACK HAND IGNORING PARENT RETURN VALUE
/obj/item/minigunpack/attack_hand(var/mob/living/carbon/user)
/obj/item/minigunpack/on_attack_hand(var/mob/living/carbon/user)
if(src.loc == user)
if(!armed)
if(user.get_item_by_slot(SLOT_BACK) == src)