Can Anyone Explain why my Actors Disappear after Bouncing?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)

Can Anyone Explain why my Actors Disappear after Bouncing?

Postby slayer87 » Sat Jan 08, 2022 9:32 am

Perhaps I misunderstand the "Projectile" flag, but can anyone explain why my "glass shards" bounce normally, but when they lose momentum, right before they stop bouncing, they actually disappear? I actually want them to hang around for a bit.

Code: Select allExpand view
ACTOR glass_shard1   29026
{
   Gravity 1
   PROJECTILE
   -NOGRAVITY
   +BOUNCEAUTOOFFFLOORONLY
   +ALLOWBOUNCEONACTORS
   +BOUNCEONWALLS
   +BOUNCEONFLOORS
   +BOUNCEONCEILINGS
  BounceFactor 0.5
  BounceType Doom
  friction 0.8
  mass 100
  Radius 1
  Height 6
  scale .02
  renderstyle translucent
  alpha 0.45
  States
  {
   Spawn:
   GSHR A -1
    stop
  }
}


I've deleted it, but before I had a Delay() and then A_Remove to despawn all glass shards. (to clean up actor count). This worked well, but after implementing the bouncing, they just disappear way before the delay timer ever got done.
slayer87
 
Joined: 22 Dec 2021
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: Can Anyone Explain why my Actors Disappear after Bouncin

Postby Jekyll Grim Payne » Sat Jan 08, 2022 10:32 am

Since you're using bouncetype "Doom", the projectile is put in its Death sequence once it doesn't have enough momentum for bouncing. Since you don't have a Death sequence, it becomes removed.

Note, you should not mix bouncetype property with flags that imply the same behavior. Bouncetype "Doom" already implies BOUNCEONWALLS, BOUNCEONFLOORS and BOUNCEONCEILINGS. It also implies BOUNCEAUTOOFF, so your BOUNCEAUTOOFFFLOORONLY flag has no effect, because BOUNCEAUTOOFF takes precedence.

Bouncetype property can only be mixed with unsetting flags that are implied by its behavior. For example, if you use bouncetype "Doom" and then -BOUNCEAUTOOFF, this will prevent the actor from being put into Death sequence once its velocity is too low.

If you want to define very specific bouncing behavior, use only flags and omit the bouncetype property.
User avatar
Jekyll Grim Payne
 
 
 
Joined: 21 Jul 2008
Discord: Agent_Ash#4401
Github ID: jekyllgrim
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)

Re: Can Anyone Explain why my Actors Disappear after Bouncin

Postby slayer87 » Sat Jan 08, 2022 3:32 pm

Jekyll Grim Payne wrote:Since you're using bouncetype "Doom", the projectile is put in its Death sequence once it doesn't have enough momentum for bouncing. Since you don't have a Death sequence, it becomes removed.

Note, you should not mix bouncetype property with flags that imply the same behavior. Bouncetype "Doom" already implies BOUNCEONWALLS, BOUNCEONFLOORS and BOUNCEONCEILINGS. It also implies BOUNCEAUTOOFF, so your BOUNCEAUTOOFFFLOORONLY flag has no effect, because BOUNCEAUTOOFF takes precedence.

Bouncetype property can only be mixed with unsetting flags that are implied by its behavior. For example, if you use bouncetype "Doom" and then -BOUNCEAUTOOFF, this will prevent the actor from being put into Death sequence once its velocity is too low.

If you want to define very specific bouncing behavior, use only flags and omit the bouncetype property.


Thank you. I'll correct that redundancy.

For reference, several mods (Embers of Armageddon, heck even Proj Brutality, etc) have bouncing Health, Armor, and Ammo pickups on glory kills. Maybe I can inspect their code.

Currently have a glass sprite that, when destroyed, spawns several glass shards going off in several directions. I wanted to emulate the bouncing effect from those mods. (even Duke Nukem 3D had some bouncing glass from windows)

Thanks again.
slayer87
 
Joined: 22 Dec 2021
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: Can Anyone Explain why my Actors Disappear after Bouncin

Postby Jekyll Grim Payne » Mon Jan 10, 2022 8:16 am

There are many ways to handle bouncing. For example, here's a test example I threw together:

Code: Select allExpand view
version "4.7.0"

mixin class BouncingInventory
{   
   Default
   {
      +MISSILE
      +BOUNCEONFLOORS
      +BOUNCEONWALLS
      +CANBOUNCEWATER
      bouncecount 5;
   }
   
   override void Tick()
   {
      super.Tick();
      if (!bMISSILE)
         return;
      if (vel.length () < 0.25 || bouncecount <= 0)
      {
         bCORPSE = true;
         bMISSILE = false;
      }
   }
}

class BouncingInventoryBase : Inventory
{
   mixin BouncingInventory;
}

class BouncingAmmo : Ammo
{
   mixin BouncingInventory;
}

class BouncyClip : BouncingAmmo replaces Clip
{
   Default
   {
      Inventory.PickupMessage "$GOTCLIP";
      Inventory.Amount 10;
      Inventory.MaxAmount 200;
      Ammo.BackpackAmount 10;
      Ammo.BackpackMaxAmount 400;
      Inventory.Icon "CLIPA0";
      Tag "$AMMO_CLIP";
   }
   States
   {
   Spawn:
      CLIP A -1;
      Stop;
   }
}


I made it into a mixin so that it can be used to create both a custom Inventory and a custom Ammo class, and added a Clip replacement for demonstration. This will bounce a few times, then once its velocity is low enough, it'll switch to CORPSE (which will allow it to slide but will disable bouncing). Alternativerly you can just add +BOUNCEAUTOOFF, of course.
User avatar
Jekyll Grim Payne
 
 
 
Joined: 21 Jul 2008
Discord: Agent_Ash#4401
Github ID: jekyllgrim
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)


Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests