do_after_advanced

This commit is contained in:
kevinz000
2020-04-11 05:10:07 -07:00
parent 99edc1e1a5
commit 234687c5c8
9 changed files with 431 additions and 173 deletions
+13 -4
View File
@@ -10,12 +10,18 @@
else
stop_pulling()
return
if("Insert", "G")
a_intent_change(INTENT_HOTKEY_RIGHT)
if("Insert")
if(client.keys_held["Ctrl"])
keybind_toggle_active_blocking()
return
else
keybind_parry()
return
if("G")
keybind_parry()
return
if("F")
a_intent_change(INTENT_HOTKEY_LEFT)
return
keybind_start_active_blocking()
if("X", "Northeast") // Northeast is Page-up
swap_hand()
return
@@ -91,4 +97,7 @@
if("Alt")
toggle_move_intent()
return
if("F")
keybind_stop_active_blocking()
return
return ..()
@@ -11,7 +11,9 @@
status_flags = CANSTUN|CANKNOCKDOWN|CANUNCONSCIOUS|CANPUSH|CANSTAGGER
blocks_emissive = EMISSIVE_BLOCK_UNIQUE
active_block_enabled = TRUE
//Hair colour and style
var/hair_color = "000"
var/hair_style = "Bald"
+49 -2
View File
@@ -2,6 +2,10 @@
/mob/living
/// Whether or not the user is actively blocking.
var/active_blocking = FALSE
/// Whether or not we can actively block. Disabled by default since a lot of mobs do not support stamina damage. Imagine a dextrous guardian with a shield..
var/active_block_enabled = FALSE
/// Whether or not we are in the process of raising our shield/whatever.
var/active_block_starting = FALSE
/// The item the user is actively blocking with if any.
var/obj/item/active_block_item
@@ -52,7 +56,7 @@
/mob/living/get_standard_pixel_x_offset()
. = ..()
if(active_blocking)
if(active_blocking || active_block_starting)
if(dir & EAST)
. += 12
if(dir & WEST)
@@ -60,12 +64,55 @@
/mob/living/get_standard_pixel_y_offset()
. = ..()
if(active_blocking)
if(active_blocking || active_block_starting)
if(dir & NORTH)
. += 12
if(dir & SOUTH)
. -= 12
/**
* Proc called by keybindings to toggle active blocking.
*/
/mob/living/proc/keybind_toggle_active_blocking()
if(active_blocking)
return keybind_stop_active_blocking()
else
return keybind_start_active_blocking()
/**
* Proc called by keybindings to start active blocking.
*/
/mob/living/proc/keybind_start_active_blocking()
if(active_blocking || active_block_starting)
return FALSE
if(!CHECK_BITFIELD(combat_flags, COMBAT_FLAG_COMBAT_ACTIVE))
to_chat(src, "<span class='warning'>You must be in combat mode to actively block!</span>")
return FALSE
var/obj/item/I = get_active_held_item()
if(!I)
to_chat(src, "<span class='warning'>You can't block with your bare hands!</span>")
return
if(!(I.item_flags & ITEM_CAN_BLOCK))
to_chat(src, "<span class='warning'>[I] is not capable of actively being used to block!</span>")
return
var/datum/block_parry_data/data = get_block_parry_data(I.block_parry_data)
var/delay = data.block_start_delay
active_block_starting = TRUE
animate(src, pixel_x = get_standard_pixel_x_offset(), pixel_y = get_standard_pixel_y_offset(), time = delay, FALSE, SINE_EASING | EASE_IN)
if(!do_after_advanced(src, delay, src, DO_AFTER_REQUIRES_USER_ON_TURF|DO_AFTER_NO_COEFFICIENT|DO_AFTER_DISALLOW_ACTIVE_ITEM_CHANGE, null, MOBILITY_USE, COMBAT_FLAG_COMBAT_ACTIVE, null, I))
to_chat(src, "<span class='warning'>You fail to raise [src].</span>")
animate(src, pixel_x = get_standard_pixel_x_offset(), pixel_y = get_standard_pixel_y_offset(), time = 2.5, FALSE, SINE_EASING | EASE_IN, ANIMATION_END_NOW)
return
active_block_starting = FALSe
start_active_blocking(I)
/**
* Proc called by keybindings to stop active blocking.
*/
/mob/living/proc/keybind_stop_active_blocking()
stop_active_blocking(FALSE)
return TRUE
/// The amount of damage that is blocked.
/obj/item/proc/active_block_damage_mitigation(mob/living/owner, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return)
var/datum/block_parry_data/data = get_block_parry_data(block_parry_data)
@@ -0,0 +1 @@
/mob/living/proc/keybind_parry()
@@ -47,6 +47,8 @@ GLOBAL_LIST_EMPTY(block_parry_data)
var/block_lock_attacking = TRUE
/// The priority we get in [mob/do_run_block()] while we're being used to parry.
var/block_active_priority = BLOCK_PRIORITY_ACTIVE_BLOCK
/// Windup before we have our blocking active.
var/block_start_delay = 5
/// Amount of "free" damage blocking absorbs
var/block_damage_absorption = 10