Skip to content
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

Gun attachments #2917

Merged
merged 246 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 226 commits
Commits
Show all changes
246 commits
Select commit Hold shift + click to select a range
cd42997
clean this shit up
ZephyrTFA Aug 9, 2021
003dd66
attachment boilerplate
ZephyrTFA Aug 9, 2021
e6171aa
tick attachment stuff and alphabatize
ZephyrTFA Aug 9, 2021
dce2de0
get rid of snowflake attachments
ZephyrTFA Aug 9, 2021
0e6fcb6
Merge branch 'shiptest-ss13:master' into gunattach
ZephyrTFA Aug 9, 2021
ab61772
attachment radial
ZephyrTFA Aug 11, 2021
12cd826
fix a 'static ref warning'
ZephyrTFA Aug 11, 2021
73bea52
change overlay passing to generate on the fly
ZephyrTFA Aug 11, 2021
cc18b88
update invoke args
ZephyrTFA Aug 11, 2021
7c5f098
begone
ZephyrTFA Aug 11, 2021
b30f3bd
attachment helper subtype and tick
ZephyrTFA Aug 11, 2021
86de93a
laser sight :)
ZephyrTFA Aug 11, 2021
44da3ff
wordage? idk
ZephyrTFA Aug 11, 2021
5ddef6d
just gonna sneak this one in here
ZephyrTFA Aug 11, 2021
3c7f5cb
if they didnt pass offsets dont runtime trying to use them
ZephyrTFA Aug 11, 2021
3fff14f
uncomment this
ZephyrTFA Aug 11, 2021
78ac1cc
ugly ass fucking sprites
ZephyrTFA Aug 11, 2021
8aae9ff
update icon on detach too
ZephyrTFA Aug 11, 2021
41ec513
haha yea boy
ZephyrTFA Aug 11, 2021
b59758f
better flag handling
ZephyrTFA Aug 11, 2021
e765c5e
attack animation if any attachment handles it
ZephyrTFA Aug 11, 2021
1dd9149
stabby stabby :)
ZephyrTFA Aug 11, 2021
3f11acf
tick
ZephyrTFA Aug 11, 2021
db3a7ac
fix proc path
ZephyrTFA Aug 11, 2021
1feef8d
preattack callback
ZephyrTFA Aug 11, 2021
a890431
bayonets make a sound when you toggle them
ZephyrTFA Aug 11, 2021
3fe8540
what if we just call the melee chain directly
ZephyrTFA Aug 11, 2021
298249c
actually fix reach
ZephyrTFA Aug 11, 2021
0c7b1ae
Merge remote-tracking branch 'upstream/master' into gunattach
ZephyrTFA Aug 12, 2021
a0c6510
Merge remote-tracking branch 'upstream/master' into gunattach
ZephyrTFA Aug 15, 2021
caa6f5b
better sprites
ZephyrTFA Aug 25, 2021
d0bffcc
fix this
ZephyrTFA Aug 25, 2021
2944785
extendo and correct icon state
ZephyrTFA Aug 25, 2021
5f115bc
correct lasersight proc parameters and icon state
ZephyrTFA Aug 25, 2021
8887405
fix rail light params and icon state
ZephyrTFA Aug 25, 2021
b87fd94
remove deprecated vars
ZephyrTFA Aug 25, 2021
764826e
remove old flight vars
ZephyrTFA Aug 25, 2021
2fc75cd
this will default to zero for the time being
ZephyrTFA Aug 25, 2021
bab49d4
slots are handled as bflags
ZephyrTFA Aug 27, 2021
14253fe
update icon on any attachment change always
ZephyrTFA Aug 27, 2021
938e213
correcet attach icon states
ZephyrTFA Aug 27, 2021
f37814f
silencer into attachment
ZephyrTFA Aug 27, 2021
563019b
haha AHHA AHHAHAHA
ZephyrTFA Aug 27, 2021
1a19ae1
craft plasma bayonet
ZephyrTFA Aug 27, 2021
3656aeb
update icon state again
ZephyrTFA Aug 27, 2021
d8f698f
haha dont forget this yes
ZephyrTFA Aug 27, 2021
cd46a0b
Merge branch 'master' into gunattach
ZephyrTFA Sep 6, 2021
46e4dce
a thing
FalloutFalcon Nov 22, 2023
55d0b19
kinda workin
FalloutFalcon Nov 22, 2023
809d204
this uhh is not working. gonna rework this all
FalloutFalcon Nov 22, 2023
c4906ac
Improves deconstruction functionality to lathe
FalloutFalcon Nov 22, 2023
b1c734e
new options? half working
FalloutFalcon Nov 22, 2023
3bbba1f
might try to port some eris stuff (foolish)
FalloutFalcon Nov 23, 2023
39679d8
gun parts
FalloutFalcon Nov 23, 2023
d3155d0
"works" dont like how this is handled
FalloutFalcon Nov 25, 2023
5bbc36a
we getting there
FalloutFalcon Nov 25, 2023
db2edc3
grip dont control gun and seperate files
FalloutFalcon Nov 25, 2023
de7c2b5
shrug
FalloutFalcon Nov 25, 2023
22de36f
scrap blueprint system
FalloutFalcon Jan 19, 2024
8f28e6b
frames on gun init
FalloutFalcon Jan 20, 2024
976ae14
dynamicly generate the parts
FalloutFalcon Jan 22, 2024
04982c4
yea
FalloutFalcon Jan 24, 2024
08df15f
yea
FalloutFalcon Jan 24, 2024
8cc5bfe
aaa
FalloutFalcon Jan 24, 2024
5304d07
wow it just works!!
FalloutFalcon Jan 25, 2024
182551f
bitflags soon
FalloutFalcon Jan 25, 2024
ad28497
ye
FalloutFalcon Jan 26, 2024
8a870e0
yea
FalloutFalcon Jan 26, 2024
a5dc317
commit to recipes
FalloutFalcon Jan 31, 2024
98b5d80
yea
FalloutFalcon Jan 31, 2024
8c1b7c5
Refactor gun crafting module and add new tools
FalloutFalcon Jan 31, 2024
2959730
poorly optimized holy dang
FalloutFalcon Jan 31, 2024
93f1813
yea
FalloutFalcon Jan 31, 2024
2bf0717
evil tbh
FalloutFalcon Jan 31, 2024
f08b4bb
ye
FalloutFalcon Jan 31, 2024
4420698
kinda working i think?
FalloutFalcon Jan 31, 2024
f4c2581
unit test?
FalloutFalcon Jan 31, 2024
3a2863c
yea
FalloutFalcon Jan 31, 2024
d4762b3
hard to tell if parts are reinstalled without any
FalloutFalcon Jan 31, 2024
f80aad3
what if wrong?
FalloutFalcon Jan 31, 2024
026d860
TEST
FalloutFalcon Jan 31, 2024
7503789
bleh
FalloutFalcon Feb 1, 2024
b05cf87
no bitflags
FalloutFalcon Feb 1, 2024
2aec984
shrug
FalloutFalcon Feb 1, 2024
52e6d39
Merge branch 'guncrafting' of https://github.com/FalloutFalcon/Shipte…
FalloutFalcon Feb 2, 2024
281debc
yea
FalloutFalcon Feb 2, 2024
0eee121
yea
FalloutFalcon Feb 2, 2024
c52fb7f
wooo so much stuff..
FalloutFalcon Feb 4, 2024
3c9125d
much clearer
FalloutFalcon Feb 4, 2024
e814742
oops all camelCase
FalloutFalcon Feb 5, 2024
422ddb1
see how this goes
FalloutFalcon Feb 5, 2024
67db4f3
Merge branch 'master' into guncrafting
FalloutFalcon Feb 5, 2024
0ffb50f
ballistic
FalloutFalcon Feb 5, 2024
e54f627
cruft guns
FalloutFalcon Feb 5, 2024
30277b3
kills pins
FalloutFalcon Feb 5, 2024
48deb25
Merge branch 'master' of https://github.com/shiptest-ss13/Shiptest in…
FalloutFalcon Feb 5, 2024
8e1c8d2
Merge branch 'master' into guncrafting
FalloutFalcon Feb 5, 2024
4756438
hm
FalloutFalcon Feb 5, 2024
a049ff9
oh the paths changed alot?
FalloutFalcon Feb 5, 2024
54ec418
yea
FalloutFalcon Feb 5, 2024
f6af122
candor
FalloutFalcon Feb 5, 2024
f39fe7e
firing pins are the devil i think
FalloutFalcon Feb 6, 2024
b81b109
Merge branch 'master' into kills-magic
FalloutFalcon Feb 6, 2024
bc765fa
ok no errors?
FalloutFalcon Feb 6, 2024
6c3113d
some more
FalloutFalcon Feb 6, 2024
5981540
than k you thingrvr :thumbsup:
FalloutFalcon Feb 6, 2024
7547ca6
proper foam darts where needed
FalloutFalcon Feb 7, 2024
830f01c
Merge remote-tracking branch 'upstream/master' into kills-magic
FalloutFalcon Feb 24, 2024
ed83234
Merge remote-tracking branch 'upstream/master' into guncrafting
FalloutFalcon Feb 24, 2024
a4604f4
ya
FalloutFalcon Feb 29, 2024
08c5872
Merge branch 'master' of https://github.com/shiptest-ss13/Shiptest in…
FalloutFalcon Mar 5, 2024
e735f97
i dunno
FalloutFalcon Mar 5, 2024
f345d44
yea
FalloutFalcon Mar 9, 2024
8506478
culling to pistols and revvys and reduces gun part quanity from crate
FalloutFalcon Mar 21, 2024
9e22fae
augh
FalloutFalcon Mar 21, 2024
44e83b3
Merge remote-tracking branch 'Shiptest/master' into guncrafting
FalloutFalcon Mar 21, 2024
a466463
Merge remote-tracking branch 'Shiptest/master' into kills-magic
FalloutFalcon Apr 1, 2024
91e07f2
unit unit
FalloutFalcon Apr 2, 2024
4dd50c8
Merge remote-tracking branch 'Shiptest/master' into guncrafting
FalloutFalcon Apr 2, 2024
1fe0695
soft port of CEV-eris tool system
FalloutFalcon Apr 2, 2024
1cba2a0
stuff
FalloutFalcon Apr 2, 2024
d0f6552
yea
FalloutFalcon Apr 2, 2024
ecfdd90
pass mabye
FalloutFalcon Apr 2, 2024
ad53bb3
Merge branch 'master' into kills-magic
FalloutFalcon Apr 3, 2024
570b279
Merge branch 'guncrafting' into gun-qol
FalloutFalcon Apr 3, 2024
e7a6c2b
wow surpised it already builds
FalloutFalcon Apr 4, 2024
6564855
regenerate and Atomproc call admin tools make these pointless
FalloutFalcon Apr 4, 2024
32ad922
how did i readd this
FalloutFalcon Apr 4, 2024
d5046c5
more lol
FalloutFalcon Apr 4, 2024
1d48d3e
yea
FalloutFalcon Apr 4, 2024
c696e68
removes more magic
FalloutFalcon Apr 6, 2024
c306c51
Merge remote-tracking branch 'Upstream/master' into kills-magic
FalloutFalcon Apr 11, 2024
f220ab1
Merge branch 'master' of https://github.com/shiptest-ss13/Shiptest in…
FalloutFalcon Apr 11, 2024
5e86a57
fix
FalloutFalcon Apr 11, 2024
c346395
unrestricted no longer exists
FalloutFalcon Apr 11, 2024
68e23f2
gun defines more orginized
FalloutFalcon Apr 18, 2024
6b3e430
Merge remote-tracking branch 'Shiptest/master' into gunattach2
FalloutFalcon Apr 18, 2024
fdd4e40
a bit to fix for sure
FalloutFalcon Apr 18, 2024
30327b7
removes removed vars
FalloutFalcon Apr 18, 2024
902663d
insane
FalloutFalcon Apr 18, 2024
039813a
Merge remote-tracking branch 'Shiptest/master' into gun-qol
FalloutFalcon Apr 18, 2024
13999e2
e
FalloutFalcon Apr 18, 2024
1cbe9e6
Merge branch 'gun-qol' into gunattach2
FalloutFalcon Apr 18, 2024
1819710
Merge branch 'master' into kills-magic
FalloutFalcon Apr 18, 2024
4d6244f
Update beach_ancient_ruin.dmm
FalloutFalcon Apr 18, 2024
de2336d
nvm im dum
FalloutFalcon Apr 18, 2024
1eb41c3
Delete _maps/shuttles/syndicate/syndicate_luxembourg.dmm
FalloutFalcon Apr 18, 2024
cc24059
yea
FalloutFalcon Apr 18, 2024
36397d5
Merge branch 'kills-magic' into gun-qol
FalloutFalcon Apr 19, 2024
a4059d5
Merge branch 'master' into gun-qol
FalloutFalcon Apr 19, 2024
97df7be
Merge branch 'gun-qol' into gunattach2
FalloutFalcon Apr 19, 2024
9b8f6f9
PROC_REF stuff
FalloutFalcon Apr 19, 2024
e31f446
orgnzies vars
FalloutFalcon Apr 19, 2024
4a857b2
dumps subtype of gun vars into gun so i can combine like half of them…
FalloutFalcon Apr 19, 2024
9bac270
ALMOST every powered var was a energy var
FalloutFalcon Apr 19, 2024
fecc734
formating and combining small_gun and big_gun into mag_size
FalloutFalcon Apr 19, 2024
848ee9b
adds bool for toggling and wish for death looking at powered
FalloutFalcon Apr 19, 2024
c4b0492
right
FalloutFalcon Apr 19, 2024
d009f2d
stuff
FalloutFalcon Apr 19, 2024
552204d
hoepfully it gets garbo colllected now?
FalloutFalcon Apr 19, 2024
fa0b972
kill him
FalloutFalcon Apr 19, 2024
6fbd0f1
yea
FalloutFalcon Apr 21, 2024
e895ad1
yea
FalloutFalcon Apr 22, 2024
d589f5c
can suprres junk
FalloutFalcon Apr 23, 2024
151a4c8
attachment orginize
FalloutFalcon Apr 23, 2024
f67ca1d
stuff
FalloutFalcon Apr 23, 2024
99771ce
yea
FalloutFalcon Apr 23, 2024
02b4056
pixel offsets for attachments, very bad scope, normal bayonet
FalloutFalcon Apr 24, 2024
f73ac76
Merge branch 'master' of https://github.com/shiptest-ss13/Shiptest in…
FalloutFalcon Apr 24, 2024
2e7c8f7
cant belive those all were like that, copy paste smh
FalloutFalcon Apr 24, 2024
b6c472b
duplicate declerations
FalloutFalcon Apr 24, 2024
5936ef8
I dont think we need to do it like this
FalloutFalcon Apr 29, 2024
34a8abd
examine stuff
FalloutFalcon Apr 29, 2024
7e626c1
better examine
FalloutFalcon Apr 29, 2024
fb47493
ok im lazy im going back to how they had it instead of figuring it out
FalloutFalcon Apr 29, 2024
4a11781
cleaning up radial and overlay shiifting
FalloutFalcon Apr 29, 2024
db3c264
crates!
FalloutFalcon Apr 29, 2024
76cf650
gonna get bitfield proper working
FalloutFalcon Apr 30, 2024
2e364bb
bit
FalloutFalcon Apr 30, 2024
c55f50d
actions and bipod
FalloutFalcon Apr 30, 2024
b12c615
buttons
FalloutFalcon Apr 30, 2024
da2af2a
ough idk actions are being slighlty annoying
FalloutFalcon May 1, 2024
5ddd1a0
making progress just need to get the icon updated
FalloutFalcon May 1, 2024
42f1ac1
attachment flags
FalloutFalcon May 1, 2024
62f651c
sound and var orginization
FalloutFalcon May 1, 2024
3a448a9
these do the same thing
FalloutFalcon May 1, 2024
d1e6134
true false
FalloutFalcon May 1, 2024
0b3d1cd
dumps some attachments to a do later folder
FalloutFalcon May 1, 2024
c8eb226
bitflag yo
FalloutFalcon May 1, 2024
8377242
Merge branch 'master' into gunattach2
FalloutFalcon May 5, 2024
747c17f
bayonet examine and FALSE
FalloutFalcon May 6, 2024
659febc
stuff
FalloutFalcon May 6, 2024
93671b8
Merge branch 'master' into gunattach2
FalloutFalcon May 6, 2024
1669b24
attach vars for ballistic and energy
FalloutFalcon May 8, 2024
03db99d
Merge branch 'master' into gunattach2
FalloutFalcon May 15, 2024
584767e
?
FalloutFalcon May 15, 2024
6dc6826
this?
FalloutFalcon May 15, 2024
9181588
wrong
FalloutFalcon May 15, 2024
9e09fac
stop tests failing i think
FalloutFalcon May 15, 2024
499d5a4
Merge branch 'master' into gunattach2
FalloutFalcon May 15, 2024
95c24cd
Merge branch 'master' into gunattach2
FalloutFalcon May 17, 2024
2ca3238
better fix for the create and destroy fail
FalloutFalcon May 18, 2024
c9a6ee7
Merge branch 'master' of https://github.com/shiptest-ss13/Shiptest in…
FalloutFalcon Jun 7, 2024
5f7b945
ytea
FalloutFalcon Jun 7, 2024
992549e
dont rename that
FalloutFalcon Jun 7, 2024
0d24ffd
conflict merges where kinda a bitch
FalloutFalcon Jun 7, 2024
95de680
yea
FalloutFalcon Jun 7, 2024
586540b
removes replaced var
FalloutFalcon Jun 8, 2024
a527125
Merge branch 'master' of https://github.com/shiptest-ss13/Shiptest in…
FalloutFalcon Jun 9, 2024
08fa2f6
changes to attachment removal, moves it to alt click
FalloutFalcon Jun 9, 2024
1ac8243
small improvments to attachment code, default attachs work, better gu…
FalloutFalcon Jun 10, 2024
7cf26b5
improvments to attachment holder examine more
FalloutFalcon Jun 10, 2024
dd097fe
stocks working!
FalloutFalcon Jun 10, 2024
4879517
linters
FalloutFalcon Jun 10, 2024
e183e56
Merge branch 'master' into gunattach2
FalloutFalcon Jun 20, 2024
53c23de
oops i need that
FalloutFalcon Jun 20, 2024
b86528f
oops merge broke a var name
FalloutFalcon Jun 23, 2024
fe272e4
testing why this fails
FalloutFalcon Jun 23, 2024
96e1285
issue with button cleanup..
FalloutFalcon Jun 23, 2024
28bb45c
ough gun
FalloutFalcon Jun 23, 2024
41a3c7f
Merge branch 'master' into gunattach2
FalloutFalcon Jun 23, 2024
64aba3e
Merge branch 'master' into gunattach2
SomeguyManperson Jun 26, 2024
5a25cb1
Merge branch 'master' of https://github.com/shiptest-ss13/Shiptest in…
FalloutFalcon Jul 3, 2024
cf1bcff
removes some comments
FalloutFalcon Jul 4, 2024
ea16feb
Merge branch 'master' of https://github.com/shiptest-ss13/Shiptest in…
FalloutFalcon Jul 6, 2024
9bbf028
merge conflict fail
FalloutFalcon Jul 6, 2024
bce4c12
removes wip file
FalloutFalcon Jul 6, 2024
e290b96
Update code/modules/projectiles/gun.dm
FalloutFalcon Jul 7, 2024
6cc3196
Update code/modules/cargo/packs/gun.dm
FalloutFalcon Jul 7, 2024
ab923f3
Update code/modules/cargo/packs/gun.dm
FalloutFalcon Jul 7, 2024
af0aff1
Update code/game/objects/items/attachments/laser_sight.dm
FalloutFalcon Jul 7, 2024
d7293cb
Update code/game/objects/items/attachments/rail_light.dm
FalloutFalcon Jul 7, 2024
51d3bbf
Update code/game/objects/items/attachments/silencer.dm
FalloutFalcon Jul 7, 2024
459d814
Update code/game/objects/items/attachments/silencer.dm
FalloutFalcon Jul 7, 2024
b3db307
Update code/game/objects/items/attachments/stock.dm
FalloutFalcon Jul 7, 2024
dfd9150
Update code/game/objects/items/attachments/stock.dm
FalloutFalcon Jul 7, 2024
657438d
Update code/modules/cargo/packs/gun.dm
FalloutFalcon Jul 7, 2024
227aadb
Update code/modules/cargo/packs/gun.dm
FalloutFalcon Jul 7, 2024
b591114
Update code/modules/cargo/packs/gun.dm
FalloutFalcon Jul 7, 2024
c17adc9
Addresing some of the review
FalloutFalcon Jul 7, 2024
33c64d8
Autodoc
FalloutFalcon Jul 7, 2024
8e1005a
comments
FalloutFalcon Jul 7, 2024
47d3000
forgot to make these 3 not 2
FalloutFalcon Jul 7, 2024
53b69d1
defines for few gun things
FalloutFalcon Jul 14, 2024
b36f606
Merge branch 'master' of https://github.com/shiptest-ss13/Shiptest in…
FalloutFalcon Jul 14, 2024
1d4621a
fixes e weapons being broken
FalloutFalcon Jul 14, 2024
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: 1 addition & 1 deletion code/__DEFINES/combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ GLOBAL_LIST_INIT(shove_disarming_types, typecacheof(list(/obj/item/gun)))
#define EXPLODE_DEVASTATE 1
#define EXPLODE_HEAVY 2
#define EXPLODE_LIGHT 3
#define EXPLODE_GIB_THRESHOLD 50 //ex_act() with EXPLODE_DEVASTATE severity will gib mobs with less than this much bomb armor
#define EXPLODE_GIB_THRESHOLD 50 //ex_act() with EXPLODE_DEVASTATE severity will gib mobs with less than this much bomb armor

