code:
var CC_Mod = CC_Mod || {};
CC_Mod.PregMod = CC_Mod.PregMod || {};

//=============================================================================
 /*:
 * @plugindesc Various minor changes and tweaks
 * @author chainchariot/drchainchair/whatever random throwaway name I picked
 *  Current account on F95: https://f95zone.to/members/drchainchair2.2159881/
 *
 * @help
 * This is a free plugin.
 * If you want to redistribute it, leave this header intact.
 * Thanks to LOTD for his mod as looking at it let me figure some stuff out
 *
 * Status picture images from eraSumireTeru
 * Fetus pictures from RJ295803
 *
 */
//=============================================================================

// Mod Options
//////////////////////////////////////////////////////////////
// Set to true to enable, false to disable

const CCMod_pregModEnabled = true;
const CCMod_statusPictureEnabled = true;
// Remove the gift text from the status window since it gets a bit crowded
const CCMod_disableGiftText = true;

// This is a fixed +/- amount added to fertility chance (if base >0)
const CCMod_fertilityChanceVariance = 0.015;
// The higher this is the more creampies in a single day will increase fertility
const CCMod_fertilityChanceFluidsFactor = 4;
// Multiplier applied to fertility chance at the end of the calc
const CCMod_fertilityChanceGlobalMult = 1;

// Passives
// This is the record count that needs to be met to learn the passive
const CCMod_passiveRecordThreshold_BirthOne = 1;
const CCMod_passiveRecordThreshold_BirthTwo = 5;
const CCMod_passiveRecordThreshold_BirthThree = 15;
const CCMod_passiveRecordThreshold_Race = 10;

// This is multiplied to the base chance, not additive
const CCMod_passive_fertilityRateIncreaseMult = 1.15;
// Value for one step of the speed increase.  Subtracted from duration on each stage while preg
const CCMod_passive_fertilityPregnancyAcceleration = 1;

// Edicts
// Additive to base chance
const CCMod_edict_fertilityRateIncrease = 0.10;
// Subtract this value to from remaining duration while preg
const CCMod_edict_fertilityPregnancyAcceleration = 1;
// This is supposed to trigger when a riot starts
const CCMod_edict_CargillSabotageChance_Base = 0.20;
const CCMod_edict_CargillSabotageChance_OrderMod = 0.35;

const CCMod_fertilityCycleDurationArray =
   [0,  // null
    1,  // safe
    3,  // normal
    2,  // before danger
    1,  // danger
    1,  // ovulation
    1,  // fertilized
    3,  // trimester 1
    3,  // trimester 2
    3,  // trimester 3
    1,  // due date
    1,  // recovery
    1]; // birth control

const CCMod_fertilityCycleFertilizationChanceArray =
   [0,      // null
    0.04,   // safe
    0.09,   // normal
    0.20 ,  // before danger
    0.35,   // danger
    0.27,   // ovulation
    0,      // fertilized
    0,      // trimester 1
    0,      // trimester 2
    0,      // trimester 3
    0,      // due date
    0.03,   // recovery
    0.02];  // birth control

// Karryn is...
const CCMod_fertilityCycleNameArray =
   ["NULL",
    "on a safe day",
    "feeling normal",
    "feeling frisky",
    "on her dangerous day",
    "ovulating",
    "fertilized",
    "in her first trimester",
    "in her second trimester",
    "in her third trimester",
    "going to go into labor soon",
    "recovering from pregnancy",
    "on birth control"];

// Charm percent param modifier
// rate = 1 + val
const CCMod_fertilityCycleCharmParamRates =
   [0,      // null
    -0.05,  // safe
    0,      // normal
    0.10,   // before danger
    0.20,   // danger
    0.15,   // ovulation
    0.02,   // fertilized
    0.05,   // trimester 1
    0.10,   // trimester 2
    0.15,   // trimester 3
    0,      // due date
    0,      // recovery
    -0.10]; // birth control

// General modifier to gainFatigue()
// rate = 1 + val
const CCMod_fertilityCycleFatigueRates =
   [0,      // null
    0.03,   // safe
    -0.05,  // normal
    0,      // before danger
    0,      // danger
    0,      // ovulation
    0.02,   // fertilized
    0.07,   // trimester 1
    0.15,   // trimester 2
    0.30,   // trimester 3
    0.75,   // due date
    0.50,   // recovery
    0];     // birth control

//=============================================================================
//////////////////////////////////////////////////////////////
// Vars & Utility Functions

const CCMOD_DEBUG = false;

const CCMOD_CUTIN_FERTILIZATION_NAME = 10062;

const CCMOD_ANIMATION_FERTSFX_ID = 178;
const CCMOD_ANIMATION_BIRTHSFX_ID = 179;

// This has turned into displaying the full string instead of just a name
const CCMOD_VARIABLE_FATHER_NAME_ID = 152;

const CCMOD_SWITCH_BIRTH_QUEUED_ID = 247;
const CCMOD_SWITCH_BED_STRIP_ID = 248; // Enables strip option in bed menu

// Edicts
const CCMOD_EDICT_FERTILITYRATE_ID = 1356;
const CCMOD_EDICT_PREGNANCYSPEED_ID = 1357;
const CCMOD_EDICT_BIRTHCONTROL_NONE_ID = 1358;
const CCMOD_EDICT_BIRTHCONTROL_ACTIVE_ID = 1359;

// Passives
const CCMOD_PASSIVE_BIRTH_COUNT_ONE_ID = 1360; // Fert rate up
const CCMOD_PASSIVE_BIRTH_COUNT_TWO_ID = 1361; // Speed up
const CCMOD_PASSIVE_BIRTH_COUNT_THREE_ID = 1362; // Speed up, Child count up (stacks with racial)
const CCMOD_PASSIVE_BIRTH_HUMAN_ID = 1363; // Child count up
const CCMOD_PASSIVE_BIRTH_GOBLIN_ID = 1364; // Child count up
const CCMOD_PASSIVE_BIRTH_SLIME_ID = 1365; // Child count up
const CCMOD_PASSIVE_BIRTH_LIZARD_ID = 1366; // Child count up
const CCMOD_PASSIVE_BIRTH_WOLF_ID = 1367; // There's a wolfman picture in the game files

// Exhibitionist Passives
// This is all implemented in the other file but I want to keep ID declarations in the same spot
const CCMOD_PASSIVE_EXHIBITIONIST_ONE_ID = 1370; // No penalty
const CCMOD_PASSIVE_EXHIBITIONIST_TWO_ID = 1371; // Pleasure while walking around naked, wake up naked

const CCMOD_SKILL_GIVE_BIRTH_ID = 1372;
const CCMOD_SKILL_ENEMY_IMPREG_ID = 1373;

// Status Window
const CCMOD_STATUSPICTURE_FOLDER = 'img/statusmenu/';
const CCMOD_STATUSPICTURE_PREFIX = 'statusWindow_';

const CCMOD_STATUSPICTURE_COLORARRAY_HUMAN  = [0, 0, 0, 0];
const CCMOD_STATUSPICTURE_COLORARRAY_GOBLIN = [35, 0, 0, 0];
const CCMOD_STATUSPICTURE_COLORARRAY_SLIME  = [180, 0, 0, 0];
const CCMOD_STATUSPICTURE_COLORARRAY_LIZARD = [-30, 0, 0, 0];

// These numbers are also array indices
const CCMOD_CYCLE_STATE_NULL = 0;
const CCMOD_CYCLE_STATE_SAFE = 1;
const CCMOD_CYCLE_STATE_NORMAL = 2;
const CCMOD_CYCLE_STATE_BEFORE_DANGER = 3;
const CCMOD_CYCLE_STATE_DANGER_DAY = 4;
const CCMOD_CYCLE_STATE_OVULATION = 5;
const CCMOD_CYCLE_STATE_FERTILIZEZD = 6;
const CCMOD_CYCLE_STATE_TRIMESTER_ONE = 7;
const CCMOD_CYCLE_STATE_TRIMESTER_TWO = 8;
const CCMOD_CYCLE_STATE_TRIMESTER_THREE = 9;
const CCMOD_CYCLE_STATE_DUE_DATE = 10;
const CCMOD_CYCLE_STATE_BIRTH_RECOVERY = 11;
const CCMOD_CYCLE_STATE_BIRTHCONTROL = 12;

CC_Mod.initializePregMod = function(actor) {
    if (actor._CCMod_version < CCMOD_VERSION_4u) {
        // Init all persistent variables here
        actor._CCMod_fertilityCycleState = CCMOD_CYCLE_STATE_NULL;
        actor._CCMod_fertilityCycleStateDuration = CCMod_fertilityCycleDurationArray[actor._CCMod_fertilityCycleState];
        actor._CCMod_currentFertility = 0;

        actor._CCMod_recordPregCount = 0;
        actor._CCMod_recordBirthCount = 0;
        actor._CCMod_recordBirthCountHuman = 0;
        actor._CCMod_recordBirthCountGoblin = 0;
        actor._CCMod_recordBirthCountSlime = 0;

        actor._CCMod_recordFirstFatherWantedID = -1;
        actor._CCMod_recordFirstFatherName = false;
        actor._CCMod_recordFirstFatherDateImpreg = false;
        actor._CCMod_recordFirstFatherDateBirth = false;
        actor._CCMod_recordFirstFatherMapID = -1;

        actor._CCMod_recordLastFatherName = false;
        actor._CCMod_recordLastFatherDateImpreg = false;
        actor._CCMod_recordLastFatherDateBirth = false;
        actor._CCMod_recordLastFatherMapID = -1;

        actor._CCMod_birthControlID = -1;
        actor._CCMod_fertilityDrugID = -1;
        actor._CCMod_fertilityDrugDuration = -1;
    }

    if (actor._CCMod_version < CCMOD_VERSION_5e) {
        actor._CCMod_recordLastFatherSpecies = false;
    }

    if (actor._CCMod_version < CCMOD_VERSION_6c) {
        actor._CCMod_recordBirthCountLizardmen = 0;
    }

    if (actor._CCMod_version < CCMOD_VERSION_6i_2) {
        actor._CCMod_recordFirstFatherSpecies = false;
        // First child count will not be retroactively accurate
        actor._CCMod_recordFirstFatherChildCount = -1;
        actor._CCMod_recordLastFatherChildCount = -1;

        actor.learnSkill(CCMOD_EDICT_BIRTHCONTROL_NONE_ID);
    }

    CC_Mod.lastDrawnBabyState = 0;

    CC_Mod.fertilityCycle_Init(actor);
};

