Skip to content

Commit

Permalink
Merge pull request #5801 from Trilbyspaceclone/npc_shoot_rng
Browse files Browse the repository at this point in the history
better shooting for mobs
  • Loading branch information
Trilbyspaceclone authored Oct 28, 2024
2 parents 344337b + 2399424 commit 127aa0b
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

prefix = "Deadeye"

description = "This one seems to be very accurate and precise with its shots. It'll likely shoot slower, but with more precision, giving it extra damage and AP."
description = "This one seems to be very accurate and precise with its shots. It'll likely shoot slower, but with more precision, giving it extra damage and AP as well as alining its aim to be for headshots, and arms!."

stattags = RANGED_STATTAG
zone_hit_rates_setter = list(BP_HEAD = 30, BP_CHEST = 10, BP_GROIN = 10, BP_R_ARM = 50, BP_L_ARM = 50, BP_R_LEG = 20, BP_L_LEG = 20)

/datum/stat_modifier/mob/living/carbon/superior_animal/slowaimed

Expand Down Expand Up @@ -43,6 +44,8 @@
description = "This one seems overeager to shoot. It's likely they'll fire more often than others, although with less precision, thus less armor penetration and damage."

stattags = RANGED_STATTAG
zone_hit_rates_setter = list(BP_HEAD = 5, BP_CHEST = 80, BP_GROIN = 60, BP_R_ARM = 10, BP_L_ARM = 10, BP_R_LEG = 30, BP_L_LEG = 30)


/datum/stat_modifier/mob/living/carbon/superior_animal/quickdraw

Expand All @@ -53,6 +56,9 @@
description = "This one seems vigilant, especially when it comes to keeping whatever they use as a weapon at the ready. It's likely they'll react faster than others."

stattags = RANGED_STATTAG
zone_hit_rates_setter = list(BP_HEAD = 25, BP_CHEST = 25, BP_GROIN = 25, BP_R_ARM = 60, BP_L_ARM = 60, BP_R_LEG = 15, BP_L_LEG = 15)



/datum/stat_modifier/mob/living/carbon/superior_animal/slowdraw

Expand All @@ -63,3 +69,12 @@
description = "This one seems to take a bit longer to fire than others."

stattags = RANGED_STATTAG

/datum/stat_modifier/mob/living/carbon/superior_animal/headhunter
prefix = "Head Hunter"

description = "This one is trainned to aim for targets heads rather then center of mass."

stattags = RANGED_STATTAG
zone_hit_rates_setter = list(BP_HEAD = 55, BP_CHEST = 35, BP_GROIN = 35, BP_R_ARM = 15, BP_L_ARM = 15, BP_R_LEG = 5, BP_L_LEG = 5)

21 changes: 21 additions & 0 deletions code/datums/stat_modifiers/stat_modifier.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
/// Any modifier typepaths in this will have their prob on our holder set to 0 if we're added, and their original prob stored as the value of the typepath, for use in remove().
var/list/mutually_exclusive_with = list()

var/list/zone_hit_rates_setter = null


//todo: store the vars we change for more accurate removal

/// Inverts all effects the modifier provided, and optionally qdeletes it. Needs to have effects manually added.
Expand Down Expand Up @@ -98,6 +101,14 @@

holder = null //we no longer have a holder

if(zone_hit_rates_setter)
if(istype(holder, /mob/living/simple_animal/hostile))
var/mob/living/simple_animal/hostile/H = holder
H.zone_hit_rates = initial(H.zone_hit_rates)
if(issuperioranimal(holder))
var/mob/living/carbon/superior_animal/SA
SA.zone_hit_rates = initial(SA.zone_hit_rates)

if (qdel_src)
qdel(src)

Expand Down Expand Up @@ -179,6 +190,16 @@
LAZYADD(target.name_prefixes, prefix) // if so, lets add ours to their prefix list...
target.update_prefixes() // ...and regenerate their prefixes

if(zone_hit_rates_setter)
if(istype(holder, /mob/living/simple_animal/hostile))
var/mob/living/simple_animal/hostile/H = target
H.zone_hit_rates = zone_hit_rates_setter
if(issuperioranimal(holder))
var/mob/living/carbon/superior_animal/SA = target
SA.zone_hit_rates = zone_hit_rates_setter



return TRUE

