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