diff --git a/code/__DEFINES/projectiles.dm b/code/__DEFINES/projectiles.dm index 0ed0d01889..1bd67fbe02 100644 --- a/code/__DEFINES/projectiles.dm +++ b/code/__DEFINES/projectiles.dm @@ -1,3 +1,12 @@ +/// This atom should be ricocheted off of from its inherent properties using standard % chance handling. +#define PROJECTILE_RICOCHET_YES 1 +/// This atom should not be ricocheted off of from its inherent properties. +#define PROJECTILE_RICOCHET_NO 2 +/// This atom should prevent any kind of projectile ricochet from its inherent properties. +#define PROJECTILE_RICOCHET_PREVENT 3 +/// This atom should force a projectile ricochet from its inherent properties. +#define PROJECTILE_RICOCHET_FORCE 4 + //bullet_act() return values #define BULLET_ACT_HIT "HIT" //It's a successful hit, whatever that means in the context of the thing it's hitting. #define BULLET_ACT_BLOCK "BLOCK" //It's a blocked hit, whatever that means in the context of the thing it's hitting. diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 852391112c..de9df3a23e 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -156,6 +156,13 @@ return ..() +/** + * Checks if a projectile should ricochet off of us. Projectiles get final say. + * [__DEFINES/projectiles.dm] for return values. + */ +/atom/proc/check_projectile_ricochet(obj/item/projectile/P) + return (flags_1 & DEFAULT_RICOCHET_1)? PROJECTILE_RICOCHET_YES : PROJECTILE_RICOCHET_NO + /atom/proc/handle_ricochet(obj/item/projectile/P) var/turf/p_turf = get_turf(P) var/face_direction = get_dir(src, p_turf) diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm index 39f2d276a1..b758317fe2 100644 --- a/code/game/objects/structures.dm +++ b/code/game/objects/structures.dm @@ -9,8 +9,10 @@ var/mob/living/structureclimber var/broken = 0 //similar to machinery's stat BROKEN layer = BELOW_OBJ_LAYER - flags_ricochet = RICOCHET_HARD - ricochet_chance_mod = 0.5 + //ricochets on structures commented out for now because there's a lot of structures that /shouldnt/ be ricocheting and those need to be reviewed first + //flags_1 = DEFAULT_RICOCHET_1 + //flags_ricochet = RICOCHET_HARD + //ricochet_chance_mod = 0.5 /obj/structure/Initialize() if (!armor) diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index 6aae4955f1..3373278c0c 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -17,7 +17,6 @@ GLOBAL_LIST_EMPTY(electrochromatic_window_lookup) layer = ABOVE_OBJ_LAYER //Just above doors pressure_resistance = 4*ONE_ATMOSPHERE anchored = TRUE //initially is 0 for tile smoothing - flags_1 = ON_BORDER_1 max_integrity = 25 var/ini_dir = null var/state = WINDOW_OUT_OF_FRAME @@ -38,7 +37,8 @@ GLOBAL_LIST_EMPTY(electrochromatic_window_lookup) var/hitsound = 'sound/effects/Glasshit.ogg' rad_insulation = RAD_VERY_LIGHT_INSULATION rad_flags = RAD_PROTECT_CONTENTS - flags_ricochet = RICOCHET_HARD + flags_1 = ON_BORDER_1|DEFAULT_RICOCHET_1 + flags_ricochet = RICOCHET_HARD ricochet_chance_mod = 0.4 attack_hand_speed = CLICK_CD_MELEE attack_hand_is_action = TRUE diff --git a/code/game/turfs/simulated/wall/mineral_walls.dm b/code/game/turfs/simulated/wall/mineral_walls.dm index 096f0a0b89..ed48c24462 100644 --- a/code/game/turfs/simulated/wall/mineral_walls.dm +++ b/code/game/turfs/simulated/wall/mineral_walls.dm @@ -191,7 +191,7 @@ icon = 'icons/turf/walls/shuttle_wall.dmi' icon_state = "map-shuttle" explosion_block = 3 - flags_1 = CAN_BE_DIRTY_1 + flags_1 = CAN_BE_DIRTY_1 | DEFAULT_RICOCHET_1 flags_ricochet = RICOCHET_SHINY | RICOCHET_HARD sheet_type = /obj/item/stack/sheet/mineral/titanium smooth = SMOOTH_MORE|SMOOTH_DIAGONAL diff --git a/code/game/turfs/simulated/walls.dm b/code/game/turfs/simulated/walls.dm index ba88baea08..31f8d1cef0 100644 --- a/code/game/turfs/simulated/walls.dm +++ b/code/game/turfs/simulated/walls.dm @@ -6,6 +6,7 @@ icon = 'icons/turf/walls/wall.dmi' icon_state = "wall" explosion_block = 1 + flags_1 = DEFAULT_RICOCHET_1 flags_ricochet = RICOCHET_HARD thermal_conductivity = WALL_HEAT_TRANSFER_COEFFICIENT heat_capacity = 312500 //a little over 5 cm thick , 312500 for 1 m by 2.5 m by 0.25 m plasteel wall diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 75ae93a83f..db72307176 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -316,7 +316,7 @@ if(!trajectory) return var/turf/T = get_turf(A) - if(check_ricochet(A) && check_ricochet_flag(A)) //if you can ricochet, attempt to ricochet off the object + if(A.check_projectile_ricochet(src) && check_ricochet_flag(A) && check_ricochet(A)) //if you can ricochet, attempt to ricochet off the object ricochets++ if(A.handle_ricochet(src)) on_ricochet(A) //if allowed, use autoaim to ricochet into someone, otherwise default to ricocheting off the object from above