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

ports sharp rifle #280

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions code/__DEFINES/conflict.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#define AMMO_MP (1<<21)
/// Handles sentry flamers glob
#define AMMO_FLAME (1<<22)
// If the projectile hits a dense turf it'll do on_hit_turf on the turf just in front of the turf instead of on the turf itself (This one does not work on mobs)
#define AMMO_STRIKES_SURFACE_ONLY (1<<23)
// NOTE: Don't add flags past 1<<23, it'll break things due to BYOND limitations. You can usually use a Component instead.

/// Projectile is shrpanel which allow it to skip some collisions
Expand Down
3 changes: 3 additions & 0 deletions code/datums/ammo/bullet/shotgun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
penetration = ARMOR_PENETRATION_TIER_7
scatter = SCATTER_AMOUNT_TIER_5

/datum/ammo/bullet/shotgun/flechette_spread/awesome
damage = 60

/datum/ammo/bullet/shotgun/buckshot
name = "buckshot shell"
icon_state = "buckshot"
Expand Down
147 changes: 147 additions & 0 deletions code/datums/ammo/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,150 @@
var/obj/item/clothing/mask/facehugger/child = new(T)
child.hivenumber = hugger_hive
INVOKE_ASYNC(child, TYPE_PROC_REF(/obj/item/clothing/mask/facehugger, leap_at_nearest_target))

/*
//========
SHARP Dart Ammo
//========
*/
/datum/ammo/rifle/sharp
name = "dart"
ping = null //no bounce off.
damage_type = BRUTE
shrapnel_type = /obj/item/sharp
flags_ammo_behavior = AMMO_SPECIAL_EMBED|AMMO_NO_DEFLECT|AMMO_STRIKES_SURFACE_ONLY|AMMO_HITS_TARGET_TURF
icon_state = "sonicharpoon"
var/embed_object = /obj/item/sharp/explosive

shrapnel_chance = 100
accuracy = HIT_ACCURACY_TIER_MAX
accurate_range = 12
max_range = 7
damage = 35
shell_speed = AMMO_SPEED_TIER_2

/datum/ammo/rifle/sharp/on_embed(mob/embedded_mob, obj/limb/target_organ)
if(!ishuman(embedded_mob))
return
var/mob/living/carbon/human/humano = embedded_mob
if(humano.species.flags & NO_SHRAPNEL)
return
if(istype(target_organ))
target_organ.embed(new embed_object)

/datum/ammo/rifle/sharp/on_hit_obj(obj/O, obj/projectile/P)
drop_dart(P.loc, P)

/datum/ammo/rifle/sharp/on_hit_turf(turf/T, obj/projectile/P)
drop_dart(T, P)

/datum/ammo/rifle/sharp/do_at_max_range(obj/projectile/P)
drop_dart(P.loc, P)

/datum/ammo/rifle/sharp/proc/drop_dart(loc, obj/projectile/P)
new embed_object(loc, P.dir)

/datum/ammo/rifle/sharp/explosive
name = "9X-E sticky explosive dart"

/datum/ammo/rifle/sharp/explosive/on_hit_mob(mob/living/M, obj/projectile/P)
if(!M || M == P.firer) return
var/mob/shooter = P.firer
shake_camera(M, 2, 1)
if(shooter && ismob(shooter))
if(!M.get_target_lock(shooter.faction_group))
var/obj/item/weapon/gun/rifle/sharp/weapon = P.shot_from
if(weapon && weapon.explosion_delay_sharp)
addtimer(CALLBACK(src, PROC_REF(delayed_explosion), P, M, shooter), 5 SECONDS)
else
addtimer(CALLBACK(src, PROC_REF(delayed_explosion), P, M, shooter), 1 SECONDS)

/datum/ammo/rifle/sharp/explosive/drop_dart(loc, obj/projectile/P, mob/shooter)
var/signal_explosion = FALSE
if(locate(/obj/item/explosive/mine) in get_turf(loc))
signal_explosion = TRUE
var/obj/item/explosive/mine/sharp/dart = new /obj/item/explosive/mine/sharp(loc)
// if no darts on tile, don't arm, explode instead.
if(signal_explosion)
INVOKE_ASYNC(dart, TYPE_PROC_REF(/obj/item/explosive/mine/sharp, prime), shooter)
else
dart.anchored = TRUE
addtimer(CALLBACK(dart, TYPE_PROC_REF(/obj/item/explosive/mine/sharp, deploy_mine), shooter), 3 SECONDS, TIMER_DELETE_ME)
addtimer(CALLBACK(dart, TYPE_PROC_REF(/obj/item/explosive/mine/sharp, disarm)), 1 MINUTES, TIMER_DELETE_ME)