CC_Mod.setupPregModRecords = function(actor) {
    actor._CCMod_recordPregCount = 0;
    actor._CCMod_recordBirthCount = 0;
    actor._CCMod_recordBirthCountHuman = 0;
    actor._CCMod_recordBirthCountGoblin = 0;
    actor._CCMod_recordBirthCountSlime = 0;
    actor._CCMod_recordBirthCountLizardmen = 0;

    actor._CCMod_recordFirstFatherWantedID = -1;
    actor._CCMod_recordFirstFatherName = false;
    actor._CCMod_recordFirstFatherDateImpreg = false;
    actor._CCMod_recordFirstFatherDateBirth = false;
    actor._CCMod_recordFirstFatherMapID = -1;
    actor._CCMod_recordFirstFatherSpecies = false;
    actor._CCMod_recordFirstFatherChildCount = -1;

    actor._CCMod_recordLastFatherName = false;
    actor._CCMod_recordLastFatherDateImpreg = false;
    actor._CCMod_recordLastFatherDateBirth = false;
    actor._CCMod_recordLastFatherMapID = -1;
    actor._CCMod_recordLastFatherSpecies = false;
    actor._CCMod_recordLastFatherChildCount = -1;

    actor._CCMod_birthControlID = -1;
    actor._CCMod_fertilityDrugID = -1;
    actor._CCMod_fertilityDrugDuration = -1;

    actor._CCMod_fertilityCycleState = CCMOD_CYCLE_STATE_NULL;
    CC_Mod.fertilityCycle_Init(actor);
};

CC_Mod.CCMod_debugFunc = function () {
    let actor = $gameActors.actor(ACTOR_KARRYN_ID);

    //CC_Mod.fertilityCycle_Calc(actor);

    //actor._CCMod_currentFertility = 0.80;

    //actor.setPleasureToOrgasmPoint();

    //actor._CCMod_recordFirstFatherSpecies = actor._CCMod_recordLastFatherSpecies;

    //$gameSwitches.setValue(CCMOD_SWITCH_BED_STRIP_ID, true);

    if ($gameVariables.value(CCMOD_VARIABLE_FATHER_NAME_ID) == 0) {
        //CC_Mod.setFatherNameGameVar(actor._CCMod_recordFirstFatherSpecies);
        //CC_Mod.setupChildCount();
    }

    if (!actor.CCMod_isPreg()) {
        //let father = $gameParty.getWantedEnemyById(1);
        //CC_Mod.fertilityCycle_TryImpregnation(actor, father);
        //CC_Mod.fertilityCycle_SetState(actor, CCMOD_CYCLE_STATE_TRIMESTER_THREE);
        //actor._CCMod_recordLastFatherName = "Karryn gave birth to the child/children of Bob Smith (Level 1 Thug)";
    }

};

//=============================================================================
//////////////////////////////////////////////////////////////
// Battle Fertilization CutIn

// @param enemy actor
CC_Mod.processCreampie = function(actor, target) {
    //let target = $gameActors.actor(ACTOR_KARRYN_ID);
    return CC_Mod.fertilityCycle_TryImpregnation(actor, target);
};

Game_Enemy.prototype.dmgFormula_fertilization = function(target, area) {
    target.setTachieCutIn(CCMOD_CUTIN_FERTILIZATION_NAME);
    return 0; // This return is really important
};

Game_Enemy.prototype.postDamage_fertilization = function(target, area) {
    // Empty for now, but it's still called from the skill
    //this.setTachieCutIn(CCMOD_CUTIN_FERTILIZATION_NAME);
};

Game_Actor.prototype.CCMod_cutInArray_Fertilization = function() {
	let cutInArray = [ false, 0, 0, false, 0, 0, [] ];
	let cutInFrame = this.cutInFrame();
	let backImageName = false;
	let back_x_offset = 0;
	let back_y_offset = 0;
	let frontImageName = false;
	let front_x_offset = 0;
	let front_y_offset = 0;
	let fasterCutIns = ConfigManager.remCutinsFast;

    backImageName = 'fert_cutin_back';
    back_x_offset = 0;
    back_y_offset = 0;

    /* // Dunno why this doesn't work
    if( (cutInFrame >= 20) && (cutInFrame < 60 ) {
        frontImageName = 'fert_cutin_01';
    } else if( (cutInFrame >= 60) && (cutInFrame < 100 ) {
        frontImageName = 'fert_cutin_02';
    } else if( cutInFrame >= 100 ) {
        frontImageName = 'fert_cutin_03';
    }
    */
    if( cutInFrame >= 100 ) {
        frontImageName = 'fert_cutin_03';
    }

	cutInArray[CUT_IN_ARRAY_BACK_NAME_ID] = backImageName;
	cutInArray[CUT_IN_ARRAY_BACK_X_OFFSET_ID] = back_x_offset;
	cutInArray[CUT_IN_ARRAY_BACK_Y_OFFSET_ID] = back_y_offset;
	cutInArray[CUT_IN_ARRAY_FRONT_NAME_ID] = frontImageName;
	cutInArray[CUT_IN_ARRAY_FRONT_X_OFFSET_ID] = front_x_offset;
	cutInArray[CUT_IN_ARRAY_FRONT_Y_OFFSET_ID] = front_y_offset;
	return cutInArray;
};

Game_Actor.prototype.CCMod_setCutInWaitAndDirection = function(cutInName) {
	let poseName = this.poseName;
	let wait = CUTIN_DEFAULT_DURATION;
	let startingX = REM_CUT_IN_RIGHT_X;
	let startingY = REM_CUT_IN_TOP_Y;
	let goalX = REM_CUT_IN_LEFT_X;
	let goalY = REM_CUT_IN_TOP_Y;
	let directionX = -1 * REM_CUT_IN_SPEED_X;
	let directionY = 0;

    wait = 220; 		//wait = CutInの時間
    startingX = 0; 		//startingX = CutInが始まる時のX位置
    goalX = 0; 		//goalX = CutInが終わる時のX位置
    startingY = 0; 		//startingY = CutInが始まる時のY位置
    goalY = 0; 		//goalY = CutInが終わる時のY位置
    directionX = 0; 		//directionX = CutInのX方向
    directionY = 0; 		//directionY = CutInのY方向

	BattleManager.cutinWait(wait);
	this._tachieCutInPosX = startingX;
	this._tachieCutInGoalX = goalX;
	this._tachieCutInPosY = startingY;
	this._tachieCutInGoalY = goalY;
	this._tachieCutInDirectionX = directionX;
	this._tachieCutInDirectionY = directionY;
};

//=============================================================================
//////////////////////////////////////////////////////////////
// Pause Menu

// Color code notes:
/*
    0   default white
    2   minor stat loss
    18  major stat loss

    11  green positive (gift color)
    23  good rest stats
    29  well rested stats
    28  very well rested stats

*/

CC_Mod.CCMod_getFertilityText = function(fertVal) {
    fertVal = Math.round(fertVal * 1000) / 10;

    let fertText = "";

    if (fertVal >= 100) {
        fertText += "\\C[5]";
    } else if (fertVal >= 70) {
        fertText += "\\C[1]";
    } else if (fertVal >= 40) {
        fertText += "\\C[27]";
    } else if (fertVal >= 20) {
        fertText += "\\C[30]";
    } else if (fertVal >= 10) {
        fertText += "";
    } else if (fertVal >= 5) {
        fertText += "\\C[8]";
    } else {
        fertText += "\\C[7]";
    }

    fertText += fertVal + "%\\C[0]";

    return fertText;
};

CC_Mod.CCMod_getFertilityStatusText = function(actor) {
    CC_Mod.fertilityCycle_Calc(actor);
    let fertPercentText = CC_Mod.CCMod_getFertilityText(actor._CCMod_currentFertility);
    let statusText = "";
    let state = actor._CCMod_fertilityCycleState;

    if (CCMOD_DEBUG) {
        statusText += "H: " + CC_Mod.Gyaru_getHairName(actor) + " | " + actor._CCMod_currentHairColor +
                      " E: " + CC_Mod.Gyaru_getEyeName(actor) + " | " + actor._CCMod_currentEyeColor +
                      (CC_Mod.Gyaru_isEyeChanged(actor) ? " T" : " F") + (CC_Mod.Gyaru_hasEyeEdict(actor) ? " T" : " F") +
                      //"TE: " + actor.tachieEyesFile() + //actor.tachieHead + //actor.tachieHeadFile() +
                      //" E: " + CC_Mod.CCMod_currentEyeName +
                      //" G:" + CC_Mod.Gyaru_getSkinName(actor) +
                      //" EC: " + ((actor.tachieEyesFile() != CC_Mod.CCMod_currentEyeName) ? "Diff" : "NoDiff") +
                      //" RQ: " + (CC_Mod.CCMod_eyeRedrawQueued ? "True" : "False") +
                      //" P:" + (CC_Mod.Gyaru_isPoseSupported(actor.poseName) ? "Yes" : "No") +
                      //" CD:" + actor._CCMod_fertilityCycleStateDuration +
                      //" Dur:" + actor._clothingDurability + "/" + actor.getClothingMaxDurability() +
                      //" E:" + (actor.hasEdict(CCMOD_EDICT_BIRTHCONTROL_ACTIVE_ID) ? "Active" : "Inactive") +
                      "\n";
    } else {
        statusText += "\n";
    }

    statusText += "Karryn is " + CCMod_fertilityCycleNameArray[state];
    let charmRate = Math.round(CCMod_fertilityCycleCharmParamRates[state] * 100);
    let fatigueRate = Math.round(CCMod_fertilityCycleFatigueRates[state] * 100);

    if (charmRate != 0 || fatigueRate != 0) {
        statusText += " (";

        if (charmRate != 0) {
            if (charmRate > 0) {
                statusText += "\\C[11]Charm +" + charmRate + "%\\C[0]";
            } else {
                statusText += "\\C[10]Charm " + charmRate + "%\\C[0]";
            }
            if (fatigueRate != 0) {
                statusText += " ";
            }
        }

        if (fatigueRate != 0) {
            if (fatigueRate < 0) {
                statusText += "\\C[29]Fatigue " + fatigueRate + "%\\C[0]";
            } else {
                statusText += "\\C[2]Fatigue +" + fatigueRate + "%\\C[0]";
            }
        }

        statusText += ")";
    }

    if (!actor.CCMod_isPreg()) {
        statusText += " \\C[27]♥\\C[0] " + fertPercentText;
    }

    // TODO: Display liquids?  Probably best done via status picture

    if (CCMOD_DEBUG) {
        CC_Mod.CCMod_debugFunc();
    }

    return statusText;
};

