Home Gallery Resources The Team Rules chat Login Register
Pages: [1]
Author Topic: Implementing Visual Battle Damage  (Read 5163 times)
0 Members and 1 Guest are viewing this topic.
Advanced Kitten
Offline Offline

Posts: 24


  • Awards Favorite'd Tutorial Writer

  • View Profile Awards
    « on: February 21, 2020, 10:03:56 PM »

    Hello, after my Battle Damage Meta Knight, I've had a couple people from the Custom Brawl Modding discord ask how I did it. the process is relatively simple, but does require a decent understanding of Brawl's fighter files, so I'll also go over tons of absolute-beginner basic stuff that other tutorials already cover.

    If you dont need to go over model editing or using 3ds max, you can skip to Part II where I talk specifically about model visibility and PSA stuff. If I accidentally miss something important, I'll have some more specific and indepth tutorials at the end that you can supplement.

    My Meta Knight mod touches all the fighter file types, that being the FitFighter, costumes, and the MotionEtc, but for this we'll only modify the FitFighter and costumes.

    3ds Max
    PSA Compressor

    We're going to use Captain Falcon. Feel free to follow along, so you can have a better understanding of the process.
    We'll have his visor crack at 100%, and break off completely at 200%. Luckily, part of the work is already partially done for us because (like Meta Knight) he was initially planned to have a battle damage system, and his textures have an alternate version with some wear, and his face is actually partially modeled under the visor where it was meant to break.

    Part 1: 3ds Max and BrawlCrate Edits
    We'll start by getting Falcon into 3ds Max for some model edits. Right click the MDL0 in BrawlCrate and press export. Choose a path and set it to export as a .dae file.
    Right click the BRES Texture Data holder and press Export All, and export as png. Place them alongside your .dae.
    In 3ds, import with these settings.
    It should look something like this.

    Now, to start with, Falcon has 3 eye models that shine through his visor. we cant see them, so we'll hide everything except them for now. (press the lightbulb icon beside each of the object names you dont need)
    We're going to separate all 3 into a left eye and a right eye, giving us 6 total models. This is going to be useful for hiding just one eye later on. There are a few ways to do this, but this time we'll just select the 3 objects, and add an Edit Mesh modifier.
    Select all 3 faces of one of the eyes, and then press Detach on the rollout. Type whatever you want for the name when it asks.
    Rename the results to something memorable. Go ahead and rename the original eye models if you want.
    Now, for each of the original eye objects, we're gonna want to get rid of the old skin modifier because generally editing objects that are already skinned is a bad idea. Right click the top of the modifier stack and then press Collapse All. Alternatively you can just delete the skin modifier before you even separate them, but I forgot to and dont want to retake screenshots. Cool
    Next, as I mentioned, I want the visor to crack for the first stage. We'll right-click the visor object and press clone, making sure the box that opens is set to Copy.
    Now we'll copy the original material the visor uses, and edit that copy to use my new texture.

    Open the Material Editor, and select the visor using the eyedropper tool to grab the material. Then press Make Material Copy and put in a new name in the text box.
    Finally, select assign material to selection to make the visor duplicate use our copied material.
    Click the M beside the diffuse color box,
    and change the Bitmap to the new cracked version you made (or download mine located at the end of this post)

    Now, in the modifiers, we're going to delete the Skin modifier right out the gate. I've made an alternate texture with a broken visor, and we'll use the Unwrap UVW modifier to replace the old texture.
    Click the polygon selection tool in the Unwrap UVW rollout and select all of the polygons, then press Open UV Editor. If its not already displaying the new visor texture, in this selection box, choose Pick Texture and find your visor texture.
    Now everything should look like this.
    We'll now select half of the visor in the 3d view, select the UV window, and press Ctrl+B to break off that half of the uv. Now the visor doesnt use the same half of the visor, and we can set it to use our broken part on one half.
    Press this button (1.) to flip our new half, and then you can use the freeform tool (2.) to line everything up.
    This should be what our final visor looks like.
    We will now proceed to skin all of our stuff. Luckily, since we're just rigging to the head, this is really easy.
    Remember, edits to your objects past this point are a pain to do, so make sure you've got all that handled already.
    Unhide all your eye models, and then select all 6 of them + your new visor and add a skin modifier.
    Press Edit Envelopes, select Add Bones, and select TopN. It should select the whole hierarchy of bones. Remember, if you dont add all bones, you'll run into issues.
    Check the vertices box and then press Ctrl+A to select all vertices from the selected objects.
    Scroll down in the rollout and press this wrench button. In the bones list, select HeadN, and then press this 1 button in the weight tool dialogue. This will rig everything to the head.
    Press Edit Envelopes a second time to exit this mode.

    Select all your new objects + the skeleton (as long as none of the original objects are visible, you should be able to just Ctrl+A to select everything), and go into the top-left options box, Export Selected,
    and export as a .dae with these settings

    Now, back in BrawlCrate, we're going to add our new stuff onto falcon. Right click his mdl0 and press Reimport Meshes, and select the .dae you just exported.
    Default settings should be fine, but here are mine for reference.
    Next, right click the Texture Data holder and select import > textures, and select your cracked visor texture.
    Set the import settings to use RGBA8, and make sure your textures are multiples of 8. (8, 16, 32, 64, 128, 256, 512, etc)
    Now we have some cleanup to do.

    Our import will have some new materials that we dont need so we'll go ahead and select those 4 and press ctrl+del to delete them. It will ask if you want to delete a shader, select yes. It is talking about an extra visor shader that got generated, but our new visor material we'll be making can reuse the original shader.

    Now to assign some materials.
    First, lets right-click the original visor material and duplicate it. Right click and rename that something else.
    now, expand the material, select the texture, and set it to our new visor texture (you may have to type in the texture name manually).
    Then, open the objects folder, and click on your visor. Set its material to use the new material.
    Also, for your new eyes, set the smallest eyes to use eyeEfA, the medium eyes to use eyeEfB, and the big eyes to use eyeEfC.
    Now we're going to set up transparency draw order.
    Select the new visor once again, uncheck "Doesn't Matter", and set the draw priority to be 10.
    Repeat this for all 6 of our eye objects, but for the small eyes make it 100, the medium eyes 80, and the big eyes 40.

    We also no longer need the original eye objects since we have our separated duplicates. Select polygon9, 10, and 11 and delete them. Say yes to whatever else it asks you to delete. Now we can open up the model viewer by rightclicking our mdl0 and pressing preview and look at our handywork. Check out what happens if we hide the original visor and the right eyes! fun fact, falcon reuses snakes eye, haha
    We now have one stage of our battle damage implemented.

    Now lets get back into 3ds and work on the second stage of battle damage, where the visor is completely gone and you can see his whole face. I'm going to borrow JoeTE's face texture and edit it to only include the parts we need, along with directly texturing on his eyebrows instead of having them fully modeled. (I forgot to do the eyebrows until after taking most of the following screenshots, sorry)

    Clone his head (polygon6) and delete the skin modifier. Now we need a symmetrical face, as this one is low-poly around the always-hidden eye. Add a symmetry modifier, check Flip so we get the side we need, and turn the weld threshold down significantly so that no vertices get accidentally merged.
    As you can see, the normals get destroyed and his mesh becomes faceted. This is an unfortunate side effect of mirroring, and I personally cannot figure out how to mirror or symmetricize a mesh in a way that preserves the normals. If you do know, I'd love to know how! For now, we'll just add an Edit Normals modifier, select Faces, select everything in the 3d view, and Unify your normals. As you may have noticed, when you first added the modifier, it actually fixed the original half of the model. If you really want to, you can try and fix the other side manually, but thats outside of this guides scope.
    Just like with the visor earlier, we're going to add an Unwrap UVW modifier and separate the two UV halves to fit on our new texture.
    Now we need to skin this. To copy a reasonably accurate version of the original heads' skin, we can use the Skin Wrap modifier. Press Add, and add polygon6, set threshold to 1.0, weight all points, and convert to skin.
    Now for the eyes.
    Select polygon5. Add a symmetry modifier, then unify all the normals, just as before. Then add a skin modifier and rig it all to HeadN.
    Just as before, select everything new, export selected, and reimport over the mdl0.
    Import your new face texture.
    Delete the new materials and extra shader, and duplicate the face material and replace the material's texture with the new one. (btw, the face uses the material named "eyeball")

    Now, open the model viewer and check our results! Along with magically appearing eyebrows.
    We are now done with 3ds max and all of our modelling woes.

    Now we have everything we need to create our battle damage edit.
    Time to move on to the more interesting stuff...
    Part 2: PSA Edits
    We're almost ready to move onto PSA Compressor, but first we gotta add our new visibility bones.
    There are multiple ways to do this, but they all boil down to copying an existing bone, renaming it, and adding a new entry into the FitFighter.
    For every object you want to be able to independently toggle, you must have a visibility bone.
    We have three total states we want our battle damage to reflect: Undamaged, partial damage, and completely broken.

    At the default state, we want to have Falcon look just as he does in vBrawl: default face, default visor, both eyes.
    During the first damage state, we want one eye hidden, the new visor showing. During the final damage state, we want both eyes toggled off, along with both visors, and our new face showing with the old one hidden.
    The optimal amount of bones we can use is 4: one for the first missing visor eye AND the first visor, one for the cracked visor, one to hide the original face AND the other visor eye, and finally one for the new face.

    To make our bones, we can simply right click the TopN bone in BrawlCrate, add a child, and rename it for our purpose.
    Expand the Bones folder in your MDL0, and create 4 new bones, following any naming convention you prefer.
    Important: Place all your new bones at the end of the list, then right-click TopN and press Regenerate Bone Array.
    They should already be at the end and numbered properly but I thought I'd make this warning anyway. The order the bones are numbered as is very important for all manner of things for a fighter, and you can royally screw things up if they arent in the order the game expects.
    Oh, and write down the BoneIndex of all your new bones, we'll need them later.
    Now that we have our bones, we'll assign our objects to make use of them.

    We're now done in BrawlCrate! (with any luck, lol)
    Now, moving right along to PSA Compressor...
    Opening up our FitFighter.pac (in our case, FitCaptain.pac) in PSAC will greet us with some compression settings. We don't need to touch any of this, so go ahead and start by clicking on the Data tab.
    Here we see plenty of settings related to various fighter-related properties, but we are of course only interested in ModelVisibility. Expand that, and then expand Model. BoneSwitches are what we use to call what set of visibilty bones we want to toggle, and which bones those happen to be are defined by any number of BoneGroups.

    We'll begin by highlighting and then right-clicking Model, and pressing Add New Switch
    Then highlight our new BoneSwitch2 and right click, add 3 groups for the 3 states of damage we outlined earlier.
    Now, when using BoneSwitches, we must remember that brawl is choosing what to show based on what we put in the corresponding BoneGroup.
    For the first BoneGroup, which is representative of the default state, we want to add the bones for the original visor and eye (Eye1Visor1) and the original face with other eye (Face1Eye2). If you remembered to write down the BoneIndex numbers of your visibility bones, now's the time to use them.

    Highlight and rightclick your first new BoneGroup, and press Add Data. This will add a List element, click it and select the new Data0 item that appears. In the bottom text box, add your BoneIndex number IN HEX. (windows calculator is capable of converting between decimal and hex if you set it to Programmer mode)
    Then press Done.
    Repeat this, adding a new Data item for the original face.
    Your BoneGroup0 should now resemble this.

    Repeat this process for BoneGroup1, where we want to show the second visor(Visor2) and original face(Face1Eye2) to get our semi-damaged state.
    Finally, repeat it once again for BoneGroup2, where we have to only select our new face bone for the game to handle the rest (Face2).
    Now we've got everything set up for using our visibility bones. We shall now begin writing some PSA code.

    In the events tab, go to Sub Routines and Create a new subroutine. This is where we'll be putting all of our checks for percentages, which is where we execute the commands necessary to visualize the battle damage.

    To begin with, we'll Modify the auto-generated "No event" command into the third-from-the-top If command (000A0400).
    In the Requirement parameter, set the type to Requirement, and set the Requirement to Compare.
    Set the first Variable parameter to be IC-Basic[2], which is the constant that tracks the fighter's current
    Leave the Comparison Method parameter at 0, which means "Less Than"
    Set the second Variable parameter to be of Scalar type, and put 100 as the value.

    What these parameters do is tell the game, "If the percentage is less than 100:"

    Then, add a Model Display Toggle command (0B010200) and set Thing to Change to 2 (denoting BoneSwitch2) and leave How to Change at 0 (denoting BoneGroup0)

    Finally, add an End If command (000F0000) to close out our if statement.

    Repeat this process again but, in the If command, instead of asking if the percent is less than 100, set it to ask if the percent is more or equal than 100
    also, right after the If event, add an And Comparison (000B0400) command to add an extra layer of certainty for our check. This is also required if you plan to add one-time events like GFX or SFX, so you can accurately keep track of variables. Take a look at my Meta Knight mod to see what I mean.

    For the Model Changer, set it to Thing to Change to 2, and How to Change to 1.
    Then repeat all that (minus the And event) but with the percentage to 200. Your final subroutine should look like this:

    Now this subroutine won't do us any good if the fighter never calls for it. We're going to add this in a few subactions to make sure its often checked and used.

    Change to the Sub Actions tab and scroll "List" down to Other, this is typically where you deal with model changers.
    Add a Sub Routine (00070100) event and set it to use the offset address of your subroutine. Every time the fighter enters Wait1, it will run a check to see which model changer to use.
    While Wait1 does happen fairly often, it would be best to add it to a couple more subactions for some better coverage.
    Highlight the Sub Routine event and press Copy. Navigate to Sub Action 98 and press paste. Move your Sub Routine to before the Asynchronous timer happens so that it doesnt check for the model changer on a delay.
    Repeat this for all the damage subactions. (98 through to A9)
    Finally, go to both Entry subactions (1C2 and 1C3) and all Win subactions not including WinWaits (1C4, 1C6, 1C8) and Lose subaction (1CA) and paste it there too. Now all your bases are covered, and with any luck, you've just implemented Battle Damage into your fighter.

    Oh, and I may have screwed something up, so check back later for possible edits.
    Wow, 3k words... I may have gone overboard. I doubt as many people will find this useful proportional to how much effort I put into making it. Oh well, it was fun to learn how to write a tutorial anyway.
    Message me on discord malistaticy#9718 or find me on the Custom Brawl Modding server if you have any questions!

    3ds Max to BrawlCrate Dae import guide
    Strange Matter's Model Changer guide


    "So I can put anything here and people can read it?"
    -malistaticy, 2016

    Pages: [1]
    Jump to: