This commit is contained in:
kevinz000
2020-03-24 19:29:54 -07:00
parent d139234c6d
commit 2e0992dbb9
2 changed files with 33 additions and 8 deletions
+24
View File
@@ -0,0 +1,24 @@
// We can't determine things like NORTHEAST vs NORTH *and* EAST without making our own flags :(
#define BLOCK_DIR_NORTH (1<<0)
#define BLOCK_DIR_NORTHEAST (1<<1)
#define BLCOK_DIR_NORTHWEST (1<<2)
#define BLOCK_DIR_WEST (1<<3)
#define BLOCK_DIR_EAST (1<<4)
#define BLOCK_DIR_SOUTH (1<<5)
#define BLOCK_DIR_SOUTHEAST (1<<6)
#define BLOCK_DIR_SOUTHWEST (1<<7)
#define BLOCK_DIR_ONTOP (1<<8)
GLOBAL_LIST_INIT(dir2blockdir, list(
"[NORTH]" = "[BLOCK_DIR_NORTH]",
"[NORTHEAST]" = "[BLOCK_DIR_NORTHEAST]",
"[NORTHWEST]" = "[BLOCK_DIR_NORTHWEST]",
"[WEST]" = "[BLOCK_DIR_WEST]",
"[EAST]" = "[BLOCK_DIR_EAST]",
"[SOUTH]" = "[BLOCK_DIR_SOUTH]",
"[SOUTHEAST]" = "[BLOCK_DIR_SOUTHEAST]",
"[SOUTHWEST]" = "[BLOCK_DIR_SOUTHWEST]",
"[NONE]" = "[BLOCK_DIR_ONTOP]",
))
#define DIR2BLOCKDIR(d) (GLOB.dir2blockdir["[d]"])
@@ -7,9 +7,10 @@
/datum/block_parry_data
/obj/item
/// From a point of reference of someone facing NORTH. Put in DOWN to block attacks from our tile.
var/can_block_directions = list(NORTHWEST, NORTH, NORTHEAST)
/// See defines.
var/can_block_directions = BLOCK_DIR_NORTH | BLOCK_DIR_NORTHEAST | BLOCK_DIR_NORTHWEST
/// Defense flags, see __DEFINES/flags.dm
var/defense_flags = NONE
@@ -17,16 +18,18 @@
return ..()
/// This item can be used to parry. Only a basic check.
/// This item can be used to parry. Only a basic check used to determine if we should proceed with parry chain at all.
#define ITEM_DEFENSE_CAN_PARRY (1<<0)
/// This item can be used in the directional blocking system. Only a basic check.
/// This item can be used in the directional blocking system. Only a basic check used to determine if we should proceed with directional block handling at all.
#define ITEM_DEFENSE_CAN_BLOCK (1<<1)
/**
* Gets the list of directions we can block. Include DOWN to block attacks from our same tile.
*/
/obj/item/proc/blockable_directions()
return list()
return can_block_directions
/**
* Checks if we can block from a specific direction from our direction.
@@ -41,9 +44,7 @@
// dir2angle(), ss13 proc is clockwise so dir2angle(EAST) == 90
// turn(), byond proc is counterclockwise so turn(NORTH, 90) == WEST
their_dir = turn(their_dir, turn_angle)
if(their_dir == NONE)
return (DOWN in blockable_directions())
return (their_dir in blockable_directions())
return (DIR2BLOCKDIR(their_dir) in blockable_directions())
/**
* can_block_direction but for "compound" directions to check all of them and return the number of directions that were blocked.