CC_Mod.CCMod_drawKarrynStatus = function(win) {
    let actor = $gameActors.actor(ACTOR_KARRYN_ID);
    let x = win.textPadding();
    let lh = win.lineHeight();
    let width = win.width - win.textPadding() * 4;
    let line = 9;

    //if (CCMOD_DEBUG)
    //    line--;

    let statusText = "";
    if (CCMod_pregModEnabled) {
        statusText += CC_Mod.CCMod_getFertilityStatusText(actor);
    }
    if (statusText != "") {
        if (CCMod_disableGiftText) {
            statusText += "\n";
            line--;
        } else {
            statusText += " | ";
        }
    }
    statusText += CC_Mod.CCMod_getExhibitionistStatusText(actor);

    win.drawTextEx(statusText, x, line * lh, width, 'left', true);
};

CC_Mod.PregMod.Game_Actor_allGiftsText = Game_Actor.prototype.allGiftsText;
Game_Actor.prototype.allGiftsText = function() {
    if (CCMod_disableGiftText) {
        return '';
    }
    return CC_Mod.PregMod.Game_Actor_allGiftsText.call(this);
};

//=============================================================================
//////////////////////////////////////////////////////////////
// Status Picture

// Amounts taken from Game_Actor.prototype.getTachieSemenCrotchId.  Consistency!
const CCMOD_STATUSPICTURE_CUMLIMIT_01 = 1;
const CCMOD_STATUSPICTURE_CUMLIMIT_02 = 30;
const CCMOD_STATUSPICTURE_CUMLIMIT_03 = 75;
const CCMOD_STATUSPICTURE_CUMLIMIT_04 = 100;

CC_Mod.PregMod.DKTools_PreloadManager_preloadKarrynPoses = DKTools.PreloadManager.preloadKarrynPoses;
DKTools.PreloadManager.preloadKarrynPoses = function() {
    CC_Mod.PregMod.DKTools_PreloadManager_preloadKarrynPoses.call(this);
    if (CCMod_statusPictureEnabled) {
        DKTools.PreloadManager.preloadImage({ path: CCMOD_STATUSPICTURE_FOLDER, hue: 0, caching: true });
    }
};

// I don't know if linking it to the window object matters, but it works for now
CC_Mod.CCMod_bitmapStatusPicture = function(win, actor) {
    win.CCMod_actorBitmapStatusPicture = win.CCMod_actorBitmapStatusPicture || {};
    var actorId = actor.actorId();
    if (actor.temp) {
        actorId = -1;
    }
    if (!win.CCMod_actorBitmapStatusPicture[actorId]) {
        win.CCMod_actorBitmapStatusPicture[actorId] = new Bitmap(Graphics.width + TACHIE_REM_CUSTOM_WIDTH, Graphics.height+TACHIE_REM_CUSTOM_HEIGHT);
    }
    return win.CCMod_actorBitmapStatusPicture[actorId];
};

CC_Mod.CCMod_bitmapBabyStatusPicture = function(actor) {
    this.CCMod_actorBitmapStatusPicture = this.CCMod_actorBitmapStatusPicture || {};
    var actorId = actor.actorId();
    if (actor.temp) {
        actorId = -1;
    }
    if (!this.CCMod_actorBitmapStatusPicture[actorId]) {
        this.CCMod_actorBitmapStatusPicture[actorId] = new Bitmap(Graphics.width + TACHIE_REM_CUSTOM_WIDTH, Graphics.height+TACHIE_REM_CUSTOM_HEIGHT);
    }
    return this.CCMod_actorBitmapStatusPicture[actorId];
};

// Copy of SabaTachie drawTachieFile and drawTachieImage
CC_Mod.CCMod_drawTachieFile = function (file, bitmap, actor, x, y, rect, scale) {
    if (!file) {
        return;
    }

    if (x === void 0) { x = 0; }
    if (y === void 0) { y = 0; }
    if (scale === void 0) { scale = 1; }

    if (!rect) {
        rect = Rectangle.emptyRectangle;
    }

    let offsetArray = actor.getBattlePoseOffetArray();
    x += offsetArray[0];
    y += offsetArray[1];

    CC_Mod.CCMod_drawTachieImage(file, bitmap, actor, x, y, rect, scale);
};

CC_Mod.CCMod_drawTachieImage = function (file, bitmap, actor, x, y, rect, scale) {
    var img = ImageManager.loadBitmap(CCMOD_STATUSPICTURE_FOLDER, file, 0, true);
    //img.adjustTone(233,33,39);
    if (!img.isReady()) {
        console.log('draw' + file + ' not ready');
        actor.setDirty();
        return;
    }
    var xx = -rect.x < 0 ? 0 : -rect.x;
    var yy = -rect.y < 0 ? 0 : -rect.y;
    var ww = rect.width / scale;
    var w = rect.width;
    if (w <= 0 || w + xx > img.width) {
        w = img.width - xx;
        ww = w;
    }
    if (xx + ww > img.width) {
        var xScale = (img.width - xx) * 1.0 / ww;
        ww = img.width - xx;
        w *= xScale;
    }
    var hh = rect.height / scale;
    var h = rect.height;
    if (h <= 0 || h + yy > img.height) {
        h = img.height - yy;
        hh = h;
    }
    if (yy + hh > img.height) {
        var yScale = (img.height - yy) * 1.0 / hh;
        hh = img.height - yy;
        h *= yScale;
    }
    bitmap.blt(img, xx, yy, ww, hh, x, y, w, h);
};

CC_Mod.CCMod_drawStatusPictureLayers = function (actor, bitmap) {
    // This is effectively a 'mini-tachie' with only a few parts and fixed layering order

    /* // Debug
    actor._liquidCreampiePussy = 999;
    actor._liquidCreampieAnal = 999;

	actor.setBodyPartToy(PUSSY_ID);
	actor._wearingPussyToy = PUSSY_TOY_PENIS_DILDO;
    actor._toyValue_pussyToy = 10;

	actor.setBodyPartToy(ANAL_ID);
	actor._wearingAnalToy = ANAL_TOY_ANAL_BEADS;
    actor._toyValue_analToy = 10;
    */

    let x = 455;
    let y = 320;
    let baseImg = CCMOD_STATUSPICTURE_PREFIX + 'Base_';
    let anusImg = CCMOD_STATUSPICTURE_PREFIX + 'Anus_Cum_';
    let anusExtraImg = false;
    let anusExtraImgBase = false;
    let uterusImg = CCMOD_STATUSPICTURE_PREFIX + 'Uterus_Cum_';
    let uterusExtraImg = false;

    if (actor._wearingAnalToy === ANAL_TOY_ANAL_BEADS) {
        anusExtraImg = CCMOD_STATUSPICTURE_PREFIX + 'Anus_Beads';
    }

    if (actor._wearingPussyToy === PUSSY_TOY_PENIS_DILDO) {
        uterusExtraImg = CCMOD_STATUSPICTURE_PREFIX + 'Uterus_Dildo';
    };

    // Base
    if (uterusExtraImg || actor._CCMod_fertilityCycleState == CCMOD_CYCLE_STATE_BIRTH_RECOVERY) {
        baseImg += '02';
    } else {
        baseImg += '01';
    }
    CC_Mod.CCMod_drawTachieFile(baseImg, bitmap, actor, x, y);

    // Anus
    if (anusExtraImg) {
        anusExtraImgBase = CCMOD_STATUSPICTURE_PREFIX + 'Anus_Aroused';
        CC_Mod.CCMod_drawTachieFile(anusExtraImgBase, bitmap, actor, x, y);
    }

    if (actor._liquidCreampieAnal >= CCMOD_STATUSPICTURE_CUMLIMIT_04) {
        anusImg += '04';
    } else if (actor._liquidCreampieAnal >= CCMOD_STATUSPICTURE_CUMLIMIT_03) {
        anusImg += '03';
    } else if (actor._liquidCreampieAnal >= CCMOD_STATUSPICTURE_CUMLIMIT_02) {
        anusImg += '02';
    } else if (actor._liquidCreampieAnal >= CCMOD_STATUSPICTURE_CUMLIMIT_01) {
        anusImg += '01';
    } else {
        anusImg += '00';
    }

    if (anusExtraImg) {
        CC_Mod.CCMod_drawTachieFile(anusExtraImg, bitmap, actor, x, y);
    }

    // Uterus
    if (actor.CCMod_isPreg()) {
        // Should return 1~4, due date is same picture but it's stateId is 10
        stateId = Math.min(actor._CCMod_fertilityCycleState - 5, 4);
        let babyBaseImg = CCMOD_STATUSPICTURE_PREFIX + 'Uterus_BabyBase_' + stateId;
        CC_Mod.CCMod_drawTachieFile(babyBaseImg, bitmap, actor, x, y);
        CC_Mod.CCMod_drawStatusBaby(stateId, actor, bitmap, x, y);
    } else {
        if (actor._liquidCreampiePussy >= CCMOD_STATUSPICTURE_CUMLIMIT_04) {
            uterusImg += '04';
        } else if (actor._liquidCreampiePussy >= CCMOD_STATUSPICTURE_CUMLIMIT_03) {
            uterusImg += '03';
        } else if (actor._liquidCreampiePussy >= CCMOD_STATUSPICTURE_CUMLIMIT_02) {
            uterusImg += '02';
        } else if (actor._liquidCreampiePussy >= CCMOD_STATUSPICTURE_CUMLIMIT_01) {
            uterusImg += '01';
        } else {
            uterusImg += '00';
        }
        CC_Mod.CCMod_drawTachieFile(uterusImg, bitmap, actor, x, y);
    }

    if (uterusExtraImg) {
        CC_Mod.CCMod_drawTachieFile(uterusExtraImg, bitmap, actor, x, y);
    }
};

