Skip to content

Commit

Permalink
Prop gun effect (#4450)
Browse files Browse the repository at this point in the history
# About the pull request

Adds an effect for a prop gun, where you enter the type path as its
variable and it automatically makes it look like the gun but unusable

(Codersprites should only be visible in mapping)
# Explain why it's good for the game

Makes it easier to map in destroyed or non-functional guns
# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
add: Added a mapping effect for prop guns
/:cl:
  • Loading branch information
BeagleGaming1 authored Sep 23, 2023
1 parent 9ececbe commit ba78ea1
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 7 deletions.
91 changes: 91 additions & 0 deletions code/game/objects/effects/spawners/prop_gun_spawner.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/obj/effect/spawner/prop_gun //Makes a prop that looks similar to the original gun, for use such as broken guns
name = "prop gun spawner"
icon = 'icons/landmarks.dmi'
icon_state = "prop_gun"
///The typepath of the gun the prop will copy
var/obj/item/weapon/gun/prop_gun_type = /obj/item/weapon/gun
///if the prop will have a custom name
var/custom_gun_name
///if the prob will have a custom desc
var/custom_gun_desc
///The probability of the prop gun spawning
var/spawn_prob = 100

/obj/effect/spawner/prop_gun/Initialize(mapload, ...)
. = ..()
if(!ispath(prop_gun_type, /obj/item/weapon/gun))
stack_trace("[src] using incorrect typepath, \"[prop_gun_type]\".") //Can't make a prop gun of something not a gun
qdel(src)
return
if(!spawn_prob)
qdel(src)
return
if(!mapload)
prepare_gun_skin()
return
return INITIALIZE_HINT_ROUNDSTART

/obj/effect/spawner/prop_gun/LateInitialize()
prepare_gun_skin()

///Spawns the items and modifies source to set skin on prop
/obj/effect/spawner/prop_gun/proc/prepare_gun_skin()
///The source, which the skin will be copied from
var/obj/item/weapon/gun/source_gun = new prop_gun_type(src)
if(custom_gun_name)
source_gun.name = custom_gun_name
if(custom_gun_desc)
source_gun.desc = custom_gun_desc
source_gun.pixel_x = pixel_x
source_gun.pixel_y = pixel_y
source_gun.layer = layer

///The prop itself, which the skin will be copied to
var/obj/item/prop/prop_gun/prop_gun = new /obj/item/prop/prop_gun(loc)
prop_gun.set_gun_skin(source_gun)
qdel(src)

/obj/item/prop/prop_gun
name = "prop gun"
desc = "A non-functional gun prop. You should not be able to see this."
icon = 'icons/landmarks.dmi'
icon_state = "prop_gun"
flags_item = TWOHANDED
pickup_sound = "gunequip"
drop_sound = "gunrustle"
pickupvol = 7
dropvol = 15

///Makes the gun look similar to the source, using the source as an atom reference
/obj/item/prop/prop_gun/proc/set_gun_skin(obj/item/weapon/gun/source_gun)
if(!source_gun)
return
name = source_gun.name
desc = source_gun.desc
icon = source_gun.icon
item_icons = source_gun.item_icons
icon_state = source_gun.icon_state
item_state = source_gun.item_state
w_class = source_gun.w_class
flags_equip_slot = source_gun.flags_equip_slot
pixel_x = source_gun.pixel_x
pixel_y = source_gun.pixel_y
layer = source_gun.layer

/obj/item/prop/prop_gun/attack_self(mob/user) //Mimic wielding of real guns
. = ..()
if(!(flags_item & TWOHANDED))
return
if(flags_item & WIELDED)
unwield(user)
else
wield(user)

/obj/item/prop/prop_gun/dropped(mob/user)
..()
unwield(user)

/obj/effect/spawner/prop_gun/m41aMK1
prop_gun_type = /obj/item/weapon/gun/rifle/m41aMK1
custom_gun_name = "\improper Broken M41A pulse rifle"
custom_gun_desc = "An older design of the Pulse Rifle commonly used by Colonial Marines. This one has seen better days. The trigger is missing, the barrel is bent, and it no longer appropriately feeds magazines."
3 changes: 2 additions & 1 deletion code/modules/clothing/suits/marine_armor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
siemens_coefficient = 0.7
slowdown = SLOWDOWN_ARMOR_MEDIUM
allowed = list(
/obj/item/weapon/gun/,
/obj/item/weapon/gun,
/obj/item/prop/prop_gun,
/obj/item/tank/emergency_oxygen,
/obj/item/device/flashlight,
/obj/item/storage/fancy/cigarettes,
Expand Down
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ s// DM Environment file for colonialmarines.dme.
#include "code\game\objects\effects\landmarks\structure_spawners\structure_spawner.dm"
#include "code\game\objects\effects\landmarks\structure_spawners\xvx_hive.dm"
#include "code\game\objects\effects\spawners\gibspawner.dm"
#include "code\game\objects\effects\spawners\prop_gun_spawner.dm"
#include "code\game\objects\effects\spawners\random.dm"
#include "code\game\objects\effects\spawners\spawner.dm"
#include "code\game\objects\effects\spawners\vaultspawner.dm"
Expand Down
Binary file modified icons/landmarks.dmi
Binary file not shown.
7 changes: 1 addition & 6 deletions maps/map_files/USS_Almayer/USS_Almayer.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -69822,12 +69822,7 @@
pixel_y = 2
},
/obj/structure/largecrate/random/case,
/obj/item/prop{
desc = "An older design of the Pulse Rifle commonly used by Colonial Marines. This one has seen better days. The trigger is missing, the barrel is bent, and it no longer appropriately feeds magazines.";
icon = 'icons/obj/items/weapons/guns/guns_by_faction/uscm.dmi';
icon_state = "m41amk1_e";
item_state = "m41amk1";
name = "\improper Broken M41A pulse rifle";
/obj/effect/spawner/prop_gun/m41aMK1{
pixel_y = 7
},
/obj/item/prop/helmetgarb/gunoil{
Expand Down

0 comments on commit ba78ea1

Please sign in to comment.