working ricochets

This commit is contained in:
Timothy Teakettle
2020-08-03 14:46:24 +01:00
parent 0bf9553eca
commit 2bbe4631d6
7 changed files with 25 additions and 51 deletions

View File

@@ -1,12 +1,3 @@
/// 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 //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_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. #define BULLET_ACT_BLOCK "BLOCK" //It's a blocked hit, whatever that means in the context of the thing it's hitting.

View File

@@ -156,13 +156,6 @@
return ..() 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) /atom/proc/handle_ricochet(obj/item/projectile/P)
var/turf/p_turf = get_turf(P) var/turf/p_turf = get_turf(P)
var/face_direction = get_dir(src, p_turf) var/face_direction = get_dir(src, p_turf)

View File

@@ -191,7 +191,8 @@
icon = 'icons/turf/walls/shuttle_wall.dmi' icon = 'icons/turf/walls/shuttle_wall.dmi'
icon_state = "map-shuttle" icon_state = "map-shuttle"
explosion_block = 3 explosion_block = 3
flags_1 = CAN_BE_DIRTY_1 | DEFAULT_RICOCHET_1 flags_1 = CAN_BE_DIRTY_1
flags_ricochet = RICOCHET_SHINY | RICOCHET_HARD
sheet_type = /obj/item/stack/sheet/mineral/titanium sheet_type = /obj/item/stack/sheet/mineral/titanium
smooth = SMOOTH_MORE|SMOOTH_DIAGONAL smooth = SMOOTH_MORE|SMOOTH_DIAGONAL
canSmoothWith = list(/turf/closed/wall/mineral/titanium, /obj/machinery/door/airlock/shuttle, /obj/machinery/door/airlock, /obj/structure/window/shuttle, /obj/structure/shuttle/engine/heater, /obj/structure/falsewall/titanium) canSmoothWith = list(/turf/closed/wall/mineral/titanium, /obj/machinery/door/airlock/shuttle, /obj/machinery/door/airlock, /obj/structure/window/shuttle, /obj/structure/shuttle/engine/heater, /obj/structure/falsewall/titanium)

View File

@@ -6,7 +6,7 @@
icon = 'icons/turf/walls/wall.dmi' icon = 'icons/turf/walls/wall.dmi'
icon_state = "wall" icon_state = "wall"
explosion_block = 1 explosion_block = 1
flags_ricochet = RICOCHET_HARD
thermal_conductivity = WALL_HEAT_TRANSFER_COEFFICIENT 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 heat_capacity = 312500 //a little over 5 cm thick , 312500 for 1 m by 2.5 m by 0.25 m plasteel wall
attack_hand_speed = 8 attack_hand_speed = 8

View File

@@ -45,11 +45,8 @@
desc = "A solid wall of slightly twitching tendrils with a reflective glow." desc = "A solid wall of slightly twitching tendrils with a reflective glow."
damaged_desc = "A wall of twitching tendrils with a reflective glow." damaged_desc = "A wall of twitching tendrils with a reflective glow."
icon_state = "blob_glow" icon_state = "blob_glow"
flags_ricochet = RICOCHET_SHINY
point_return = 8 point_return = 8
max_integrity = 100 max_integrity = 100
brute_resist = 1 brute_resist = 1
explosion_block = 2 explosion_block = 2
/obj/structure/blob/shield/reflective/check_projectile_ricochet(obj/item/projectile/P)
return PROJECTILE_RICOCHET_FORCE

View File