CC_Mod.CCMod_drawStatusBaby = function(stateId, actor, bitmap, x, y) {
    babyBitmap = CC_Mod.CCMod_bitmapBabyStatusPicture(actor);

    if (CC_Mod.lastDrawnBabyState != actor._CCMod_fertilityCycleState) {
        CC_Mod.lastDrawnBabyState = actor._CCMod_fertilityCycleState;
        let babyImg = CCMOD_STATUSPICTURE_PREFIX + 'Uterus_Baby_' + stateId;

        babyColorArray = CCMOD_STATUSPICTURE_COLORARRAY_HUMAN;
        if (actor._CCMod_recordLastFatherSpecies == ENEMYCOCK_GREEN_TAG) {
            babyColorArray = CCMOD_STATUSPICTURE_COLORARRAY_GOBLIN;
        } else if (actor._CCMod_recordLastFatherSpecies == ENEMYCOCK_SLIME_TAG) {
            babyColorArray = CCMOD_STATUSPICTURE_COLORARRAY_SLIME;
        } else if (actor._CCMod_recordLastFatherSpecies == ENEMYCOCK_RED_TAG) {
            babyColorArray = CCMOD_STATUSPICTURE_COLORARRAY_LIZARD;
        }

        babyBitmap.clear();
        CC_Mod.CCMod_drawTachieFile(babyImg, babyBitmap, actor, x, y);
        CC_Mod.Gyaru_setBitmapColor(babyBitmap, babyColorArray);
    }
    bitmap.blt(babyBitmap, 0, 0, babyBitmap.width, babyBitmap.height, 0, 0);
};

CC_Mod.CCMod_drawStatusPicture = function(win) {
    if (!CCMod_statusPictureEnabled) {
        return;
    }
    let actor = $gameActors.actor(ACTOR_KARRYN_ID);
    let statusBitmap = CC_Mod.CCMod_bitmapStatusPicture(win, actor);
    CC_Mod.CCMod_drawStatusPictureLayers(actor, statusBitmap);

    win.contents.blt(statusBitmap, 0, 0, statusBitmap.width, statusBitmap.height, 0, 0);
};

//=============================================================================
//////////////////////////////////////////////////////////////
// Records Keeping & Profile

CC_Mod.birthRecords_addNewFather = function(father, karryn) {
    karryn._CCMod_recordPregCount += 1;

    if (!karryn._CCMod_recordFirstFatherName) {
        karryn._CCMod_recordFirstFatherName = father.name();
        karryn._CCMod_recordFirstFatherDateImpreg = Prison.date;
        karryn._CCMod_recordFirstFatherMapID = $gameMap._mapId;
        karryn._CCMod_recordFirstFatherSpecies = father.enemyCock();
		if(father.isWanted) {
			karryn._CCMod_recordFirstFatherWantedID = father.getWantedId();
		}
		else {
			karryn._CCMod_recordFirstFatherWantedID = $gameParty.addNewWanted(father);
		}
    }
    karryn._CCMod_recordLastFatherName = father.name();
    karryn._CCMod_recordLastFatherDateImpreg = Prison.date;
    karryn._CCMod_recordLastFatherMapID = $gameMap._mapId;
    karryn._CCMod_recordLastFatherDateBirth = false;
    karryn._CCMod_recordLastFatherSpecies = father.enemyCock();
}

CC_Mod.birthRecords_addBirthDate = function(date, babyCount) {
    let karryn = $gameActors.actor(ACTOR_KARRYN_ID);
    if (!karryn._CCMod_recordFirstFatherDateBirth) {
        karryn._CCMod_recordFirstFatherDateBirth = date;
    }

    karryn._CCMod_recordLastFatherDateBirth = date;
    karryn._CCMod_recordBirthCount += babyCount;
};

CC_Mod.PregMod.Window_StatusInfo_drawRecords = Window_StatusInfo.prototype.drawRecords;
Window_StatusInfo.prototype.drawRecords = function(drawRecords) {
    CC_Mod.PregMod.Window_StatusInfo_drawRecords.call(this, drawRecords);
    if (CCMod_pregModEnabled) {
        this.CCMod_drawPregnancyRecords();
    }
}

const CCMod_recordsMenuText = "Impregnated %1 times and gave birth %2 times.  Children: %3 human, %4 goblin, %5 slime, and %6 lizardmen.";
// Line 26 is max at bottom of the screen
const CCMod_recordsMenuLineCount = 26;

Window_StatusInfo.prototype.CCMod_drawPregnancyRecords = function() {
	if(!this._actor) return;
	let actor = this._actor;
	let firstColumnX = WINDOW_STATUS_FIRST_X;
	let firstTextPaddingX = firstColumnX + this.textPadding();
	let textPaddingY = -6;
	let lineHeight = this.lineHeight() * 0.5;
	let lineCount = CCMod_recordsMenuLineCount;
	let screenWidth = this.width - this.standardPadding() * 2;
	let fontSize = 18;

	this.contents.fontSize = fontSize;

	let recordText = false;
    let rectY = lineCount * lineHeight;
    let textY = lineCount * lineHeight + textPaddingY;

    let fmt = CCMod_recordsMenuText;
    let value1 = actor._CCMod_recordPregCount;
    let value2 = actor._CCMod_recordBirthCount;
    let value3 = actor._CCMod_recordBirthCountHuman;
    let value4 = actor._CCMod_recordBirthCountGoblin;
    let value5 = actor._CCMod_recordBirthCountSlime;
    let value6 = actor._CCMod_recordBirthCountLizardmen
    recordText = fmt.format(value1, value2, value3, value4, value5, value6);

    this.drawDarkRect(firstColumnX, rectY, screenWidth, lineHeight);
    this.drawTextEx(recordText, firstTextPaddingX, textY, screenWidth, 'left', true);
};

// Unfortunately need to remove profile to make room
Object.defineProperties(TextManager, {
	profileBio_One: {
		get: function() {
            if (CCMod_pregModEnabled) return "";
			if(this.isJapanese) return ProfileBio_One_JP;
			else if(this.isEnglish) return ProfileBio_One_EN;
		}, configurable: true
	},

	RemErrorMessage: {
		get: function() {
			return "This is a modded version, and thus any warranty is void.  Go post this crash in the thread on F95 or the mod discord channel with a detailed description of what you were doing along with your save file so I can reproduce the error.  If you made any changes to the game besides my mod only, this is an error you caused yourself, so you get to fix it yourself.";
		}, configurable: true
	},

	RCMenuGiftsSingleText: {
		get: function() {
            if (CCMod_disableGiftText) return "";
			if(this.isJapanese) return RCMenuGiftsSingleTextJP;
			else if(this.isEnglish) return RCMenuGiftsSingleTextEN;
		}, configurable: true
	},
	RCMenuGiftsPluralText: {
		get: function() {
            if (CCMod_disableGiftText) return "";
			if(this.isJapanese) return RCMenuGiftsPluralTextJP;
			else if(this.isEnglish) return RCMenuGiftsPluralTextEN;
		}, configurable: true
	},

});

const CCMod_profileRecordPregnancy = "Birth";
const CCMod_profileRecordFirstImpreg = "Got knocked up for the first time by \\C[31]%2\\C[0] in %3 on \\C[26]Day %1\\C[0].";
const CCMod_profileRecordFirstBirth = "Impregnated by \\C[31]%2\\C[0] in %3, gave birth to my first %4 child on \\C[26]Day %1\\C[0].";
const CCMod_profileRecordFirstBirthPlural = "Impregnated by \\C[31]%2\\C[0] in %3, gave birth to %5 %4 children on \\C[26]Day %1\\C[0].";
const CCMod_profileRecordLastImpreg = "Knocked up by \\C[31]%2\\C[0] in %3 on \\C[26]Day %1\\C[0].";
const CCMod_profileRecordLastBirth = "Made a %4 baby with \\C[31]%2\\C[0] in %3, gave birth on \\C[26]Day %1\\C[0].";
const CCMod_profileRecordLastBirthPlural = "Made %5 %4 babies with \\C[31]%2\\C[0] in %3, gave birth on \\C[26]Day %1\\C[0].";
const CCMod_profileRecordLineCount = 13;

CC_Mod.PregMod.Window_StatusInfo_drawProfile = Window_StatusInfo.prototype.drawProfile;
Window_StatusInfo.prototype.drawProfile = function() {
    CC_Mod.PregMod.Window_StatusInfo_drawProfile.call(this);
    if (CCMod_pregModEnabled) {
        this.CCMod_drawPregnancyProfile();
    }
};