/datum/ammo/rifle/sharp/explosive/proc/delayed_explosion(obj/projectile/P, mob/M, mob/shooter)
if(ismob(M))
var/explosion_size = 100
var/falloff_size = 50
var/cause_data = create_cause_data("P9 SHARP Rifle", shooter)
cell_explosion(get_turf(M), explosion_size, falloff_size, EXPLOSION_FALLOFF_SHAPE_LINEAR, P.dir, cause_data)
M.ex_act(150, P.dir, P.weapon_cause_data, 100)
M.apply_effect(2, WEAKEN)
M.apply_effect(2, PARALYZE)
playsound(get_turf(M), 'sound/weapons/gun_sharp_explode.ogg', 45)

/datum/ammo/rifle/sharp/track
name = "9X-T sticky tracker dart"
icon_state = "sonicharpoon_tracker"
embed_object = /obj/item/sharp/track
var/tracker_timer = 1 MINUTES

/datum/ammo/rifle/sharp/track/on_hit_mob(mob/living/M, obj/projectile/P)
if(!M || M == P.firer) return
shake_camera(M, 2, 1)
var/obj/item/weapon/gun/rifle/sharp/weapon = P.shot_from
if(weapon)
weapon.sharp_tracked_mob_list |= M
addtimer(CALLBACK(src, PROC_REF(remove_tracker), M, P), tracker_timer)

/datum/ammo/rifle/sharp/track/proc/remove_tracker(mob/living/M, obj/projectile/P)
var/obj/item/weapon/gun/rifle/sharp/weapon = P.shot_from
if(weapon)
weapon.sharp_tracked_mob_list -= M

/datum/ammo/rifle/sharp/track/infinite
tracker_timer = 999 MINUTES

/datum/ammo/rifle/sharp/flechette
name = "9X-F flechette dart"
icon_state = "sonicharpoon_flechette"
embed_object = /obj/item/sharp/flechette
shrapnel_type = /datum/ammo/bullet/shotgun/flechette_spread/awesome

/datum/ammo/rifle/sharp/flechette/on_hit_mob(mob/living/M, obj/projectile/P)
if(!M || M == P.firer) return
var/mob/shooter = P.firer
shake_camera(M, 2, 1)
if(shooter && ismob(shooter))
if(!M.get_target_lock(shooter.faction_group))
create_flechette(M.loc, P)

/datum/ammo/rifle/sharp/flechette/on_pointblank(mob/living/M, obj/projectile/P)
if(!M) return
P.dir = get_dir(P.firer, M)

/datum/ammo/rifle/sharp/flechette/on_hit_obj(obj/O, obj/projectile/P)
create_flechette(O.loc, P)

/datum/ammo/rifle/sharp/flechette/on_hit_turf(turf/T, obj/projectile/P)
create_flechette(T, P)

/datum/ammo/rifle/sharp/flechette/do_at_max_range(obj/projectile/P)
create_flechette(P.loc, P)

/datum/ammo/rifle/sharp/flechette/proc/create_flechette(loc, obj/projectile/P)
var/shrapnel_count = 15
var/direct_hit_shrapnel = 8
var/dispersion_angle = 20
create_shrapnel(loc, min(direct_hit_shrapnel, shrapnel_count), P.dir, dispersion_angle, shrapnel_type, P.weapon_cause_data, FALSE, 100)
shrapnel_count -= direct_hit_shrapnel
if(shrapnel_count)
create_shrapnel(loc, shrapnel_count, P.dir, dispersion_angle ,shrapnel_type, P.weapon_cause_data, FALSE, 0)
apply_explosion_overlay(loc)

/datum/ammo/rifle/sharp/flechette/proc/apply_explosion_overlay(turf/loc)
var/obj/effect/overlay/O = new /obj/effect/overlay(loc)
O.name = "grenade"
O.icon = 'icons/effects/explosion.dmi'
flick("grenade", O)
QDEL_IN(O, 7)
65 changes: 65 additions & 0 deletions code/game/objects/items/explosives/mine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,71 @@
matter = list("metal" = 3750)
has_blast_wave_dampener = TRUE

/obj/item/explosive/mine/sharp
name = "\improper P9 SHARP explosive dart"
desc = "An experimental P9 SHARP proximity triggered explosive dart designed by Armat Systems for use by the United States Colonial Marines. This one has full 360 detection range."
icon_state = "sonicharpoon_g"
angle = 360
var/disarmed = FALSE
var/explosion_size = 200
var/explosion_falloff = 100

/obj/item/explosive/mine/sharp/check_for_obstacles(mob/living/user)
return FALSE

/obj/item/explosive/mine/sharp/attackby(obj/item/W, mob/user)
return

/obj/item/explosive/mine/sharp/set_tripwire()
if(!active && !tripwire)
for(var/direction in CARDINAL_ALL_DIRS)
var/tripwire_loc = get_turf(get_step(loc,direction))
tripwire = new(tripwire_loc)
tripwire.linked_claymore = src
active = TRUE

/obj/item/explosive/mine/sharp/prime(mob/user)
set waitfor = 0
if(!cause_data)
cause_data = create_cause_data(initial(name), user)
cell_explosion(loc, explosion_size, explosion_falloff, EXPLOSION_FALLOFF_SHAPE_LINEAR, CARDINAL_ALL_DIRS, cause_data)
playsound(loc, 'sound/weapons/gun_sharp_explode.ogg', 45)
qdel(src)

