From 3a32603c1583e4f382cf91c511851092399ec15e Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Sat, 6 Jul 2024 16:49:01 -0400 Subject: [PATCH] misc projectiles raycasting tweaks, makes projectiles faster (#6578) makes projectiles faster adds a tuning variable again removes a useless button in set-ticklag fixes homing optimizes projectiles / makes them easier to reason about --- .../configuration_old/configuration.dm | 3 -- .../subsystem/processing/projectiles.dm | 3 ++ code/modules/admin/verbs/ticklag.dm | 3 -- .../mechanical/mecha/adv_dark_gygax.dm | 3 +- .../simple_mob/subtypes/slime/feral/feral.dm | 2 +- code/modules/projectiles/projectile.dm | 46 +++++++++++-------- code/modules/projectiles/projectile/arc.dm | 7 +-- .../modules/projectiles/projectile/bullets.dm | 13 ++---- code/modules/projectiles/projectile/hook.dm | 3 +- 9 files changed, 39 insertions(+), 44 deletions(-) diff --git a/code/controllers/configuration_old/configuration.dm b/code/controllers/configuration_old/configuration.dm index 95e30b2287e..d5f4efefc8f 100644 --- a/code/controllers/configuration_old/configuration.dm +++ b/code/controllers/configuration_old/configuration.dm @@ -596,9 +596,6 @@ if("socket_talk") socket_talk = text2num(value) - if("tickcomp") - Tickcomp = 1 - if("humans_need_surnames") humans_need_surnames = 1 diff --git a/code/controllers/subsystem/processing/projectiles.dm b/code/controllers/subsystem/processing/projectiles.dm index d0005da211b..adaf3945de0 100644 --- a/code/controllers/subsystem/processing/projectiles.dm +++ b/code/controllers/subsystem/processing/projectiles.dm @@ -4,3 +4,6 @@ PROCESSING_SUBSYSTEM_DEF(projectiles) stat_tag = "PP" priority = FIRE_PRIORITY_PROJECTILES subsystem_flags = SS_NO_INIT + + /// global projectile speed multiplier + var/global_projectile_speed_multiplier = 1 diff --git a/code/modules/admin/verbs/ticklag.dm b/code/modules/admin/verbs/ticklag.dm index 83f29b65c2c..61e9fdef27b 100644 --- a/code/modules/admin/verbs/ticklag.dm +++ b/code/modules/admin/verbs/ticklag.dm @@ -15,9 +15,6 @@ world.set_ticklag(newtick) feedback_add_details("admin_verb","TICKLAG") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! - switch(alert("Enable Tick Compensation?","Tick Comp is currently: [config_legacy.Tickcomp]","Yes","No")) - if("Yes") config_legacy.Tickcomp = 1 - else config_legacy.Tickcomp = 0 else to_chat(src, "Error: ticklag(): Invalid world.ticklag value. No changes made.") diff --git a/code/modules/mob/living/simple_mob/subtypes/mechanical/mecha/adv_dark_gygax.dm b/code/modules/mob/living/simple_mob/subtypes/mechanical/mecha/adv_dark_gygax.dm index f9d04e65ecb..bc4e027a9d7 100644 --- a/code/modules/mob/living/simple_mob/subtypes/mechanical/mecha/adv_dark_gygax.dm +++ b/code/modules/mob/living/simple_mob/subtypes/mechanical/mecha/adv_dark_gygax.dm @@ -124,7 +124,8 @@ damage = 20 damage_type = BURN damage_flag = ARMOR_LASER - speed = 32 // 10 tiles a second + speed = 5 * WORLD_ICON_SIZE + homing_turn_speed = 85 /obj/projectile/energy/homing_bolt/launch_projectile(atom/target, target_zone, mob/user, params, angle_override, forced_spread = 0) ..() diff --git a/code/modules/mob/living/simple_mob/subtypes/slime/feral/feral.dm b/code/modules/mob/living/simple_mob/subtypes/slime/feral/feral.dm index 479a70b9376..349fd1bfe42 100644 --- a/code/modules/mob/living/simple_mob/subtypes/slime/feral/feral.dm +++ b/code/modules/mob/living/simple_mob/subtypes/slime/feral/feral.dm @@ -68,7 +68,7 @@ damage_type = BRUTE damage_flag = ARMOR_MELEE armor_penetration = 30 - speed = 32 / 2 // ~5 tiles/second + speed = 7.5 * WORLD_ICON_SIZE icon_scale_x = 2 // It hits like a truck. icon_scale_y = 2 sharp = TRUE diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 4469da18408..b5ad45b8a1c 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -28,8 +28,8 @@ //* Physics - Configuration *// - /// speed, in pixels per decisecond - var/speed = 32 / 0.55 // ~18 tiles/second + /// speed, in pixels per second + var/speed = 25 * WORLD_ICON_SIZE /// are we a hitscan projectile? var/hitscan = FALSE /// angle, in degrees **clockwise of north** @@ -40,6 +40,24 @@ var/range = WORLD_ICON_SIZE * 50 // todo: lifespan + //* Physics - Homing *// + /// Are we homing in on something? + var/homing = FALSE + /// current homing target + var/atom/homing_target + /// angle per second + /// + /// * this is smoother the less time between SSprojectiles fires + var/homing_turn_speed = 100 + /// rand(min, max) for inaccuracy offsets + var/homing_inaccuracy_min = 0 + /// rand(min, max) for inaccuracy offsets + var/homing_inaccuracy_max = 0 + /// pixels; added to the real location of target so we're not exactly on-point + var/homing_offset_x = 0 + /// pixels; added to the real location of target so we're not exactly on-point + var/homing_offset_y = 0 + //* Physics - Tracers *// /// tracer /datum/point's @@ -138,17 +156,6 @@ var/impact_light_range = 2 var/impact_light_color_override - //Homing - var/homing = FALSE - var/atom/homing_target - // angle per deciseconds - // this is smoother the less time between SSprojectiles fires - var/homing_turn_speed = 10 - var/homing_inaccuracy_min = 0 //in pixels for these. offsets are set once when setting target. - var/homing_inaccuracy_max = 0 - var/homing_offset_x = 0 - var/homing_offset_y = 0 - //Targetting var/yo = null var/xo = null @@ -897,7 +904,7 @@ * sets our speed in pixels per decisecond */ /obj/projectile/proc/set_speed(new_speed) - speed = clamp(new_speed, 1, WORLD_ICON_SIZE * 5) + speed = clamp(new_speed, 1, WORLD_ICON_SIZE * 100) /** * sets our angle and speed @@ -949,8 +956,7 @@ /obj/projectile/process(delta_time) if(paused) return - delta_time *= 10 // sigh im fucking mad but whatever why are we using delta_time as seconds and not deciseconds - physics_iteration(delta_time * speed, delta_time) + physics_iteration(min(10 * WORLD_ICON_SIZE, delta_time * speed * SSprojectiles.global_projectile_speed_multiplier), delta_time) /** * immediately processes hitscan @@ -996,7 +1002,7 @@ */ /obj/projectile/proc/physics_iteration(pixels, delta_time, additional_animation_length) // setup iteration - var/safety = 10 + var/safety = 15 var/pixels_remaining = pixels distance_travelled_this_iteration = 0 @@ -1244,14 +1250,16 @@ GLOBAL_VAR_INIT(projectile_raycast_debug_visual_delay, 2 SECONDS) * todo: this has absolutely no arc/animation support; this is bad */ /obj/projectile/proc/physics_tick_homing(delta_time) + if(!homing) + return FALSE // checks if they're 1. on a turf, 2. on our z // todo: should we add support for tracking something even if it leaves a turf? if(homing_target?.z != z) // bye bye! return FALSE // todo: this assumes single-tile objects. at some point, we should upgrade this to be unnecessarily expensive and always center-mass. - var/dx = (homing_target.x - src.x) * WORLD_ICON_SIZE + (0 - current_px) - var/dy = (homing_target.y - src.y) * WORLD_ICON_SIZE + (0 - current_py) + var/dx = (homing_target.x - src.x) * WORLD_ICON_SIZE + (0 - current_px) + homing_offset_x + var/dy = (homing_target.y - src.y) * WORLD_ICON_SIZE + (0 - current_py) + homing_offset_y // say it with me, arctan() // is CCW of east if (dx, dy) // and CW of north if (dy, dx) diff --git a/code/modules/projectiles/projectile/arc.dm b/code/modules/projectiles/projectile/arc.dm index d4fb271b296..f0a0a86cbe8 100644 --- a/code/modules/projectiles/projectile/arc.dm +++ b/code/modules/projectiles/projectile/arc.dm @@ -11,10 +11,10 @@ icon_state = "fireball" // WIP movement_type = MOVEMENT_UNSTOPPABLE plane = ABOVE_PLANE // Since projectiles are 'in the air', they might visually overlap mobs while in flight, so the projectile needs to be above their plane. + speed = 10 * WORLD_ICON_SIZE var/fired_dir = null // Which direction was the projectile fired towards. Needed to invert the projectile turning based on if facing left or right. var/distance_to_fly = null // How far, in pixels, to fly for. Will call on_range() when this is passed. var/visual_y_offset = -16 // Adjusts how high the projectile and its shadow start, visually. This is so the projectile and shadow align with the center of the tile. - var/projectile_speed_modifier = 0.5 // Slows it down to make the arcing more noticable, and improve pixel calculation accuracy. var/obj/effect/projectile_shadow/shadow = null // Visual indicator for the projectile's 'true' position. Needed due to being bound to two dimensions in reality. /obj/projectile/arc/Bump() @@ -61,11 +61,6 @@ fired_dir = get_dir(source, target) distance_to_fly = calculate_initial_pixel_distance(source, target) - -/obj/projectile/arc/fire(angle, atom/direct_target) - ..() // The trajectory must exist for set_pixel_speed() to work. - set_speed(32 * projectile_speed_modifier) - /obj/projectile/arc/physics_iteration(pixels) // Do the other important stuff first. . = ..() diff --git a/code/modules/projectiles/projectile/bullets.dm b/code/modules/projectiles/projectile/bullets.dm index 759ec43f3a7..22c6f93641e 100644 --- a/code/modules/projectiles/projectile/bullets.dm +++ b/code/modules/projectiles/projectile/bullets.dm @@ -129,13 +129,10 @@ agony = 10 // brute easily heals, agony not so much armor_penetration = 30 // reduces shield blockchance accuracy = -20 // he do miss actually - // if the pathfinder gets a funny burst rifle, they deserve a rival - // ~25 tiles/second - speed = 32 / 0.4 + speed = 25 * WORLD_ICON_SIZE /obj/projectile/bullet/pistol/medium/ap/suppressor/turbo // spicy boys - // ~50 tiles/second - speed = 32 / 0.2 + speed = 50 * WORLD_ICON_SIZE /obj/projectile/bullet/pistol/strong // .357 and .44 caliber stuff. High power pistols like the Mateba or Desert Eagle. Sacrifice capacity for power. fire_sound = 'sound/weapons/weaponsounds_heavypistolshot.ogg' @@ -302,8 +299,7 @@ SA_bonus_damage = 45 // 70 total on animals. SA_vulnerability = MOB_CLASS_ANIMAL embed_chance = -1 - // ~25 tiles/second - speed = 32 / 0.4 + speed = 25 * WORLD_ICON_SIZE /obj/projectile/bullet/rifle/a762/silver // Hunting Demons with bolt action rifles. damage = 20 @@ -390,8 +386,7 @@ /obj/projectile/bullet/musket // Big Slow and bad against armor. fire_sound = 'sound/weapons/weaponsounds_heavypistolshot.ogg' damage = 60 - // ~8.3 tiles/second - speed = 32 / 1.2 + speed = 8.3 * WORLD_ICON_SIZE armor_penetration = -50 /obj/projectile/bullet/musket/silver // What its a classic diff --git a/code/modules/projectiles/projectile/hook.dm b/code/modules/projectiles/projectile/hook.dm index f01bdb90578..797063ec8ab 100644 --- a/code/modules/projectiles/projectile/hook.dm +++ b/code/modules/projectiles/projectile/hook.dm @@ -9,8 +9,7 @@ var/beam_state = "b_beam" damage = 5 - // ~5 tiles/second - speed = 32 / 2 + speed = 7.5 * WORLD_ICON_SIZE damage_type = BURN damage_flag = ARMOR_ENERGY armor_penetration = 15