Skip to content

[PORT] Weapons that cannot fit into turrets also cannot fit into emitters, adds a blacklist to turrets #6551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/__DEFINES/obj_flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
#define TOY_FIREARM_OVERLAY (1<<0) // If update_overlay would add some indicator that the gun is a toy, like a plastic cap on a pistol
/// Currently used to identify valid guns to steal
#define NOT_A_REAL_GUN (1<<1)
/// This gun shouldn't be allowed to go in a turret (it probably causes a bug/exploit)
#define TURRET_INCOMPATIBLE (1<<2)
#define GUN_SMOKE_PARTICLES (1<<2)

/// Flags for sharpness in obj/item
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ DEFINE_BITFIELD(sharpness, list(
DEFINE_BITFIELD(gun_flags, list(
"NOT_A_REAL_GUN" = NOT_A_REAL_GUN,
"TOY_FIREARM_OVERLAY" = TOY_FIREARM_OVERLAY,
"TURRET_INCOMPATIBLE" = TURRET_INCOMPATIBLE,
))

DEFINE_BITFIELD(physics_flags, list(
Expand Down
79 changes: 41 additions & 38 deletions code/game/machinery/porta_turret/portable_turret_construct.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,119 +40,122 @@
if(PTURRET_START_EXTERNAL_ARMOUR)
. += span_notice("The turret's armor needs to be <b>welded</b> in place, the armor looks like it could be <i>pried</i> off.")

/obj/machinery/porta_turret_construct/attackby(obj/item/I, mob/user, params)
/obj/machinery/porta_turret_construct/attackby(obj/item/used, mob/user, params)
//this is a bit unwieldy but self-explanatory
switch(build_step)
if(PTURRET_UNSECURED) //first step
if(I.tool_behaviour == TOOL_WRENCH && !anchored)
I.play_tool_sound(src, 100)
if(used.tool_behaviour == TOOL_WRENCH && !anchored)
used.play_tool_sound(src, 100)
to_chat(user, span_notice("You secure the external bolts."))
set_anchored(TRUE)
build_step = PTURRET_BOLTED
return

else if(I.tool_behaviour == TOOL_CROWBAR && !anchored)
I.play_tool_sound(src, 75)
else if(used.tool_behaviour == TOOL_CROWBAR && !anchored)
used.play_tool_sound(src, 75)
to_chat(user, span_notice("You dismantle the turret construction."))
new /obj/item/stack/sheet/iron(loc, 5)
qdel(src)
return

if(PTURRET_BOLTED)
if(istype(I, /obj/item/stack/sheet/iron))
var/obj/item/stack/sheet/iron/M = I
if(M.use(2))
if(istype(used, /obj/item/stack/sheet/iron))
var/obj/item/stack/sheet/iron/sheet = used
if(sheet.use(2))
to_chat(user, span_notice("You add some metal armor to the interior frame."))
build_step = PTURRET_START_INTERNAL_ARMOUR
icon_state = "turret_frame2"
else
to_chat(user, span_warning("You need two sheets of iron to continue construction!"))
return

else if(I.tool_behaviour == TOOL_WRENCH)
I.play_tool_sound(src, 75)
else if(used.tool_behaviour == TOOL_WRENCH)
used.play_tool_sound(src, 75)
to_chat(user, span_notice("You unfasten the external bolts."))
set_anchored(FALSE)
build_step = PTURRET_UNSECURED
return


if(PTURRET_START_INTERNAL_ARMOUR)
if(I.tool_behaviour == TOOL_WRENCH)
I.play_tool_sound(src, 100)
if(used.tool_behaviour == TOOL_WRENCH)
used.play_tool_sound(src, 100)
to_chat(user, span_notice("You bolt the metal armor into place."))
build_step = PTURRET_INTERNAL_ARMOUR_ON
return

else if(I.tool_behaviour == TOOL_WELDER)
if(!I.tool_start_check(user, amount = 5)) //uses up 5 fuel
else if(used.tool_behaviour == TOOL_WELDER)
if(!used.tool_start_check(user, amount = 5)) //uses up 5 fuel
return

to_chat(user, span_notice("You start to remove the turret's interior metal armor..."))

if(I.use_tool(src, user, 20, volume = 50, amount = 5)) //uses up 5 fuel
if(used.use_tool(src, user, 20, volume = 50, amount = 5)) //uses up 5 fuel
build_step = PTURRET_BOLTED
to_chat(user, span_notice("You remove the turret's interior metal armor."))
new /obj/item/stack/sheet/iron(drop_location(), 2)
return


if(PTURRET_INTERNAL_ARMOUR_ON)
if(istype(I, /obj/item/gun/energy)) //the gun installation part
var/obj/item/gun/energy/E = I
if(!user.transferItemToLoc(E, src))
if(istype(used, /obj/item/gun/energy)) //the gun installation part
var/obj/item/gun/energy/egun = used
if(egun.gun_flags & TURRET_INCOMPATIBLE)
to_chat(user, span_notice("You don't think it would be right to add [used] to the turret"))
return
installed_gun = E
to_chat(user, span_notice("You add [I] to the turret."))
if(!user.transferItemToLoc(egun, src))
return
installed_gun = egun
to_chat(user, span_notice("You add [used] to the turret."))
build_step = PTURRET_GUN_EQUIPPED
return
else if(I.tool_behaviour == TOOL_WRENCH)
I.play_tool_sound(src, 100)
else if(used.tool_behaviour == TOOL_WRENCH)
used.play_tool_sound(src, 100)
to_chat(user, span_notice("You remove the turret's metal armor bolts."))
build_step = PTURRET_START_INTERNAL_ARMOUR
return

if(PTURRET_GUN_EQUIPPED)
if(isprox(I))
if(isprox(used))
build_step = PTURRET_SENSORS_ON
if(!user.temporarilyRemoveItemFromInventory(I))
if(!user.temporarilyRemoveItemFromInventory(used))
return
to_chat(user, span_notice("You add the proximity sensor to the turret."))
qdel(I)
qdel(used)
return


if(PTURRET_SENSORS_ON)
if(I.tool_behaviour == TOOL_SCREWDRIVER)
I.play_tool_sound(src, 100)
if(used.tool_behaviour == TOOL_SCREWDRIVER)
used.play_tool_sound(src, 100)
build_step = PTURRET_CLOSED
to_chat(user, span_notice("You close the internal access hatch."))
return


if(PTURRET_CLOSED)
if(istype(I, /obj/item/stack/sheet/iron))
var/obj/item/stack/sheet/iron/M = I
if(M.use(2))
if(istype(used, /obj/item/stack/sheet/iron))
var/obj/item/stack/sheet/iron/sheet = used
if(sheet.use(2))
to_chat(user, span_notice("You add some metal armor to the exterior frame."))
build_step = PTURRET_START_EXTERNAL_ARMOUR
else
to_chat(user, span_warning("You need two sheets of iron to continue construction!"))
return

else if(I.tool_behaviour == TOOL_SCREWDRIVER)
I.play_tool_sound(src, 100)
else if(used.tool_behaviour == TOOL_SCREWDRIVER)
used.play_tool_sound(src, 100)
build_step = PTURRET_SENSORS_ON
to_chat(user, span_notice("You open the internal access hatch."))
return

if(PTURRET_START_EXTERNAL_ARMOUR)
if(I.tool_behaviour == TOOL_WELDER)
if(!I.tool_start_check(user, amount = 5))
if(used.tool_behaviour == TOOL_WELDER)
if(!used.tool_start_check(user, amount = 5))
return

to_chat(user, span_notice("You begin to weld the turret's armor down..."))
if(I.use_tool(src, user, 30, volume = 50, amount = 5))
if(used.use_tool(src, user, 30, volume = 50, amount = 5))
build_step = PTURRET_EXTERNAL_ARMOUR_ON
to_chat(user, span_notice("You weld the turret's armor down."))

Expand All @@ -171,14 +174,14 @@
qdel(src)
return

else if(I.tool_behaviour == TOOL_CROWBAR)
I.play_tool_sound(src, 75)
else if(used.tool_behaviour == TOOL_CROWBAR)
used.play_tool_sound(src, 75)
to_chat(user, span_notice("You pry off the turret's exterior armor."))
new /obj/item/stack/sheet/iron(loc, 2)
build_step = PTURRET_CLOSED
return

if(istype(I, /obj/item/pen)) //you can rename turrets like bots!
if(istype(used, /obj/item/pen)) //you can rename turrets like bots!
var/choice = tgui_input_text(user, "Enter a new turret name", "Turret Classification", finish_name, MAX_NAME_LEN)
if(!choice)
return
Expand Down
9 changes: 6 additions & 3 deletions code/modules/power/singularity/emitter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,15 @@
/obj/machinery/power/emitter/AltClick(mob/user)
return ..() // This hotkey is BLACKLISTED since it's used by /datum/component/simple_rotation

/obj/machinery/power/emitter/proc/integrate(obj/item/gun/energy/energy_gun, mob/user)
if(!istype(energy_gun, /obj/item/gun/energy))
/obj/machinery/power/emitter/proc/integrate(obj/item/gun/energy/, mob/user)
if(!istype(, /obj/item/gun/energy))
return
if(!user.transferItemToLoc(energy_gun, src))
if(!user.transferItemToLoc(, src))
return
if(energy_gun.gun_flags & TURRET_INCOMPATIBLE)

Check failure on line 370 in code/modules/power/singularity/emitter.dm

View workflow job for this annotation

GitHub Actions / Run Linters

OD0404: Unknown identifier "gun_flags"

Check warning on line 370 in code/modules/power/singularity/emitter.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "gun_flags"

Check failure on line 370 in code/modules/power/singularity/emitter.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "energy_gun"
user.balloon_alert(user, "[energy_gun] won't fit!")

Check failure on line 371 in code/modules/power/singularity/emitter.dm

View workflow job for this annotation

GitHub Actions / Run Linters

OD0404: Unknown identifier "energy_gun"

Check failure on line 371 in code/modules/power/singularity/emitter.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "energy_gun"
return
gun = energy_gun

Check failure on line 373 in code/modules/power/singularity/emitter.dm

View workflow job for this annotation

GitHub Actions / Run Linters

OD0404: Unknown identifier "energy_gun"

Check failure on line 373 in code/modules/power/singularity/emitter.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "energy_gun"
gun_properties = gun.get_turret_properties()
set_projectile()
return TRUE
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/guns/energy/dueling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
w_class = WEIGHT_CLASS_SMALL
ammo_type = list(/obj/item/ammo_casing/energy/duel)
automatic_charge_overlays = FALSE
gun_flags = TURRET_INCOMPATIBLE
var/unlocked = FALSE
var/setting = DUEL_SETTING_A
var/datum/duel/duel
Expand Down
Loading