def try_sim_pregnancy_from_sex_handler(sex_handler, sims_list, actor_id,
                                       sim_info):
    if not can_sim_get_pregnant(sim_info):
        return False
    if TurboSimUtil.Pregnancy.is_pregnant(sim_info):
        return False
    sim_pregnancy_chance = get_sim_current_pregnancy_chance(sim_info)
    if get_sex_setting(
            SexSetting.PREGNANCY_MODE, variable_type=int
    ) == PregnancyModeSetting.SIMPLE and sim_pregnancy_chance <= 0.0:
        return False
    pregnancy_partners = _get_possible_partners(sex_handler, sims_list,
                                                actor_id, sim_info)
    absolute_days = TurboWorldUtil.Time.get_absolute_days()
    enable_pregnancy_discovery = False
    for (partner_sim_id, is_cum_inside) in pregnancy_partners:
        partner_sim_info = TurboManagerUtil.Sim.get_sim_info(partner_sim_id)
        if partner_sim_info is None:
            pass
        if has_relationship_bit_with_sim(
                sim_info, partner_sim_info,
                SimRelationshipBit.WW_POTENTIAL_PREGNANCY_PARENT):
            pass
        if get_sex_setting(
                SexSetting.BIRTH_CONTROL_MODE,
                variable_type=int) == BirthControlModeSetting.REALISTIC:
            enable_pregnancy_discovery = True
        if _is_sim_on_birth_control(partner_sim_info):
            pass
        enable_pregnancy_discovery = True
        partner_pregnancy_chance = get_sim_current_pregnancy_chance(
            partner_sim_info)
        if partner_pregnancy_chance <= 0.0:
            pass
        if is_cum_inside is False:
            if has_sim_trait(partner_sim_info, SimTrait.LAZY) or has_sim_trait(
                    partner_sim_info, SimTrait.CLUMSY):
                partner_pregnancy_chance /= 2.0
            else:
                partner_pregnancy_chance /= 4.0
        chance_value = random.Random(
            (absolute_days, TurboManagerUtil.Sim.get_sim_id(sim_info),
             partner_sim_id)).uniform(0, 1)
        while chance_value <= sim_pregnancy_chance and (
                sim_ev(sim_info).pregnancy_fertility_boost[0] > 0
                or chance_value <= partner_pregnancy_chance):
            sim_ev(sim_info).pregnancy_coming_flag = True
            add_relationsip_bit_with_sim(
                sim_info, partner_sim_info,
                SimRelationshipBit.WW_POTENTIAL_PREGNANCY_PARENT)
            enable_pregnancy_discovery = True
    if enable_pregnancy_discovery is True and sex_handler.has_displayed_pregnancy_notification is False:
        set_sim_pregnancy_discovery(sim_info, True)
        sex_handler.has_displayed_pregnancy_notification = True
def _wickedwhims_on_basemental_drugs_use_interaction(interaction_instance):
    if not get_sex_setting(SexSetting.MISCARRIAGE_SWITCH, variable_type=bool):
        return
    if not is_basemental_drugs_installed():
        return
    sim = TurboInteractionUtil.get_interaction_sim(interaction_instance)
    if not can_sim_get_pregnant(
            sim) and not TurboSimUtil.Pregnancy.is_pregnant(sim):
        return
    interaction_guid = TurboResourceUtil.Resource.get_guid64(
        interaction_instance)
    for (interaction_id, miscarriage_value) in DRUGS_INTERACTIONS:
        while interaction_guid == interaction_id:
            break
Example #3
0
def _is_sim_fearing_possible_pregnancy(sim_identifier):
    if TurboSimUtil.Sim.is_player(sim_identifier):
        return False
    if not can_sim_get_pregnant(sim_identifier):
        return False
    if is_sim_birth_control_safe(sim_identifier, allow_potentially=True):
        return False
    if get_sex_setting(
            SexSetting.AUTONOMY_NPC_PREGNANCY_AWARENESS, variable_type=bool
    ) and get_sex_setting(
            SexSetting.PREGNANCY_MODE, variable_type=bool
    ) == PregnancyModeSetting.MENSTRUAL_CYCLE and get_sim_current_pregnancy_chance(
            sim_identifier) > 0:
        return True
    return False
Example #4
0
def _get_sim_current_menstrual_pregnancy_chance(sim_identifier):
    sim_info = TurboManagerUtil.Sim.get_sim_info(sim_identifier)
    if not can_sim_get_pregnant(sim_info):
        return 0.0
    pregnancy_matrix = get_sim_menstrual_pregnancy_chance_matrix(sim_info)
    menstrual_cycle_days = get_sim_menstrual_cycle_days(sim_info)
    cycle_day = (TurboWorldUtil.Time.get_absolute_days() +
                 ABSOLUTE_DAYS_OFFSET) % menstrual_cycle_days + 1
    if cycle_day not in pregnancy_matrix:
        return 0.0
    pregnancy_chance = pregnancy_matrix[cycle_day]
    if is_sim_on_basemental_drugs(sim_info, skip_weed=True):
        pregnancy_chance -= pregnancy_chance * 0.25
    pregnancy_chance *= max(1, sim_ev(sim_info).pregnancy_fertility_boost[1])
    return min(pregnancy_chance, 1.0)
def _on_sim_basemental_drugs_buff_added(buff_type, sim_id):
    if buff_type is None:
        return
    if not is_basemental_drugs_installed():
        return
    sim_info = TurboManagerUtil.Sim.get_sim_info(sim_id)
    if sim_info is None:
        return
    if not can_sim_get_pregnant(
            sim_info) and not TurboSimUtil.Pregnancy.is_pregnant(sim_info):
        return
    target_buff_id = TurboResourceUtil.Resource.get_guid64(buff_type)
    if target_buff_id == SimBuff.BASEMENTAL_REHAB_COMPLETED:
        sim_ev(sim_info).miscarriage_potential = 0
        return
    for (buff_id, miscarriage_value) in DRUGS_BUFFS:
        while buff_id == target_buff_id:
            break
def try_pregnancy_from_sex_handler(sex_handler, sims_list):
    if get_sex_setting(SexSetting.PREGNANCY_MODE,
                       variable_type=int) == PregnancyModeSetting.DISABLED:
        return
    if not is_sex_handler_allowed_for_pregnancy(sex_handler):
        return
    for (_, sim_info) in sims_list:
        try_late_assign_birth_control(sim_info)
    try_auto_apply_condoms(sex_handler, sims_list)
    if sex_handler.pregnancy_sex_counter < 10:
        return
    if sex_handler.is_npc_only() and get_sex_setting(
            SexSetting.PREGNANCY_MODE, variable_type=int
    ) == PregnancyModeSetting.MENSTRUAL_CYCLE and not get_sex_setting(
            SexSetting.MENSTRUAL_CYCLE_NPC_PREGNANCY, variable_type=bool):
        return
    for (actor_id, sim_info) in sims_list:
        if not can_sim_get_pregnant(sim_info):
            pass
        if _is_sim_on_birth_control(sim_info):
            pass
        try_sim_pregnancy_from_sex_handler(sex_handler, sims_list, actor_id,
                                           sim_info)
    sex_handler.pregnancy_sex_counter = 0
Example #7
0
def try_auto_apply_condoms(sex_handler, sims_list):
    if sex_handler.tried_auto_apply_birth_control is True:
        return True
    if get_sex_setting(SexSetting.PREGNANCY_MODE,
                       variable_type=int) == PregnancyModeSetting.DISABLED:
        return False
    if get_sex_setting(SexSetting.PREGNANCY_MODE, variable_type=int
                       ) == PregnancyModeSetting.SIMPLE and get_sex_setting(
                           SexSetting.SIMPLE_PREGNANCY_CHANCE,
                           variable_type=int) <= 0 and get_sex_setting(
                               SexSetting.SIMPLE_NPC_PREGNANCY_CHANCE,
                               variable_type=int) <= 0:
        return False
    is_pregnancy_sex = False
    for (actor_id, sim_info) in sims_list:
        if is_pregnancy_sex is True:
            break
        if not can_sim_get_pregnant(sim_info):
            pass
        actions = sex_handler.get_animation_instance(
        ).get_actor_received_actions(actor_id)
        for (action_actor_id, action_type, __) in actions:
            if action_type != SexCategoryType.VAGINAL:
                pass
            if actor_id == action_actor_id:
                pass
            actor_sim_id = sex_handler.get_sim_id_by_actor_id(action_actor_id)
            actor_sim_info = TurboManagerUtil.Sim.get_sim_info(actor_sim_id)
            if actor_sim_info is None:
                pass
            if not can_sim_impregnate(actor_sim_info):
                pass
            is_pregnancy_sex = True
            break
        while len(sims_list) == 2 and sex_handler.get_animation_instance(
        ).get_sex_category() == SexCategoryType.VAGINAL:
            while True:
                for (action_actor_id, actor_sim_info) in sims_list:
                    if actor_id == action_actor_id:
                        pass
                    if actor_sim_info is sim_info:
                        pass
                    if not can_sim_impregnate(actor_sim_info):
                        pass
                    is_pregnancy_sex = True
                    break
    if is_pregnancy_sex is False:
        return False
    condom_sims = list()
    has_sims_requiring_condom_use = False
    for (_, sim_info) in sims_list:
        condoms_count = get_object_amount_in_sim_inventory(
            sim_info, CONDOM_WRAPPER_OBJECT_ID)
        if _is_sim_requiring_condom_auto_use(sim_info, condoms_count):
            has_sims_requiring_condom_use = True
        condom_sims.append((sim_info, condoms_count))
    if has_sims_requiring_condom_use is False or not condom_sims:
        return False
    (condom_sim, condoms_count) = sorted(condom_sims,
                                         key=lambda x: x[1],
                                         reverse=True)[0]
    if condoms_count <= 0:
        return False
    try_to_take_and_use_condoms(condom_sim, silent_failure=True)
    sex_handler.tried_auto_apply_birth_control = True
    return True