Window_StatusInfo.prototype.CCMod_drawPregnancyProfile = function() {
	if(!this._actor) return;
	let actor = this._actor;
	let firstColumnX = WINDOW_STATUS_FIRST_X;
	let firstTextPaddingX = firstColumnX + this.textPadding();
	let screenWidth = this.width - this.standardPadding() * 2;
	let lineWidth = screenWidth * 0.5;
	let secondColumnX = firstColumnX + lineWidth + this.standardPadding();
	let secondTextPaddingX = secondColumnX + this.textPadding();

    //if(!actor.hasEdict(EDICT_PUBLISH_VIRGIN_STATUS)) continue;
    //if(!actor.hasEdict(EDICT_PUBLISH_OTHER_FIRST_TIMES) && i > 0) continue;
    let rectX = firstColumnX;
    let textX = firstTextPaddingX;
    let firstColumnWidth = 140;
    let recordFirstTextX = 175;
    let recordSecondTextX = 230;
    if(TextManager.isJapanese) recordSecondTextX = 248;
    let recordFirstLineY = -5;
    let recordSecondLineY = 18;

	let paddingY = 0;
	let lineHeight = this.lineHeight() * 0.9;
	let lineCount = CCMod_profileRecordLineCount;

	let normalFontSize = 28;
	let lineTextFontSize = 16;
	let lineTextFontSize_EN = 15;
    let recordName = '';
    let firstLine = '';
    let lastLine = '';
    let firstTextLine = '';
    let lastTextLine = '';
    let firstName = false;
    let firstDate = false;
    let firstBirthDate = false;
    let firstChildCount = false;
    let firstChildSpecies = false;
    let firstLocationName = false;
    let lastName = false;
    let lastDate = false;
    let lastBirthDate = false;
    let lastChildCount = false;
    let lastChildSpecies = false;
    let lastLocationName = false;

    recordName = CCMod_profileRecordPregnancy;
    firstDate = actor._CCMod_recordFirstFatherDateImpreg;
    lastDate = actor._CCMod_recordLastFatherDateImpreg;
    if (firstDate) {
        firstName = actor._CCMod_recordFirstFatherName;
        lastName = actor._CCMod_recordLastFatherName;
        firstBirthDate = actor._CCMod_recordFirstFatherDateBirth;
        if (firstBirthDate) {
            firstDate = firstBirthDate;
            firstChildCount = actor._CCMod_recordFirstFatherChildCount;
            firstChildSpecies = actor._CCMod_recordFirstFatherSpecies;
            if (firstChildCount == 1) {
                firstTextLine = CCMod_profileRecordFirstBirth;
            } else {
                firstTextLine = CCMod_profileRecordFirstBirthPlural;
            }
        } else {
            firstTextLine = CCMod_profileRecordFirstImpreg;
        }
        lastBirthDate = actor._CCMod_recordLastFatherDateBirth;
        if (lastBirthDate) {
            lastDate = lastBirthDate;
            lastChildCount = actor._CCMod_recordLastFatherChildCount;
            lastChildSpecies = actor._CCMod_recordLastFatherSpecies;
            if (lastChildCount == 1) {
                lastTextLine = CCMod_profileRecordLastBirth;
            } else {
                lastTextLine = CCMod_profileRecordLastBirthPlural;
            }
        } else {
            lastTextLine = CCMod_profileRecordLastImpreg;
        }
        firstLocationName = $gameParty.getMapName(actor._CCMod_recordFirstFatherMapID);
        lastLocationName = $gameParty.getMapName(actor._CCMod_recordLastFatherMapID);
    }

    this.drawDarkRect(rectX, lineCount * lineHeight, screenWidth, lineHeight);
    this.changeTextColor(this.systemColor());
    this.drawText(recordName, textX, lineCount * lineHeight, firstColumnWidth, 'left');
    this.changeTextColor(this.normalColor());

    if (firstDate) {
        firstLine = firstTextLine.format(firstDate, firstName, firstLocationName, firstChildSpecies, firstChildCount);
        lastLine = lastTextLine.format(lastDate, lastName, lastLocationName, lastChildSpecies, lastChildCount);
    } else {
        firstLine = TextManager.profileRecordNever;
        lastLine = TextManager.profileRecordNever;
    }

    this.contents.fontSize = lineTextFontSize;
    if(TextManager.isEnglish) this.contents.fontSize = lineTextFontSize_EN;

    this.drawTextEx(TextManager.profileRecordFirst, recordFirstTextX, lineCount * lineHeight + recordFirstLineY, lineWidth, 'left', true);
    if(actor.hasEdict(EDICT_PUBLISH_LAST_TIMES))
        this.drawTextEx(TextManager.profileRecordLast, recordFirstTextX, lineCount * lineHeight + recordSecondLineY, lineWidth, 'left', true);

    this.drawTextEx(firstLine, recordSecondTextX, lineCount * lineHeight + recordFirstLineY, lineWidth, 'left', true);
    if(actor.hasEdict(EDICT_PUBLISH_LAST_TIMES))
        this.drawTextEx(lastLine, recordSecondTextX, lineCount * lineHeight + recordSecondLineY, lineWidth, 'left', true);

    this.contents.fontSize = normalFontSize;

};

//=============================================================================
//////////////////////////////////////////////////////////////
// Fertility Cycle

CC_Mod.fertilityCycle_Init = function(actor) {
    // This will determine the initial cycle state
    if (actor._CCMod_fertilityCycleState == CCMOD_CYCLE_STATE_NULL) {
        actor._CCMod_fertilityCycleState = Math.randomInt(CCMOD_CYCLE_STATE_OVULATION) + 1;
    }

    // Then calculate for current state
    CC_Mod.fertilityCycle_Calc(actor);
};

// Determine fertility chance
CC_Mod.fertilityCycle_Calc = function(actor) {
    if (!CCMod_pregModEnabled) {
        actor._CCMod_fertilityCycleState = CCMOD_CYCLE_STATE_NULL;
        actor._CCMod_currentFertility = 0;
        return;
    }

    let state = actor._CCMod_fertilityCycleState;
    let fertChance = CCMod_fertilityCycleFertilizationChanceArray[state];
    if (fertChance == 0) {
        actor._CCMod_currentFertility = fertChance;
        return;
    }

    if (CCMOD_DEBUG) {
        fertChance += 1;
    }

    fertChance = fertChance + (Math.random() * CCMod_fertilityChanceVariance * 2 - CCMod_fertilityChanceVariance);

    if (fertChance <= 0) {
        fertChance = 0.01;
    }

    if (actor.hasEdict(CCMOD_EDICT_FERTILITYRATE_ID)) {
        fertChance += CCMod_edict_fertilityRateIncrease;
    }
    if (actor.hasPassive(CCMOD_PASSIVE_BIRTH_COUNT_ONE_ID)) {
        fertChance *= CCMod_passive_fertilityRateIncreaseMult;
    }

    // Add fluids to calc
    // Example: 30% fertility * 4 * 30ml/100 = +0.36 added to chance = 56%
    let fluidsFactor = fertChance * CCMod_fertilityChanceFluidsFactor * actor._liquidCreampiePussy / 100;
    fertChance += fluidsFactor;

    fertChance *= CCMod_fertilityChanceGlobalMult;

    actor._CCMod_currentFertility = fertChance;
};

// Roll for impregnation chance
// Actor is frivolous man, target is Karryn
CC_Mod.fertilityCycle_TryImpregnation = function(actor, target) {
    // Update current fertility
    CC_Mod.fertilityCycle_Calc(target);

    //if (CCMOD_DEBUG) {
    //    target._CCMod_currentFertility = 1;
    //}

    let impreg = false;

    if (Math.random() < target._CCMod_currentFertility) {
        impreg = true;
        CC_Mod.fertilityCycle_SetState(target, CCMOD_CYCLE_STATE_FERTILIZEZD);
        CC_Mod.birthRecords_addNewFather(actor, target);
        actor.useAISkill(CCMOD_SKILL_ENEMY_IMPREG_ID, target);
    }

    return impreg;
};

Game_Actor.prototype.CCMod_isPreg = function() {
    if (this._CCMod_fertilityCycleState == CCMOD_CYCLE_STATE_FERTILIZEZD ||
        this._CCMod_fertilityCycleState == CCMOD_CYCLE_STATE_TRIMESTER_ONE ||
        this._CCMod_fertilityCycleState == CCMOD_CYCLE_STATE_TRIMESTER_TWO ||
        this._CCMod_fertilityCycleState == CCMOD_CYCLE_STATE_TRIMESTER_THREE ||
        this._CCMod_fertilityCycleState == CCMOD_CYCLE_STATE_DUE_DATE)
        return true;
    return false;
}

CC_Mod.fertilityCycle_AdvanceState = function(actor) {
    let currentState = actor._CCMod_fertilityCycleState;
    let targetState = CCMOD_CYCLE_STATE_NULL;

    if (currentState == CCMOD_CYCLE_STATE_SAFE) {
        targetState = CCMOD_CYCLE_STATE_NORMAL;
    } else if (currentState == CCMOD_CYCLE_STATE_NORMAL) {
        targetState = CCMOD_CYCLE_STATE_BEFORE_DANGER;
    } else if (currentState == CCMOD_CYCLE_STATE_BEFORE_DANGER) {
        targetState = CCMOD_CYCLE_STATE_DANGER_DAY;
    } else if (currentState == CCMOD_CYCLE_STATE_DANGER_DAY) {
        targetState = CCMOD_CYCLE_STATE_OVULATION;
    } else if (currentState == CCMOD_CYCLE_STATE_OVULATION) {
        targetState = CCMOD_CYCLE_STATE_SAFE;
    } else if (currentState == CCMOD_CYCLE_STATE_FERTILIZEZD) {
        targetState = CCMOD_CYCLE_STATE_TRIMESTER_ONE;
    } else if (currentState == CCMOD_CYCLE_STATE_TRIMESTER_ONE) {
        targetState = CCMOD_CYCLE_STATE_TRIMESTER_TWO;
    } else if (currentState == CCMOD_CYCLE_STATE_TRIMESTER_TWO) {
        targetState = CCMOD_CYCLE_STATE_TRIMESTER_THREE;
    } else if (currentState == CCMOD_CYCLE_STATE_TRIMESTER_THREE) {
        targetState = CCMOD_CYCLE_STATE_DUE_DATE;
    } else if (currentState == CCMOD_CYCLE_STATE_DUE_DATE) {
        // Let the event trigger and advance this in case there's a hiccup with a defeat scene
        targetState = CCMOD_CYCLE_STATE_DUE_DATE;
    } else if (currentState == CCMOD_CYCLE_STATE_BIRTH_RECOVERY) {
        targetState = Math.randomInt(CCMOD_CYCLE_STATE_BEFORE_DANGER) + 1;
    } else if (currentState == CCMOD_CYCLE_STATE_BIRTHCONTROL) {
        // Expired, so restart cycle
        targetState = Math.randomInt(CCMOD_CYCLE_STATE_BEFORE_DANGER) + 1;
    }

    CC_Mod.fertilityCycle_SetState(actor, targetState);
};

CC_Mod.fertilityCycle_SetState = function(actor, state) {
    actor._CCMod_fertilityCycleState = state;
    actor._CCMod_fertilityCycleStateDuration = CCMod_fertilityCycleDurationArray[state];
};

CC_Mod.fertilityCycle_NextDay = function() {
    let actor = $gameActors.actor(ACTOR_KARRYN_ID);

    CC_Mod.fertilityCycle_CheckBirth(actor);

    actor._CCMod_fertilityCycleStateDuration -= 1;

    if (CCMOD_DEBUG) {
        actor._CCMod_fertilityCycleStateDuration -= 100;
    }

    if (actor.hasPassive(CCMOD_PASSIVE_BIRTH_COUNT_TWO_ID) && actor.CCMod_isPreg()) {
        actor._CCMod_fertilityCycleStateDuration -= CCMod_passive_fertilityPregnancyAcceleration;
    }
    if (actor.hasPassive(CCMOD_PASSIVE_BIRTH_COUNT_THREE_ID) && actor.CCMod_isPreg()) {
        actor._CCMod_fertilityCycleStateDuration -= CCMod_passive_fertilityPregnancyAcceleration;
    }
    if (actor.hasEdict(CCMOD_EDICT_PREGNANCYSPEED_ID) && actor.CCMod_isPreg()) {
        actor._CCMod_fertilityCycleStateDuration -= CCMod_edict_fertilityPregnancyAcceleration;
    }

    if (actor.hasEdict(CCMOD_EDICT_BIRTHCONTROL_ACTIVE_ID) && !actor.CCMod_isPreg()) {
        CC_Mod.fertilityCycle_SetState(actor, CCMOD_CYCLE_STATE_BIRTHCONTROL);
    }

    if (actor._CCMod_fertilityCycleStateDuration <= 0) {
        CC_Mod.fertilityCycle_AdvanceState(actor);
    }

    // Unused
    if (actor._CCMod_birthControlDuration > 0) {
        actor._CCMod_birthControlDuration -= 1;
    }

    // Unused.  TODO: Add it as a random act from Cargill?
    if (actor._CCMod_fertilityDrugDuration > 0) {
        actor._CCMod_fertilityDrugDuration -= 1;
    }

    CC_Mod.fertilityCycle_Calc(actor);

};

// This is called in the restoreClothingDurability function
// For some unknown reason this both doesn't work and it breaks the waitress minigame
// TODO: More research
/*
CC_Mod.maternityClothingEffects = function(actor) {

    let currentState = actor._CCMod_fertilityCycleState;

    let clothingStage = CLOTHES_STARTING_STAGE;

    if (currentState == CCMOD_CYCLE_STATE_TRIMESTER_TWO) {
        clothingStage += 1;
    } else if (currentState == CCMOD_CYCLE_STATE_TRIMESTER_THREE ||
               currentState == CCMOD_CYCLE_STATE_DUE_DATE) {
        clothingStage += 2;
    }

    if (clothingStage != CLOTHES_STARTING_STAGE) {
        this.changeClothingToStage(clothingStage);
    }
};
*/

CC_Mod.fertilityFatigueRate = function(actor, value) {
    let rate = 1 + CCMod_fertilityCycleFatigueRates[actor._CCMod_fertilityCycleState];
    return value * rate;
};

CC_Mod.PregMod.Game_Actor_gainFatigue = Game_Actor.prototype.gainFatigue;
Game_Actor.prototype.gainFatigue = function(value) {
    value = CC_Mod.fertilityFatigueRate(this, value);
    CC_Mod.PregMod.Game_Actor_gainFatigue.call(this, value);
};

CC_Mod.fertilityCharmParamRate = function(actor, paramId) {
    let rate = 1;

    if(paramId === PARAM_CHARM_ID) {
        rate = 1 + CCMod_fertilityCycleCharmParamRates[actor._CCMod_fertilityCycleState];
    }

    return rate;
};

CC_Mod.PregMod.Game_Actor_paramRate = Game_Actor.prototype.paramRate;
Game_Actor.prototype.paramRate = function(paramId) {
    let rate = CC_Mod.PregMod.Game_Actor_paramRate.call(this, paramId);
    return rate * CC_Mod.fertilityCharmParamRate(this, paramId);
};

//=============================================================================
//////////////////////////////////////////////////////////////
// Birth

// 1 race 2 name
const CCMod_birthStringSingular = "Karryn gave birth to the %1 child of %2!"
const CCMod_birthStringPlural = "Karryn gave birth to the %3 %1 children of %2!"

// Going to sleep calls advanceNext day, where this is called from
// Flag is set but only checked on sleeping in a bed so that defeat scenes don't trigger it
CC_Mod.fertilityCycle_CheckBirth = function(actor) {
    let currentState = actor._CCMod_fertilityCycleState;

    if (currentState == CCMOD_CYCLE_STATE_DUE_DATE) {
        $gameSwitches.setValue(CCMOD_SWITCH_BIRTH_QUEUED_ID, true);
    }
};

// It sets the whole string now not just the name
CC_Mod.setFatherNameGameVar = function(value) {
    $gameVariables.setValue(CCMOD_VARIABLE_FATHER_NAME_ID, value);
};

// This is called from Map034 'Template Event' bed1
// Triggered by Karryn sleeping in a bed
CC_Mod.mapTemplateEvent_giveBirth = function() {
    let babyCount = CC_Mod.setupChildCount(); // This also sets up the game var string
    CC_Mod.birthRecords_addBirthDate(Prison.date, babyCount);
    CC_Mod.fertilityCycle_SetState($gameActors.actor(ACTOR_KARRYN_ID), CCMOD_CYCLE_STATE_BIRTH_RECOVERY);
};

CC_Mod.setupChildCount = function() {
    let actor = $gameActors.actor(ACTOR_KARRYN_ID);

    let babyCount = 1;

    if (actor.hasPassive(CCMOD_PASSIVE_BIRTH_COUNT_THREE_ID)) {
        babyCount += Math.randomInt(1);
    }

    if (actor._CCMod_recordLastFatherSpecies == ENEMYCOCK_HUMAN_TAG) {
        if (actor.hasPassive(CCMOD_PASSIVE_BIRTH_HUMAN_ID)) {
            babyCount += Math.randomInt(1);
        }
        actor._CCMod_recordBirthCountHuman += babyCount;
        actor._CCMod_recordLastFatherSpecies = "human";
        if (CC_Mod.checkIfSpeciesIsCockTag(actor._CCMod_recordFirstFatherSpecies)) {
            actor._CCMod_recordFirstFatherSpecies = actor._CCMod_recordLastFatherSpecies;
        }
    }
    if (actor._CCMod_recordLastFatherSpecies == ENEMYCOCK_GREEN_TAG) {
        if (actor.hasPassive(CCMOD_PASSIVE_BIRTH_GOBLIN_ID)) {
            babyCount += Math.randomInt(2);
        }
        babyCount += Math.randomInt(3);
        actor._CCMod_recordBirthCountGoblin += babyCount;
        actor._CCMod_recordLastFatherSpecies = "goblin";
        if (CC_Mod.checkIfSpeciesIsCockTag(actor._CCMod_recordFirstFatherSpecies)) {
            actor._CCMod_recordFirstFatherSpecies = actor._CCMod_recordLastFatherSpecies;
        }
    }
    if (actor._CCMod_recordLastFatherSpecies == ENEMYCOCK_SLIME_TAG) {
        if (actor.hasPassive(CCMOD_PASSIVE_BIRTH_SLIME_ID)) {
            babyCount += Math.randomInt(2);
        }
        babyCount += Math.randomInt(2);
        actor._CCMod_recordBirthCountSlime += babyCount;
        actor._CCMod_recordLastFatherSpecies = "slime";
        if (CC_Mod.checkIfSpeciesIsCockTag(actor._CCMod_recordFirstFatherSpecies)) {
            actor._CCMod_recordFirstFatherSpecies = actor._CCMod_recordLastFatherSpecies;
        }
    }
    if (actor._CCMod_recordLastFatherSpecies == ENEMYCOCK_RED_TAG) {
        if (actor.hasPassive(CCMOD_PASSIVE_BIRTH_LIZARD_ID)) {
            babyCount += Math.randomInt(1);
        }
        babyCount += Math.randomInt(2);
        actor._CCMod_recordBirthCountLizardmen += babyCount;
        actor._CCMod_recordLastFatherSpecies = "lizardmen";
        if (CC_Mod.checkIfSpeciesIsCockTag(actor._CCMod_recordFirstFatherSpecies)) {
            actor._CCMod_recordFirstFatherSpecies = actor._CCMod_recordLastFatherSpecies;
        }
    }

    if (actor._CCMod_recordFirstFatherChildCount < 0) {
        actor._CCMod_recordFirstFatherChildCount = babyCount;
    }
    actor._CCMod_recordLastFatherChildCount = babyCount;

    let str = null;
    if (babyCount == 1) {
        str = CCMod_birthStringSingular.format(actor._CCMod_recordLastFatherSpecies, actor._CCMod_recordLastFatherName);
    } else {
        str = CCMod_birthStringPlural.format(actor._CCMod_recordLastFatherSpecies, actor._CCMod_recordLastFatherName, babyCount);
    }
    CC_Mod.setFatherNameGameVar(str);

    return babyCount;
};