/obj/item/explosive/mine/sharp/disarm()
anchored = FALSE
active = FALSE
triggered = FALSE
icon_state = base_icon_state + "_disarmed"
QDEL_NULL(tripwire)
disarmed = TRUE
add_to_garbage(src)

/obj/item/explosive/mine/sharp/attack_self(mob/living/user)
if(disarmed)
return
. = ..()

/obj/item/explosive/mine/sharp/deploy_mine(mob/user)
if(disarmed)
return
if(!hard_iff_lock && user)
iff_signal = user.faction

cause_data = create_cause_data(initial(name), user)
if(user)
user.drop_inv_item_on_ground(src)
setDir(user ? user.dir : dir) //The direction it is planted in is the direction the user faces at that time
activate_sensors()
update_icon()
for(var/mob/living/carbon/mob in range(1, src))
src.try_to_prime(mob)

/obj/item/explosive/mine/sharp/attack_alien()
if(disarmed)
..()
else
return
/obj/item/explosive/mine/sebb
name = "\improper G2 Electroshock grenade"
icon_state = "grenade_sebb_planted"
Expand Down
53 changes: 53 additions & 0 deletions code/game/objects/items/shards.dm
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,59 @@
icon_state = "alienbonechips"
desc = "Sharp, jagged fragments of alien bone. Looks like the previous owner exploded violently..."

/obj/item/sharp
name = "sharp dart shrapnel"
desc = "It looks like a used 9X-E Sticky Explosive Dart, useless now."
icon = 'icons/obj/items/weapons/projectiles.dmi'
icon_state = "sonicharpoon"
sharp = IS_SHARP_ITEM_BIG
w_class = SIZE_SMALL
edge = TRUE
force = 0
throwforce = 0
var/damage_on_move = 3
var/count = 1
garbage = TRUE

/obj/item/sharp/Initialize(mapload, dir)
. = ..()
if(dir && dir <= 6)
turn_object(90)
else
turn_object(270)

/obj/item/sharp/proc/on_embed(mob/embedded_mob, obj/limb/target_organ)
return

/obj/item/sharp/proc/on_embedded_movement(mob/living/embedded_mob)
if(!ishuman(embedded_mob))
return
var/mob/living/carbon/human/H = embedded_mob
if(H.species.flags & NO_SHRAPNEL)
return
var/obj/limb/organ = embedded_organ
if(istype(organ))
organ.take_damage(damage_on_move * count, 0, 0, no_limb_loss = TRUE)

embedded_mob.pain.apply_pain(damage_on_move * count)

/obj/item/sharp/proc/turn_object(amount)
var/matrix/initial_matrix = matrix(transform)
initial_matrix.Turn(amount)
apply_transform(initial_matrix)

/obj/item/sharp/explosive
name = "\improper 9X-E sticky explosive dart"

/obj/item/sharp/track
name = "\improper 9X-T sticky tracker dart"
desc = "It looks like a used 9X-T Sticky Tracker Dart, useless now."
icon_state = "sonicharpoon_tracker"

/obj/item/sharp/flechette
name = "\improper 9X-F flechette dart"
desc = "It looks like a used 9X-F Flechette Dart, useless now."
icon_state = "sonicharpoon_flechette"
/obj/item/shard/shrapnel/tutorial
damage_on_move = 0

3 changes: 3 additions & 0 deletions code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,9 @@
else if(istype(W, /obj/item/shard/shrapnel))
var/obj/item/shard/shrapnel/embedded = W
embedded.on_embedded_movement(src)
else if(istype(W, /obj/item/sharp))
var/obj/item/sharp/embedded = W
embedded.on_embedded_movement(src)
// Check if its a sharp weapon
else if(is_sharp(W))
if(organ.status & LIMB_SPLINTED) //Splints prevent movement.
Expand Down
4 changes: 3 additions & 1 deletion code/modules/projectiles/ammunition.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ They're all essentially identical when it comes to getting the job done.
/// Is the greyscale icon used for the ammo band when it's empty of bullets.
var/ammo_band_icon_empty

var/description_ammo = "rounds"


/obj/item/ammo_magazine/Initialize(mapload, spawn_empty)
. = ..()
Expand Down Expand Up @@ -98,7 +100,7 @@ They're all essentially identical when it comes to getting the job done.
. += "Something went horribly wrong. Ahelp the following: ERROR CODE R1: negative current_rounds on examine."
log_debug("ERROR CODE R1: negative current_rounds on examine. User: <b>[usr]</b> Magazine: <b>[src]</b>")
else
. += "[src] has <b>[current_rounds]</b> rounds out of <b>[max_rounds]</b>."
. += "[src] has <b>[current_rounds]</b> [description_ammo] out of <b>[max_rounds]</b>."

/obj/item/ammo_magazine/attack_hand(mob/user)
if(flags_magazine & AMMUNITION_REFILLABLE) //actual refillable magazine, not just a handful of bullets or a fuel tank.
Expand Down
Loading
Loading