RMMV CCEX: Force Equip Section Piece within Character Creator Scene

Status
Not open for further replies.

lesbrarians

Veteran
Veteran
Joined
May 23, 2021
Messages
85
Reaction score
63
First Language
English
Primarily Uses
RMMV
Hello again! So, I had great success with my last thread asking for help with the CCEX plugin, and now I have a followup problem that I could use some help in resolving.

To recap: I have my character creator set up so that when a player selects a certain body type, it sets a variable to a certain value, which then shows the player the clothing folders associated with that body type. This works as desired, and I'm thrilled! However, when playtesting, I ran into a new dilemma. If the player chooses a "female" body type and adds a shirt to the body, which has breasts, then they decide to switch the body to a "male" body type with a flat chest... they're stuck with the shirt that has breasts.

I've been poring over the code for the Character Creator EX as well as Dynamic Actors (which uses a notetag <Force [section] Piece: [file-name]> to change the custom character's clothing) to see if there's some way I can use the same logic to resolve this situation. Ideally, I'm trying to create a condition to activate when the player selects a new body type that's like "If the preview image includes 'Clothing (i)' in Section ('Female Top'), change Clothing (i) to Clothing (0) in Section ('Female Top'), and equip 'Clothing (i)' in Section ('Male Top')." In this example, Clothing (0) is the "blank" image that is used to remove a section piece, and Clothing (i) is the offending article of clothing, which can be anywhere from Clothing (1) to Clothing (10).

I imagine I would have to use a for loop to check for each possibly equipped item -- that, I can set up. What I'm stuck on is the actual script to forcibly equip a piece in a section.

Within the CCEX .js, this code is used to add the image for the currently selected Section and Piece. I was hoping I could modify this to specifically reference a different Section and a different File, instead of currentSection and currentFile, but I've not had any luck.

JavaScript:
this._previewWindow.addImage(this._fileList.currentFilePath(), this._fileList.currentSection(), this._fileList.currentFile());

Can anyone offer any suggestions to maybe steer me in the right direction? You can view the code for CCEX by clicking on "view" at the links above. I'm still a novice to JS (been going thru W3Schools as I study this code to try and educate myself on what I'm looking at!) but I'm determined to make this work. Any advice would be much appreciated! Thanks for all your help so far, folks!
 

lesbrarians

Veteran
Veteran
Joined
May 23, 2021
Messages
85
Reaction score
63
First Language
English
Primarily Uses
RMMV
It's been 72 hours, so I hope it's alright to bump this up with my current progress/questions!
I've been able to remove equipped pieces successfully, but I'm still not satisfied with that. I really want to store the current selected clothing parts into a variable, and apply their counterparts when switching bodies. (i.e. If someone equips file Body (1) in folder PantsB, then I switch to a body type that uses PantsA, I want to remove Body (1) from PantsB (which I have accomplished!) AND apply the Body (1) in PantsA instead.)

So, here's my full code so far. I can trim it down to just the necessary parts if someone would like me to do so! But I figured to start, it'd be best to show you the whole thing.

