From f65a97322e9debe2c9c155c4b7dd75a32809c6dc Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Tue, 31 Mar 2020 19:30:27 +0800 Subject: [PATCH 01/10] Add an alpha parameter to StatusBar.DrawBar --- wadsrc/static/zscript/ui/statusbar/statusbar.zs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wadsrc/static/zscript/ui/statusbar/statusbar.zs b/wadsrc/static/zscript/ui/statusbar/statusbar.zs index 131649a2f..4944104d8 100644 --- a/wadsrc/static/zscript/ui/statusbar/statusbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/statusbar.zs @@ -1019,7 +1019,7 @@ class BaseStatusBar native ui // //============================================================================ - void DrawBar(String ongfx, String offgfx, double curval, double maxval, Vector2 position, int border, int vertical, int flags = 0) + void DrawBar(String ongfx, String offgfx, double curval, double maxval, Vector2 position, int border, int vertical, int flags = 0, double alpha = 1.0) { let ontex = TexMan.CheckForTexture(ongfx, TexMan.TYPE_MiscPatch); if (!ontex.IsValid()) return; @@ -1050,17 +1050,17 @@ class BaseStatusBar native ui for(int i = 0; i < 4; i++) Clip[i] += border; //Draw the whole foreground - DrawTexture(ontex, position, flags | DI_ITEM_LEFT_TOP); + DrawTexture(ontex, position, flags | DI_ITEM_LEFT_TOP, alpha); SetClipRect(position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3], flags); } if (offtex.IsValid() && TexMan.GetScaledSize(offtex) == texsize) DrawTexture(offtex, position, flags | DI_ITEM_LEFT_TOP); - else Fill(color(255,0,0,0), position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3]); + else Fill(color(int(255*alpha),0,0,0), position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3]); - if (border == 0) + if (border == 0) { SetClipRect(position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3], flags); - DrawTexture(ontex, position, flags | DI_ITEM_LEFT_TOP); + DrawTexture(ontex, position, flags | DI_ITEM_LEFT_TOP, alpha); } // restore the previous clipping rectangle screen.SetClipRect(cx, cy, cw, ch); From d563b0339c236e3867500343123b5e4b825f369d Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Wed, 1 Apr 2020 01:45:28 +0800 Subject: [PATCH 02/10] Apply alpha to the background texture in DrawBar --- wadsrc/static/zscript/ui/statusbar/statusbar.zs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/zscript/ui/statusbar/statusbar.zs b/wadsrc/static/zscript/ui/statusbar/statusbar.zs index 4944104d8..c2ed4c6d9 100644 --- a/wadsrc/static/zscript/ui/statusbar/statusbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/statusbar.zs @@ -1054,7 +1054,7 @@ class BaseStatusBar native ui SetClipRect(position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3], flags); } - if (offtex.IsValid() && TexMan.GetScaledSize(offtex) == texsize) DrawTexture(offtex, position, flags | DI_ITEM_LEFT_TOP); + if (offtex.IsValid() && TexMan.GetScaledSize(offtex) == texsize) DrawTexture(offtex, position, flags | DI_ITEM_LEFT_TOP, alpha); else Fill(color(int(255*alpha),0,0,0), position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3]); if (border == 0) From 6b70cad6e1fc8d161e893f4e118f4e20d14e1622 Mon Sep 17 00:00:00 2001 From: arookas Date: Tue, 24 Mar 2020 23:21:26 -0400 Subject: [PATCH 03/10] Add option to invert mouse x --- src/d_main.cpp | 6 +++++- src/g_game.cpp | 1 + wadsrc/static/menudef.txt | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 163c9824f..bf2eb02df 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -171,6 +171,7 @@ EXTERN_CVAR (Bool, freelook) EXTERN_CVAR (Float, m_pitch) EXTERN_CVAR (Float, m_yaw) EXTERN_CVAR (Bool, invertmouse) +EXTERN_CVAR (Bool, invertmousex) EXTERN_CVAR (Bool, lookstrafe) EXTERN_CVAR (Int, screenblocks) EXTERN_CVAR (Bool, sv_cheats) @@ -449,7 +450,10 @@ void D_PostEvent (const event_t *ev) } if (!buttonMap.ButtonDown(Button_Strafe) && !lookstrafe) { - G_AddViewAngle (int(ev->x * m_yaw * mouse_sensitivity * 8.0), true); + int turn = int(ev->x * m_yaw * mouse_sensitivity * 8.0); + if (invertmousex) + turn = -turn; + G_AddViewAngle (turn, true); events[eventhead].x = 0; } if ((events[eventhead].x | events[eventhead].y) == 0) diff --git a/src/g_game.cpp b/src/g_game.cpp index 0bf781260..b29f67d6b 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -202,6 +202,7 @@ int lookspeed[2] = {450, 512}; CVAR (Bool, cl_run, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // Always run? CVAR (Bool, invertmouse, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // Invert mouse look down/up? +CVAR (Bool, invertmousex, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // Invert mouse look left/right? CVAR (Bool, freelook, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // Always mlook? CVAR (Bool, lookstrafe, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // Always strafe with mouse? CVAR (Float, m_pitch, 1.f, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // Mouse speeds diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index b59af595f..e7803545e 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -734,6 +734,7 @@ OptionMenu "MouseOptions" protected Slider "$MOUSEMNU_STRAFESPEED", "m_side", 0, 2.5, 0.1 StaticText "" Option "$MOUSEMNU_ALWAYSMOUSELOOK", "freelook", "OnOff" + Option "$MOUSEMNU_INVERTMOUSEX", "invertmousex", "OnOff" Option "$MOUSEMNU_INVERTMOUSE", "invertmouse", "OnOff" Option "$MOUSEMNU_LOOKSPRING", "lookspring", "OnOff" Option "$MOUSEMNU_LOOKSTRAFE", "lookstrafe", "OnOff" From 4b4ff8dd0e55178be233ab97d04bcaa28a425e63 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Thu, 30 Apr 2020 12:55:09 +0600 Subject: [PATCH 04/10] Fix bouncing missiles not dealing damage when hitting top/bottom (#1068) * Fix bouncing missiles not dealing damage when hitting top/bottom --- src/playsim/p_local.h | 1 + src/playsim/p_map.cpp | 84 +++++++++++++++++---------- src/playsim/p_mobj.cpp | 1 + wadsrc/static/zscript/actors/actor.zs | 1 + 4 files changed, 55 insertions(+), 32 deletions(-) diff --git a/src/playsim/p_local.h b/src/playsim/p_local.h index 0c7bb1bc7..2a031b689 100644 --- a/src/playsim/p_local.h +++ b/src/playsim/p_local.h @@ -246,6 +246,7 @@ extern TArray portalhit; int P_TestMobjLocation (AActor *mobj); int P_TestMobjZ (AActor *mobj, bool quick=true, AActor **pOnmobj = NULL); bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly = false); +void P_DoMissileDamage(AActor* inflictor, AActor* target); bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, bool actorsonly = false); AActor *P_CheckOnmobj (AActor *thing); void P_FakeZMovement (AActor *mo); diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index ae0eecef0..ac7b817d5 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -1230,6 +1230,57 @@ static bool CanAttackHurt(AActor *victim, AActor *shooter) return true; } +//========================================================================== +// +// P_DoMissileDamage +// Handle damaging/poisoning enemies from missiles. +// target is the target to be dealt damage to. +// inflictor is the actor dealing the damage. +// +//========================================================================== + +void P_DoMissileDamage(AActor* inflictor, AActor* target) +{ + // Do poisoning (if using new style poison) + if (inflictor->PoisonDamage > 0 && inflictor->PoisonDuration != INT_MIN) + { + P_PoisonMobj(target, inflictor, inflictor->target, inflictor->PoisonDamage, inflictor->PoisonDuration, inflictor->PoisonPeriod, inflictor->PoisonDamageType); + } + + // Do damage + int damage = inflictor->GetMissileDamage((inflictor->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1); + if ((damage > 0) || (inflictor->flags6 & MF6_FORCEPAIN) || (inflictor->flags7 & MF7_CAUSEPAIN)) + { + int newdam = P_DamageMobj(target, inflictor, inflictor->target, damage, inflictor->DamageType); + if (damage > 0) + { + if ((inflictor->flags5 & MF5_BLOODSPLATTER) && + !(target->flags & MF_NOBLOOD) && + !(target->flags2 & MF2_REFLECTIVE) && + !(target->flags2 & (MF2_INVULNERABLE | MF2_DORMANT)) && + !(inflictor->flags3 & MF3_BLOODLESSIMPACT) && + (pr_checkthing() < 192)) + { + P_BloodSplatter(inflictor->Pos(), target, inflictor->AngleTo(target)); + } + if (!(inflictor->flags3 & MF3_BLOODLESSIMPACT)) + { + P_TraceBleed(newdam > 0 ? newdam : damage, target, inflictor); + } + } + } + else + { + P_GiveBody(target, -damage); + } +} +DEFINE_ACTION_FUNCTION(AActor, DoMissileDamage) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_OBJECT_NOT_NULL(target, AActor); + P_DoMissileDamage(self, target); + return 0; +} //========================================================================== // // PIT_CheckThing @@ -1555,38 +1606,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch } } - // Do poisoning (if using new style poison) - if (tm.thing->PoisonDamage > 0 && tm.thing->PoisonDuration != INT_MIN) - { - P_PoisonMobj(thing, tm.thing, tm.thing->target, tm.thing->PoisonDamage, tm.thing->PoisonDuration, tm.thing->PoisonPeriod, tm.thing->PoisonDamageType); - } - - // Do damage - damage = tm.thing->GetMissileDamage((tm.thing->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1); - if ((damage > 0) || (tm.thing->flags6 & MF6_FORCEPAIN) || (tm.thing->flags7 & MF7_CAUSEPAIN)) - { - int newdam = P_DamageMobj(thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); - if (damage > 0) - { - if ((tm.thing->flags5 & MF5_BLOODSPLATTER) && - !(thing->flags & MF_NOBLOOD) && - !(thing->flags2 & MF2_REFLECTIVE) && - !(thing->flags2 & (MF2_INVULNERABLE | MF2_DORMANT)) && - !(tm.thing->flags3 & MF3_BLOODLESSIMPACT) && - (pr_checkthing() < 192)) - { - P_BloodSplatter(tm.thing->Pos(), thing, tm.thing->AngleTo(thing)); - } - if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT)) - { - P_TraceBleed(newdam > 0 ? newdam : damage, thing, tm.thing); - } - } - } - else - { - P_GiveBody(thing, -damage); - } + P_DoMissileDamage(tm.thing, thing); if ((thing->flags7 & MF7_THRUREFLECT) && (thing->flags2 & MF2_REFLECTIVE) && (tm.thing->flags & MF_MISSILE)) { diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 0f6f32e9d..c98bc9c7b 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -3976,6 +3976,7 @@ void AActor::Tick () // to be in line with the case when an actor's side is hit. if (!res && (flags & MF_MISSILE)) { + P_DoMissileDamage(this, onmo); P_ExplodeMissile(this, nullptr, onmo); } } diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 0b3841a19..27a929fdd 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -759,6 +759,7 @@ class Actor : Thinker native native void GiveSecret(bool printmsg = true, bool playsound = true); native clearscope double GetCameraHeight() const; native clearscope double GetGravity() const; + native void DoMissileDamage(Actor target); //========================================================================== // From 331f3d85d61fb52c571afbdb9f76a8da8a834ca4 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 30 Apr 2020 16:26:12 +0300 Subject: [PATCH 05/10] - fixed secondary ammo display in strife status bar https://forum.zdoom.org/viewtopic.php?t=68315 --- wadsrc/static/zscript/ui/statusbar/strife_sbar.zs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/zscript/ui/statusbar/strife_sbar.zs b/wadsrc/static/zscript/ui/statusbar/strife_sbar.zs index 79fc0ada4..912effbb4 100644 --- a/wadsrc/static/zscript/ui/statusbar/strife_sbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/strife_sbar.zs @@ -353,8 +353,8 @@ class StrifeStatusBar : BaseStatusBar if (ammo2 != NULL && ammo1!=ammo2) { // Draw secondary ammo just above the primary ammo - DrawString(mGrnFont, FormatNumber(ammo1.Amount, 3), (-23, -48)); - DrawInventoryIcon(ammo1, (-14, -55)); + DrawString(mGrnFont, FormatNumber(ammo2.Amount, 3), (-23, -48)); + DrawInventoryIcon(ammo2, (-14, -55)); } } From a528290b5c6e1bae4179756adb56beeedc1cfa22 Mon Sep 17 00:00:00 2001 From: PaulyB <43163391+3saster@users.noreply.github.com> Date: Sat, 2 May 2020 23:22:44 -0700 Subject: [PATCH 06/10] Fix single top level filter folder not being read I have no idea why the missing comma broke it in this particular way... --- src/d_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index bf2eb02df..eee2b3647 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -186,7 +186,7 @@ extern bool insave; extern TDeletingArray LightDefaults; const char* iwad_folders[13] = { "flats/", "textures/", "hires/", "sprites/", "voxels/", "colormaps/", "acs/", "maps/", "voices/", "patches/", "graphics/", "sounds/", "music/" }; -const char* iwad_reserved[12] = { "mapinfo", "zmapinfo", "gameinfo", "sndinfo", "sbarinfo", "menudef", "gldefs", "animdefs", "decorate", "zscript", "iwadinfo" "maps/" }; +const char* iwad_reserved[12] = { "mapinfo", "zmapinfo", "gameinfo", "sndinfo", "sbarinfo", "menudef", "gldefs", "animdefs", "decorate", "zscript", "iwadinfo", "maps/" }; CUSTOM_CVAR(Float, i_timescale, 1.0f, CVAR_NOINITCALL) From 50e0353668738c54e7f3e6bbaf6bf3f399e368fb Mon Sep 17 00:00:00 2001 From: Nemrtvi <26684396+Nemrtvi@users.noreply.github.com> Date: Wed, 6 May 2020 10:55:44 +0200 Subject: [PATCH 07/10] =?UTF-8?q?Revised=20Serbian=20characters=20=D0=8B/?= =?UTF-8?q?=D0=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filter/doom.id/fonts/bigfont/0402.lmp | Bin 281 -> 301 bytes .../filter/doom.id/fonts/bigfont/040B.lmp | Bin 279 -> 297 bytes .../filter/doom.id/fonts/bigupper/0402.lmp | Bin 376 -> 404 bytes .../filter/doom.id/fonts/bigupper/040B.lmp | Bin 368 -> 397 bytes .../filter/doom.id/fonts/bigupper/0452.lmp | Bin 281 -> 301 bytes .../filter/doom.id/fonts/bigupper/045B.lmp | Bin 279 -> 297 bytes 6 files changed, 0 insertions(+), 0 deletions(-) diff --git a/wadsrc_extra/static/filter/doom.id/fonts/bigfont/0402.lmp b/wadsrc_extra/static/filter/doom.id/fonts/bigfont/0402.lmp index a00a09d09988ad747ef8e578264644a5d6582d23..e159c4c17faf44240992bdb8e1e3cd16c17e9905 100644 GIT binary patch literal 301 zcmYk0%MHRX3_y)k3Wp+b<<2l18%0qS5-Acw9Ks5$zzVFu3ar2itiS-}IpOE(RnBwl zcqyG|Y{0-4j&OoAT;K{fxWfaUAQO=VtY8h&~m zHhzS)+;Kl)eBg`W+hXXAt`06U^toXE#DIwG5fAU7T1yDOM>KP-`s8#6Jp|*1P%1O7 Qk?StgmfR=REu9+U3uSm*X#fBK literal 281 zcmYL@!3hE}5Je-p=CUC6o6o5Ru+Y+z!q%57Hq*5Y{3>Rz(f4WX7$4h!z1&P zm1h6wIYT`o6jn!gySTPbq2UF z3FkWGFD!ek1piyH*rjePE~WW7CXv|J4ubI93+=1Omj|Xm2Z%I8qWo{i z_STF>;{Xs`gma&9+X=RnlhK@neSg5je4*-vd6)g!3Gd;n3RAt0 IBX#-77m@{5{{R30 diff --git a/wadsrc_extra/static/filter/doom.id/fonts/bigupper/0402.lmp b/wadsrc_extra/static/filter/doom.id/fonts/bigupper/0402.lmp index 4f72414a26a931d8cd3dcc9177d4c6449f546c1a..23ca1421525be18a0f18e97e991f00f703e200e1 100644 GIT binary patch literal 404 zcmZ9GJx&BM426Tx{y?+Mb{v93aDj&E3sR6^{>Xa#vv{rg@T!CJ{t)&iPLxib+)wz079Cwx<$rL`%1| z&K{cUu%ajz&%I%2vq38cZ6X_*L|-w2LD=PtB S6^h=uS;tcN)V96uHtiRG%7Cu` literal 376 zcmZ9I%?$z}5QQ=E_hjP9A}qoZ7Fh%wHe@%RIPBRXEW#oz!Xhlf4%Rp0E(a(1;N|5F z1MJjRaaG^~uAm1ua0d_Y1TXLgA26ROwFd`q1U2YD57Z+6YGCEsF6Td`JMp$TiyGtD z2E|@VDaJ^IC5>K{5(Ve1v!)7@7r3l7TI=Fj%bi3a(A295(+p9$6=s+u9wJgQ*A_38 w`0a z9`I53?sPwUGa2d#GI$4{;0v6=1zf>5_yND5-x+fNPv9B601w{42RH%KmAfhYx zBAZ)oDy2p1@Ay>1oT|ncL%^eJZdMKAz4LCFWy=ZW++wZ$%Q?r+5JbY(YXi2uCcacP zV=0R=r(v~@HmlvL5jMrm3acr)b#I%JqF_E%yAf5aj7fP0ZT5mIWQKisgl&%F`hj~i LB_22Q>~E?!ga>`U literal 368 zcmZ9G%?$z}5QXvJ>UwY!ORxxw@U&#Z0uF@iMlW;lY!Mb=5f)()7GVeYV1HtqTx7mDn;QYaD}em3a;P^uHXs|AQJzisUCdC@p1Pj zE2@a-6E^5uumfjs0Ry;#8@Pi9c!C#rgK|c+2DH#rAr9uK8mLmOWwfzp!KtL3L~U#h zte=Fn4eBq9IGlL*J2ANBW(-cD@i}4Dw#yj|;iOaEXAzfsVb2GMqEz*Q$UL8%NRN40 NV5yBCE9WUad;xMwS-JoK diff --git a/wadsrc_extra/static/filter/doom.id/fonts/bigupper/045B.lmp b/wadsrc_extra/static/filter/doom.id/fonts/bigupper/045B.lmp index 4687f235651967ee302bc14ac820c00e08d12673..cd1b9de37475c79ea0c97281d63db0e87a639e98 100644 GIT binary patch literal 297 zcmYL@%?ScA5JpFER}Xs-3$PxK8$t*%fd!AT1zWHMTd)NiumM}J0WT8YB&;U9FyEK? z+sGgypR(sQaDWq>;R08GWLuzuZagjCSXcmpuBRsPcJJjx)G|ihW`AsJH+DJuo&Uu}y UVhYX&72OJvLedTUzKtRL0`J*fzyJUM literal 279 zcmYL^;RymU422`=c|Q(a%D=*ua)!|Ap@>2za0ORz1y^tZS8xRf@R!urYpa1TJRW%o zSx`enpRhzU2&x=NY%1U|TsE#X;EjJ4{Sxs$Q5kSs$J77P_i1 K)%!S7mruT~;8^ Date: Mon, 30 Mar 2020 14:27:36 +0300 Subject: [PATCH 08/10] Add optional direction parameters for SprayDecal and its A_SprayDecal zscript counterpart --- src/playsim/a_decals.cpp | 21 +++++++++++++++------ src/playsim/a_sharedglobal.h | 2 +- src/playsim/p_actionfunctions.cpp | 5 ++++- wadsrc/static/zscript/actors/actor.zs | 2 +- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/playsim/a_decals.cpp b/src/playsim/a_decals.cpp index fc712a5d8..1eb5a588e 100644 --- a/src/playsim/a_decals.cpp +++ b/src/playsim/a_decals.cpp @@ -830,14 +830,23 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl // //---------------------------------------------------------------------------- -void SprayDecal(AActor *shooter, const char *name, double distance) +void SprayDecal(AActor *shooter, const char *name, double distance, double DirX, double DirY, double DirZ) { FTraceResults trace; - - DAngle ang = shooter->Angles.Yaw; - DAngle pitch = shooter->Angles.Pitch; - double c = pitch.Cos(); - DVector3 vec(c * ang.Cos(), c * ang.Sin(), -pitch.Sin()); + DVector3 vec; + //use new behavior only if directional vector not equal to zero vector + if (DirX != 0 || DirY != 0 || DirZ != 0) + { + vec = DVector3(DirX, DirY, DirZ); + } + + else + { + DAngle ang = shooter->Angles.Yaw; + DAngle pitch = shooter->Angles.Pitch; + double c = pitch.Cos(); + vec = DVector3(c * ang.Cos(), c * ang.Sin(), -pitch.Sin()); + } if (Trace(shooter->PosPlusZ(shooter->Height / 2), shooter->Sector, vec, distance, 0, ML_BLOCKEVERYTHING, shooter, trace, TRACE_NoSky)) { diff --git a/src/playsim/a_sharedglobal.h b/src/playsim/a_sharedglobal.h index 9396b10a8..1246255ea 100644 --- a/src/playsim/a_sharedglobal.h +++ b/src/playsim/a_sharedglobal.h @@ -12,7 +12,7 @@ class DBaseDecal; struct SpreadInfo; DBaseDecal *ShootDecal(FLevelLocals *Level, const FDecalTemplate *tpl, sector_t *sec, double x, double y, double z, DAngle angle, double tracedist, bool permanent); -void SprayDecal(AActor *shooter, const char *name,double distance = 172.); +void SprayDecal(AActor *shooter, const char *name,double distance = 172., double DirX = 0., double DirY = 0., double DirZ = 0.); class DBaseDecal : public DThinker { diff --git a/src/playsim/p_actionfunctions.cpp b/src/playsim/p_actionfunctions.cpp index 78dce5852..047aed2a5 100644 --- a/src/playsim/p_actionfunctions.cpp +++ b/src/playsim/p_actionfunctions.cpp @@ -4917,7 +4917,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SprayDecal) PARAM_SELF_PROLOGUE(AActor); PARAM_STRING(name); PARAM_FLOAT(dist); - SprayDecal(self, name, dist); + PARAM_FLOAT(DirX); + PARAM_FLOAT(DirY); + PARAM_FLOAT(DirZ); + SprayDecal(self, name, dist, DirX, DirY, DirZ); return 0; } diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 27a929fdd..28dd0b295 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1157,7 +1157,7 @@ class Actor : Thinker native native bool A_SetVisibleRotation(double anglestart = 0, double angleend = 0, double pitchstart = 0, double pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetTranslation(name transname); native bool A_SetSize(double newradius = -1, double newheight = -1, bool testpos = false); - native void A_SprayDecal(String name, double dist = 172); + native void A_SprayDecal(String name, double dist = 172, double DirX = 0, double DirY = 0, double DirZ = 0); native void A_SetMugshotState(String name); native void CopyBloodColor(Actor other); From 0e9ca3c850668441b1175955e2c8570802bc2d22 Mon Sep 17 00:00:00 2001 From: Mekboss Date: Mon, 30 Mar 2020 18:52:27 +0300 Subject: [PATCH 09/10] Replace function variables to DVector3 --- src/playsim/a_decals.cpp | 6 +++--- src/playsim/a_sharedglobal.h | 2 +- src/playsim/p_actionfunctions.cpp | 2 +- wadsrc/static/zscript/actors/actor.zs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/playsim/a_decals.cpp b/src/playsim/a_decals.cpp index 1eb5a588e..03fd79ebd 100644 --- a/src/playsim/a_decals.cpp +++ b/src/playsim/a_decals.cpp @@ -830,14 +830,14 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl // //---------------------------------------------------------------------------- -void SprayDecal(AActor *shooter, const char *name, double distance, double DirX, double DirY, double DirZ) +void SprayDecal(AActor *shooter, const char *name, double distance, DVector3 Dir) { FTraceResults trace; DVector3 vec; //use new behavior only if directional vector not equal to zero vector - if (DirX != 0 || DirY != 0 || DirZ != 0) + if (!Dir.isZero() ) { - vec = DVector3(DirX, DirY, DirZ); + vec = Dir; } else diff --git a/src/playsim/a_sharedglobal.h b/src/playsim/a_sharedglobal.h index 1246255ea..0ca4673b9 100644 --- a/src/playsim/a_sharedglobal.h +++ b/src/playsim/a_sharedglobal.h @@ -12,7 +12,7 @@ class DBaseDecal; struct SpreadInfo; DBaseDecal *ShootDecal(FLevelLocals *Level, const FDecalTemplate *tpl, sector_t *sec, double x, double y, double z, DAngle angle, double tracedist, bool permanent); -void SprayDecal(AActor *shooter, const char *name,double distance = 172., double DirX = 0., double DirY = 0., double DirZ = 0.); +void SprayDecal(AActor *shooter, const char *name,double distance = 172., DVector3 Dir = (0, 0, 0) ); class DBaseDecal : public DThinker { diff --git a/src/playsim/p_actionfunctions.cpp b/src/playsim/p_actionfunctions.cpp index 047aed2a5..c1a2015af 100644 --- a/src/playsim/p_actionfunctions.cpp +++ b/src/playsim/p_actionfunctions.cpp @@ -4920,7 +4920,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SprayDecal) PARAM_FLOAT(DirX); PARAM_FLOAT(DirY); PARAM_FLOAT(DirZ); - SprayDecal(self, name, dist, DirX, DirY, DirZ); + SprayDecal(self, name, dist, DVector3(DirX, DirY, DirZ) ); return 0; } diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 28dd0b295..02aaab205 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1157,7 +1157,7 @@ class Actor : Thinker native native bool A_SetVisibleRotation(double anglestart = 0, double angleend = 0, double pitchstart = 0, double pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetTranslation(name transname); native bool A_SetSize(double newradius = -1, double newheight = -1, bool testpos = false); - native void A_SprayDecal(String name, double dist = 172, double DirX = 0, double DirY = 0, double DirZ = 0); + native void A_SprayDecal(String name, double dist = 172, vector3 Dir = (0, 0, 0) ); native void A_SetMugshotState(String name); native void CopyBloodColor(Actor other); From 4807f4240b7e972c05ca47770f83619cde9a8bbf Mon Sep 17 00:00:00 2001 From: Mekboss Date: Tue, 7 Apr 2020 23:11:49 +0300 Subject: [PATCH 10/10] Fix MSVS compile bug and add offset parameter for SprayDecal --- src/playsim/a_decals.cpp | 31 ++++++++++++++++++--------- src/playsim/a_sharedglobal.h | 2 +- src/playsim/p_actionfunctions.cpp | 11 ++++++---- wadsrc/static/zscript/actors/actor.zs | 2 +- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/playsim/a_decals.cpp b/src/playsim/a_decals.cpp index 03fd79ebd..b9e54d25a 100644 --- a/src/playsim/a_decals.cpp +++ b/src/playsim/a_decals.cpp @@ -830,25 +830,36 @@ DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, doubl // //---------------------------------------------------------------------------- -void SprayDecal(AActor *shooter, const char *name, double distance, DVector3 Dir) +void SprayDecal(AActor *shooter, const char *name, double distance, DVector3 offset, DVector3 direction) { + //just in case + if (!shooter) + return; + FTraceResults trace; - DVector3 vec; - //use new behavior only if directional vector not equal to zero vector - if (!Dir.isZero() ) - { - vec = Dir; - } - + DVector3 off(0, 0, 0), dir(0, 0, 0); + + //use vanilla offset only if "custom" equal to zero + if (offset.isZero() ) + off = shooter->PosPlusZ(shooter->Height / 2); + else + off = shooter->Pos() + offset; + + //same for direction + if (direction.isZero() ) { DAngle ang = shooter->Angles.Yaw; DAngle pitch = shooter->Angles.Pitch; double c = pitch.Cos(); - vec = DVector3(c * ang.Cos(), c * ang.Sin(), -pitch.Sin()); + dir = DVector3(c * ang.Cos(), c * ang.Sin(), -pitch.Sin()); } + + else + dir = direction; - if (Trace(shooter->PosPlusZ(shooter->Height / 2), shooter->Sector, vec, distance, 0, ML_BLOCKEVERYTHING, shooter, trace, TRACE_NoSky)) + + if (Trace(off, shooter->Sector, dir, distance, 0, ML_BLOCKEVERYTHING, shooter, trace, TRACE_NoSky)) { if (trace.HitType == TRACE_HitWall) { diff --git a/src/playsim/a_sharedglobal.h b/src/playsim/a_sharedglobal.h index 0ca4673b9..955d8d900 100644 --- a/src/playsim/a_sharedglobal.h +++ b/src/playsim/a_sharedglobal.h @@ -12,7 +12,7 @@ class DBaseDecal; struct SpreadInfo; DBaseDecal *ShootDecal(FLevelLocals *Level, const FDecalTemplate *tpl, sector_t *sec, double x, double y, double z, DAngle angle, double tracedist, bool permanent); -void SprayDecal(AActor *shooter, const char *name,double distance = 172., DVector3 Dir = (0, 0, 0) ); +void SprayDecal(AActor *shooter, const char *name,double distance = 172., DVector3 offset = DVector3(0., 0., 0.), DVector3 direction = DVector3(0., 0., 0.) ); class DBaseDecal : public DThinker { diff --git a/src/playsim/p_actionfunctions.cpp b/src/playsim/p_actionfunctions.cpp index c1a2015af..5983e77a9 100644 --- a/src/playsim/p_actionfunctions.cpp +++ b/src/playsim/p_actionfunctions.cpp @@ -4917,10 +4917,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SprayDecal) PARAM_SELF_PROLOGUE(AActor); PARAM_STRING(name); PARAM_FLOAT(dist); - PARAM_FLOAT(DirX); - PARAM_FLOAT(DirY); - PARAM_FLOAT(DirZ); - SprayDecal(self, name, dist, DVector3(DirX, DirY, DirZ) ); + PARAM_FLOAT(offset_x); + PARAM_FLOAT(offset_y); + PARAM_FLOAT(offset_z); + PARAM_FLOAT(direction_x); + PARAM_FLOAT(direction_y); + PARAM_FLOAT(direction_z); + SprayDecal(self, name, dist, DVector3(offset_x, offset_y, offset_z), DVector3(direction_x, direction_y, direction_z) ); return 0; } diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 02aaab205..b80415cbd 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1157,7 +1157,7 @@ class Actor : Thinker native native bool A_SetVisibleRotation(double anglestart = 0, double angleend = 0, double pitchstart = 0, double pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetTranslation(name transname); native bool A_SetSize(double newradius = -1, double newheight = -1, bool testpos = false); - native void A_SprayDecal(String name, double dist = 172, vector3 Dir = (0, 0, 0) ); + native void A_SprayDecal(String name, double dist = 172, vector3 offset = (0, 0, 0), vector3 direction = (0, 0, 0) ); native void A_SetMugshotState(String name); native void CopyBloodColor(Actor other);