Example #8
0
def _test_for_children_hater(sim_info, sim_info_list, animation_category,
                             **args):
    if get_sex_setting(SexSetting.ALWAYS_ACCEPT_STATE, variable_type=bool):
        return True
    if get_sex_setting(SexSetting.PREGNANCY_MODE,
                       variable_type=int) == PregnancyModeSetting.DISABLED:
        return True
    if animation_category != SexCategoryType.VAGINAL and animation_category != SexCategoryType.CLIMAX:
        return True
    if not has_sim_trait(sim_info, SimTrait.HATESCHILDREN):
        return True
    if not can_sim_get_pregnant(sim_info):
        return True
    is_npc_only = False not in [
        TurboSimUtil.Sim.is_npc(target_sim_info)
        for target_sim_info in sim_info_list
    ]
    if get_sex_setting(SexSetting.PREGNANCY_MODE,
                       variable_type=int) == PregnancyModeSetting.SIMPLE:
        if is_npc_only:
            if get_sex_setting(SexSetting.SIMPLE_NPC_PREGNANCY_CHANCE,
                               variable_type=int) <= 0:
                return True
                if get_sex_setting(SexSetting.SIMPLE_PREGNANCY_CHANCE,
                                   variable_type=int) <= 0:
                    return True
        elif get_sex_setting(SexSetting.SIMPLE_PREGNANCY_CHANCE,
                             variable_type=int) <= 0:
            return True
    try_late_assign_birth_control(sim_info)
    if sim_ev(sim_info).has_condom_on is True or sim_ev(
            sim_info
    ).day_used_birth_control_pills == TurboWorldUtil.Time.get_absolute_days():
        return True
    condoms_needed = 0
    if 'is_joining' in args:
        for actor_sim_info in sim_info_list:
            while sim_ev(
                    actor_sim_info).has_condom_on is False and has_sim_trait(
                        actor_sim_info,
                        SimTrait.GENDEROPTIONS_PREGNANCY_CANIMPREGNATE):
                condoms_needed += 1
    elif sim_ev(sim_info).active_sex_handler is not None:
        for actor_sim_info in sim_ev(
                sim_info).active_sex_handler.get_actors_sim_info_gen():
            while sim_ev(
                    actor_sim_info).has_condom_on is False and has_sim_trait(
                        actor_sim_info,
                        SimTrait.GENDEROPTIONS_PREGNANCY_CANIMPREGNATE):
                condoms_needed += 1
    else:
        condoms_needed = 1
    if condoms_needed == 0:
        return True
    has_needed_condoms = False
    for actor_sim_info in sim_info_list:
        condoms_count = get_object_amount_in_sim_inventory(
            actor_sim_info, get_condom_wrapper_object_id())
        while condoms_count >= condoms_needed:
            has_needed_condoms = True
            break
    if has_needed_condoms is False:
        return SexDenialReason(
            False, SexDenialReasonType.NO_PROTECTION_HATES_CHILDREN, sim_info)
    return True