Skip to content

Commit

Permalink
Merge branch 'projectiles-modular-system' into projectiles-modular-ma…
Browse files Browse the repository at this point in the history
…gnetic
  • Loading branch information
silicons committed Aug 2, 2024
2 parents 53f23ca + 7011eb0 commit 0375b1f
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 31 deletions.
2 changes: 2 additions & 0 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
#include "code\__DEFINES\projectiles\ammo_casing.dm"
#include "code\__DEFINES\projectiles\gun_components.dm"
#include "code\__DEFINES\projectiles\guns.dm"
#include "code\__DEFINES\projectiles\guns_legacy.dm"
#include "code\__DEFINES\radiation\flags.dm"
#include "code\__DEFINES\radiation\ignore.dm"
#include "code\__DEFINES\radiation\insulation.dm"
Expand Down Expand Up @@ -4296,6 +4297,7 @@
#include "code\modules\preferences\preference_setup\vore\08_traits.dm"
#include "code\modules\preferences\preference_setup\vore\09_nif.dm"
#include "code\modules\preferences\preference_setup\vore\10_misc.dm"
#include "code\modules\projectiles\gun-firing.dm"
#include "code\modules\projectiles\gun-modular.dm"
#include "code\modules\projectiles\gun.dm"
#include "code\modules\projectiles\gun_component.dm"
Expand Down
30 changes: 2 additions & 28 deletions code/__DEFINES/projectiles/guns.dm
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
///do not do anything after firing. Manual action, like pump shotguns, or guns that want to define custom behaviour
#define HOLD_CASINGS 0
///drop spent casings on the ground after firing
#define EJECT_CASINGS 2
///cycle casings, like a revolver. Also works for multibarrelled guns
#define CYCLE_CASINGS 3
//Gun loading types
///The gun only accepts ammo_casings. ammo_magazines should never have this as their mag_type.
#define SINGLE_CASING 1
///Transfers casings from the mag to the gun when used.
#define SPEEDLOADER 2
///The magazine item itself goes inside the gun
#define MAGAZINE 4
#define BULLET_IMPACT_NONE "none"
#define BULLET_IMPACT_METAL "metal"
#define BULLET_IMPACT_MEAT "meat"
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 silicons *//

#define SOUNDS_BULLET_MEAT list('sound/effects/projectile_impact/bullet_meat1.ogg', 'sound/effects/projectile_impact/bullet_meat2.ogg', 'sound/effects/projectile_impact/bullet_meat3.ogg', 'sound/effects/projectile_impact/bullet_meat4.ogg')
#define SOUNDS_BULLET_METAL list('sound/effects/projectile_impact/bullet_metal1.ogg', 'sound/effects/projectile_impact/bullet_metal2.ogg', 'sound/effects/projectile_impact/bullet_metal3.ogg')
#define SOUNDS_LASER_MEAT list('sound/effects/projectile_impact/energy_meat1.ogg','sound/effects/projectile_impact/energy_meat2.ogg')
#define SOUNDS_LASER_METAL list('sound/effects/projectile_impact/energy_metal1.ogg','sound/effects/projectile_impact/energy_metal2.ogg')

// safety states
/// no safeties are on this gun
#define GUN_NO_SAFETY -1
/// safety off
#define GUN_SAFETY_OFF 0
/// safety on
#define GUN_SAFETY_ON 1
29 changes: 29 additions & 0 deletions code/__DEFINES/projectiles/guns_legacy.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
///do not do anything after firing. Manual action, like pump shotguns, or guns that want to define custom behaviour
#define HOLD_CASINGS 0
///drop spent casings on the ground after firing
#define EJECT_CASINGS 2
///cycle casings, like a revolver. Also works for multibarrelled guns
#define CYCLE_CASINGS 3
//Gun loading types
///The gun only accepts ammo_casings. ammo_magazines should never have this as their mag_type.
#define SINGLE_CASING 1
///Transfers casings from the mag to the gun when used.
#define SPEEDLOADER 2
///The magazine item itself goes inside the gun
#define MAGAZINE 4
#define BULLET_IMPACT_NONE "none"
#define BULLET_IMPACT_METAL "metal"
#define BULLET_IMPACT_MEAT "meat"

#define SOUNDS_BULLET_MEAT list('sound/effects/projectile_impact/bullet_meat1.ogg', 'sound/effects/projectile_impact/bullet_meat2.ogg', 'sound/effects/projectile_impact/bullet_meat3.ogg', 'sound/effects/projectile_impact/bullet_meat4.ogg')
#define SOUNDS_BULLET_METAL list('sound/effects/projectile_impact/bullet_metal1.ogg', 'sound/effects/projectile_impact/bullet_metal2.ogg', 'sound/effects/projectile_impact/bullet_metal3.ogg')
#define SOUNDS_LASER_MEAT list('sound/effects/projectile_impact/energy_meat1.ogg','sound/effects/projectile_impact/energy_meat2.ogg')
#define SOUNDS_LASER_METAL list('sound/effects/projectile_impact/energy_metal1.ogg','sound/effects/projectile_impact/energy_metal2.ogg')

// safety states
/// no safeties are on this gun
#define GUN_NO_SAFETY -1
/// safety off
#define GUN_SAFETY_OFF 0
/// safety on
#define GUN_SAFETY_ON 1
9 changes: 9 additions & 0 deletions code/modules/projectiles/gun-firing.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 silicons *//

#warn impl all

/**
* called exactly once at the start of a firing cycle
*/
/obj/item/gun/proc/begin_firing_cycle(datum/event_args/actor/actor, atom/target, angle, burst_count, burst_delay, )
32 changes: 30 additions & 2 deletions code/modules/projectiles/gun-modular.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 silicons *//

/obj/item/gun
//* Modular Components - Compatibility *//

#warn impl all
/**
* hard check
*/
/obj/item/gun/proc/can_install_component(obj/item/gun_component/component, force)
SHOULD_NOT_OVERRIDE(TRUE)
#warn slot enforcement
return force || component.fits_on_gun(src, fits_modular_component(component))

/**
* checks if we can attach a component; component gets final say
*/
/obj/item/gun/proc/fits_modular_component(obj/item/gun_component/component)
return TRUE

//* Modular Components - Add / Remove *//

/**
* * moves the component into us if it wasn't already
*/
/obj/item/gun/proc/attach_modular_component(obj/item/gun_component/component, force)
#warn impl

/**
* * deletes the component if no location is provided to move it to
*/
/obj/item/gun/proc/detach_modular_component(obj/item/gun_component/component, atom/new_loc)
#warn impl

#warn hook everything in attackby's
18 changes: 17 additions & 1 deletion code/modules/projectiles/gun_component.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@
/// * The actual APIs used are agnostic of this value.
var/component_slot

/**
* returns if we should fit on a gun
*
* we get the final say
*/
/obj/item/gun_component/proc/fits_on_gun(obj/item/gun/gun, gun_opinion)
return TRUE

/**
* called on attach
*/
/obj/item/gun_component/proc/on_attach(obj/item/gun/gun)
SHOULD_CALL_PARENT(TRUE)

#warn impl all
/**
* called on detach
*/
/obj/item/gun_component/proc/on_detach(obj/item/gun/gun)
SHOULD_CALL_PARENT(TRUE)

0 comments on commit 0375b1f

Please sign in to comment.