#define EMP_HEAVY 1
#define EMP_LIGHT 2
Expand Down
92 changes: 79 additions & 13 deletions code/__DEFINES/guns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#define TRIGGER_GUARD_NONE 0
#define TRIGGER_GUARD_NORMAL 1
//Gun bolt types
///The gun has a closed bolt, when resting it's closed, and must be racked to get a bullet from a magazine. see: Every Fucking Videogame Gun Ever
///Gun has a bolt, it stays closed while not cycling. The gun must be racked to have a bullet chambered when a mag is inserted.
/// Example: c20, shotguns, m90
#define BOLT_TYPE_STANDARD 1
///Gun has a bolt, it is open when ready to fire. The gun can never have a chambered bullet with no magazine, but the bolt stays ready when a mag is removed.
/// Example: Some SMGs, the L6
Expand All @@ -29,18 +30,6 @@
///added recoil of sawn off guns
#define SAWN_OFF_RECOIL 1

//ammo box sprite defines
///ammo box will always use provided icon state
#define AMMO_BOX_ONE_SPRITE 0
///ammo box will have a different state for each bullet; <icon_state>-<bullets left>
#define AMMO_BOX_PER_BULLET 1
///ammo box will have a different state for full and empty; <icon_state>-max_ammo and <icon_state>-0
#define AMMO_BOX_FULL_EMPTY 2