JavaScript:
Scene_CharacterCreator.prototype.saveCurrentSelection = function() {
    const NotA1Pants = ['PantsB'];
    const NotA1Tops = ['TopsA2', 'TopsB1', 'TopsB2', 'TopsC1', 'TopsC2'];
    const NotA1Faces = ['BodyA2 Part1', 'BodyA2 Part2', 'BodyA3 Part1', 'BodyA3 Part2', 'BodyB1 Part1', 'BodyB1 Part2', 'BodyB2 Part1', 'BodyB2 Part2', 'BodyB3 Part1', 'BodyB3 Part2', 'BodyC1 Part1', 'BodyC1 Part2', 'BodyC2 Part1', 'BodyC2 Part2', 'BodyC3 Part1', 'BodyC3 Part2'];
    const CurrentPants = ['Clothing (0)'];
//If player selects the file named Clothing (1) in folder PantsB
if (this._folderList.currentFolder() == 'PantsB' && this._fileList.currentFile() == 'Clothing (1)') {
    //Store Clothing (1) in CurrentPants array, replacing Clothing (0) [all files ending in (0) are the "unequip" files]
    //If I can get this test to work, I will set up a loop to check for other selections, such as Clothing (2) etc, as well as other folders, such as Tops... I'm using splice bc it should allow me to store just one string in the CurrentPants variable, even if the player selects a bunch of different pants to see how they look equipped.
    CurrentPants.splice(0, 1, 'Clothing (1)');
}
    //If player selects Body Type A1
if (this._folderList.currentFolder() == 'Body' && this._fileList.currentFile() == 'Body (1)')
    //Unhide the folders for the Pants, Tops, and Faces that correspond with Body Type A1
    {   $gameVariables.setValue(64, 1);
        $gameVariables.setValue(65, 1);
        $gameVariables.setValue(66, 1);
        $gameSwitches.setValue(80, true);
    for (let i = 0, j = 0, k = 0; i < NotA1Pants.length, j < NotA1Tops.length, k < NotA1Faces.length; i++, j++, k++){
        //Bundle together all folders that don't correspond to Body Type A1 into one variable
        const NotA1Folders = [NotA1Pants[i], NotA1Tops[j], NotA1Faces[k]];
        for (let l = 0; l < NotA1Folders.length; l++) {
        //Remove any parts that were equipped from other body types
        this._previewWindow.addImage(_.path + NotA1Folders[l] + '/walk/', NotA1Folders[l], 'Clothing (0)');
        this._previewWindowDead.addImage(_.path + NotA1Folders[l] + '/dead/', NotA1Folders[l], 'Clothing (0)');
        this._previewWindowPose.addImage(_.path + NotA1Folders[l] + '/pose/', NotA1Folders[l], 'Clothing (0)');
        this._previewWindowSv.addImage(_.path + NotA1Folders[l] + '/sv/', NotA1Folders[l], 'Clothing (0)');
        this._previewWindowFace.addImage(_.path + NotA1Folders[l] + '/face/', NotA1Folders[l], 'Clothing (0)');
        //Replace pants for A1 with any pants that were selected on other Body Types
        this._previewWindow.addImage(_.path + 'PantsA' + '/walk/', 'PantsA', CurrentPants[0]);
        this._previewWindowDead.addImage(_.path + 'PantsA' + '/dead/', 'PantsA', CurrentPants[0]);
        this._previewWindowPose.addImage(_.path + 'PantsA' + '/pose/', 'PantsA', CurrentPants[0]);
        this._previewWindowSv.addImage(_.path + 'PantsA' + '/sv/', 'PantsA', CurrentPants[0]);
        this._previewWindowFace.addImage(_.path + 'PantsA' + '/face/', 'PantsA', CurrentPants[0]);
        }    
    }
     //If other body types are selected, unhide their folders instead
    } else if  (this._folderList.currentFolder() == 'Body' && this._fileList.currentFile() == ('Body (2)')) {
        $gameVariables.setValue(64, 2);
        $gameVariables.setValue(65, 1);
        $gameVariables.setValue(66, 2);
        $gameSwitches.setValue(80, true);
    } else if (this._folderList.currentFolder() == 'Body' && this._fileList.currentFile() == ('Body (3)')) {
        $gameVariables.setValue(64, 3);
        $gameVariables.setValue(65, 1);
        $gameVariables.setValue(66, 2);
        $gameSwitches.setValue(80, true);
    } else if (this._folderList.currentFolder() == 'Body' && this._fileList.currentFile() == ('Body (4)')) {
        $gameVariables.setValue(64, 4);
        $gameVariables.setValue(65, 1);
        $gameVariables.setValue(66, 3);
        $gameSwitches.setValue(80, true);
    } else if (this._folderList.currentFolder() == 'Body' && this._fileList.currentFile() == ('Body (5)')) {
        $gameVariables.setValue(64, 5);
        $gameVariables.setValue(65, 1);
        $gameVariables.setValue(66, 4);
        $gameSwitches.setValue(80, true);
    } else if (this._folderList.currentFolder() == 'Body' && this._fileList.currentFile() == ('Body (6)')) {
        $gameVariables.setValue(64, 6);
        $gameVariables.setValue(65, 1);
        $gameVariables.setValue(66, 4);
        $gameSwitches.setValue(80, true);
    } else if (this._folderList.currentFolder() == 'Body' && this._fileList.currentFile() == ('Body (7)')) {
        $gameVariables.setValue(64, 7);
        $gameVariables.setValue(65, 2);
        $gameVariables.setValue(66, 5);
        $gameSwitches.setValue(80, true);
    } else if (this._folderList.currentFolder() == 'Body' && this._fileList.currentFile() == ('Body (8)')) {
        $gameVariables.setValue(64, 8);
        $gameVariables.setValue(65, 2);
        $gameVariables.setValue(66, 6);
        $gameSwitches.setValue(80, true);
    } else if (this._folderList.currentFolder() == 'Body' && this._fileList.currentFile() == ('Body (9)')) {
        $gameVariables.setValue(64, 9);
        $gameVariables.setValue(65, 2);
        $gameVariables.setValue(66, 6);
        $gameSwitches.setValue(80, true);
    }
    //Add the image for the selected part, so it shows in the preview window
    if(!this._combinedMode) {
        this._previewWindow.addImage(this._fileList.currentFilePath(),
    } else {
        const combines = this._folderList.combines();
        for(let i = 0; i < combines.length; i++) {
            this._previewWindow.addImage(_.path + combines[i] + '/walk/',
                combines[i], this._fileList.currentFile());
        }
    }
    this._folderList.refresh();
};

Here's what's throwing me. If I put CurrentPants.splice(0, 1, 'Clothing (1)'); outside of the conditional statement, it works as intended! The pants are removed from any other body type, and the corresponding pants are equipped for Body A1! Perfect!

Except, I need to store the pants that the player selects within CurrentPants, so I need it to be inside the conditional statement. So I'm just kind of.... scratching my head. Idk why the splice isn't working within the conditional, especially since nothing is wrong with the conditional statement itself (I've tested other things within that conditional, and it's fine...)

Any thoughts?

EDIT: Never mind, figured it out!!! Had to initialize the variable outside of the saveCurrentSelection function!! I'll keep this thread open if I run into any problems with setting up my loops to check for all items and folders. :>

EDIT2: All figured out! It's working to perfection, and I've streamlined the code a bit too. No more ghost parts, players can switch between body types at will throughout the character creation process. Thank you to anyone who considered replying to this query, and if future people stumble across this thread w the same question, feel free to use the code above as a base! Just intialize all variables outside the function, and use "for" loops to check for different selections. Onto the next thing I'd like to fix about CCEX!
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,023
Reaction score
5,905
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Something might be coming...
Hallo.png
A new day for creating :)
2021 has been the runner-up for the worst year of my life. 2015 may take that title, but '21 is pushing it. Excuses really don't justify how much of a jerk I've been this year to a lot of people.

I'm sorry. I don't intend to be a jerk forever, but I'd rather back up my intent with actions, not words.
"Another hundred habaneros... a teaspoon of tumeric... and a heaping helping of nitroglycerin!" The kitten in a chef's hat laughed maniacally as the pot he was stirring promptly exploded.

Forum statistics

Threads
116,018
Messages
1,094,953
Members
151,332
Latest member
RaxecV
Top