From 51726864fe0aa0593bca122e30f58441dbc2099e Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Mon, 1 Feb 2021 14:34:52 +0100 Subject: [PATCH] Allow players to remove Nazi textures by using them. --- language.version | 4 +- zscript/swwm_player.zsc | 148 +++++++++++++++++++++++++++++++++++++++ zscript/swwm_utility.zsc | 12 ++++ 3 files changed, 162 insertions(+), 2 deletions(-) diff --git a/language.version b/language.version index b120a060d..33a54f1d3 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r245 \cu(Mon 1 Feb 13:38:23 CET 2021)\c-"; -SWWM_SHORTVER="\cw0.9.11b-pre r245 \cu(2021-02-01 13:38:23)\c-"; +SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r246 \cu(Mon 1 Feb 14:34:52 CET 2021)\c-"; +SWWM_SHORTVER="\cw0.9.11b-pre r246 \cu(2021-02-01 14:34:52)\c-"; diff --git a/zscript/swwm_player.zsc b/zscript/swwm_player.zsc index 7c1a088a3..9e09dac18 100644 --- a/zscript/swwm_player.zsc +++ b/zscript/swwm_player.zsc @@ -455,6 +455,48 @@ Class Demolitionist : PlayerPawn SWWMItemSense.Spawn(self,i); } } + void CheckNaziRemove() + { + if ( player.usedown ) + return; + FLineTraceData d; + LineTrace(angle,DEFMELEERANGE*2,pitch,TRF_THRUACTORS,player.viewheight,data:d); + if ( d.HitType == TRACE_HitNone ) return; + bool remove; + TextureID replacewith; + [remove, replacewith] = SWWMUtility.NaziTexRemover(d.HitTexture); + if ( !remove ) return; + player.usedown = true; + A_StartSound("bestsound",CHAN_ITEMEXTRA,CHANF_OVERLAP); + if ( d.HitType == TRACE_HitWall ) + { + if ( d.Hit3DFloor ) + { + if ( d.Hit3DFloor.flags&F3DFloor.FF_UPPERTEXTURE ) d.HitLine.sidedef[d.LineSide].SetTexture(0,replacewith); + else if ( d.Hit3DFloor.flags&F3DFloor.FF_LOWERTEXTURE ) d.HitLine.sidedef[d.LineSide].SetTexture(2,replacewith); + else d.Hit3DFloor.master.sidedef[0].SetTexture(1,replacewith); + } + else d.HitLine.sidedef[d.LineSide].SetTexture(d.LinePart,replacewith); + } + else if ( d.HitType == TRACE_HitCeiling ) + { + if ( d.Hit3DFloor ) + { + if ( d.Hit3DFloor.flags&F3DFloor.FF_INVERTSECTOR ) d.Hit3DFloor.model.SetTexture(1,replacewith); + else d.Hit3DFloor.model.SetTexture(0,replacewith); + } + else d.HitSector.SetTexture(1,replacewith); + } + else if ( d.HitType == TRACE_HitFloor ) + { + if ( d.Hit3DFloor ) + { + if ( d.Hit3DFloor.flags&F3DFloor.FF_INVERTSECTOR ) d.Hit3DFloor.model.SetTexture(0,replacewith); + else d.Hit3DFloor.model.SetTexture(1,replacewith); + } + else d.HitSector.SetTexture(0,replacewith); + } + } void CheckUnderwaterAmb( bool restore = false ) { Vector3 headpos = Vec3Offset(0,0,player.viewheight); @@ -582,6 +624,8 @@ Class Demolitionist : PlayerPawn { oldangle = angle; oldpitch = pitch; + if ( player && (player.mo == self) && (player.playerstate != PST_DEAD) && (player.cmd.buttons&BT_USE) ) + CheckNaziRemove(); Super.PlayerThink(); oldlagangle = lagangle; oldlagpitch = lagpitch; @@ -3200,8 +3244,112 @@ Class LoveHeart : Actor A_AttachLight('LOVELIGHT',DynamicLight.PointLight,Color(255,176,208),80,80,DYNAMICLIGHT.LF_ATTENUATE); special2 = 25; } + void CheckNaziRemove() + { + TextureID HitTexture; + Line HitLine; + int LineSide, LinePart; + Sector HitSector; + F3DFloor Hit3DFloor; + bool HitCeiling; + if ( BlockingLine ) + { + HitLine = BlockingLine; + // which side and part we hit? + LineSide = SWWMUtility.PointOnLineSide(pos.xy,BlockingLine); + double fl, cl; + if ( BlockingLine.sidedef[1] ) + { + fl = min(BlockingLine.frontsector.floorplane.ZAtPoint(pos.xy),BlockingLine.backsector.floorplane.ZAtPoint(pos.xy)); + cl = max(BlockingLine.frontsector.ceilingplane.ZAtPoint(pos.xy),BlockingLine.backsector.ceilingplane.ZAtPoint(pos.xy)); + if ( max(floorz,pos.z) < fl ) LinePart = 0; + else if ( min(ceilingz,pos.z+height) > cl ) LinePart = 2; + else LinePart = 1; + } + else LinePart = 1; // always middle + if ( Blocking3DFloor ) + { + for ( int i=0; i