What Actor Uses the SmokeCounter var?

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!)

What Actor Uses the SmokeCounter var?

Postby 22alpha22 » Mon Jun 20, 2022 1:26 am

I need a int or double variable that is stored locally on any given actor and it wouldn't be convenient in this particular case to create a new class and spawn a copy of it for every actor that needs this variable. To avoid having to do that, I looked through the GZDoom pk3 at the actor class to see if there was any niche ints, floats, or doubles that would be safe to repurpose. I've come across four candidates: accuracy, stamina, fountaincolor, and lastly smokecounter. I know what the first three are used for and any of them probably would work but I have never seen smokecounter used before and thus I'm wondering what actors use it and how?
User avatar
22alpha22
So lonely...
 
Joined: 21 Feb 2014
Location: Montana, USA
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: What Actor Uses the SmokeCounter var?

Postby Gez » Mon Jun 20, 2022 1:38 am

Smokecounter is used for the optional rocket and grenade trail effects.
void AActor::Tick ()

Code: Select allExpand view
      if (effects & FX_ROCKET)
      {
         if (++smokecounter == 4)
         {
            // add some smoke behind the rocket
            smokecounter = 0;
            AActor *th = Spawn(Level, "RocketSmokeTrail", Vec3Offset(-Vel), ALLOW_REPLACE);
            if (th)
            {
               th->tics -= pr_rockettrail()&3;
               if (th->tics < 1) th->tics = 1;
               if (!(cl_rockettrails & 2)) th->renderflags |= RF_INVISIBLE;
            }
         }
      }
      else if (effects & FX_GRENADE)
      {
         if (++smokecounter == 8)
         {
            smokecounter = 0;
            DAngle moveangle = Vel.Angle();
            double xo = -moveangle.Cos() * radius * 2 + pr_rockettrail() / 64.;
            double yo = -moveangle.Sin() * radius * 2 + pr_rockettrail() / 64.;
            double zo = -Height * Vel.Z / 8. + Height * (2 / 3.);
            AActor * th = Spawn(Level, "GrenadeSmokeTrail", Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
            if (th)
            {
               th->tics -= pr_rockettrail()&3;
               if (th->tics < 1) th->tics = 1;
               if (!(cl_rockettrails & 2)) th->renderflags |= RF_INVISIBLE;
            }
         }
      }


So it should be safe to repurpose for actors that do not have the ROCKETTRAIL or GRENADETRAIL flags.
Gez
 
 
 
Joined: 06 Jul 2007

Re: What Actor Uses the SmokeCounter var?

Postby 22alpha22 » Mon Jun 20, 2022 1:57 am

As projectiles are one of the actor types that will need this repurposed var, it is probably best not to use smokecounter in that case, good to know, I appreciate it.
User avatar
22alpha22
So lonely...
 
Joined: 21 Feb 2014
Location: Montana, USA
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: What Actor Uses the SmokeCounter var?

Postby Graf Zahl » Tue Jun 21, 2022 11:49 am

The short answer: Never try to repurpose any internal variable. Their use may change over time
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest