SpriteShadow (Duke3D Shadows) v1.9

Post your example zscripts/ACS scripts/etc here.

Re: SpriteShadow (Duke3D Shadows) v1.85 [more optimization!]

Postby Caligari87 » Wed Jan 16, 2019 11:27 am

@NightFright: Just open the .pk3 in SLADE or 7zip and delete the MENUDEF file. Everything else will continue working as normal, including the configuration cvars

8-)
User avatar
Caligari87
I'm just here for the community
User Accounts Assistant
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA
Discord: Caligari87#3089

Re: SpriteShadow (Duke3D Shadows) v1.85 [more optimization!]

Postby NightFright » Thu Jan 17, 2019 1:59 am

Actually the idea was to avoid cvar entries in the ini file, too. My apologies if that wasn't clear before.
User avatar
NightFright
 
Joined: 02 May 2008
Location: Germany

Re: SpriteShadow (Duke3D Shadows) v1.85 [more optimization!]

Postby zrrion the insect » Thu Jan 17, 2019 7:39 pm

If you want that you'll probably have to DIY it
User avatar
zrrion the insect
Like a fish in a child's hands.
 
Joined: 25 Jun 2009
Location: Time Station 1: Moon of Glendale

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby Nash » Wed Jul 10, 2019 10:06 am

Update July 10th 2019 (version 1.9)

- GZDoom version bump to 4.1.3.
- Do not serialize shadows. This means the shadow actors do not get written into saved games. Might help with multiplayer saved game stability.
- Github repository added.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby vsonnier » Mon Jul 29, 2019 11:03 pm

Hello Nash, thank you for your SpriteShadow code !
I've adapted it with some changes you may found interesting:

- The Z_ShadeMe inventory is still added for all +ISMONSTER like you did, and is never removed afterwards, rather only the Z_Shadow is enebled/disabled.
- Added a CVAR to enable/disable shadows
- Cleanup of Shadows based on age, not distance re-computing.

Z_ShadeMe:

Code: Select allExpand view
class Z_ShadeMe : CustomInventory
{
   // reference to the shadow
   Z_SpriteShadow myShadow;
   
    int countFromLastUpdate;
    int maxMonsterShadowAgeInTicks;
    bool shadowCloseEnoughToPlayer;
   
...
   
    void setEnableShadow(bool bEnable) {
   
        countFromLastUpdate = 0;
       
        if (bEnable != self.shadowCloseEnoughToPlayer) {
         
            if (bEnable) {
               
                if (!self.myShadow) {
               
                    let sh = Z_SpriteShadow(Spawn("Z_SpriteShadow", Owner.Pos, NO_REPLACE));
           
                    if (sh)
                    {
                        self.myShadow = sh;
                        self.myShadow.ownerRef = Owner;
                    }
       
                }
               
            } else {
           
                 //destroy the shadow because disabled, or too far from the player.
                if (self.myShadow) {
                    self.myShadow.Destroy();
                    self.myShadow = null;
                }                 
            }
            //update
            self.shadowCloseEnoughToPlayer = bEnable;
        }
    }
   
    override void PostBeginPlay() {
        //by default is false, and is enabled in Handler WorldTick():
        self.shadowCloseEnoughToPlayer = false;
        //if countFromLastUpdate is bigger than 2s (35 * 2 ticks) remove the shadow unconditionally.
        maxMonsterShadowAgeInTicks = 35 * 2;
        Super.PostBeginPlay();
    }
   
    override void Tick() {
     
        countFromLastUpdate++;

        //Cleanup : shadow is too old, it means it has not been tested
        //for player proximity for a long time, which means it is indeed too far !
        if (countFromLastUpdate > maxMonsterShadowAgeInTicks) {
                self.setEnableShadow(false);
        }
       
        Super.Tick();
    }
   
   ...
}


SpriteShadowHandler:

Code: Select allExpand view
class SpriteShadowHandler : EventHandler
{
    int countTicks;
   
   // spawn shadows for monsters
   override void WorldThingSpawned(WorldEvent e)
   {
      if (e.Thing.bIsMonster && !e.Thing.CountInv("Z_ShadeMe"))
      {   
                      //Every monster got a Z_ShadeMe inventory token, but your shadow is effectively enabled or not later.
         e.Thing.A_GiveInventory("Z_ShadeMe", 1);   
      }
   }

    ...

