From a3357251fe620dbb13d0e6397fc345528b8dc572 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Fri, 16 Aug 2019 22:35:42 +0200 Subject: [PATCH] Fixups and adjustments to some item code. Armors now properly sort themselves. Powershield drains over time, for balance reasons. Backpack no longer displays extra items text, I felt this was too verbose. A little tease of something that's coming soon. The code is commented out until the feature is greenlit and merged. --- language.txt | 2 - zscript/miscitems.zsc | 14 +---- zscript/uarmoritems.zsc | 35 +++++------ zscript/unrealcommon.zsc | 23 ++++++++ zscript/unrealhud.zsc | 121 ++++++++++++++++++++++++++++++++++++--- 5 files changed, 158 insertions(+), 37 deletions(-) diff --git a/language.txt b/language.txt index 9a4b723..e90ecc1 100644 --- a/language.txt +++ b/language.txt @@ -7,7 +7,6 @@ I_STINGERAMMOL = "You picked up "; I_STINGERAMMOR = " Tarydium Shards."; I_STINGER = "You picked up the Stinger."; I_TRANSLATOR = "You picked up the Universal Translator."; -I_BACKPACKEXTRA = "The backpack also contains: "; I_ASMDAMMO = "You picked up an ASMD Core."; I_ASMDAMMO2 = "You picked up a Small ASMD Core."; I_ASMD = "You got the ASMD."; @@ -83,7 +82,6 @@ I_STINGERAMMOL = "Has recogido "; I_STINGERAMMOR = " fragmentos de Tarydium."; I_STINGER = "Has obtenido el Arma Aguijón."; I_TRANSLATOR = "Has obtenido el Traductor Universal."; -I_BACKPACKEXTRA = "La mochila tambien contiene: "; I_ASMDAMMO = "Has recogido un Núcleo de ASMD."; I_ASMDAMMO2 = "Has recogido un Núcleo Pequeño de ASMD."; I_ASMD = "Has obtenido el ASMD."; diff --git a/zscript/miscitems.zsc b/zscript/miscitems.zsc index bf213de..c1bdf36 100644 --- a/zscript/miscitems.zsc +++ b/zscript/miscitems.zsc @@ -105,19 +105,11 @@ Class UnrealBackpack : BackpackItem replaces Backpack if ( !Random[BackpackExtra](0,6) ) xitemn[4] *= 2; if ( !Random[BackpackExtra](0,5) ) xitemn[5] *= 2; if ( !Random[BackpackExtra](0,9) ) xitemn[6] *= 2; - int total = 0; - for ( int i=0; i<7; i++ ) total += xitemn[i]; - if ( total <= 0 ) return; - String extratxt = StringTable.Localize("$I_BACKPACKEXTRA"); for ( int i=0; i<7; i++ ) { if ( xitemn[i] <= 0 ) continue; - extratxt = extratxt..String.Format("%dx %s, ",xitemn[i],GetDefaultByType(xitems[i]).GetTag()); toucher.GiveInventory(xitems[i],xitemn[i]); } - // remove trailing comma - extratxt.Truncate(extratxt.Length()-2); - PrintPickupMessage(true,extratxt.."."); } } Default @@ -386,7 +378,7 @@ Class Dampener : UnrealInventory if ( DrainCharge(1) ) { Owner.A_PlaySound("dampener/off",CHAN_ITEM); - PrintPickupMessage(true,StringTable.Localize("$D_DAMPENER")); + if ( Owner.CheckLocalView() ) Console.Printf(StringTable.Localize("$D_DAMPENER")); } } Default @@ -429,13 +421,13 @@ Class Forcefield : UnrealInventory origin = level.Vec3Offset(origin,(0,0,-GetDefaultByType("ForceFieldEffect").Height*.5)); if ( !level.IsPointInLevel(origin) ) { - PrintPickupMessage(true,StringTable.Localize("$M_FFNOROOM")); + if ( Owner.CheckLocalView() ) Console.Printf(StringTable.Localize("$M_FFNOROOM")); return false; } let a = Spawn("ForceFieldEffect",origin); if ( !a.TestMobjLocation() ) { - PrintPickupMessage(true,StringTable.Localize("$M_FFNOROOM")); + if ( Owner.CheckLocalView() ) Console.Printf(StringTable.Localize("$M_FFNOROOM")); a.Destroy(); return false; } diff --git a/zscript/uarmoritems.zsc b/zscript/uarmoritems.zsc index 19a94b0..f5e4fe8 100644 --- a/zscript/uarmoritems.zsc +++ b/zscript/uarmoritems.zsc @@ -10,26 +10,28 @@ Class UnrealArmor : UTArmor UnrealArmor.AbsorptionPriority 0; } + override void AbsorbDamage( int damage, Name damageType, out int newdamage ) + { + Console.Printf("%s absorbs %d",GetTag(),damage); + Super.AbsorbDamage(damage,damageType,newdamage); + } + override void AttachToOwner( Actor other ) { Super.AttachToOwner(other); - // re-sort self against other armors based on priority - Inventory cprev = null, prev = null; + // find last armor that's better than us + Inventory found = null; for ( Inventory i=other.Inv; i; i=i.Inv ) { - if ( i.Inv == self ) prev = i; - if ( !(i is 'UnrealArmor') || (i == self) || (UnrealArmor(i).priority >= priority) ) - { - cprev = i; - continue; - } - // got one, move ourselves - if ( prev ) prev.Inv = Inv; - if ( cprev ) cprev.Inv = self; - else other.Inv = self; - Inv = i; - break; + if ( !(i is 'UnrealArmor') || (i == self) || (UnrealArmor(i).priority < priority) ) continue; + found = i; } + if ( !found ) return; + // place ourselves right after it + Inventory saved = found.Inv; + found.Inv = self; + other.Inv = Inv; + Inv = saved; } } @@ -169,7 +171,7 @@ Class ShieldBelt : UnrealArmor } int oldamt = amount; Super.AbsorbDamage(damage,damageType,newdamage); - if ( (oldamt > 0) && (amount <= 0) ) PrintPickupMessage(true,StringTable.Localize("$D_SHIELDBELT")); + if ( (oldamt > 0) && (amount <= 0) && Owner.CheckLocalView() ) Console.Printf(StringTable.Localize("$D_SHIELDBELT")); } Default { @@ -220,9 +222,10 @@ Class PowerShield : UnrealArmor amount--; gothit = false; } + if ( !(level.maptime%15) ) amount--; if ( amount <= 0 ) { - PrintPickupMessage(true,StringTable.Localize("$D_POWERSHIELD")); + if ( Owner.CheckLocalView() ) Console.Printf(StringTable.Localize("$D_POWERSHIELD")); DepleteOrDestroy(); } } diff --git a/zscript/unrealcommon.zsc b/zscript/unrealcommon.zsc index c8f7508..c80f1cc 100644 --- a/zscript/unrealcommon.zsc +++ b/zscript/unrealcommon.zsc @@ -518,6 +518,29 @@ Class UnrealInventory : Inventory } return Super.HandlePickup(item); } + override void Tick() + { + Super.Tick(); + // don't slide on floor when dropped + if ( bDROPPED && (pos.z <= floorz) ) + vel.xy *= 0; + } + override void OnDrop( Actor dropper ) + { + Super.OnDrop(dropper); + // deactivate + bActive = false; + // drop like weapons + Vector2 hofs = RotateVector((dropper.radius,0),dropper.angle); + SetOrigin(dropper.Vec3Offset(hofs.x,hofs.y,dropper.height*0.5),false); + Vector3 x, y, z; + [x, y, z] = dt_CoordUtil.GetAxes(dropper.pitch,dropper.angle,dropper.roll); + vel = x*12.0; + vel.z += 4.0; + angle = dropper.angle; + pitch = 0; + roll = 0; + } Default { diff --git a/zscript/unrealhud.zsc b/zscript/unrealhud.zsc index 5c4b3f6..29ba46a 100644 --- a/zscript/unrealhud.zsc +++ b/zscript/unrealhud.zsc @@ -22,6 +22,13 @@ Class UnrealHUD : BaseStatusBar // Common Textures TextureID HalfHud, HudLine, HudAmmo, IconHeal, IconSkul, IconSel, IconBase, KeyIcons[7]; + // These can't be used yet + /*String PickupMsg; + int PickupMsgTic; + String ShortMsg[4]; + int ShortMsgTic[4]; + int ShortMsgCol[4];*/ + // 0.83 HUD stuff String OldAmmo[18]; Class OldAmmoType[18]; @@ -128,6 +135,7 @@ Class UnrealHUD : BaseStatusBar override void Draw( int state, double TicFrac ) { Super.Draw(state,TicFrac); + FracTic = TicFrac; HudMode = CVar.GetCVar('stinger_hudmode',players[consoleplayer]).GetInt(); scalev.x = scalev.y = Max(0,CVar.GetCVar('stinger_hudscale',players[consoleplayer]).GetInt()); if ( scalev.x == 0 ) scalev.x = scalev.y = max(1,min(Screen.GetWidth()/640.,Screen.GetHeight()/480.)); @@ -144,13 +152,11 @@ Class UnrealHUD : BaseStatusBar if ( state == HUD_StatusBar ) { BeginStatusBar(); - FracTic = TicFrac; DrawUnrealBar(); } else if ( state == HUD_Fullscreen ) { BeginHUD(); - FracTic = TicFrac; DrawUnrealHUD(); } for ( Inventory i=CPlayer.mo.inv; i; i=i.inv ) @@ -158,6 +164,7 @@ Class UnrealHUD : BaseStatusBar UnrealInventory(i).PostRender(lbottom); if ( CPlayer.ReadyWeapon is 'UTWeapon' ) UTWeapon(CPlayer.ReadyWeapon).PostRender(lbottom); + DrawMessages(state); } private void DrawNumberOf( Inventory i, double x, double y ) @@ -384,8 +391,9 @@ Class UnrealHUD : BaseStatusBar } } - private void DrawArmor( double x, double y, bool bDrawOne = false ) + private bool DrawArmor( double x, double y, bool bDrawOne = false, bool bCheckOnly = false ) { + bool hasdrawn = false; int ArmorAmount = 0, CurAbs = 0; Inventory Inv, BestArmor; double XL, YL; @@ -398,10 +406,11 @@ Class UnrealHUD : BaseStatusBar if ( (Inv.Amount <= 0) || Inv.Icon.IsNull() ) continue; if ( !bDrawOne ) { - DrawHudIcon(CurX,y,Inv,false); + hasdrawn = true; + if ( !bCheckOnly ) DrawHudIcon(CurX,y,Inv,false); CurX += 32; CurY += HudMode?29:27; - DrawIconValue(Inv.Amount); + if ( !bCheckOnly ) DrawIconValue(Inv.Amount); CurY -= HudMode?29:27; } else if ( UTArmor(Inv).absorb > CurAbs ) @@ -412,14 +421,19 @@ Class UnrealHUD : BaseStatusBar } if ( bDrawOne && BestArmor ) { - DrawHudIcon(CurX,Y,BestArmor,false); + hasdrawn = true; + if ( !bCheckOnly ) DrawHudIcon(CurX,Y,BestArmor,false); CurX += 32; CurY += HudMode?29:27; - DrawIconValue(BestArmor.Amount); + if ( !bCheckOnly ) DrawIconValue(BestArmor.Amount); CurY -= HudMode?29:27; } if ( (ArmorAmount > 0) && !HudMode ) - Screen.DrawText(LargeFont,Font.CR_UNTRANSLATED,CurX+2,Y,String.Format("%d",ArmorAmount),DTA_VirtualWidthF,ClipX,DTA_VirtualHeightF,ClipY,DTA_KeepRatio,true); + { + hasdrawn = true; + if ( !bCheckOnly ) Screen.DrawText(LargeFont,Font.CR_UNTRANSLATED,CurX+2,Y,String.Format("%d",ArmorAmount),DTA_VirtualWidthF,ClipX,DTA_VirtualHeightF,ClipY,DTA_KeepRatio,true); + } + return hasdrawn; } private void DrawAmmo( double x, double y ) @@ -614,11 +628,21 @@ Class UnrealHUD : BaseStatusBar if ( deathmatch ) DrawFragCount(ClipX-32,0); // Need to draw the inventory bar (and translator) DrawInventory(ClipX-(deathmatch?128:96),0,false,true); + // Display Identification Info + DrawIdentifyInfo(); } override void Tick() { Super.Tick(); + // prune expired short messages + /*for ( int i=0; i<3; i++ ) + { + if ( (gametic-ShortMsgTic[i]) < 70 ) continue; + ShortMsg[i] = ShortMsg[i+1]; + ShortMsgTic[i] = ShortMsgTic[i+1]; + ShortMsgCol[i] = ShortMsgCol[i+1]; + }*/ CPlayer.inventorytics = 0; vtracer.ignore = CPlayer.mo; vtracer.trace(CPlayer.mo.Vec2OffsetZ(0,0,CPlayer.viewz),CPlayer.mo.CurSector,(cos(CPlayer.mo.angle)*cos(CPlayer.mo.pitch),sin(CPlayer.mo.angle)*cos(CPlayer.mo.pitch),-sin(CPlayer.mo.pitch)),1000,0); @@ -627,6 +651,87 @@ Class UnrealHUD : BaseStatusBar lastseentic = gametic; } + // all of this requires features that are not available yet + /*override void NewGame() + { + PickupMsg = ""; + } + + override void FlushNotify() + { + for ( int i=0; i<4; i++ ) + ShortMsg[i] = ""; + } + + override bool ProcessNotify( EPrintLevel printlevel, String outline ) + { + if ( printlevel == PRINT_LOW ) + { + // set pickup message + PickupMsg = outline; + PickupMsgTic = gametic; + return true; + } + else + { + // put message into queue + for ( int i=3; i>0; i-- ) + { + ShortMsg[i] = ShortMsg[i-1]; + ShortMsgTic[i] = ShortMsgTic[i-1]; + ShortMsgCol[i] = ShortMsgCol[i-1]; + } + if ( printlevel == PRINT_MEDIUM ) ShortMsgCol[0] = Font.CR_RED; + else if ( (printlevel == PRINT_CHAT) || (printlevel == PRINT_TEAMCHAT) ) ShortMsgCol[0] = Font.CR_GREEN; + else ShortMsgCol[0] = Font.CR_WHITE; + ShortMsg[0] = outline; + ShortMsgTic[0] = gametic; + return true; + } + return false; + } + + override bool DrawChat( String txt ) + { + int xpos = 4*CleanXFac_1; + int ypos = (screenblocks<=10)?GetTopOfStatusBar():(Screen.GetHeight()-((screenblocks>11)?0:int(32*scalev.y))); + ypos -= (WhiteFont.GetHeight()+4)*CleanYFac_1; + String fullstr = String.Format("(> Say %s%s",txt,WhiteFont.GetCursor()); + // cut out until it fits + while ( (WhiteFont.StringWidth(fullstr) > CleanWidth_1) && fullstr.Length() > 7 ) + fullstr.Remove(7,1); + Screen.DrawText(WhiteFont,Font.CR_GREEN,xpos,ypos,fullstr,DTA_CleanNoMove_1,true); + return true; + }*/ + + private void DrawMessages( int state ) + { + // TODO add map intro text like in Unreal + /*double malpha = 2.0-((gametic+fractic)-PickupMsgTic)/Thinker.TICRATE; + int xpos, ypos; + if ( PickupMsg.Length() > 0 && (malpha > 0) ) + { + xpos = (Screen.GetWidth()-WhiteFont.StringWidth(PickupMsg)*CleanXFac_1)/2; + if ( state == HUD_Statusbar ) ypos = GetTopOfStatusBar()-21*CleanYFac_1; + else ypos = Screen.GetHeight()-41*CleanYFac_1; + Screen.DrawText(WhiteFont,Font.CR_WHITE,xpos,ypos,PickupMsg,DTA_CleanNoMove_1,true,DTA_Alpha,min(1.,malpha),DTA_LegacyRenderStyle,STYLE_Add); + } + // draw messages + xpos = 4*CleanXFac_1; + ypos = 4*CleanYFac_1; + if ( (state == HUD_Fullscreen) && (HudMode < 2) && DrawArmor(0,0,false,true) ) ypos += int(32*scalev.y); + for ( int i=3; i>=0; i-- ) + { + if ( (ShortMsg[i].Length() <= 0) || (gametic-ShortMsgTic[i] >= 70) ) continue; + let lines = WhiteFont.BreakLines(ShortMsg[i],CleanWidth_1/2); + for ( int j=0; j