/datum/stat_modifier/proc/consider_custom_effect(atom/movable/target, list/arguments, arguments_to_pass, status)
Expand Down
5 changes: 4 additions & 1 deletion code/modules/mob/living/carbon/superior_animal/attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@
if(!A)
return

var/def_zone = get_exposed_defense_zone(target)
var/def_zone = pickweight(zone_hit_rates)

//message_admins("pre-fire def_zone = [def_zone]")

var/datum/penetration_holder/trace_penetration

Expand Down Expand Up @@ -177,6 +179,7 @@
A.original_firer = src
if(friendly_to_colony)
A.friendly_to_colony = TRUE
A.predetermed = def_zone
A.launch(target, def_zone, firer_arg = src, angle_offset = offset_temp) //this is where we actually shoot the projectile
right_after_firing()
SEND_SIGNAL(src, COMSIG_SUPERIOR_FIRED_PROJECTILE, A)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
/datum/stat_modifier/mob/living/carbon/superior_animal/slowaimed = 5,
/datum/stat_modifier/mob/living/carbon/superior_animal/triggerfinger/robotic = 5,
/datum/stat_modifier/mob/living/carbon/superior_animal/quickdraw = 5,
/datum/stat_modifier/mob/living/carbon/superior_animal/headhunter = 1
)

contaminant_immunity = TRUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,6 @@
/// Used to dictate if the critter is poisonous or not
var/poison_per_bite = 0
var/poison_type

var/list/zone_hit_rates = list(BP_HEAD = 10, BP_CHEST = 50, BP_GROIN = 35, BP_R_ARM = 30, BP_L_ARM = 30, BP_R_LEG = 20, BP_L_LEG = 20)

5 changes: 4 additions & 1 deletion code/modules/mob/living/simple_animal/hostile/hostile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ var/list/mydirs = list(NORTH, SOUTH, EAST, WEST, SOUTHWEST, NORTHWEST, NORTHEAST
var/poison_per_bite = 0 //To handle poisonous bigguns
var/poison_type

var/list/zone_hit_rates = list(BP_HEAD = 10, BP_CHEST = 50, BP_GROIN = 35, BP_R_ARM = 30, BP_L_ARM = 30, BP_R_LEG = 20, BP_L_LEG = 20)

/mob/living/simple_animal/hostile/Destroy()
target_mob = null

Expand Down Expand Up @@ -301,8 +303,9 @@ var/list/mydirs = list(NORTH, SOUTH, EAST, WEST, SOUTHWEST, NORTHWEST, NORTHEAST
var/obj/item/projectile/A = new projectiletype(src.loc)
playsound(user, projectilesound, 100, 1)
if(!A) return
var/def_zone = get_exposed_defense_zone(target)
var/def_zone = pickweight(zone_hit_rates)
A.original_firer = src
A.predetermed = def_zone
A.launch(target, def_zone)

/mob/living/simple_animal/hostile/MiddleClickOn(mob/targetDD as mob) //Letting Mobs Fire when middle clicking as someone controlling it.
Expand Down
9 changes: 5 additions & 4 deletions code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@
var/wounding_mult = 1 // A multiplier on damage inflicted to and damage blocked by mobs

var/ignition_source = TRUE //Used for deciding if a projectile should blow up a benzin.
var/predetermed = null //Used for NPCs to sudo rng, uses define zones directly


/obj/item/projectile/New()

Expand Down Expand Up @@ -391,7 +393,6 @@
//roll to-hit
miss_modifier = 0
var/hit_zone = check_zone(def_zone)

var/result = PROJECTILE_FORCE_MISS
if(hit_zone)
def_zone = hit_zone //set def_zone, so if the projectile ends up hitting someone else later (to be implemented), it is more likely to hit the same part
Expand Down Expand Up @@ -715,12 +716,12 @@
if(istargetloc(target_mob) == 0)
def_zone = pick(BP_R_ARM, BP_L_ARM, BP_CHEST, BP_HEAD)
//head


//message_admins("predetermed = [predetermed] def_zone = [def_zone]")
if(predetermed)
def_zone = predetermed

result = target_mob.bullet_act(src, def_zone)//this returns mob's armor_check and another - see modules/mob/living/living_defense.dm


if(result == PROJECTILE_FORCE_MISS)
if (!testing) //doesnt matter, we collided with something, NIKO COME BACK HERE AND REVIEW THIS
if(!silenced)
Expand Down

0 comments on commit 127aa0b

Please sign in to comment.