#define SUPPRESSED_NONE 0
#define SUPPRESSED_QUIET 1 ///standard suppressed
#define SUPPRESSED_VERY 2 /// no message

//Autofire component
/// Compatible firemode is in the gun. Wait until it's held in the user hands.
#define AUTOFIRE_STAT_IDLE (1<<0)
Expand All @@ -54,6 +43,10 @@
#define COMSIG_AUTOFIRE_SHOT "autofire_shot"
#define COMPONENT_AUTOFIRE_SHOT_SUCCESS (1<<0)

#define SUPPRESSED_NONE 0
#define SUPPRESSED_QUIET 1 ///standard suppressed
#define SUPPRESSED_VERY 2 /// no message

#define DUALWIELD_PENALTY_EXTRA_MULTIPLIER 1.6

#define MANUFACTURER_NONE null
Expand All @@ -72,6 +65,67 @@
#define MANUFACTURER_PGF "the Etherbor Industries emblem"
#define MANUFACTURER_IMPORT "Lanchester Import Co."

/////////////////
// ATTACHMENTS //
/////////////////
#define TRAIT_ATTACHABLE "attachable"

#define COMSIG_ATTACHMENT_ATTACH "attach-attach"
#define COMSIG_ATTACHMENT_DETACH "attach-detach"
#define COMSIG_ATTACHMENT_EXAMINE "attach-examine"
#define COMSIG_ATTACHMENT_EXAMINE_MORE "attach-examine-more"
#define COMSIG_ATTACHMENT_PRE_ATTACK "attach-pre-attack"
#define COMSIG_ATTACHMENT_ATTACK "attach-attacked"
#define COMSIG_ATTACHMENT_UPDATE_OVERLAY "attach-overlay"