  override void WorldTick(void)
  {
        //0) Save game : do not serialize shadows.
      if (gameaction == ga_savegame || gameaction == ga_autosave)
      {
         ThinkerIterator it = ThinkerIterator.Create("Z_ShadeMe");
         Z_ShadeMe shadeMe;
         while (shadeMe = Z_ShadeMe(it.Next()))
         {   
                              //VSO: Destroy all shadows, NOT the Z_ShadeMe !
                             // monster Shadows will be re-created at nexts WorldTick().
                            if (shadeMe) {
                              shadeMe.setEnableShadow(false);
                           }
             }
                       //VSO: Trick so that the next Shadow re-creation will only occur in 35 ticks = 1s.
         countTicks = 0;
                       return;
      }
       
        countTicks++;
       
        // no need to update this too often
        if (countTicks % 35 != 0) return;
               
        PlayerInfo p = players[consoleplayer];
        if (!p) return;

        double shadowDist = Cvar.FindCvar("spriteshadowdistance").GetFloat();
        bool shadows_enabled = Cvar.FindCvar("spriteshadowenabled").GetBool();
       
      //1) update shadows enabling flag to Z_ShadeMe according to distance to player:
        // look for shadow casters around you
        BlockThingsIterator it = BlockThingsIterator.Create(p.mo, shadowDist);
        while (it.Next())
        {
            Actor mo = it.thing;
            //only consider monster-tagged things:
            if (mo.bIsMonster)
            {
                let shadeMe = Z_ShadeMe(mo.FindInventory("Z_ShadeMe"));
               
                         if (shadeMe)
                         {
                                if (shadows_enabled && (mo.Distance2DSquared(p.mo) < shadowDist ** 2)) {
                     
                                        shadeMe.setEnableShadow(true);
                                } else {
                                       shadeMe.setEnableShadow(false);
                                }
                        }
           }
            }//end while.
   }
}
vsonnier
 
Joined: 11 Apr 2019
Github ID: vsonnier
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby Nash » Tue Jul 30, 2019 12:20 am

Can you make a pull request at https://github.com/nashmuhandes/SpriteShadow ? It is more convenient to review code changes that way.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby vsonnier » Tue Jul 30, 2019 11:37 am

Can you make a pull request at https://github.com/nashmuhandes/SpriteShadow ? It is more convenient to review code changes that way.

Thanks, I'll do it properly in a few days.
vsonnier
 
Joined: 11 Apr 2019
Github ID: vsonnier
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby vsonnier » Fri Aug 02, 2019 3:40 am

Hello Nash, I've submitted a PR you can look at: https://github.com/nashmuhandes/SpriteShadow/pull/1
vsonnier
 
Joined: 11 Apr 2019
Github ID: vsonnier
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby NightFright » Fri Aug 09, 2019 3:54 pm

Did anybody have crashes to console with this? I have had some recently. Levels play fine after reloading the last savegame, though. Next time it happens I'll note down the message to track down the issue.

My impression is this happens since v1.9, can't remember the mod ever causing trouble before.
User avatar
NightFright
 
Joined: 02 May 2008
Location: Germany

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby ZellSF » Tue Aug 13, 2019 1:08 pm

1.9 seems to have broken something slightly.

In MAP09 of Valiant archviles teleport around in the starting areas of the map. With 1.9 they leave their shadows when they teleport away, 1.85 works fine.
ZellSF
 
Joined: 13 Aug 2019
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby Nash » Tue Aug 13, 2019 7:07 pm

Thanks, I've opened an issue on Github: https://github.com/nashmuhandes/SpriteShadow/issues/2

(Please feel free to leave other bug reports on the Github)
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby panzerfaustmna » Thu Aug 15, 2019 6:59 pm



Hi, ive got this error while playing brutal doom on gz 4.1.3 , its happens when iam using brutality on enemys
sry 4 bad english =)
panzerfaustmna
 
Joined: 21 Jul 2017

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby Nash » Thu Aug 15, 2019 9:17 pm

@panzerfaustmna: thank you, added to Github issues. Will fix when I have more spare time. :) https://github.com/nashmuhandes/SpriteShadow/issues/3
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby vsonnier » Sat Aug 17, 2019 1:36 am

@panzerfaustmna: thank you, added to Github issues. Will fix when I have more spare time. :) https://github.com/nashmuhandes/SpriteShadow/issues/3


I've asubmitted a PR fixing this problem that I have encountered as well.
vsonnier
 
Joined: 11 Apr 2019
Github ID: vsonnier
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: SpriteShadow (Duke3D Shadows) v1.9

Postby Nash » Mon Aug 19, 2019 5:00 am

vsonnier wrote:
@panzerfaustmna: thank you, added to Github issues. Will fix when I have more spare time. :) https://github.com/nashmuhandes/SpriteShadow/issues/3


I've asubmitted a PR fixing this problem that I have encountered as well.


Thanks, this is an easy one. :)
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

PreviousNext

Return to Script Library

Who is online

Users browsing this forum: Awario [RSS] and 0 guests