From e6d180821867fe313f98653e80d54da1c9e35aef Mon Sep 17 00:00:00 2001 From: Marisa the Magician Date: Wed, 26 Oct 2022 14:17:19 +0200 Subject: [PATCH] Add slider for healthbar fade distance. --- cvarinfo.base | 1 + language.def_menu | 2 ++ language.es_menu | 2 ++ language.version | 4 ++-- menudef.txt | 3 ++- zscript/hud/swwm_hud.zsc | 9 +++++++++ zscript/swwm_common.zsc | 11 +++++++---- 7 files changed, 25 insertions(+), 7 deletions(-) diff --git a/cvarinfo.base b/cvarinfo.base index d0e845aba..45bf3b2c8 100644 --- a/cvarinfo.base +++ b/cvarinfo.base @@ -85,6 +85,7 @@ server bool swwm_bonkhammer = false; // combat hammer makes bonk sounds when hi server int swwm_friendlyfire = 0; // 0: allow all friendly fire, 1: block incoming damage, 2: block incoming and outgoing damage nosave bool swwm_showmaptitle = false; // shows the name of the map when entering, just like in dark souls! server bool swwm_lobdoubled = false; // [LOB] Enable Double Death monster spawns +nosave int swwm_bardist = 2000; // distance at which healthbars will be visible (does not affect player bars) // minimap settings nosave bool swwm_mm_enable = true; // show a minimap below the score counter diff --git a/language.def_menu b/language.def_menu index 4ba96f61b..4e3ea372b 100644 --- a/language.def_menu +++ b/language.def_menu @@ -188,6 +188,7 @@ SWWM_FF_ALL = "Block All"; SWWM_DAMNUMS_COLOR = "Color Damage Numbers"; SWWM_SHOWMAPTITLE = "Animated Map Title"; SWWM_LOBDOUBLED = "LOB Double Death"; +SWWM_BARDIST = "Healthbar Distance"; SWWM_MM_ENABLE = "Show Minimap"; SWWM_MM_MISSILES = "Projectiles In Minimap"; SWWM_MM_COLORSET = "Minimap Color Set"; @@ -287,6 +288,7 @@ TOOLTIP_SWWM_FRIENDLYFIRE = "Controls whether friendlies can deal damage to or t TOOLTIP_SWWM_DAMNUMS_COLOR = "Damage numbers will change color based on the type of damage dealt. Otherwise, default to red."; TOOLTIP_SWWM_SHOWMAPTITLE = "Shows an animated title card when entering a map. It's just like Dark Souls!"; TOOLTIP_SWWM_LOBDOUBLED = "[Legion of Bones] Enables \"Double Death\", which makes enemies first spawn as their vanilla variants to then turn undead on defeat."; +TOOLTIP_SWWM_BARDIST = "Distance in map units at which healthbar visibility will begin to fade. Does not affect the healthbars of other players."; TOOLTIP_SWWMACHIEVEMENTMENU = "View your achievements."; TOOLTIP_SWWM_MM_ENABLE = "Displays a minimap on the top right corner of the screen."; TOOLTIP_SWWM_MM_MISSILES = "Displays projectiles in the minimap. Can be toggled if this clutters too much."; diff --git a/language.es_menu b/language.es_menu index d2fbeb18d..cf906f42c 100644 --- a/language.es_menu +++ b/language.es_menu @@ -185,6 +185,7 @@ SWWM_FF_ALL = "Bloquear Todo"; SWWM_DAMNUMS_COLOR = "Colorear Números de Daño"; SWWM_SHOWMAPTITLE = "Título de Mapa Animado"; SWWM_LOBDOUBLED = "LOB Doble Muerte"; +SWWM_BARDIST = "Distancia de Barras de Salud"; SWWM_MM_ENABLE = "Mostrar Minimapa"; SWWM_MM_MISSILES = "Proyectiles en Minimapa"; SWWM_MM_COLORSET = "Set de Colores de Minimapa"; @@ -285,6 +286,7 @@ TOOLTIP_SWWM_FRIENDLYFIRE = "Controla el que los aliados puedan causar daño o s TOOLTIP_SWWM_DAMNUMS_COLOR = "Los números de daño cambiarán color en base al tipo de daño. De lo contrario, serán siempre rojos."; TOOLTIP_SWWM_SHOWMAPTITLE = "Muestra una animación de título al entrar en un mapa. ¡Es igualito que Dark Souls!"; TOOLTIP_SWWM_LOBDOUBLED = "[Legion of Bones] Habilita \"Doble Muerte\", lo cual hace que los enemigos aparezcan primero como sus variantes vanilla para luego volverse no-muertos al derrotarlos."; +TOOLTIP_SWWM_BARDIST = "Distancia en unidades de mapa a la cual la visibilidad de las barras de salud irá desvaneciendo. No afecta a las barras de salud de otros jugadores."; TOOLTIP_SWWMACHIEVEMENTMENU = "Revisa tus logros."; TOOLTIP_SWWM_MM_ENABLE = "Muestra un minimapa en la esquina superior derecha de la pantalla."; TOOLTIP_SWWM_MM_MISSILES = "Muestra proyectiles en el minimapa. Puede ser desactivado si causa problemas de visibilidad."; diff --git a/language.version b/language.version index 9e3e1b032..40fce46f8 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r589 \cu(Tue 25 Oct 10:56:43 CEST 2022)\c-"; -SWWM_SHORTVER="\cw1.3pre r589 \cu(2022-10-25 10:56:43)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r590 \cu(Wed 26 Oct 14:17:19 CEST 2022)\c-"; +SWWM_SHORTVER="\cw1.3pre r590 \cu(2022-10-26 14:17:19)\c-"; diff --git a/menudef.txt b/menudef.txt index 44d7f7eea..b55141eda 100644 --- a/menudef.txt +++ b/menudef.txt @@ -153,6 +153,7 @@ OptionMenu "SWWMOptionMenu" Option "$SWWM_MM_MISSILES", "swwm_mm_missiles", "YesNo" Option "$SWWM_MM_COLORSET", "swwm_mm_colorset", "SWWMMinimapColorset" Option "$SWWM_TARGET", "swwm_targeter", "SWWMTarget" + ScaleSliderFix "$SWWM_BARDIST", "swwm_bardist", 0, 4000, 100, "$SWWM_UNLIMITED" Option "$SWWM_TARGETTAG", "swwm_targettags", "YesNo" Option "$SWWM_BIGTAGS", "swwm_bigtags", "YesNo" Option "$SWWM_DAMNUMS", "swwm_damnums", "YesNo" @@ -175,7 +176,7 @@ OptionMenu "SWWMOptionMenu" StaticText " " StaticText "$SWWM_ETITLE", 1 Option "$SWWM_SHADOWS", "swwm_shadows", "YesNo" - ScaleSlider "$SWWM_SHADOWDIST", "swwm_shadowdist", -1, 4000, 1, "$SWWM_NONE", "$SWWM_UNLIMITED" + ScaleSliderFix "$SWWM_SHADOWDIST", "swwm_shadowdist", -1, 4000, 100, "$SWWM_NONE", "$SWWM_UNLIMITED" Option "$SWWM_ITEMSPARKLES", "swwm_itemsparkles", "YesNo" Option "$SWWM_ITEMGLOWS", "swwm_itemglows", "YesNo" Option "$SWWM_BLOOD", "swwm_blood", "YesNo" diff --git a/zscript/hud/swwm_hud.zsc b/zscript/hud/swwm_hud.zsc index 39b01faf4..60ed3bd1f 100644 --- a/zscript/hud/swwm_hud.zsc +++ b/zscript/hud/swwm_hud.zsc @@ -1467,6 +1467,7 @@ Class SWWMStatusBar : BaseStatusBar else cti.Reinit(); SWWMQuickCombatTracker ct; bool onlyfriends = (swwm_targeter >= 2); + int fadedist = swwm_bardist; while ( ct = SWWMQuickCombatTracker(cti.Next()) ) { // this ensures that projection data isn't cached if there are no target array elements, to avoid needless GC thrashing @@ -1492,6 +1493,9 @@ Class SWWMStatusBar : BaseStatusBar Vector3 smpos = level.Vec3Offset(SWWMUtility.LerpVector3(ct.Owner.prev,ct.Owner.pos,fractic),(0,0,ct.lvheight)); Vector3 tdir = level.Vec3Diff(viewpos,smpos); if ( viewvec dot tdir < 0 ) continue; + // ignore trackers that are too far away + double dist = tdir.length(); + if ( (fadedist > 0) && (dist > fadedist*1.5) ) continue; Vector3 ndc = SWWMUtility.ProjectPoint(projdata,viewpos+tdir); if ( ndc.z >= 1. ) continue; Vector2 vpos = SWWMUtility.NDCToViewport(projdata,ndc)/hs1; @@ -1499,6 +1503,11 @@ Class SWWMStatusBar : BaseStatusBar double fin = clamp(ct.fadein+fractic,0.,5.)/5.; double fout = clamp(ct.lifespan-fractic,0.,25.)/25.; double alph = fin*fout; + if ( fadedist > 0 ) + { + double df = 1.-(clamp((dist-fadedist)/fadedist,0.,.5)*2.); + alph *= df; + } Vector2 barpos = vpos-(27,7); if ( swwm_targettags && (ct.mytag != "") ) { diff --git a/zscript/swwm_common.zsc b/zscript/swwm_common.zsc index 70e6d413f..2a4a7c417 100644 --- a/zscript/swwm_common.zsc +++ b/zscript/swwm_common.zsc @@ -356,15 +356,18 @@ Class SWWMQuickCombatTracker : Inventory t = tt; break; } + // must exclude players (unless they're voodoo dolls) + // this is mainly for deathmatch so players you hit don't become easy to track when out of view + bool realmonster = target.bISMONSTER&&(!target.player||(target.player&&(target.player.mo!=target))); if ( t ) { // re-fade in if ( t.lifespan < 20 ) t.fadein = t.lifespan/4; - t.lifespan = max(t.lifespan,target.bISMONSTER?((damage>0)?700:70):((damage>0)?140:35)); + t.lifespan = max(t.lifespan,realmonster?((damage>0)?700:70):((damage>0)?140:35)); if ( damage > 0 ) { t.cummdamage += damage; - t.cummspan = target.bISMONSTER?120:30; + t.cummspan = realmonster?120:30; t.cummflash = 15; } return t; @@ -381,12 +384,12 @@ Class SWWMQuickCombatTracker : Inventory if ( damage > 0 ) { t.cummdamage = damage; - t.cummspan = target.bISMONSTER?120:30; + t.cummspan = realmonster?120:30; t.cummflash = 15; } t.intp = SmoothDynamicValueInterpolator.Create(t.lasthealth,.5); t.intpl = SmoothLinearValueInterpolator.Create(t.laghealth[9],max(1,t.maxhealth/50)); - t.lifespan = target.bISMONSTER?((damage>0)?700:70):((damage>0)?140:35); + t.lifespan = realmonster?((damage>0)?700:70):((damage>0)?140:35); t.fadein = 0; t.lvheight = target.Height; t.UpdateTag(hnd);