#define COMSIG_ATTACHMENT_TOGGLE "attach-toggle"

#define COMSIG_ATTACHMENT_GET_SLOT "attach-slot-who"
#define ATTACHMENT_SLOT_MUZZLE "muzzle"
#define ATTACHMENT_SLOT_SCOPE "scope"
#define ATTACHMENT_SLOT_GRIP "grip"
#define ATTACHMENT_SLOT_RAIL "rail"
#define ATTACHMENT_SLOT_STOCK "stock"

/proc/attachment_slot_to_bflag(slot)
switch(slot)
if(ATTACHMENT_SLOT_MUZZLE)
return (1<<0)
if(ATTACHMENT_SLOT_SCOPE)
return (1<<1)
if(ATTACHMENT_SLOT_GRIP)
return (1<<2)
if(ATTACHMENT_SLOT_RAIL)
return (1<<3)
if(ATTACHMENT_SLOT_STOCK)
return (1<<4)

/proc/attachment_slot_from_bflag(slot)
switch(slot)
if(1<<0)
return ATTACHMENT_SLOT_MUZZLE
if(1<<1)
return ATTACHMENT_SLOT_SCOPE
if(1<<2)
return ATTACHMENT_SLOT_GRIP
if(1<<3)
return ATTACHMENT_SLOT_RAIL
if(1<<4)
return ATTACHMENT_SLOT_STOCK