CC_Mod.checkIfSpeciesIsCockTag = function(tag) {
    if (tag == ENEMYCOCK_HUMAN_TAG ||
        tag == ENEMYCOCK_GREEN_TAG ||
        tag == ENEMYCOCK_SLIME_TAG ||
        tag == ENEMYCOCK_RED_TAG) {
            return true;
    }
    // If it's empty also return true - this function is really just to see if it was assigned already
    if (tag == false) {
        return true;
    }
    return false;
};

// Skill is unused
Game_Actor.prototype.beforeEval_giveBirth = function() {
};

Game_Actor.prototype.dmgFormula_giveBirth = function(target) {
    return 0; // This return is really important
};

Game_Actor.prototype.postDamage_giveBirth = function(target) {
};

//=============================================================================
//////////////////////////////////////////////////////////////
// Edicts & Passives

/*
    actor._CCMod_recordPregCount = 0;
    actor._CCMod_recordBirthCount = 0;
    actor._CCMod_recordBirthCountHuman = 0;
    actor._CCMod_recordBirthCountGoblin = 0;
    actor._CCMod_recordBirthCountSlime = 0;
    actor._CCMod_recordBirthCountLizardmen = 0;
*/

Game_Actor.prototype.CCMod_checkForNewBirthPassives = function() {
    if (!CCMod_pregModEnabled) {
        return;
    }

    if (!this.hasPassive(CCMOD_PASSIVE_BIRTH_COUNT_ONE_ID) && this._CCMod_recordBirthCount >= CCMod_passiveRecordThreshold_BirthOne) {
        this.learnNewPassive(CCMOD_PASSIVE_BIRTH_COUNT_ONE_ID);
    }
    else if (!this.hasPassive(CCMOD_PASSIVE_BIRTH_COUNT_TWO_ID) && this._CCMod_recordBirthCount >= CCMod_passiveRecordThreshold_BirthTwo) {
        this.learnNewPassive(CCMOD_PASSIVE_BIRTH_COUNT_TWO_ID);
    }
    else if (!this.hasPassive(CCMOD_PASSIVE_BIRTH_COUNT_THREE_ID) && this._CCMod_recordBirthCount >= CCMod_passiveRecordThreshold_BirthThree) {
        this.learnNewPassive(CCMOD_PASSIVE_BIRTH_COUNT_THREE_ID);
    }

    if (!this.hasPassive(CCMOD_PASSIVE_BIRTH_HUMAN_ID) && this._CCMod_recordBirthCountHuman >= CCMod_passiveRecordThreshold_Race) {
        this.learnNewPassive(CCMOD_PASSIVE_BIRTH_HUMAN_ID);
    }
    if (!this.hasPassive(CCMOD_PASSIVE_BIRTH_GOBLIN_ID) && this._CCMod_recordBirthCountGoblin >= CCMod_passiveRecordThreshold_Race) {
        this.learnNewPassive(CCMOD_PASSIVE_BIRTH_GOBLIN_ID);
    }
    if (!this.hasPassive(CCMOD_PASSIVE_BIRTH_SLIME_ID) && this._CCMod_recordBirthCountSlime >= CCMod_passiveRecordThreshold_Race) {
        this.learnNewPassive(CCMOD_PASSIVE_BIRTH_SLIME_ID);
    }
    if (!this.hasPassive(CCMOD_PASSIVE_BIRTH_LIZARD_ID) && this._CCMod_recordBirthCountLizardmen >= CCMod_passiveRecordThreshold_Race) {
        this.learnNewPassive(CCMOD_PASSIVE_BIRTH_LIZARD_ID);
    }

    /*
    if (!this.hasPassive(CCMOD_PASSIVE_BIRTH_WOLF_ID)) {
        this.learnNewPassive(CCMOD_PASSIVE_BIRTH_WOLF_ID);
    }
    */
};

// Hook to remove on bankrupt
CC_Mod.PregMod.Game_Party_titlesBankruptcyOrder = Game_Party.prototype.titlesBankruptcyOrder;
Game_Party.prototype.titlesBankruptcyOrder = function() {
    CC_Mod.PregMod.Game_Party_titlesBankruptcyOrder.call(this);
    CC_Mod.removeBirthControlEdict();
};

// Sabotage on Riot hook
CC_Mod.PregMod.Game_Party_riotOutbreakPrisonLevelOne = Game_Party.prototype.riotOutbreakPrisonLevelOne;
Game_Party.prototype.riotOutbreakPrisonLevelOne = function() {
    CC_Mod.PregMod.Game_Party_riotOutbreakPrisonLevelOne.call(this);
    CC_Mod.sabotageBirthControl();
};

CC_Mod.PregMod.Game_Party_riotOutbreakPrisonLevelTwo = Game_Party.prototype.riotOutbreakPrisonLevelTwo;
Game_Party.prototype.riotOutbreakPrisonLevelTwo = function() {
    CC_Mod.PregMod.Game_Party_riotOutbreakPrisonLevelTwo.call(this);
    CC_Mod.sabotageBirthControl();
};

CC_Mod.PregMod.Game_Party_riotOutbreakPrisonLevelThree = Game_Party.prototype.riotOutbreakPrisonLevelThree;
Game_Party.prototype.riotOutbreakPrisonLevelThree = function() {
    CC_Mod.PregMod.Game_Party_riotOutbreakPrisonLevelThree.call(this);
    CC_Mod.sabotageBirthControl();
};

CC_Mod.sabotageBirthControl = function() {
    let actor = $gameActors.actor(ACTOR_KARRYN_ID);

    if (!Karryn.hasEdict(CCMOD_EDICT_BIRTHCONTROL_ACTIVE_ID)) {
        return;
    }

    let orderMod = ($gameParty._order / 100) * CCMod_edict_CargillSabotageChance_OrderMod;
    orderMod += CCMod_edict_CargillSabotageChance_Base;
    if (Math.random() < orderMod) {
        CC_Mod.removeBirthControlEdict();
        // Riot manager is called before the mod calls advanceNextDay,
        // so set this to one state before the desired state with 0 duration
        // Target is danger day
        CC_Mod.fertilityCycle_SetState(actor, CCMOD_CYCLE_STATE_BEFORE_DANGER);
        actor._CCMod_fertilityCycleStateDuration = 0;
    }
};

CC_Mod.removeBirthControlEdict = function() {
    if (Karryn.hasEdict(CCMOD_EDICT_BIRTHCONTROL_ACTIVE_ID)) {
        Karryn.learnSkill(CCMOD_EDICT_BIRTHCONTROL_NONE_ID);
    }
};

Game_Actor.prototype.CCMod_setupStartingPregEdicts = function() {
    this.learnSkill(CCMOD_EDICT_BIRTHCONTROL_NONE_ID);
};

CC_Mod.PregMod.Game_Actor_setupStartingEdicts = Game_Actor.prototype.setupStartingEdicts;
Game_Actor.prototype.setupStartingEdicts = function() {
    CC_Mod.PregMod.Game_Actor_setupStartingEdicts.call(this);
    this.CCMod_setupStartingPregEdicts();
    this.CCMod_setupStartingGyaruEdicts();
};

//=============================================================================
//////////////////////////////////////////////////////////////
// Function hooks & overwrites
//////////////////////////////////////////////////////////////

CC_Mod.PregMod.Game_Enemy_dmgFormula_creampie = Game_Enemy.prototype.dmgFormula_creampie;
Game_Enemy.prototype.dmgFormula_creampie = function(target, area) {
    let dmg = CC_Mod.PregMod.Game_Enemy_dmgFormula_creampie.call(this, target, area);
    if (area == CUM_CREAMPIE_PUSSY) {
        if (CC_Mod.processCreampie(this, target)) {
            let result = target.result();
            result.pleasureDamage = result.pleasureDamage * 10;
        }
    }
    return dmg;
};

CC_Mod.PregMod.Game_Actor_getCutInArray = Game_Actor.prototype.getCutInArray;
Game_Actor.prototype.getCutInArray = function() {
    let cutInName = this.tachieCutInFile();
    if(cutInName === CCMOD_CUTIN_FERTILIZATION_NAME) {
        return this.CCMod_cutInArray_Fertilization();
    }
    return CC_Mod.PregMod.Game_Actor_getCutInArray.call(this);
};

CC_Mod.PregMod.Game_Actor_setCutInWaitAndDirection = Game_Actor.prototype.setCutInWaitAndDirection;
Game_Actor.prototype.setCutInWaitAndDirection = function(cutInName) {
    if(cutInName === CCMOD_CUTIN_FERTILIZATION_NAME) {
        return this.CCMod_setCutInWaitAndDirection(cutInName);
    }
    return CC_Mod.PregMod.Game_Actor_setCutInWaitAndDirection.call(this, cutInName);
};

