Skip to content

Commit

Permalink
Railings, barricades, pick up your guns
Browse files Browse the repository at this point in the history
Makes barricades climbable in general (and stops you being able to climb into walls with them)
  • Loading branch information
Bokkiewokkie committed Oct 11, 2024
1 parent e3e60c1 commit 9583c2e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 42 deletions.
21 changes: 13 additions & 8 deletions code/__HELPERS/path.dm
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,21 @@
* * ID: An ID card that decides if we can gain access to doors that would otherwise block a turf
* * simulated_only: Do we only worry about turfs with simulated atmos, most notably things that aren't space?
*/
//NSV13 refactored this to use a typecache for directional objects in src
/turf/proc/LinkBlockedWithAccess(turf/destination_turf, caller, ID)
var/actual_dir = get_dir(src, destination_turf)

for(var/obj/structure/window/iter_window in src)
if(!iter_window.CanAStarPass(ID, actual_dir))
return TRUE

for(var/obj/machinery/door/window/iter_windoor in src)
if(!iter_windoor.CanAStarPass(ID, actual_dir))
return TRUE
var/static/list/directionals = typecacheof(list(
/obj/structure/window,
/obj/machinery/door/window,
/obj/structure/railing,
/obj/structure/barricade,
/obj/machinery/door/firedoor
))

for(var/obj/iter_object in src)
if(directionals(iter_object.type))
if(!iter_object.CanAstarPass(ID, actual_dir, caller))
return TRUE

var/reverse_dir = get_dir(destination_turf, src)
for(var/obj/iter_object in destination_turf)
Expand Down
1 change: 0 additions & 1 deletion code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@
//NSV13 - npcs can into firelock
/obj/machinery/door/firedoor/border_only/CanAStarPass(obj/item/card/id/ID, to_dir, atom/movable/caller)
if((welded || (machine_stat & NOPOWER)) && (dir == to_dir))
message_admins("[src]([ADMIN_FLW(src)]) returned false astarpass with dir [dir], weld [welded] and machine stat [machine_state]")
return FALSE
return TRUE

Expand Down
28 changes: 18 additions & 10 deletions nsv13/code/game/objects/structures/barricade.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/obj/structure/peacekeeper_barricade //CREDIT TO CM FOR THIS. Cleanup up by Kmc.
icon = 'nsv13/icons/obj/barricades.dmi'
climbable = FALSE //Disable climbing.
anchored = TRUE
density = TRUE
layer = BELOW_OBJ_LAYER
Expand All @@ -13,7 +12,6 @@
var/base_acid_damage = 2
var/barricade_resistance = 5 //How much force an item needs to even damage it at all.
var/barricade_hitsound

var/barricade_type = "barricade" //"metal", "plasteel", etc.
var/can_change_dmg_state = TRUE
var/damage_state = 0
Expand Down Expand Up @@ -49,7 +47,6 @@
barricade_type = "plasteel"
density = FALSE
closed = TRUE
can_wire = TRUE

/obj/structure/peacekeeper_barricade/metal/plasteel/deployable //Preset one that starts unanchored and placed down.
icon_state = "plasteel_0"
Expand All @@ -58,16 +55,17 @@
anchored = FALSE
build_state = 0

/* You can reenable this when you fix it, KMC.
/obj/structure/peacekeeper_barricade/do_climb(var/mob/living/user)
if(is_wired) //Ohhh boy this is gonna hurt...
if(is_wired) //Even trying this is gonna hurt...
user.apply_damage(10)
user.Stun(20) //Leaping into barbed wire is VERY bad
if(get_turf(user) == get_turf(src))
usr.forceMove(get_step(src, src.dir))
user.Stun(20) //Scaling barbed wire is VERY bad
if(loc == user.loc)
density = FALSE
. = step(user,get_step(src,src.dir))
density = TRUE
else
usr.forceMove(get_turf(src))
*/
. = ..()

/obj/structure/peacekeeper_barricade/metal/plasteel/attack_hand(mob/user as mob)
. = ..()
if(.)
Expand Down Expand Up @@ -451,6 +449,16 @@
setDir(turn(dir, 270))
return

/obj/structure/peacekeeper_barricade/CanAStarPass(obj/item/card/id/ID, to_dir, atom/movable/caller)
. = ..()
if(.)
return
if(!(dir in to_dir))
return TRUE
if(isknpc(caller)) //They can climb
return TRUE
return FALSE

/obj/item/stack/barbed_wire
name = "barbed wire"
desc = "A spiky length of wire."
Expand Down
53 changes: 30 additions & 23 deletions nsv13/code/modules/overmap/knpc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ GLOBAL_LIST_EMPTY(knpcs)
var/obj/effect/landmark/patrol_node/last_node = null //What was the last patrol node we visited?
var/stealing_id = FALSE
var/next_internals_attempt = 0
var/static/list/climbable = typecacheof(list(/obj/structure/table, /obj/structure/railing)) // climbable structures
var/static/list/climbable = typecacheof(list(
/obj/structure/table,
/obj/structure/railing,
/obj/structure/peacekeeper_barricade
)) // climbable structures
var/pathfind_timeout = 0 //If pathfinding fails, it is püt in timeout for a while to avoid spamming the server with pathfinding calls.
var/timeout_stacks = 0 //Consecutive pathfind fails add additional delay stacks to further counteract the effects of knpcs in unreachable locations.

