Jump to content

What does the parameter for player:DoFootstepSound refer to exactly? - resolved: Tchernobill


orikamii

Recommended Posts

player:doFootstepSound(5)

I just have a more specific question regarding the snippet above, the integer "5" specifically, what does it refer to? I know that this code piece mimics the player stepping and that a larger number causes a larger sound. Does it by any chance refer to a specific distance/radius? If so, given the argument 5, what specific distance would it sound out?

If anyone can point me to a guide that allows us to essentially "step into" functions that exist in PZ so that we can look at the specific code, that would be incredibly helpful as well. I've been playing with the debugger and am not quite at the point where I can step into functions to see what they do specifically. Maybe a guide on the various functions of the debugger itself?
Thanks!

Edited by orikamii
Link to comment
Share on other sites

This is the base value for radius computation.

Below is a reverse engineering of current java code for IsoGameCharacter function.

You can reverse engineer it yourself following this guide. (once you done it the first time it takes one click and some waiting minutes to reverse engineer each new version)

   public void DoFootstepSound(float var1) {
      IsoPlayer var2 = (IsoPlayer)Type.tryCastTo(this, IsoPlayer.class);
      if (GameClient.bClient && var2 != null && var2.networkAI != null) {
         var2.networkAI.footstepSoundRadius = 0;
      }

      if (var2 == null || !var2.isGhostMode() || DebugOptions.instance.Character.Debug.PlaySoundWhenInvisible.getValue()) {
         if (this.getCurrentSquare() != null) {
            if (!(var1 <= 0.0F)) {
               float var3 = var1;
               var1 *= 1.4F;
               if (this.Traits.Graceful.isSet()) {
                  var1 *= 0.6F;
               }

               if (this.Traits.Clumsy.isSet()) {
                  var1 *= 1.2F;
               }

               if (this.getWornItem("Shoes") == null) {
                  var1 *= 0.5F;
               }

               var1 *= this.getLightfootMod();
               var1 *= 2.0F - this.getNimbleMod();
               if (this.bSneaking) {
                  var1 *= this.getSneakSpotMod();
               }

               if (var1 > 0.0F) {
                  this.emitter.playFootsteps("HumanFootstepsCombined", var3);
                  if (var2 != null && var2.isGhostMode()) {
                     return;
                  }

                  int var4 = (int)Math.ceil((double)(var1 * 10.0F));
                  if (this.bSneaking) {
                     var4 = Math.max(1, var4);
                  }

                  if (this.getCurrentSquare().getRoom() != null) {
                     var4 = (int)((float)var4 * 0.5F);
                  }

                  int var5 = 2;
                  if (this.bSneaking) {
                     var5 = Math.min(12, 4 + this.getPerkLevel(PerkFactory.Perks.Lightfoot));
                  }

                  if (GameClient.bClient && var2 != null && var2.networkAI != null) {
                     var2.networkAI.footstepSoundRadius = (byte)var4;
                  }

                  if (Rand.Next(var5) == 0) {
                     WorldSoundManager.instance.addSound(this, (int)this.getX(), (int)this.getY(), (int)this.getZ(), var4, var4, false, 0.0F, 1.0F, false, false, false);
                  }
               }

            }
         }
      }
   }

 

Link to comment
Share on other sites

Amazing, thank you! For both the guide and decompiled code. Looking at that code bit I'm definitely going to want to look further in for a better approach to what I'm trying to accomplish.

You've just made modding PZ for me a million times more simple now that I have access to the source code. Muah, thank you!

Link to comment
Share on other sites

  • orikamii changed the title to What does the parameter for player:DoFootstepSound refer to exactly? - resolved: Tchernobill

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...