@@ -37,9 +37,11 @@
var/obj/item/gun/G = fired_from var/obj/item/gun/G = fired_from
BB.damage *= G.projectile_damage_multiplier BB.damage *= G.projectile_damage_multiplier
if(HAS_TRAIT(user, TRAIT_INSANE_AIM)) if(HAS_TRAIT(user, TRAIT_INSANE_AIM))
BB.ricochets_max = max(BB.ricochets_max, 20) //bouncy! BB.ricochets_max = max(BB.ricochets_max, 10) //bouncy!
BB.ricochet_chance = max(BB.ricochet_chance, 200) //it decays BB.ricochet_chance = max(BB.ricochet_chance, 200) //it decays
BB.ricochet_auto_aim_range = max(BB.ricochet_auto_aim_range, 3) BB.ricochet_auto_aim_range = max(BB.ricochet_auto_aim_range, 3)
BB.ricochet_auto_aim_angle = max(BB.ricochet_auto_aim_angle, 30)
BB.ricochet_decay_chance = min(BB.ricochet_decay_chance, 1)
BB.ricochet_incidence_leeway = 0 BB.ricochet_incidence_leeway = 0
if(reagents && BB.reagents) if(reagents && BB.reagents)

View File

@@ -316,16 +316,18 @@
if(!trajectory) if(!trajectory)
return return
var/turf/T = get_turf(A) var/turf/T = get_turf(A)
if(check_ricochet(A) && A.handle_ricochet(src)) //if you can ricochet, attempt to ricochet off the object if(check_ricochet(A) && check_ricochet_flag(A)) //if you can ricochet, attempt to ricochet off the object
on_ricochet(A) //if allowed, use autoaim to ricochet into someone, otherwise default to ricocheting off the object from above ricochets++
var/datum/point/pcache = trajectory.copy_to() if(A.handle_ricochet(src))
if(hitscan) on_ricochet(A) //if allowed, use autoaim to ricochet into someone, otherwise default to ricocheting off the object from above
store_hitscan_collision(pcache) var/datum/point/pcache = trajectory.copy_to()
decayedRange = max(0, decayedRange - reflect_range_decrease) if(hitscan)
ricochet_chance *= ricochet_decay_chance store_hitscan_collision(pcache)
damage *= ricochet_decay_damage decayedRange = max(0, decayedRange - reflect_range_decrease)
range = decayedRange ricochet_chance *= ricochet_decay_chance
return TRUE damage *= ricochet_decay_damage
range = decayedRange
return TRUE
var/distance = get_dist(T, starting) // Get the distance between the turf shot from and the mob we hit and use that for the calculations. var/distance = get_dist(T, starting) // Get the distance between the turf shot from and the mob we hit and use that for the calculations.
if(def_zone && check_zone(def_zone) != BODY_ZONE_CHEST) if(def_zone && check_zone(def_zone) != BODY_ZONE_CHEST)
@@ -401,24 +403,12 @@
//Returns null if nothing at all was found. //Returns null if nothing at all was found.
/obj/item/projectile/proc/check_ricochet(atom/A) /obj/item/projectile/proc/check_ricochet(atom/A)
if(ricochets > ricochets_max) //safety thing, we don't care about what the other thing says about this. var/chance = ricochet_chance * A.ricochet_chance_mod
return FALSE if(firer && HAS_TRAIT(firer, TRAIT_NICE_SHOT))
var/them = A.check_projectile_ricochet(src) chance += NICE_SHOT_RICOCHET_BONUS
switch(them) if(prob(chance))
if(PROJECTILE_RICOCHET_PREVENT) return TRUE
return FALSE return FALSE
if(PROJECTILE_RICOCHET_FORCE)
return TRUE
if(PROJECTILE_RICOCHET_NO)
return FALSE
if(PROJECTILE_RICOCHET_YES)
var/chance = ricochet_chance * A.ricochet_chance_mod
if(firer && HAS_TRAIT(firer, TRAIT_NICE_SHOT))
chance += NICE_SHOT_RICOCHET_BONUS
if(prob(chance))
return TRUE
else
CRASH("Invalid return value for projectile ricochet check from [A].")
/obj/item/projectile/proc/check_ricochet_flag(atom/A) /obj/item/projectile/proc/check_ricochet_flag(atom/A)
if((flag in list("energy", "laser")) && (A.flags_ricochet & RICOCHET_SHINY)) if((flag in list("energy", "laser")) && (A.flags_ricochet & RICOCHET_SHINY))