/mob/living/carbon/human/ai_boarder
faction = list("Neutral")
var/move_delay = 6 //How quickly do the boys travel?
var/action_delay = 10 //How long we delay between actions
var/move_delay = 4 //How quickly do the boys travel?
var/action_delay = 9 //How long we delay between actions
var/knpc_traits = KNPC_IS_DODGER | KNPC_IS_MERCIFUL | KNPC_IS_AREA_SPECIFIC
var/difficulty_override = FALSE //Whether to ignore overmap difficulty or not
var/list/outfit = list (
Expand Down Expand Up @@ -154,7 +158,7 @@ GLOBAL_LIST_EMPTY(knpcs)
continue
if(!blocking_firelock.density || blocking_firelock.operating)
continue
if(blocking_firelock.welded)
if((blocking_firelock.welded))
break //If at least one firedoor in our way is welded shut, welp!
blocking_firelock.open() //Open one firelock per tile per try.
break
Expand All @@ -170,12 +174,10 @@ GLOBAL_LIST_EMPTY(knpcs)
for(var/obj/structure/possible_barrier in next_turf) //If we're stuck
if(!climbable.Find(possible_barrier.type))
continue
H.forceMove(next_turf)
H.visible_message("<span class='warning'>[H] climbs onto [possible_barrier]!</span>")
var/obj/item/dropped_it
if(H.get_active_held_item())
dropped_it = H.get_active_held_item()
H.Stun(2 SECONDS) //Table.
possible_barrier.climb_structure(H)
var/obj/item/dropped_it
if(dropped_it) //Don't forget to pick up your stuff
H.put_in_hands(dropped_it, forced=TRUE)
if(get_turf(H) == path[1])
Expand Down Expand Up @@ -382,7 +384,13 @@ This is to account for sec Ju-Jitsuing boarding commandos.
var/mob/living/carbon/human/H = HA.parent
var/obj/item/storage/S = H.back
var/obj/item/gun/target_item = null
//Okay first off, is the gun already on our person?
//We must have lost our gun somehow, get it from the floor if we simply dropped it.
if(istype(H.loc, /turf))
var/turf/T = H.loc
target_item = locate(/obj/item/gun) in T.contents
if(H.put_in_hands(target_item))
return TRUE
//Otherwise, is there a gun already on our person?
if(S)
var/list/expanded_contents = S.contents + H.contents
target_item = locate(/obj/item/gun) in expanded_contents
Expand All @@ -392,7 +400,7 @@ This is to account for sec Ju-Jitsuing boarding commandos.
target_item.forceMove(get_turf(H)) //Put it on the floor so they can grab it
if(H.put_in_hands(target_item))
return TRUE //We're done!
//Now we run the more expensive check to find a gun laying on the ground.
//Now we run the more expensive check to find a gun farther away.
var/best_distance = world.maxx
for(var/obj/O in oview(HA.view_range, H))
var/dist = get_dist(O, H)
Expand Down Expand Up @@ -453,34 +461,33 @@ This is to account for sec Ju-Jitsuing boarding commandos.
if(E.selfcharge) //Okay good, it self charges we can just wait.
return TRUE
else //Discard it, we're not gonna teach them to use rechargers yet.
E.forceMove(get_turf(H))
H.dropItemToGround(E)
return FALSE
if(istype(gun, /obj/item/gun/ballistic))
var/obj/item/gun/ballistic/B = gun
if(istype(B.mag_type, /obj/item/ammo_box/magazine/internal))
//Not dealing with this. They'll just ditch the revolver when they're done with it.
B.forceMove(get_turf(H))
H.dropItemToGround(B)
return FALSE
///message_admins("Issa gun")
var/obj/item/storage/S = H.back
var/obj/item/storage/backpack = H.back
//Okay first off, is the gun already on our person?
var/list/expanded_contents = H.contents
if(S)
expanded_contents = S.contents + H.contents
if(backpack)
expanded_contents = backpack.contents + H.contents
var/obj/item/ammo_box/magazine/target_mag = locate(B.mag_type) in expanded_contents
//message_admins("Found [target_mag]")
if(target_mag)
//Dump that old mag
H.put_in_inactive_hand(target_mag)
B?.magazine?.forceMove(get_turf(H))
B.attackby(target_mag, H)
B.eject_magazine(H, FALSE, target_mag) //Tacticool reloads
H.dropItemToGround(H.get_inactive_held_item()) //We don't need that magazine anymore
B.attack_self(H) //Rack the bolt.
else
if(!S)
gun.forceMove(get_turf(H))
if(!backpack)
H.dropItemToGround(B)
return FALSE
gun.forceMove(S)

backpack.melee_attack_chain(src, B)
if(H.is_holding(B)) //No space in the backpack, this is useless to us so drop it
H.dropItemToGround(B)

/datum/ai_goal/human/engage_targets/action(datum/component/knpc/HA)
if(!can_action(HA))
Expand Down

0 comments on commit 9583c2e

Please sign in to comment.