Skip to content

Commit 7e8cd3f

Browse files
siliconsZandario
andauthored
refactors combat backend & adds kinetic gauntlets (#7144)
Co-authored-by: Zandario <zandarioh@gmail.com>
1 parent 11506dd commit 7e8cd3f

File tree

388 files changed

+6505
-5267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

388 files changed

+6505
-5267
lines changed

2025-03-15 10

Whitespace-only changes.

citadel.dme

Lines changed: 73 additions & 30 deletions
Large diffs are not rendered by default.

code/__DEFINES/_cooldowns.dm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@
9696
// admin verb cooldowns
9797
#define CD_INTERNET_SOUND "internet_sound"
9898

99-
//? Mobs ?//
99+
//* /mob *//
100+
#define TIMER_CD_INDEX_MOB_VERB_INVERT_SELF "mob-verb-invert_self"
100101

101-
#define CD_INDEX_MOB_VERB_INVERT_SELF "mob-verb-invert-self"
102+
//* /client *//
103+
#define TIMER_CD_INDEX_CLIENT_CHARACTER_DIRECTORY "client-verb-character_directory"

code/__DEFINES/_flags/item_flags.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ DEFINE_BITFIELD(inv_hide_flags, list(
140140
//* These should be used any time you need to store coverage or parts *//
141141
//* of a standard humanoid body. *//
142142

143+
// todo: is there any way at all to rename these to not be one word defines?
144+
// literally anything like BODY_COVER_* or BP_MASK_* would help
145+
143146
#define HEAD (1<<0)
144147
#define FACE (1<<1)
145148
#define EYES (1<<2)

code/__DEFINES/_flags/obj_flags.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/// wall-mounted; facing *towards* the wall we're mounted on (e.g. be NORTH if we're shifted north)
2525
#define OBJ_WALL_MOUNTED (1<<11)
2626
/// Allow throwing stuff through us if we get destroyed by a throw
27-
#define OBJ_ALLOW_THROW_THROUGH (1<<3)
27+
#define OBJ_ALLOW_THROW_THROUGH (1<<23)
2828

2929
DEFINE_BITFIELD(obj_flags, list(
3030
BITFIELD(OBJ_EMAGGED),

code/__DEFINES/combat/armor.dm

Lines changed: 112 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,39 @@
3131
//? If > 0, decreases damage linearly with 1 being 0x damage.
3232
//? If < 0, increases damage linearly with -1 being 2x damage, -2 being 3x damage.
3333

34+
/**
35+
* The ability of an armor to absorb exotic energy.
36+
*/
3437
#define ARMOR_ENERGY "energy"
38+
/**
39+
* The ability of an armor to block a shockwave from an explosion.
40+
*/
3541
#define ARMOR_BOMB "bomb"
42+
/**
43+
* The ability of an armor to block microscale particles from entering.
44+
*/
3645
#define ARMOR_BIO "bio"
46+
/**
47+
* The ability of an armor to block radiation.
48+
*/
3749
#define ARMOR_RAD "rad"
50+
/**
51+
* The ability of an armor to resist surface combustion.
52+
*/
3853
#define ARMOR_FIRE "fire"
54+
/**
55+
* The ability of an armor to resist acidic or corrosive substances from leaking through.
56+
*/
3957
#define ARMOR_ACID "acid"
4058

59+
/**
60+
* Global randomization ratio for all armor checks.
61+
* * 0.25 will make all armor randomly
62+
*
63+
* TODO: impl
64+
*/
65+
// #define ARMOR_CONF_RAND "conf-rand"
66+
4167
/**
4268
* All armor enums that can be stored in an armor datum
4369
*/
@@ -77,72 +103,91 @@ GLOBAL_REAL_LIST(armor_types) = list(
77103
ARMOR_ACID,
78104
)
79105

80-
//? --- armor tiers ---
81-
82-
#define ARMOR_TIER_DEFAULT ARMOR_TIER_BASELINE
83-
84-
#define ARMOR_TIER_LAUGHABLE -3
85-
#define ARMOR_TIER_LOW -2
86-
#define ARMOR_TIER_BELOW -1
87-
#define ARMOR_TIER_BASELINE 0
88-
#define ARMOR_TIER_ABOVE 1
89-
#define ARMOR_TIER_HIGH 2
90-
#define ARMOR_TIER_OVERWHELMING 3
91-
#define ARMOR_TIER_RIDICULOUS 4
92-
93-
#define ARMOR_BARELY_BEATS(other) (other + 0.001)
94-
95-
//? melee
96-
97-
#define MELEE_TIER_DEFAULT MELEE_TIER_MEDIUM
98-
99-
#define MELEE_TIER_UNARMED_DEFAULT ARMOR_TIER_LOW
100-
#define MELEE_TIER_UNARMED_FISTS ARMOR_TIER_LOW
101-
#define MELEE_TIER_UNARMED_CLAW ARMOR_TIER_BELOW
102-
#define MELEE_TIER_LIGHT ARMOR_TIER_BASELINE
103-
#define MELEE_TIER_MEDIUM ARMOR_TIER_ABOVE
104-
#define MELEE_TIER_HEAVY ARMOR_TIER_HIGH
105-
#define MELEE_TIER_EXTREME ARMOR_TIER_OVERWHELMING
106-
107-
//? bullet
108-
109-
#define BULLET_TIER_DEFAULT BULLET_TIER_MEDIUM
110-
111-
/// super improvised rounds / pistols / whatever.
112-
#define BULLET_TIER_LAUGHABLE ARMOR_TIER_BELOW
113-
/// pistols
114-
#define BULLET_TIER_LOW ARMOR_TIER_BASELINE
115-
/// smgs
116-
#define BULLET_TIER_MEDIUM ARMOR_TIER_ABOVE
117-
/// rifles
118-
#define BULLET_TIER_HIGH ARMOR_TIER_HIGH
119-
/// hmgs, light mech weapons
120-
#define BULLET_TIER_EXTREME ARMOR_TIER_OVERWHELMING
121-
/// heavy mech weapons
122-
#define BULLET_TIER_RIDICULOUS ARMOR_TIER_RIDICULOUS
123-
124-
//? laser
125-
126-
#define LASER_TIER_DEFAULT LASER_TIER_MEDIUM
127-
128-
/// improvised laser focis / etc
129-
#define LASER_TIER_LAUGHABLE ARMOR_TIER_BELOW
130-
/// low tier lasers
131-
#define LASER_TIER_LOW ARMOR_TIER_BASELINE
132-
/// laser carbines, energy guns, etc
133-
#define LASER_TIER_MEDIUM ARMOR_TIER_ABOVE
134-
/// x-ray rifles, snipers
135-
#define LASER_TIER_HIGH ARMOR_TIER_HIGH
136-
/// mech weapons, usualy
137-
#define LASER_TIER_EXTREME ARMOR_TIER_OVERWHELMING
138-
/// power transmission laser?
139-
#define LASER_TIER_RIDICULOUS ARMOR_TIER_RIDICULOUS
140-
141-
//? --- armor calculations ---
106+
//? --- armor tiers ---
107+
//? These are defined values so if we want to scale them nonlinearly/whatever later,
108+
//? we don't need to replace everything.
142109

143110
/// tierdiff is tier difference of armor against attack; positive = armor is higher tier.
144-
#define ARMOR_TIER_CALC(_armor, _tierdiff) \
145-
(_armor > 0? \
146-
((_tierdiff) > 0? ((_armor) ** (1 / (1 + (_tierdiff)))) : ((_armor) * (1 / (1 - (_tierdiff))))) : \
147-
(_armor) \
148-
)
111+
/// * see https://www.desmos.com/calculator/6uu1djsawl
112+
/// * armor at or below 0 (added damage) are passed back without change
113+
/proc/ARMOR_TIER_CALC(armor, tierdiff)
114+
if(armor <= 0)
115+
return 0
116+
if(!tierdiff)
117+
return armor
118+
if(tierdiff > 0)
119+
var/a = armor * (tierdiff + 1)
120+
return max(a / sqrt(2 + a ** 2), armor)
121+
else
122+
return armor / (1 + (((-tierdiff) ** 17.5) / 1.75))
123+
124+
#define ARMOR_TIER_FLOOR 0
125+
#define ARMOR_TIER_DEFAULT 3
126+
127+
/proc/ARMOR_TIER_BLUNT_CHANCE(tierdiff)
128+
switch(tierdiff)
129+
if(-INFINITY to -2)
130+
return 0
131+
if(-2 to -1)
132+
return 15
133+
if(-1 to -0.5)
134+
return 22.5
135+
if(-0.5 to -0.3)
136+
return 30
137+
if(-0.3 to 0)
138+
return 45.5
139+
if(0 to 0.3)
140+
return 57.5
141+
if(0.3 to 0.6)
142+
return 70
143+
if(0.6 to 1)
144+
return 85
145+
if(1 to 2)
146+
return 90
147+
else
148+
return 99 // tf2 critsound.ogg
149+
150+
//? -- armor tiers - melee --
151+
152+
/**
153+
* 0: toys
154+
* 1: very light weapons
155+
* 2: light weapons
156+
* 3: toolboxes, batons, knives, your usual
157+
* 4: heavy swords, sledgehammers, mech punches, etc
158+
* 5: armor piercing / specialized weapons / eswords / etc
159+
* 6: idk you got crushed by a titanium rod or something
160+
* 7: hydraulic press?
161+
*/
162+
163+
#define MELEE_TIER_DEFAULT 3
164+
165+
//? -- armor tiers - bullet --
166+
167+
/**
168+
* 0: toys / nerf guns
169+
* 1: slingshots, bb guns, etc
170+
* 2: crappy improvised real rounds
171+
* 3: most pistols and basic-er weapons are here
172+
* 4: rifles
173+
* 5: heavy rifles
174+
* 6: antimaterial rifles
175+
* 7: idk you got hit by a tank round
176+
*/
177+
178+
#define BULLET_TIER_DEFAULT 3
179+
180+
//? -- armor tiers - laser --
181+
182+
/**
183+
* 0: i don't know why there are toys for this but i guess toy guns that do damage? sunburn?
184+
* 1: improvised crappy laser diodes or smth
185+
* 2: relatively unfocused weapons, low grade, etc
186+
* 3: most laser weapons are here
187+
* 4: heavier laser rifles
188+
* 5: x-ray lasers, light mech / mounted weapons
189+
* 6: heavier mech weapons, pulse weapons
190+
* 7: you got hit by engineering's power transmission laser
191+
*/
192+
193+
#define LASER_TIER_DEFAULT 3
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
//? attack_type bitfield - bitfield for check, but pass only one in at a time.
22

33
#define ATTACK_TYPE_NONE (0)
4-
/// damage source is /obj/item
4+
/// damage source is /datum/event_args/actor/clickchain
55
#define ATTACK_TYPE_MELEE (1<<0)
66
/// damage source is /obj/projectile
77
#define ATTACK_TYPE_PROJECTILE (1<<1)
88
/// damage source is /datum/thrownthing
99
#define ATTACK_TYPE_THROWN (1<<2)
10-
/// damage source is /mob
11-
#define ATTACK_TYPE_UNARMED (1<<3)
12-
/// we're being contacted by something
13-
///
14-
/// * used internally by parry frames, mostly
15-
/// * damage source is null
10+
/// damage source is /datum/event_args/actor/clickchain
1611
#define ATTACK_TYPE_TOUCH (1<<4)
1712
/// a damage instance created by a block / parry frame transmuting damage and passing it to the user
1813
#define ATTACK_TYPE_DEFENSIVE_PASSTHROUGH (1<<5)

code/__DEFINES/combat/body_zones.dm

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* * Groin is redirected to torso
3232
* * Eyes, mouth, are redirected to head
3333
*/
34-
/proc/SIMPLIFY_BODY_ZONE(zone)
35-
var/static/list/lookup = list(
34+
/proc/BODY_ZONE_TO_SIMPLIFIED(zone)
35+
var/static/alist/lookup = alist(
3636
BODY_ZONE_GROIN = BODY_ZONE_TORSO,
3737
BODY_ZONE_L_HAND = BODY_ZONE_L_ARM,
3838
BODY_ZONE_R_HAND = BODY_ZONE_R_ARM,
@@ -42,3 +42,24 @@
4242
BODY_ZONE_EYES = BODY_ZONE_HEAD,
4343
)
4444
return lookup[zone] || zone
45+
46+
/**
47+
* body zone to body cover flags
48+
*/
49+
/proc/BODY_ZONE_TO_FLAGS(zone)
50+
var/static/alist/lookup = alist(
51+
BODY_ZONE_HEAD = HEAD,
52+
BODY_ZONE_MOUTH = FACE,
53+
BODY_ZONE_EYES = EYES,
54+
BODY_ZONE_TORSO = UPPER_TORSO,
55+
BODY_ZONE_GROIN = LOWER_TORSO,
56+
BODY_ZONE_L_ARM = ARM_LEFT,
57+
BODY_ZONE_R_ARM = ARM_RIGHT,
58+
BODY_ZONE_L_HAND = HAND_LEFT,
59+
BODY_ZONE_R_HAND = HAND_RIGHT,
60+
BODY_ZONE_L_LEG = LEG_LEFT,
61+
BODY_ZONE_R_LEG = LEG_RIGHT,
62+
BODY_ZONE_L_FOOT = FOOT_LEFT,
63+
BODY_ZONE_R_FOOT = FOOT_RIGHT,
64+
)
65+
return lookup[zone]

code/__DEFINES/combat/damage.dm

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
/// todo: better hybrid type handling
3131
#define DAMAGE_TYPE_SEARING "searing"
3232

33+
/proc/damage_type_to_visualized_color(damage_type)
34+
var/alist/lookup = alist(
35+
DAMAGE_TYPE_BRUTE = "#ff0000",
36+
DAMAGE_TYPE_BURN = "#ffff00",
37+
DAMAGE_TYPE_TOX = "#00ff00",
38+
DAMAGE_TYPE_OXY = "#0000ff",
39+
DAMAGE_TYPE_CLONE = "#ff00ff",
40+
DAMAGE_TYPE_HALLOSS = "#00ffff",
41+
)
42+
return lookup[damage_type]
43+
3344
//? damage_mode bitfield ?//
3445

3546
/// sharp weapons like knives, spears, etc
@@ -52,3 +63,20 @@
5263
#define DAMAGE_MODE_REDIRECT (1<<7)
5364
/// temporary - re-evaluate when health is reworked. prevents damage from overflowing caps.
5465
#define DAMAGE_MODE_NO_OVERFLOW (1<<8)
66+
67+
/// config: request armor / shieldcalls apply randomization.
68+
/// * disabled by default by not having this be an opt-out rather than opt-in flag.
69+
/// * disabled by default so non-determinism is controlled instead of innate.
70+
#define DAMAGE_MODE_REQUEST_ARMOR_RANDOMIZATION (1<<22)
71+
/// config: request armor damping of dangerous damage modes like pierce / shred
72+
/// * disabled by default by not having this be an opt-out rather than opt-in flag.
73+
/// * disabled by default so non-determinism is controlled instead of innate.
74+
#define DAMAGE_MODE_REQUEST_ARMOR_BLUNTING (1<<23)
75+
76+
#define DAMAGE_MODES_BLUNTED_BY_ARMOR ( \
77+
DAMAGE_MODE_SHARP | \
78+
DAMAGE_MODE_EDGE | \
79+
DAMAGE_MODE_ABLATING | \
80+
DAMAGE_MODE_PIERCE | \
81+
DAMAGE_MODE_SHRED \
82+
)

0 commit comments

Comments
 (0)