SpriteShadow v2.0 (now built into GZDoom 4.6.0!)

For high-res texture/sprite projects, sprite-fix patches, music add-ons, music randomizers, and other graphic/sound-only projects.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
Caligari87
Admin
Posts: 6190
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him

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

Post by Caligari87 »

@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
NightFright
Spotlight Team
Posts: 1373
Joined: Fri May 02, 2008 12:29 pm
Location: Germany

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

Post by NightFright »

Actually the idea was to avoid cvar entries in the ini file, too. My apologies if that wasn't clear before.
User avatar
zrrion the insect
Posts: 2431
Joined: Thu Jun 25, 2009 1:58 pm
Location: Time Station 1: Moon of Glendale

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

Post by zrrion the insect »

If you want that you'll probably have to DIY it
User avatar
Nash
 
 
Posts: 17455
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by Nash »

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
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by vsonnier »

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 all

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 all

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.
   }
}
User avatar
Nash
 
 
Posts: 17455
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by Nash »

Can you make a pull request at https://github.com/nashmuhandes/SpriteShadow ? It is more convenient to review code changes that way.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by vsonnier »

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.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by vsonnier »

Hello Nash, I've submitted a PR you can look at: https://github.com/nashmuhandes/SpriteShadow/pull/1
User avatar
NightFright
Spotlight Team
Posts: 1373
Joined: Fri May 02, 2008 12:29 pm
Location: Germany

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by NightFright »

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.
ZellSF
Posts: 18
Joined: Tue Aug 13, 2019 12:04 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by ZellSF »

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.
User avatar
Nash
 
 
Posts: 17455
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by Nash »

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)
panzerfaustmna
Posts: 13
Joined: Fri Jul 21, 2017 9:19 am

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by panzerfaustmna »



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 =)
User avatar
Nash
 
 
Posts: 17455
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by Nash »

@panzerfaustmna: thank you, added to Github issues. Will fix when I have more spare time. :) https://github.com/nashmuhandes/SpriteShadow/issues/3
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by vsonnier »

@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.
User avatar
Nash
 
 
Posts: 17455
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: SpriteShadow (Duke3D Shadows) v1.9

Post by Nash »

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. :)

Return to “Graphic/Audio Patches”