mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
@@ -375,11 +375,10 @@
|
||||
lethal_shot_sound = 'sound/weapons/eluger.ogg'
|
||||
shot_sound = 'sound/weapons/Taser.ogg'
|
||||
|
||||
/obj/machinery/porta_turret/proc/HasController()
|
||||
var/area/A = get_area(src)
|
||||
return A && A.turret_controls.len > 0
|
||||
|
||||
/obj/machinery/porta_turret/proc/isLocked(mob/user)
|
||||
if(locked && !issilicon(user))
|
||||
to_chat(user, "<span class='notice'>Controls locked.</span>")
|
||||
return TRUE // CHOMPEdit
|
||||
if(HasController())
|
||||
return TRUE
|
||||
if(isrobot(user) || isAI(user))
|
||||
@@ -407,6 +406,10 @@
|
||||
/obj/machinery/porta_turret/attack_hand(mob/user)
|
||||
tgui_interact(user)
|
||||
|
||||
/obj/machinery/porta_turret/proc/HasController()
|
||||
var/area/A = get_area(src)
|
||||
return A && A.turret_controls.len > 0
|
||||
|
||||
/obj/machinery/porta_turret/tgui_interact(mob/user, datum/tgui/ui = null)
|
||||
if(HasController())
|
||||
to_chat(user, "<span class='notice'>[src] can only be controlled using the assigned turret controller.</span>")
|
||||
@@ -672,40 +675,43 @@
|
||||
var/list/targets = list() //list of primary targets
|
||||
var/list/secondarytargets = list() //targets that are least important
|
||||
|
||||
/* CHOMPEdit Start
|
||||
var/list/seenturfs = list()
|
||||
for(var/turf/T in oview(world.view, src))
|
||||
seenturfs += T
|
||||
|
||||
for(var/mob/M as anything in living_mob_list)
|
||||
if(M.z != z) //Skip
|
||||
if(M.z != z || !(get_turf(M) in seenturfs)) // Skip
|
||||
continue
|
||||
if(get_turf(M) in seenturfs)
|
||||
assess_and_assign(M, targets, secondarytargets)
|
||||
This was dumb.*/
|
||||
assess_and_assign_l(M, targets, secondarytargets) //CHOMPEdit
|
||||
|
||||
for(var/mob/M in oview(world.view, src))
|
||||
assess_and_assign(M, targets, secondarytargets)
|
||||
//CHOMPEdit End
|
||||
for(var/obj/mecha/M as anything in mechas_list)
|
||||
if(M.z != z || !(get_turf(M) in seenturfs)) // Skip
|
||||
continue
|
||||
assess_and_assign_m(M, targets, secondarytargets) //CHOMPEdit
|
||||
|
||||
if(!tryToShootAt(targets))
|
||||
if(!tryToShootAt(secondarytargets)) // if no valid targets, go for secondary targets
|
||||
timeout--
|
||||
if(timeout <= 0)
|
||||
spawn()
|
||||
popDown() // no valid targets, close the cover
|
||||
if(!tryToShootAt(targets) && !tryToShootAt(secondarytargets) && --timeout <= 0)
|
||||
popDown() // no valid targets, close the cover
|
||||
|
||||
if(auto_repair && (health < maxhealth))
|
||||
use_power(20000)
|
||||
health = min(health+1, maxhealth) // 1HP for 20kJ
|
||||
|
||||
/obj/machinery/porta_turret/proc/assess_and_assign(var/mob/living/L, var/list/targets, var/list/secondarytargets)
|
||||
//CHOMPAdd Start
|
||||
/obj/machinery/porta_turret/proc/assess_and_assign_l(var/mob/living/L, var/list/targets, var/list/secondarytargets)
|
||||
switch(assess_living(L))
|
||||
if(TURRET_PRIORITY_TARGET)
|
||||
targets += L
|
||||
if(TURRET_SECONDARY_TARGET)
|
||||
secondarytargets += L
|
||||
|
||||
/obj/machinery/porta_turret/proc/assess_and_assign_m(var/obj/mecha/M, var/list/targets, var/list/secondarytargets)
|
||||
switch(assess_mecha(M))
|
||||
if(TURRET_PRIORITY_TARGET)
|
||||
targets += M
|
||||
if(TURRET_SECONDARY_TARGET)
|
||||
secondarytargets += M
|
||||
//CHOMPAdd End
|
||||
|
||||
/obj/machinery/porta_turret/proc/assess_living(var/mob/living/L)
|
||||
if(!istype(L))
|
||||
return TURRET_NOT_TARGET
|
||||
@@ -713,9 +719,6 @@
|
||||
if(L.invisibility >= INVISIBILITY_LEVEL_ONE) // Cannot see him. see_invisible is a mob-var
|
||||
return TURRET_NOT_TARGET
|
||||
|
||||
if(!L)
|
||||
return TURRET_NOT_TARGET
|
||||
|
||||
if(faction && L.faction == faction)
|
||||
return TURRET_NOT_TARGET
|
||||
|
||||
@@ -757,6 +760,15 @@
|
||||
|
||||
return TURRET_PRIORITY_TARGET //if the perp has passed all previous tests, congrats, it is now a "shoot-me!" nominee
|
||||
|
||||
/obj/machinery/porta_turret/proc/assess_mecha(var/obj/mecha/M)
|
||||
if(!istype(M))
|
||||
return TURRET_NOT_TARGET
|
||||
|
||||
if(!M.occupant)
|
||||
return check_all ? TURRET_SECONDARY_TARGET : TURRET_NOT_TARGET
|
||||
|
||||
return assess_living(M.occupant)
|
||||
|
||||
/obj/machinery/porta_turret/proc/assess_perp(var/mob/living/carbon/human/H)
|
||||
if(!H || !istype(H))
|
||||
return 0
|
||||
@@ -778,6 +790,7 @@
|
||||
|
||||
|
||||
/obj/machinery/porta_turret/proc/popUp() //pops the turret up
|
||||
set waitfor = FALSE
|
||||
if(disabled)
|
||||
return
|
||||
if(raising || raised)
|
||||
@@ -799,6 +812,7 @@
|
||||
timeout = 10
|
||||
|
||||
/obj/machinery/porta_turret/proc/popDown() //pops the turret down
|
||||
set waitfor = FALSE
|
||||
last_target = null
|
||||
if(disabled)
|
||||
return
|
||||
@@ -827,18 +841,17 @@
|
||||
|
||||
/obj/machinery/porta_turret/proc/target(var/mob/living/target)
|
||||
if(disabled)
|
||||
return
|
||||
return FALSE
|
||||
if(target)
|
||||
if(target in check_trajectory(target, src)) //Finally, check if we can actually hit the target
|
||||
last_target = target
|
||||
spawn()
|
||||
popUp() //pop the turret up if it's not already up.
|
||||
popUp() //pop the turret up if it's not already up.
|
||||
set_dir(get_dir(src, target)) //even if you can't shoot, follow the target
|
||||
playsound(src, 'sound/machines/turrets/turret_rotate.ogg', 100, 1) // Play rotating sound
|
||||
spawn()
|
||||
shootAt(target)
|
||||
return 1
|
||||
return
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/machinery/porta_turret/proc/shootAt(var/mob/living/target)
|
||||
//any emagged turrets will shoot extremely fast! This not only is deadly, but drains a lot power!
|
||||
@@ -850,9 +863,7 @@
|
||||
sleep(shot_delay)
|
||||
last_fired = FALSE
|
||||
|
||||
var/turf/T = get_turf(src)
|
||||
var/turf/U = get_turf(target)
|
||||
if(!istype(T) || !istype(U))
|
||||
if(!isturf(get_turf(src)) || !isturf(get_turf(target)))
|
||||
return
|
||||
|
||||
if(!raised) //the turret has to be raised in order to fire - makes sense, right?
|
||||
@@ -867,9 +878,12 @@
|
||||
A = new projectile(loc)
|
||||
playsound(src, shot_sound, 75, 1)
|
||||
|
||||
// Lethal/emagged turrets use twice the power due to higher energy beams
|
||||
// Emagged turrets again use twice as much power due to higher firing rates
|
||||
use_power(reqpower * (2 * (emagged || lethal)) * (2 * emagged))
|
||||
var/power_mult = 1
|
||||
if(emagged)
|
||||
power_mult = 4 // Lethal beams + higher rate of fire
|
||||
else if(lethal)
|
||||
power_mult = 2 // Lethal beams
|
||||
use_power(reqpower * power_mult)
|
||||
|
||||
//Turrets aim for the center of mass by default.
|
||||
//If the target is grabbing someone then the turret smartly aims for extremities
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
set desc = "Create a resource tower which will generate resources for you."
|
||||
|
||||
if(!blob_type.can_build_resources)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
createSpecial(40, blob_type.resource_type, 4, 1)
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
set desc = "Automatically places a resource tower near a node or your core, at a sufficent distance."
|
||||
|
||||
if(!blob_type.can_build_resources)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
var/obj/structure/blob/B = null
|
||||
var/list/potential_blobs = GLOB.all_blobs.Copy()
|
||||
@@ -99,7 +99,7 @@
|
||||
set desc = "Create a spore tower that will spawn spores to harass your enemies."
|
||||
|
||||
if(!blob_type.can_build_factories)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
createSpecial(60, blob_type.factory_type, 7, 1)
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
set desc = "Automatically places a resource tower near a node or your core, at a sufficent distance."
|
||||
|
||||
if(!blob_type.can_build_factories)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
var/obj/structure/blob/B = null
|
||||
var/list/potential_blobs = GLOB.all_blobs.Copy()
|
||||
@@ -143,7 +143,7 @@
|
||||
set desc = "Create a node, which will expand blobs around it, and power nearby factory and resource blobs."
|
||||
|
||||
if(!blob_type.can_build_nodes)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
createSpecial(100, blob_type.node_type, 5, 0)
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
set desc = "Automatically places a node blob at a sufficent distance."
|
||||
|
||||
if(!blob_type.can_build_nodes)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
var/obj/structure/blob/B = null
|
||||
var/list/potential_blobs = GLOB.all_blobs.Copy()
|
||||
@@ -216,23 +216,31 @@
|
||||
for(var/mob/living/L in view(src))
|
||||
if(L.stat == DEAD)
|
||||
continue // Already dying or dead.
|
||||
if(L.faction == blob_type.faction)
|
||||
continue // No friendly fire.
|
||||
if(locate(/obj/structure/blob) in L.loc)
|
||||
continue // Already has a blob over them.
|
||||
if(can_attack(L))
|
||||
potential_targets += L
|
||||
|
||||
var/obj/structure/blob/B = null
|
||||
for(var/direction in cardinal)
|
||||
var/turf/T = get_step(L, direction)
|
||||
B = locate(/obj/structure/blob) in T
|
||||
if(B && B.overmind == src)
|
||||
break
|
||||
if(!B)
|
||||
continue
|
||||
|
||||
potential_targets += L
|
||||
for(var/obj/mecha/M in view(src))
|
||||
if(!M.occupant)
|
||||
continue // Just a hunk of metal
|
||||
if(can_attack(M.occupant))
|
||||
potential_targets += M
|
||||
|
||||
if(potential_targets.len)
|
||||
var/mob/living/victim = pick(potential_targets)
|
||||
var/turf/T = get_turf(victim)
|
||||
expand_blob(T)
|
||||
|
||||
/mob/observer/blob/proc/can_attack(var/mob/living/L)
|
||||
if(!istype(L))
|
||||
return FALSE
|
||||
if(L.faction == blob_type.faction)
|
||||
return FALSE // No friendly fire.
|
||||
if(locate(/obj/structure/blob) in get_turf(L))
|
||||
return FALSE // Already has a blob over them.
|
||||
|
||||
for(var/direction in cardinal)
|
||||
var/turf/T = get_step(L, direction)
|
||||
var/obj/structure/blob/B = locate(/obj/structure/blob) in T
|
||||
if(B && B.overmind == src)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
@@ -32,7 +32,10 @@
|
||||
var/list/secondarytargets = list() //targets that are least important
|
||||
|
||||
for(var/mob/M in oview(world.view, src))
|
||||
assess_and_assign(M, targets, secondarytargets)
|
||||
assess_and_assign_l(M, targets, secondarytargets)
|
||||
|
||||
for(var/obj/mecha/M in oview(world.view, src))
|
||||
assess_and_assign_m(M, targets, secondarytargets)
|
||||
|
||||
if(!tryToShootAt(targets))
|
||||
if(!tryToShootAt(secondarytargets)) // if no valid targets, go for secondary targets
|
||||
@@ -64,4 +67,4 @@
|
||||
|
||||
/obj/machinery/porta_turret/rcd/die()
|
||||
spark_system.start()
|
||||
qdel(src)
|
||||
qdel(src)
|
||||
|
||||
Reference in New Issue
Block a user