#define ATTACHMENT_DEFAULT_SLOT_AVAILABLE list( \
ATTACHMENT_SLOT_MUZZLE = 1, \
ATTACHMENT_SLOT_SCOPE = 1, \
ATTACHMENT_SLOT_GRIP = 1, \
ATTACHMENT_SLOT_RAIL = 1, \
ATTACHMENT_SLOT_STOCK = 1, \
)

//attach_features_flags
#define ATTACH_REMOVABLE_HAND (1<<0)
#define ATTACH_REMOVABLE_TOOL (1<<1)
#define ATTACH_TOGGLE (1<<2)
#define ATTACH_NO_SPRITE (1<<3)

/////////////////
// PROJECTILES //
Expand All @@ -84,6 +138,18 @@

#define NICE_SHOT_RICOCHET_BONUS 10 //if the shooter has the NICE_SHOT trait and they fire a ricocheting projectile, add this to the ricochet chance and auto aim angle

//ammo box sprite defines
///ammo box will always use provided icon state
#define AMMO_BOX_ONE_SPRITE 0
///ammo box will have a different state for each bullet; <icon_state>-<bullets left>
#define AMMO_BOX_PER_BULLET 1
///ammo box will have a different state for full and empty; <icon_state>-max_ammo and <icon_state>-0
#define AMMO_BOX_FULL_EMPTY 2