CC_Mod.PregMod.Window_MenuStatus_drawItem = Window_MenuStatus.prototype.drawItem;
Window_MenuStatus.prototype.drawItem = function(index) {
    this.contents.clear();
	CC_Mod.PregMod.Window_MenuStatus_drawItem.call(this, index);
};

// Function Overwrite
Window_MenuStatus.prototype.drawKarrynStatus = function() {
    let x = this.textPadding();
    let width = this.width - this.textPadding() * 4;
	//this.contents.clear(); // CCMod: This is the only change made in the function, clear is done in above function
	let line = 0;
	let lh = this.lineHeight();
	let actor = $gameActors.actor(ACTOR_KARRYN_ID);
	let centerOffsetX = -75;

	let nameFontSize = 32;
	let titleFontSize = 20;
	let statsFontSize = 26;
	let statusFontSize = 16;

	this.resetTextColor();

	//Karryn
	this.contents.fontSize = nameFontSize;
	let nameText = actor.name();
	this.drawText(nameText, x, line * lh, width + centerOffsetX, 'center');
	this.resetTextColor();
	line+= 0.5;

	//Title
	this.contents.fontSize = titleFontSize;
	let titleText = actor.getTitleText();
	this.drawText(titleText, x, line * lh, width + centerOffsetX, 'center');
	this.resetTextColor();
	line++;

	////////
	//Stats
	for(let i = 0; i < 12; ++i) {
		let valueName = '';
		let valueNum = '';
		let firstX = x + 45;
		let halfWidth = width / 2;
		let lineWidth = halfWidth - 120;
		let secondX = halfWidth + this.textPadding();

		if(i === 0) {
			valueName = TextManager.wardenLevel;
			valueNum = actor.level;
		}
		else if(i === 1) {
			if(DEBUG_MODE && actor.slutLvl > 0) {
				valueName = TextManager.slutLevel;
				valueNum = actor.slutLvl;
			}
		}
		else if(i === 2) {
			valueName = TextManager.basic(2);
			valueNum = actor.param(PARAM_MAXSTAMINA_ID);
		}
		else if(i === 3) {
			valueName = TextManager.basic(4);
			valueNum = actor.param(PARAM_MAXENERGY_ID);
		}
		else if(i === 4) {
			valueName = TextManager.param(PARAM_STRENGTH_ID);
			valueNum = actor.param(PARAM_STRENGTH_ID);
		}
		else if(i === 5) {
			valueName = TextManager.param(PARAM_DEXTERITY_ID);
			valueNum = actor.param(PARAM_DEXTERITY_ID);
		}
		else if(i === 6) {
			valueName = TextManager.param(PARAM_AGILITY_ID);
			valueNum = actor.param(PARAM_AGILITY_ID);
		}
		else if(i === 7) {
			valueName = TextManager.param(PARAM_ENDURANCE_ID);
			valueNum = actor.param(PARAM_ENDURANCE_ID);
		}
		else if(i === 8) {
			valueName = TextManager.param(PARAM_MIND_ID);
			valueNum = actor.param(PARAM_MIND_ID);
		}
		else if(i === 9) {
			valueName = TextManager.param(PARAM_CHARM_ID);
			valueNum = actor.param(PARAM_CHARM_ID);
		}
		else if(i === 10) {
			valueName = TextManager.corruption;
			valueNum = Prison.corruption;
		}
		else if(i === 11) {
			if(actor.hasPassive(PASSIVE_SUBDUED_COUNT_TWO_ID)) {
				valueName = TextManager.cockiness;
				valueNum = actor.cockiness + '%';
			}
		}

		let valueX = firstX;
		if(i % 2 === 1) valueX = secondX

		this.contents.fontSize = statsFontSize;
		this.drawText(valueName, valueX, line * lh, lineWidth, 'left');
		this.drawText(valueNum, valueX, line * lh, lineWidth, 'right');

		if(i % 2 === 1) line += 0.6;
	}

	////////
	//Status
	line += 0.4;
	this.contents.fontSize = statusFontSize;

	let statusLineChange = 0.4;

	//Arousal
	if(actor.isAroused()) {
		let arousedText = '';
		if(actor.reachedOrgasmPoint()) arousedText = TextManager.RCMenuArousedLevelTwoText;
		else arousedText = TextManager.RCMenuArousedLevelOneText;
		this.drawTextEx(arousedText, x, line * lh, width, 'left', true);
		line += statusLineChange;
	}

	//Panties
	if(!actor.isWearingPanties()) {
		let lostPantiesText = TextManager.RCMenuLostPantiesText;
		this.drawTextEx(lostPantiesText, x, line * lh, width, 'left', true);
		line += statusLineChange;
	}

	//Fatigue
	let fatigueLevel = actor.getFatigueLevel();
	if(fatigueLevel > 0) {
		let fatigueText = '';
		if(fatigueLevel === 1) fatigueText = TextManager.RCMenuFatigueLevelOneText;
		else if(fatigueLevel === 2) fatigueText = TextManager.RCMenuFatigueLevelTwoText;
		else if(fatigueLevel === 3) fatigueText = TextManager.RCMenuFatigueLevelThreeText;
		else if(fatigueLevel === 4) fatigueText = TextManager.RCMenuFatigueLevelFourText;
		else if(fatigueLevel === 5) fatigueText = TextManager.RCMenuFatigueLevelFiveText;

		this.drawTextEx(fatigueText, x, line * lh, width, 'left', true);
		line += statusLineChange;
	}

	//Sleep Quality
	let sleepQuality = actor.getSleepQuality();
	let sleepQualityText = '';

	if(sleepQuality <= -2) sleepQualityText = TextManager.RCMenuSleepQualityNegTwoText;
	else if(sleepQuality === -1) sleepQualityText = TextManager.RCMenuSleepQualityNegOneText;
	else if(sleepQuality === 0) sleepQualityText = TextManager.RCMenuSleepQualityZeroText;
	else if(sleepQuality === 1) sleepQualityText = TextManager.RCMenuSleepQualityOneText;
	else if(sleepQuality === 2) sleepQualityText = TextManager.RCMenuSleepQualityTwoText;
	else if(sleepQuality >= 3) sleepQualityText = TextManager.RCMenuSleepQualityThreeText;

	this.drawTextEx(sleepQualityText, x, line * lh, width, 'left', true);
	line += statusLineChange;

	//Panties
	if(actor._halberdIsDefiled) {
		let defiledHalberdText = TextManager.RCMenuDefiledHalberdText;
		this.drawTextEx(defiledHalberdText, x, line * lh, width, 'left', true);
		line += statusLineChange;
	}

	//Metal Exp
	if(actor._todaySubduedMetalEnemiesCount > 0) {
		let metalExpText = '';

		if(actor._todaySubduedMetalEnemiesCount > 1) {
			metalExpText = TextManager.RCMenuMetalPluralText.format(actor.metalExpRateBonus(), actor._todaySubduedMetalEnemiesCount);
		}
		else {
			metalExpText = TextManager.RCMenuMetalSingleText.format(actor.metalExpRateBonus());
		}
		this.drawTextEx(metalExpText, x, line * lh, width, 'left', true);
		line += statusLineChange;
	}

	//Artisan Meal
	if(actor.hadAnArtisanMeal()) {
		let mealText = TextManager.artisanMeal(actor._artisanMeal);
		this.drawTextEx(mealText, x, line * lh, width, 'left', true);
		line += statusLineChange;
	}

	//Store Item
	if(actor.isUsingAnyStoreItem()) {
		let storeItemText = TextManager.storeItem(actor._usingStoreItem);
		this.drawTextEx(storeItemText, x, line * lh, width, 'left', true);
		line += statusLineChange;
	}

	//Gifts
	let numOfGifts = actor.numOfGifts();
	let giftsText = '';

	if(numOfGifts > 0) {
		if(numOfGifts === 1)
			giftsText = TextManager.RCMenuGiftsSingleText;
		else
			giftsText = TextManager.RCMenuGiftsPluralText;

		giftsText += actor.allGiftsText();

		this.drawTextEx(giftsText, x, line * lh, width, 'left', true);
		line += statusLineChange;
	}

};

// It is rather silly to overwrite the function again right after declaring it, but
// this should make it easier to update in the future
CC_Mod.PregMod.Window_MenuStatus_drawKarrynStatus = Window_MenuStatus.prototype.drawKarrynStatus;
Window_MenuStatus.prototype.drawKarrynStatus = function() {
    CC_Mod.CCMod_drawStatusPicture(this);
    CC_Mod.PregMod.Window_MenuStatus_drawKarrynStatus.call(this);
    CC_Mod.CCMod_drawKarrynStatus(this);
    CC_Mod.Gyaru_checkEdictChanged();
};

// Debug
CC_Mod.PregMod.Game_Actor_dmgFormula_karrynCockPetting = Game_Actor.prototype.dmgFormula_karrynCockPetting;
Game_Actor.prototype.dmgFormula_karrynCockPetting = function(target) {
    CC_Mod.PregMod.Game_Actor_dmgFormula_karrynCockPetting.call(this, target);
    if (CCMOD_DEBUG) {
        CC_Mod.processCreampie(target, this)
    }
};

CC_Mod.PregMod.Game_Actor_showEval_karrynCockPettingSkill = Game_Actor.prototype.showEval_karrynCockPettingSkill;
Game_Actor.prototype.showEval_karrynCockPettingSkill = function() {
    if (CCMOD_DEBUG) {
        return true;
    }
    return CC_Mod.PregMod.Game_Actor_showEval_karrynCockPettingSkill.call(this);
};

CC_Mod.PregMod.Game_Actor_canBePussyCreampied = Game_Actor.prototype.canBePussyCreampied;
Game_Actor.prototype.canBePussyCreampied = function() {
    if (CCMOD_DEBUG) {
        return true;
    }
    return CC_Mod.PregMod.Game_Actor_canBePussyCreampied.call(this);
};

repo_name: Rexhunk/karryn

license: unknown