Skip to content

Commit

Permalink
Cleans up code, implements damage type check
Browse files Browse the repository at this point in the history
  • Loading branch information
thgvr committed Mar 30, 2024
1 parent 7c954a5 commit 1b334fb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
32 changes: 22 additions & 10 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -780,17 +780,29 @@

target.visible_message(span_warning("[user] pulls the trigger!"), span_userdanger("[(user == target) ? "You pull" : "[user] pulls"] the trigger!"))

// Check if the gun is usable, a round is chambered, and if the chambered round's projectile has damage
var/obj/item/organ/brain/brain_to_blast = target.getorganslot(ORGAN_SLOT_BRAIN)
if(chambered?.BB && brain_to_blast && can_trigger_gun(user) && chambered.BB.damage > 0)
var/turf/splat_turf = get_turf(target)
var/turf/splat_target = get_ranged_target_turf(target, REVERSE_DIR(target.dir), BRAINS_BLOWN_THROW_RANGE)
var/datum/callback/gibspawner = CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(spawn_atom_to_turf), /obj/effect/gibspawner/generic, shotbrain, 1, FALSE, target)
chambered.BB.damage *= 4
if(chambered && chambered.BB && can_trigger_gun(user))
chambered.BB.damage *= 3
//Check is here for safeties and such, brain will be removed after
process_fire(target, user, TRUE, params, BODY_ZONE_HEAD)
brain_to_blast.Remove(target)
brain_to_blast.forceMove(splat_turf)
brain_to_blast.throw_at(splat_target, BRAINS_BLOWN_THROW_RANGE, BRAINS_BLOWN_THROW_SPEED, callback = gibspawner)

var/obj/item/organ/brain/brain_to_blast = target.getorganslot(ORGAN_SLOT_BRAIN)
if(brain_to_blast)

//Check if the projectile is actually damaging and not of type STAMINA
if(chambered.BB.nodamage || !chambered.BB.damage || chambered.BB.damage_type == STAMINA)
return

//Remove brain of the mob shot
brain_to_blast.Remove(target)

var/turf/splat_turf = get_turf(target)
//Move the brain of the person shot to selected turf
brain_to_blast.forceMove(splat_turf)

var/turf/splat_target = get_ranged_target_turf(target, REVERSE_DIR(target.dir), BRAINS_BLOWN_THROW_RANGE)
var/datum/callback/gibspawner = CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(spawn_atom_to_turf), /obj/effect/gibspawner/generic, brain_to_blast, 1, FALSE, target)
//Throw the brain that has been removed away and place a gibspawner on landing
brain_to_blast.throw_at(splat_target, BRAINS_BLOWN_THROW_RANGE, BRAINS_BLOWN_THROW_SPEED, callback = gibspawner)

#undef BRAINS_BLOWN_THROW_RANGE
#undef BRAINS_BLOWN_THROW_SPEED
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
var/homing_offset_y = 0

var/damage = 10
var/damage_type = BRUTE //BRUTE, BURN, TOX, OXY, CLONE are the only things that should be in here
var/damage_type = BRUTE //BRUTE, BURN, TOX, OXY, CLONE, STAMINA are the only things that should be in here
var/nodamage = FALSE //Determines if the projectile will skip any damage inflictions
var/flag = "bullet" //Defines what armor to use when it hits things. Must be set to bullet, laser, energy,or bomb
///How much armor this projectile pierces.
Expand Down

0 comments on commit 1b334fb

Please sign in to comment.