#define MAG_SIZE_SMALL 1
#define MAG_SIZE_MEDIUM 2
#define MAG_SIZE_LARGE 3

//Projectile Reflect
#define REFLECT_NORMAL (1<<0)
#define REFLECT_FAKEPROJECTILE (1<<1)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
return

/atom/proc/CtrlShiftClick(mob/user)
SEND_SIGNAL(src, COMSIG_CLICK_CTRL_SHIFT)
SEND_SIGNAL(src, COMSIG_CLICK_CTRL_SHIFT, user)
return

/*
Expand Down
7 changes: 4 additions & 3 deletions code/datums/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@
if(owner)
UnregisterSignal(owner, COMSIG_PARENT_QDELETING)
owner = null
button.moved = FALSE //so the button appears in its normal position when given to another owner.
button.locked = FALSE
button.id = null
if(button)
button.moved = FALSE //so the button appears in its normal position when given to another owner.
button.locked = FALSE
button.id = null

/datum/action/proc/Trigger()
if(!IsAvailable())
Expand Down
175 changes: 175 additions & 0 deletions code/datums/components/attachment.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/datum/component/attachment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autodoc all of this please

var/slot
var/attach_features_flags
var/list/valid_parent_types
var/datum/callback/on_attach
var/datum/callback/on_detach
var/datum/callback/on_toggle
var/datum/callback/on_preattack
var/list/datum/action/actions
var/datum/action/attachment/attachment_toggle_action

/datum/component/attachment/Initialize(
slot = ATTACHMENT_SLOT_RAIL,
attach_features_flags = ATTACH_REMOVABLE_HAND,
valid_parent_types = list(/obj/item/gun),
datum/callback/on_attach = null,
datum/callback/on_detach = null,
datum/callback/on_toggle = null,
datum/callback/on_preattack = null,
list/signals = null
)

if(!isitem(parent))
return COMPONENT_INCOMPATIBLE

src.slot = slot
src.attach_features_flags = attach_features_flags
src.valid_parent_types = valid_parent_types
src.on_attach = on_attach
src.on_detach = on_detach
src.on_toggle = on_toggle
src.on_preattack = on_preattack

ADD_TRAIT(parent, TRAIT_ATTACHABLE, "attachable")
RegisterSignal(parent, COMSIG_ATTACHMENT_ATTACH, PROC_REF(try_attach))
RegisterSignal(parent, COMSIG_ATTACHMENT_DETACH, PROC_REF(try_detach))
RegisterSignal(parent, COMSIG_ATTACHMENT_EXAMINE, PROC_REF(handle_examine))
RegisterSignal(parent, COMSIG_ATTACHMENT_EXAMINE_MORE, PROC_REF(handle_examine_more))
if(attach_features_flags & ATTACH_TOGGLE)
RegisterSignal(parent, COMSIG_ATTACHMENT_TOGGLE, PROC_REF(try_toggle))
attachment_toggle_action = new /datum/action/attachment(parent)
RegisterSignal(parent, COMSIG_ATTACHMENT_PRE_ATTACK, PROC_REF(relay_pre_attack))
RegisterSignal(parent, COMSIG_ATTACHMENT_UPDATE_OVERLAY, PROC_REF(update_overlays))
RegisterSignal(parent, COMSIG_ATTACHMENT_GET_SLOT, PROC_REF(send_slot))

for(var/signal in signals)
RegisterSignal(parent, signal, signals[signal])

/datum/component/attachment/Destroy(force, silent)
REMOVE_TRAIT(parent, TRAIT_ATTACHABLE, "attachable")
if(actions && length(actions))
var/obj/item/gun/parent = src.parent
parent.actions -= actions
QDEL_LIST(actions)
qdel(attachment_toggle_action)
return ..()

/datum/component/attachment/proc/try_toggle(obj/item/parent, obj/item/holder, mob/user)
SIGNAL_HANDLER
if(attach_features_flags & ATTACH_TOGGLE)
INVOKE_ASYNC(src, PROC_REF(do_toggle), parent, holder, user)
holder.update_icon()
attachment_toggle_action.UpdateButtonIcon()


FalloutFalcon marked this conversation as resolved.
Show resolved Hide resolved
/datum/component/attachment/proc/do_toggle(obj/item/parent, obj/item/holder, mob/user)
if(on_toggle)
on_toggle.Invoke(holder, user)
return TRUE

parent.attack_self(user)
return TRUE

/datum/component/attachment/proc/update_overlays(obj/item/parent, list/overlays, list/offset)
if(!(attach_features_flags & ATTACH_NO_SPRITE))
overlays += mutable_appearance(parent.icon, "[parent.icon_state]-attached")

/datum/component/attachment/proc/try_attach(obj/item/parent, obj/item/holder, mob/user, bypass_checks)
SIGNAL_HANDLER

if(!bypass_checks)
if(!parent.Adjacent(user) || (length(valid_parent_types) && (holder.type in valid_parent_types)))
return FALSE

if(on_attach && !on_attach.Invoke(holder, user))
return FALSE

parent.forceMove(holder)

if(attach_features_flags & ATTACH_TOGGLE)
holder.actions += list(attachment_toggle_action)
attachment_toggle_action.gun = holder
attachment_toggle_action.Grant(user)

return TRUE

/datum/component/attachment/proc/try_detach(obj/item/parent, obj/item/holder, mob/user)
SIGNAL_HANDLER

if(!parent.Adjacent(user) || (valid_parent_types && (holder.type in valid_parent_types)))
return FALSE

if(on_attach && !on_detach.Invoke(holder, user))
return FALSE

if(attach_features_flags & ATTACH_TOGGLE)
holder.actions -= list(attachment_toggle_action)
attachment_toggle_action.gun = null
attachment_toggle_action.Remove(user)

if(user.can_put_in_hand(parent))
user.put_in_hand(parent)
return TRUE

parent.forceMove(holder.drop_location())
return TRUE

/datum/component/attachment/proc/handle_examine(obj/item/parent, mob/user, list/examine_list)
SIGNAL_HANDLER

/datum/component/attachment/proc/handle_examine_more(obj/item/parent, mob/user, list/examine_list)
SIGNAL_HANDLER

/datum/component/attachment/proc/relay_pre_attack(obj/item/parent, obj/item/gun, atom/target_atom, mob/user, params)
SIGNAL_HANDLER_DOES_SLEEP

if(on_preattack)
return on_preattack.Invoke(gun, target_atom, user, params)

/datum/component/attachment/proc/send_slot(obj/item/parent)
SIGNAL_HANDLER
return attachment_slot_to_bflag(slot)

/datum/action/attachment
name = "Toggle Attachment"
check_flags = AB_CHECK_HANDS_BLOCKED|AB_CHECK_CONSCIOUS
button_icon_state = null
var/obj/item/gun/gun = null
FalloutFalcon marked this conversation as resolved.
Show resolved Hide resolved

/datum/action/attachment/New(Target)
..()
name = "Toggle [target.name]"
button.name = name
icon_icon = target.icon
button_icon_state = target.icon_state

/datum/action/attachment/Destroy()
. = ..()
gun = null

/datum/action/attachment/Trigger()
..()
SEND_SIGNAL(target, COMSIG_ATTACHMENT_TOGGLE, gun, owner)

/datum/action/attachment/UpdateButtonIcon()
icon_icon = target.icon
button_icon_state = target.icon_state
..()

/datum/action/attachment/ApplyIcon(atom/movable/screen/movable/action_button/current_button, force)
if(button_icon && button_icon_state)
// If set, use the custom icon that we set instead
// of the item appearence
..()
else if((target && current_button.appearance_cache != target.appearance) || force) //replace with /ref comparison if this is not valid.
var/obj/item/I = target
var/old_layer = I.layer
var/old_plane = I.plane
I.layer = FLOAT_LAYER //AAAH
I.plane = FLOAT_PLANE //^ what that guy said
current_button.cut_overlays()
current_button.add_overlay(I)
I.layer = old_layer
I.plane = old_plane
current_button.appearance_cache = I.appearance
Loading
Loading