Merge pull request #4378 from Neerti/12/1/2017_reaching_weapons

Adds Reach Variable to Weapons
This commit is contained in:
Anewbe
2017-12-02 12:00:26 -06:00
committed by GitHub
4 changed files with 16 additions and 3 deletions

View File

@@ -121,7 +121,7 @@
// A is a turf or is on a turf, or in something on a turf (pen in a box); but not something in something on a turf (pen in a box in a backpack)
sdepth = A.storage_depth_turf()
if(isturf(A) || isturf(A.loc) || (sdepth != -1 && sdepth <= 1))
if(A.Adjacent(src)) // see adjacent.dm
if(A.Adjacent(src) || (W && W.attack_can_reach(src, A, W.reach)) ) // see adjacent.dm
if(W)
// Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example)
var/resolved = W.resolve_attackby(A,src)

View File

@@ -168,7 +168,8 @@ turf/proc/AdjacentTurfsRangedSting()
/obj/structure/target_stake,
/obj/structure/cable,
/obj/structure/disposalpipe,
/obj/machinery/
/obj/machinery,
/mob
)
var/L[] = new()

View File

@@ -81,6 +81,7 @@
var/toolspeed = 1.0 // This is a multipler on how 'fast' a tool works. e.g. setting this to 0.5 will make the tool work twice as fast.
var/attackspeed = DEFAULT_ATTACK_COOLDOWN // How long click delay will be when using this, in 1/10ths of a second. Checked in the user's get_attack_speed().
var/reach = 1 // Length of tiles it can reach, 1 is adjacent.
var/addblends // Icon overlay for ADD highlights when applicable.
/obj/item/New()
@@ -641,3 +642,11 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
/obj/item/proc/pwr_drain()
return 0 // Process Kill
// Used for non-adjacent melee attacks with specific weapons capable of reaching more than one tile.
// This uses changeling range string A* but for this purpose its also applicable.
/obj/item/proc/attack_can_reach(var/atom/us, var/atom/them, var/range)
if(us.Adjacent(them))
return TRUE // Already adjacent.
if(AStar(get_turf(us), get_turf(them), /turf/proc/AdjacentTurfsRangedSting, /turf/proc/Distance, max_nodes=25, max_node_depth=range))
return TRUE
return FALSE

View File

@@ -145,6 +145,7 @@
base_icon = "spearglass"
name = "spear"
desc = "A haphazardly-constructed yet still deadly weapon of ancient design."
description_info = "This weapon can strike from two tiles away, and over certain objects such as tables, or other people."
force = 10
w_class = ITEMSIZE_LARGE
slot_flags = SLOT_BACK
@@ -159,3 +160,5 @@
default_material = "glass"
applies_material_colour = 0
fragile = 1 //It's a haphazard thing of glass, wire, and steel
reach = 2 // Spears are long.
attackspeed = 14