This commit is contained in:
Ghommie
2020-01-12 16:54:08 +01:00
parent 8c50b578b4
commit 02fbbd4f95
81 changed files with 304 additions and 235 deletions

View File

@@ -569,4 +569,4 @@
/obj/item/projectile/beam/beam_rifle/hitscan/aiming_beam/on_hit()
qdel(src)
return FALSE
return BULLET_ACT_HIT

View File

@@ -114,7 +114,7 @@
icon_state = "blastwave"
damage = 0
nodamage = FALSE
forcedodge = TRUE
movement_type = FLYING | UNSTOPPABLE
var/heavyr = 0
var/mediumr = 0
var/lightr = 0

View File

@@ -11,15 +11,16 @@
item_flags = ABSTRACT
pass_flags = PASSTABLE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
movement_type = FLYING
hitsound = 'sound/weapons/pierce.ogg'
var/hitsound_wall = ""
resistance_flags = LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
var/def_zone = "" //Aiming at
var/atom/movable/firer = null//Who shot it
var/atom/fired_from = null // the atom that the projectile was fired from (gun, turret)
var/atom/fired_from = null // the atom that the projectile was fired from (gun, turret) var/suppressed = FALSE //Attack message
var/suppressed = FALSE //Attack message
var/candink = FALSE //Can this projectile play the dink sound when hitting the head?
var/candink = FALSE //Can this projectile play the dink sound when hitting the head? var/yo = null
var/yo = null
var/xo = null
var/atom/original = null // the original target clicked
@@ -84,7 +85,8 @@
var/flag = "bullet" //Defines what armor to use when it hits things. Must be set to bullet, laser, energy,or bomb
var/projectile_type = /obj/item/projectile
var/range = 50 //This will de-increment every step. When 0, it will deletze the projectile.
var/decayedRange
var/decayedRange //stores original range
var/reflect_range_decrease = 5 //amount of original range that falls off when reflecting, so it doesn't go forever
var/is_reflectable = FALSE // Can it be reflected or not?
//Effects
var/stun = 0
@@ -99,11 +101,12 @@
var/drowsy = 0
var/stamina = 0
var/jitter = 0
var/forcedodge = 0 //to pass through everything
var/dismemberment = 0 //The higher the number, the greater the bonus to dismembering. 0 will not dismember at all.
var/impact_effect_type //what type of impact effect to show when hitting something
var/log_override = FALSE //is this type spammed enough to not log? (KAs)
var/temporary_unstoppable_movement = FALSE
/obj/item/projectile/Initialize()
. = ..()
permutated = list()
@@ -152,12 +155,12 @@
W.add_dent(WALL_DENT_SHOT, hitx, hity)
return 0
return BULLET_ACT_HIT
if(!isliving(target))
if(impact_effect_type && !hitscan)
new impact_effect_type(target_loca, hitx, hity)
return 0
return BULLET_ACT_HIT
var/mob/living/L = target
@@ -185,7 +188,6 @@
C.bleed(damage)
else
L.add_splatter_floor(target_loca)
else if(impact_effect_type && !hitscan)
new impact_effect_type(target_loca, hitx, hity)
@@ -235,24 +237,20 @@
beam_segments[beam_index] = null
/obj/item/projectile/Bump(atom/A)
var/turf/T = get_turf(A)
if(trajectory && check_ricochet(A) && check_ricochet_flag(A) && ricochets < ricochets_max)
var/datum/point/pcache = trajectory.copy_to()
ricochets++
if(A.handle_ricochet(src))
on_ricochet(A)
ignore_source_check = TRUE
range = initial(range)
decayedRange = max(0, decayedRange - reflect_range_decrease)
range = decayedRange
if(hitscan)
store_hitscan_collision(pcache)
return TRUE
if(firer && !ignore_source_check)
if(A == firer || (A == firer.loc && ismecha(A))) //cannot shoot yourself or your mech
trajectory_ignore_forcemove = TRUE
forceMove(get_turf(A))
trajectory_ignore_forcemove = FALSE
return FALSE
var/distance = get_dist(get_turf(A), 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.
def_zone = ran_zone(def_zone, max(100-(7*distance), 5)) //Lower accurancy/longer range tradeoff. 7 is a balanced number to use.
if(isturf(A) && hitsound_wall)
@@ -261,51 +259,66 @@
volume = 5
playsound(loc, hitsound_wall, volume, 1, -1)
var/turf/target_turf = get_turf(A)
return process_hit(T, select_target(T, A))
if(!prehit(A))
if(forcedodge)
trajectory_ignore_forcemove = TRUE
forceMove(target_turf)
trajectory_ignore_forcemove = FALSE
return FALSE
#define QDEL_SELF 1 //Delete if we're not UNSTOPPABLE flagged non-temporarily
#define DO_NOT_QDEL 2 //Pass through.
#define FORCE_QDEL 3 //Force deletion.
var/permutation = A.bullet_act(src, def_zone) // searches for return value, could be deleted after run so check A isn't null
if(permutation == -1 || forcedodge)// the bullet passes through a dense object!
trajectory_ignore_forcemove = TRUE
forceMove(target_turf)
trajectory_ignore_forcemove = FALSE
if(A)
permutated.Add(A)
return FALSE
else
var/atom/alt = select_target(A)
if(alt)
if(!prehit(alt))
return FALSE
alt.bullet_act(src, def_zone)
qdel(src)
return TRUE
/obj/item/projectile/proc/process_hit(turf/T, atom/target, qdel_self, hit_something = FALSE) //probably needs to be reworked entirely when pixel movement is done.
if(QDELETED(src) || !T || !target) //We're done, nothing's left.
if((qdel_self == FORCE_QDEL) || ((qdel_self == QDEL_SELF) && !temporary_unstoppable_movement && !CHECK_BITFIELD(movement_type, UNSTOPPABLE)))
qdel(src)
return hit_something
permutated |= target //Make sure we're never hitting it again. If we ever run into weirdness with piercing projectiles needing to hit something multiple times.. well.. that's a to-do.
if(!prehit(target))
return process_hit(T, select_target(T), qdel_self, hit_something) //Hit whatever else we can since that didn't work.
var/result = target.bullet_act(src, def_zone)
if(result == BULLET_ACT_FORCE_PIERCE)
if(!CHECK_BITFIELD(movement_type, UNSTOPPABLE))
temporary_unstoppable_movement = TRUE
ENABLE_BITFIELD(movement_type, UNSTOPPABLE)
return process_hit(T, select_target(T), qdel_self, TRUE) //Hit whatever else we can since we're piercing through but we're still on the same tile.
else if(result == BULLET_ACT_TURF) //We hit the turf but instead we're going to also hit something else on it.
return process_hit(T, select_target(T), QDEL_SELF, TRUE)
else //Whether it hit or blocked, we're done!
qdel_self = QDEL_SELF
hit_something = TRUE
if((qdel_self == FORCE_QDEL) || ((qdel_self == QDEL_SELF) && !temporary_unstoppable_movement && !CHECK_BITFIELD(movement_type, UNSTOPPABLE)))
qdel(src)
return hit_something
/obj/item/projectile/proc/select_target(atom/A) //Selects another target from a wall if we hit a wall.
if(!A || !A.density || (A.flags_1 & ON_BORDER_1) || ismob(A) || A == original) //if we hit a dense non-border obj or dense turf then we also hit one of the mobs or machines/structures on that tile.
return
var/turf/T = get_turf(A)
if(original in T)
#undef QDEL_SELF
#undef DO_NOT_QDEL
#undef FORCE_QDEL
/obj/item/projectile/proc/select_target(turf/T, atom/target) //Select a target from a turf.
if((original in T) && can_hit_target(original, permutated, TRUE, TRUE))
return original
var/list/mob/possible_mobs = typecache_filter_list(T, GLOB.typecache_mob) - A
if(target && can_hit_target(target, permutated, target == original, TRUE))
return target
var/list/mob/living/possible_mobs = typecache_filter_list(T, GLOB.typecache_mob)
var/list/mob/mobs = list()
for(var/i in possible_mobs)
var/mob/M = i
if(M.lying)
for(var/mob/living/M in possible_mobs)
if(!can_hit_target(M, permutated, M == original, TRUE))
continue
mobs += M
var/mob/M = safepick(mobs)
if(M)
return M.lowest_buckled_mob()
var/obj/O = safepick(typecache_filter_list(T, GLOB.typecache_machine_or_structure) - A)
var/list/obj/possible_objs = typecache_filter_list(T, GLOB.typecache_machine_or_structure)
var/list/obj/objs = list()
for(var/obj/O in possible_objs)
if(!can_hit_target(O, permutated, O == original, TRUE))
continue
objs += O
var/obj/O = safepick(objs)
if(O)
return O
//Nothing else is here that we can hit, hit the turf if we haven't.
if(!(T in permutated) && can_hit_target(T, permutated, T == original, TRUE))
return T
//Returns null if nothing at all was found.
/obj/item/projectile/proc/check_ricochet()
if(prob(ricochet_chance))
@@ -332,7 +345,7 @@
var/turf/ending = return_predicted_turf_after_moves(moves, forced_angle)
return getline(current, ending)
/obj/item/projectile/Process_Spacemove(var/movement_dir = 0)
/obj/item/projectile/Process_Spacemove(movement_dir = 0)
return TRUE //Bullets don't drift in space
/obj/item/projectile/process()
@@ -360,8 +373,7 @@
/obj/item/projectile/proc/fire(angle, atom/direct_target)
if(fired_from)
SEND_SIGNAL(fired_from, COMSIG_PROJECTILE_BEFORE_FIRE, src, original)
//If no angle needs to resolve it from xo/yo!
SEND_SIGNAL(fired_from, COMSIG_PROJECTILE_BEFORE_FIRE, src, original) //If no angle needs to resolve it from xo/yo!
if(!log_override && firer && original)
log_combat(firer, original, "fired at", src, "from [get_area_name(src, TRUE)]")
if(direct_target)
@@ -498,8 +510,6 @@
else if(T != loc)
step_towards(src, T)
hitscan_last = loc
if(can_hit_target(original, permutated))
Bump(original)
if(!hitscanning && !forcemoved)
pixel_x = trajectory.return_px() - trajectory.mpx * trajectory_multiplier * SSprojectiles.global_iterations_per_move
pixel_y = trajectory.return_py() - trajectory.mpy * trajectory_multiplier * SSprojectiles.global_iterations_per_move
@@ -528,8 +538,28 @@
homing_offset_y = -homing_offset_y
//Returns true if the target atom is on our current turf and above the right layer
/obj/item/projectile/proc/can_hit_target(atom/target, var/list/passthrough)
return (target && ((target.layer >= PROJECTILE_HIT_THRESHHOLD_LAYER) || ismob(target)) && (loc == get_turf(target)) && (!(target in passthrough)))
//If direct target is true it's the originally clicked target.
/obj/item/projectile/proc/can_hit_target(atom/target, list/passthrough, direct_target = FALSE, ignore_loc = FALSE)
if(QDELETED(target))
return FALSE
if(!ignore_source_check && firer)
var/mob/M = firer
if((target == firer) || ((target == firer.loc) && ismecha(firer.loc)) || (target in firer.buckled_mobs) || (istype(M) && (M.buckled == target)))
return FALSE
if(!ignore_loc && (loc != target.loc))
return FALSE
if(target in passthrough)
return FALSE
if(target.density) //This thing blocks projectiles, hit it regardless of layer/mob stuns/etc.
return TRUE
if(!isliving(target))
if(target.layer < PROJECTILE_HIT_THRESHHOLD_LAYER)
return FALSE
else
var/mob/living/L = target
if(!direct_target && !L.density)
return FALSE
return TRUE
//Spread is FORCED!
/obj/item/projectile/proc/preparePixelProjectile(atom/target, atom/source, params, spread = 0)
@@ -591,9 +621,20 @@
return list(angle, p_x, p_y)
/obj/item/projectile/Crossed(atom/movable/AM) //A mob moving on a tile with a projectile is hit by it.
..()
if(isliving(AM) && (AM.density || AM == original) && !(src.pass_flags & PASSMOB))
Bump(AM)
. = ..()
if(isliving(AM) && !(pass_flags & PASSMOB))
var/mob/living/L = AM
if(can_hit_target(L, permutated, (AM == original)))
Bump(AM)
/obj/item/projectile/Move(atom/newloc, dir = NONE)
. = ..()
if(.)
if(temporary_unstoppable_movement)
temporary_unstoppable_movement = FALSE
DISABLE_BITFIELD(movement_type, UNSTOPPABLE)
if(fired && can_hit_target(original, permutated, TRUE))
Bump(original)
/obj/item/projectile/Destroy()
if(hitscan)

View File

@@ -107,8 +107,8 @@
/obj/item/projectile/beam/pulse/heavy/on_hit(atom/target, blocked = FALSE)
life -= 10
if(life > 0)
. = -1
..()
. = BULLET_ACT_FORCE_PIERCE
return ..()
/obj/item/projectile/beam/emitter
name = "emitter beam"
@@ -207,4 +207,4 @@
. = ..()
if(isopenturf(target) || istype(target, /turf/closed/indestructible))//shrunk floors wouldnt do anything except look weird, i-walls shouldnt be bypassable
return
target.AddComponent(/datum/component/shrink, shrink_time)
target.AddComponent(/datum/component/shrink, shrink_time)

View File

@@ -15,7 +15,7 @@
if(M.can_inject(null, FALSE, def_zone, piercing)) // Pass the hit zone to see if it can inject by whether it hit the head or the body.
..()
if(skip == TRUE)
return
return BULLET_ACT_HIT
reagents.reaction(M, INJECT)
reagents.trans_to(M, reagents.total_volume)
return TRUE
@@ -27,7 +27,7 @@
..(target, blocked)
DISABLE_BITFIELD(reagents.reagents_holder_flags, NO_REACT)
reagents.handle_reactions()
return TRUE
return BULLET_ACT_HIT
/obj/item/projectile/bullet/dart/metalfoam/Initialize()
. = ..()
@@ -70,11 +70,11 @@
target.visible_message("<span class='notice'>\The [src] beeps!</span>")
to_chat("<span class='notice'><i>You feel a tiny prick as a smartdart embeds itself in you with a beep.</i></span>")
return TRUE
return BULLET_ACT_HIT
else
blocked = 100
target.visible_message("<span class='danger'>\The [src] was deflected!</span>", \
"<span class='userdanger'>You see a [src] bounce off you, booping sadly!</span>")
target.visible_message("<span class='danger'>\The [src] fails to land on target!</span>")
return TRUE
return BULLET_ACT_BLOCK

View File

@@ -12,7 +12,7 @@
if(M.can_inject(null, FALSE, def_zone, FALSE))
if(injector.inject(M, firer))
QDEL_NULL(injector)
return TRUE
return BULLET_ACT_HIT
else
blocked = 100
target.visible_message("<span class='danger'>\The [src] was deflected!</span>", \

View File

@@ -9,4 +9,4 @@
/obj/item/projectile/bullet/a40mm/on_hit(atom/target, blocked = FALSE)
..()
explosion(target, -1, 0, 2, 1, 0, flame_range = 3)
return TRUE
return BULLET_ACT_HIT

View File

@@ -53,7 +53,7 @@
/obj/item/projectile/bullet/shotgun_frag12/on_hit(atom/target, blocked = FALSE)
..()
explosion(target, -1, 0, 1)
return TRUE
return BULLET_ACT_HIT
/obj/item/projectile/bullet/pellet
var/tile_dropoff = 0.75

View File

@@ -34,7 +34,7 @@
icon_state = "gauss"
name = "penetrator round"
damage = 60
forcedodge = TRUE
movement_type = FLYING | UNSTOPPABLE
dismemberment = 0 //It goes through you cleanly.
knockdown = 0
breakthings = FALSE

View File

@@ -3,7 +3,7 @@
/obj/item/projectile/bullet/honker
damage = 0
knockdown = 60
forcedodge = TRUE
movement_type = FLYING | UNSTOPPABLE
nodamage = TRUE
candink = FALSE
hitsound = 'sound/items/bikehorn.ogg'

View File

@@ -15,7 +15,7 @@
var/turf/Tloc = get_turf(target)
if(!locate(/obj/effect/nettingportal) in Tloc)
new /obj/effect/nettingportal(Tloc)
..()
return ..()
/obj/item/projectile/energy/net/on_range()
do_sparks(1, TRUE, src)
@@ -69,7 +69,7 @@
else if(iscarbon(target))
var/obj/item/restraints/legcuffs/beartrap/B = new /obj/item/restraints/legcuffs/beartrap/energy(get_turf(target))
B.Crossed(target)
..()
return ..()
/obj/item/projectile/energy/trap/on_range()
new /obj/item/restraints/legcuffs/beartrap/energy(loc)
@@ -91,7 +91,7 @@
var/obj/item/restraints/legcuffs/beartrap/B = new /obj/item/restraints/legcuffs/beartrap/energy/cyborg(get_turf(target))
B.Crossed(target)
QDEL_IN(src, 10)
..()
return ..()
/obj/item/projectile/energy/trap/cyborg/on_range()
do_sparks(1, TRUE, src)

View File

@@ -17,7 +17,7 @@
var/mob/M = target
if(M.anti_magic_check())
M.visible_message("<span class='warning'>[src] vanishes on contact with [target]!</span>")
return
return BULLET_ACT_BLOCK
M.death(0)
/obj/item/projectile/magic/resurrection
@@ -31,10 +31,10 @@
. = ..()
if(isliving(target))
if(target.hellbound)
return
return BULLET_ACT_BLOCK
if(target.anti_magic_check())
target.visible_message("<span class='warning'>[src] vanishes on contact with [target]!</span>")
return
return BULLET_ACT_BLOCK
if(iscarbon(target))
var/mob/living/carbon/C = target
C.regenerate_limbs()
@@ -60,7 +60,7 @@
var/mob/M = target
if(M.anti_magic_check())
M.visible_message("<span class='warning'>[src] fizzles on contact with [target]!</span>")
return
return BULLET_ACT_BLOCK
var/teleammount = 0
var/teleloc = target
if(!isturf(target))
@@ -116,7 +116,7 @@
if(M.anti_magic_check())
M.visible_message("<span class='warning'>[src] fizzles on contact with [M]!</span>")
qdel(src)
return
return BULLET_ACT_BLOCK
wabbajack(change)
qdel(src)
@@ -264,7 +264,7 @@
/obj/item/projectile/magic/animate/on_hit(atom/target, blocked = FALSE)
target.animate_atom_living(firer)
..()
. = ..()
/atom/proc/animate_atom_living(var/mob/living/owner = null)
if((isitem(src) || isstructure(src)) && !is_type_in_list(src, GLOB.protected_objects))
@@ -315,7 +315,7 @@
if(M.anti_magic_check())
M.visible_message("<span class='warning'>[src] vanishes on contact with [target]!</span>")
qdel(src)
return
return BULLET_ACT_BLOCK
. = ..()
/obj/item/projectile/magic/arcane_barrage
@@ -334,7 +334,7 @@
if(M.anti_magic_check())
M.visible_message("<span class='warning'>[src] vanishes on contact with [target]!</span>")
qdel(src)
return
return BULLET_ACT_BLOCK
. = ..()
@@ -460,7 +460,7 @@
if(M.anti_magic_check())
visible_message("<span class='warning'>[src] fizzles on contact with [target]!</span>")
qdel(src)
return
return BULLET_ACT_BLOCK
tesla_zap(src, tesla_range, tesla_power, tesla_flags)
qdel(src)
@@ -487,7 +487,7 @@
var/mob/living/M = target
if(M.anti_magic_check())
visible_message("<span class='warning'>[src] vanishes into smoke on contact with [target]!</span>")
return
return BULLET_ACT_BLOCK
M.take_overall_damage(0,10) //between this 10 burn, the 10 brute, the explosion brute, and the onfire burn, your at about 65 damage if you stop drop and roll immediately
var/turf/T = get_turf(target)
explosion(T, -1, exp_heavy, exp_light, exp_flash, 0, flame_range = exp_fire)
@@ -504,7 +504,7 @@
if(ismob(target))
var/mob/living/M = target
if(M.anti_magic_check())
return
return BULLET_ACT_BLOCK
var/turf/T = get_turf(target)
for(var/i=0, i<50, i+=10)
addtimer(CALLBACK(GLOBAL_PROC, .proc/explosion, T, -1, exp_heavy, exp_light, exp_flash, FALSE, FALSE, exp_fire), i)
@@ -518,11 +518,11 @@
/obj/item/projectile/magic/nuclear/on_hit(target)
if(used)
return
return BULLET_ACT_HIT
new/obj/effect/temp_visual/slugboom(get_turf(src))
if(ismob(target))
if(target == victim)
return
return BULLET_ACT_FORCE_PIERCE
used = 1
visible_message("<span class='danger'>[victim] slams into [target] with explosive force!</span>")
explosion(src, 2, 3, 4, -1, TRUE, FALSE, 5)
@@ -531,8 +531,9 @@
victim.take_overall_damage(30,30)
victim.Knockdown(60)
explosion(src, -1, -1, -1, -1, FALSE, FALSE, 5)
return BULLET_ACT_HIT
/obj/item/projectile/magic/nuclear/Destroy()
for(var/atom/movable/AM in contents)
AM.forceMove(get_turf(src))
. = ..()
. = ..()

View File

@@ -12,7 +12,7 @@
knockdown = 20
speed = 2
range = 16
forcedodge = TRUE
movement_type = FLYING | UNSTOPPABLE
var/datum/beam/arm
var/handedness = 0
@@ -28,7 +28,7 @@
/obj/item/projectile/curse_hand/prehit(atom/target)
if(target == original)
forcedodge = FALSE
DISABLE_BITFIELD(movement_type, UNSTOPPABLE)
else if(!isturf(target))
return FALSE
return ..()
@@ -37,7 +37,7 @@
if(arm)
arm.End()
arm = null
if(forcedodge)
if(CHECK_BITFIELD(movement_type, UNSTOPPABLE))
playsound(src, 'sound/effects/curse3.ogg', 25, 1, -1)
var/turf/T = get_step(src, dir)
new/obj/effect/temp_visual/dir_setting/curse/hand(T, dir, handedness)

View File

@@ -6,15 +6,12 @@
nodamage = 1
flag = "energy"
impact_effect_type = /obj/effect/temp_visual/impact_effect/ion
var/emp_radius = 1
/obj/item/projectile/ion/on_hit(atom/target, blocked = FALSE)
..()
empulse(target, 1, 1)
return TRUE
empulse(target, emp_radius, emp_radius)
return BULLET_ACT_HIT
/obj/item/projectile/ion/weak
/obj/item/projectile/ion/weak/on_hit(atom/target, blocked = FALSE)
..()
empulse(target, 0, 0)
return TRUE
emp_radius = 0

View File

@@ -29,7 +29,7 @@
mine_range--
range++
if(range > 0)
return -1
return BULLET_ACT_FORCE_PIERCE
/obj/item/projectile/plasma/adv
damage = 28

View File

@@ -6,7 +6,7 @@
/obj/item/projectile/bullet/gyro/on_hit(atom/target, blocked = FALSE)
..()
explosion(target, -1, 0, 2)
return TRUE
return BULLET_ACT_HIT
/obj/item/projectile/bullet/a84mm
name ="\improper HEDP rocket"
@@ -28,7 +28,7 @@
if(issilicon(target))
var/mob/living/silicon/S = target
S.take_overall_damage(anti_armour_damage*0.75, anti_armour_damage*0.25)
return TRUE
return BULLET_ACT_HIT
/obj/item/projectile/bullet/a84mm_he
name ="\improper HE missile"
@@ -43,4 +43,4 @@
explosion(target, 0, 1, 2, 4)
else
explosion(target, 0, 0, 2, 4)
return TRUE
return BULLET_ACT_HIT

View File

@@ -25,5 +25,5 @@
/obj/item/projectile/beam/wormhole/on_hit(atom/target)
if(!gun)
qdel(src)
return
return BULLET_ACT_BLOCK
gun.create_portal(src, get_turf(src))