Example #1
0
def __eval(
    personality_string: str, disposition:int, padding:int,
    meta: dict, lis: list
    ):
    if not meta: return
    DMAX = MAX_DISPOSITION
    for k,v in meta.items():
        if (k=="generic" or k==personality_string):
            for disp_ratio, strings in v.items():
                if (disposition >= rog.around(disp_ratio*DMAX)
                    and disposition <= rog.around((disp_ratio+padding)*DMAX)
                    ):
                    for string in strings:
                        lis.append(string)
Example #2
0
def get_attraction_masculine(
    _bea,_idn,_cou,_str,_int,
    fbea=1,fidn=1,fcou=1,fstr=1,fint=1,default=-25
    ):
    ''' Get perceived masculine attraction level of an entity
            based on the provided stats.
        Masculine attraction involves much more stats than feminine.
        Assumes entity can be detected and observed by admirer.
        fbea,fidn,etc.: multiplier factors for each stat's
            effectiveness in raising attraction.
        default: base attraction level
            raise or lower this to change how "easy" women are
    '''
    attraction=default
    
    # many stats factor into attraction:
        # intimidation -- inverse quadratic
            # 200 IDN is where it crosses 0
            # max gain from IDN ~10 from ~80 to 120 IDN
    attraction += fidn * (_idn/5 - (0.001 * _idn**2))
        # beauty -- matters less than it does when judging women
    attraction += fbea * (_bea/10) # note no limits in any direction
        # strength
    attraction += fstr * ((_str - BASE_STR)/2)
        # intelligence
    attraction += fint * ((_int - BASE_INT))
        # courage -- max attraction: +30 (verify)
    x = BASE_COURAGE//2
    while (x <= _cou and x < BASE_COURAGE*8):
        x = x*2
        attraction += fcou * 10
    attraction = rog.around(attraction)
##    print("attraction: ",attraction)
    return attraction
Example #3
0
def annoy(ent:int, amt:int): # buildup for Annoyed Status
    world = rog.world()
    if not world.has_component(ent, cmp.GetsAnnoyed):
        return
    # if I love you, annoyance amount is reduced; hate increases it
    rat = get_disp_ratio(ent)
    if rat <= 0.1:
        amt = amt * 3
    elif rat <= 0.2:
        amt = amt * 2
    elif rat >= 0.4:
        amt = amt * 0.5
    elif rat >= 0.6:
        amt = amt * 0.25
    elif rat >= 0.8:
        amt = amt * 0.1
    amt = _apply_compatibility_modifier_pseudostatus(ent, amt)
    # add annoyance, set annoyed status if applicable
    dice_size = rog.around(amt * res_annoyance(ent))
    compo = world.component_for_entity(ent, cmp.GetsAnnoyed)
    compo.annoyance += dice.roll(dice_size)
    if compo.annoyance >= MAX_ANNOYANCE:
        compo.annoyance = 0
        print("ANNOYED!")
        rog.set_status(ent, cmp.StatusAnnoyed, target=rog.pc())
Example #4
0
def get_effective_disposition(ent:int, disposition:int):
    world=rog.world()
    ret = disposition
    # charmed bonus
    if world.has_component(ent, cmp.StatusCharmed):
        compo = world.component_for_entity(ent, cmp.StatusCharmed)
        if rog.pc()==world.component_for_entity(ent, cmp.StatusCharmed).entity:
            ret += compo.quality
    return rog.around(min(MAX_DISPOSITION, ret))
Example #5
0
def diabetes(ent): # buildup for Diabetes Status
    world=rog.world()
    if world.has_component(ent, cmp.GetsDiabetes):
        compo = world.component_for_entity(ent, cmp.GetsDiabetes)
        dice_size = 140 - rog.getskill(rog.pc(),SKL_PERSUASION)
        dice_size = _apply_compatibility_modifier_pseudostatus(
            ent, dice_size, factor=1.5 )
        dice_size *= res_diabetes(ent)
        compo.diabetes += dice.roll(rog.around(dice_size))
        if compo.diabetes >= MAX_DIABETES:
            compo.diabetes = 0
            rog.set_status(ent, cmp.StatusDiabetes)
        print(compo.diabetes)
Example #6
0
def get_attraction_feminine(_bea, _int=0, factor_int=False, default=0):
    ''' Get perceived feminine attraction level of an entity
            based on the provided stats.
        Feminine attraction involves few stats -- mostly just beauty.
        Assumes entity can be detected and observed by admirer.
        factor_int: factor intelligence stat into attraction?
        default: base attraction level
    '''
    attraction = default
    attraction += _bea/4 # note no limits in any direction
    if factor_int: attraction += (_int - BASE_INT)
    attraction=rog.around(attraction)
##    print("attraction: ",attraction)
    return attraction
Example #7
0
def anger(ent:int, amt:int):
    amt = rog.around(amt * res_anger(ent))
    amt = _apply_compatibility_modifier_pseudostatus(ent, amt)
    rog.anger(ent, rog.pc(), amt)
Example #8
0
def _get_reaction(
    ent:int, persuasion_type:int, personality:int, disposition:int,
    leverage=0, mx=1, value=0, style=0
    ) -> int:
    ''' get reaction from an entity based on conversational parameters
        leverage: who has the power advantage? Pos: PC. TODO: implement!
        mx: multiplier for intensity
        value: value of transaction, if it's a barter or bribe
        Returns >0 values for positive reactions, <0 for negative
            the greater the value, the higher the intensity
    '''
    world=rog.world()
    pc=rog.pc()
    DMAX = MAX_DISPOSITION
    reaction = -20
    dice_size = 20
    
        # ---- initialize ---- #
    
    # get stats for player
    speech = rog.getskill(pc, SKL_PERSUASION)
    speech_bonus_modf = 0.5 + speech/MAX_SKILL
    speech_penalty_modf = 2.25 - 2*speech/MAX_SKILL
    pc_idn = rog.getms(pc, 'idn')
    pc_bea = rog.getms(pc, 'bea')
    pc_cou = rog.getms(pc, 'cou')
    pc_str = rog.getms(pc, 'str')//MULT_STATS
    pc_int = rog.getms(pc, 'int')//MULT_STATS
    pc_pos = world.component_for_entity(pc, cmp.Position)
    
    # get stats for conversational partner
    ent_sight = rog.getms(ent,'sight')
    ent_cansee = rog.can_see(ent, pc_pos.x,pc_pos.y, ent_sight)
    
    disposition = get_effective_disposition(ent, disposition)

        # ---- basic reaction ---- #
    
    # (perceived) value of the transaction
    value_modf = max(1, (value//MULT_VALUE)*0.1)
    reaction += leverage

    # reaction based on existing disposition
    if disposition == 0:
        reaction -= 24
    elif disposition < 0.1*DMAX:
        reaction -= 18
    elif disposition < 0.2*DMAX:
        reaction -= 12
    elif disposition < 0.3*DMAX:
        reaction -= 6
    elif disposition < 0.4*DMAX:
        pass
    elif disposition < 0.5*DMAX:
        reaction += 3
    elif disposition < 0.6*DMAX:
        reaction += 6
    elif disposition < 0.7*DMAX:
        reaction += 9
    elif disposition < 0.8*DMAX:
        reaction += 12
    elif disposition < 0.9*DMAX:
        reaction += 15
    elif disposition < DMAX:
        reaction += 18
    else:
        reaction += 21
    
        # ---- status reaction ---- #
    
    if world.has_component(ent, cmp.StatusAnnoyed):
        compo = world.component_for_entity(ent, cmp.StatusAnnoyed)
        if compo.entity == pc:
            reaction -= 40
    
        # ---- special cases ---- #
    
    # people of high moral standing who never accept a bribe
    if world.has_component(ent, cmp.NeverAcceptsBribes):
        value_modf = 0
        
    # rich people don't care about low-value deals
    if (world.has_component(ent, cmp.Rich) and value < 100*MULT_VALUE):
        value_modf = 0
        if value < 10*MULT_VALUE:
            reaction -= 40
        else:
            reaction -= 20
    
        # ---- intensity, default reactions ---- #

    # intensity of the conversation based on transaction value    
    intensity = 1
    speech_mod = 0.4
    # intensity, base reaction, random variation (size of dice), and
    #   speech modifier (how much speech level affects reaction);
    #   based on type of conversation / persuasion
    if persuasion_type==TALK_TORTURE:
        speech_mod = 1.25*speech_mod
        dice_size = 100
        reaction -= 0.15*DMAX
        intensity = 10 * intensity
    elif persuasion_type==TALK_INTERROGATE:
        speech_mod = 1.5*speech_mod
        dice_size = 60
        reaction -= 0.085*DMAX
        intensity = 5 * intensity
    elif persuasion_type==TALK_INTIMIDATION:
        reaction -= 0.01*DMAX
        intensity = 4 * intensity
    elif persuasion_type==TALK_BEG:
        speech_mod = 1.33334*speech_mod
        reaction -= 0.05*DMAX
        intensity = 3 * intensity
    elif persuasion_type==TALK_BARTER:
        dice_size = 40
        intensity = 2 * intensity
        reaction -= 0.01*DMAX
        reaction += value_modf * value//MULT_VALUE
    elif persuasion_type==TALK_BRIBERY:
        dice_size = 40
        intensity = 2 * intensity
        reaction -= 0.02*DMAX
        reaction += value_modf * value//MULT_VALUE
    elif persuasion_type==TALK_CHARM: # relies on speech skill
        speech_mod = 1.5*speech_mod
        reaction -= 20
    elif persuasion_type==TALK_BOAST: # relies on perceived strength/fame
        speech_mod = 1.25*speech_mod
        reaction -= 40
        reaction += rog.get_power_level(rog.pc())
    elif persuasion_type==TALK_DEBATE:
        speech_mod = 1.5*speech_mod
        intensity = 2 * intensity
    elif persuasion_type==TALK_FLIRTATION:
        speech_mod = 1.5*speech_mod
        dice_size = 80
        reaction -= 50
        intensity = 2 * intensity
    elif persuasion_type==TALK_ASKFAVOR:
        reaction -= 0.025*DMAX
        intensity = 2 * intensity
    elif persuasion_type==TALK_FLATTERY:
        speech_mod = 1.5*speech_mod
        reaction -= 15
        dice_size = 40
        intensity = 1.5 * intensity
            # special combo-persuasion: Taunt -> Flattery
        if (world.has_component(ent, cmp.Taunted)
            and not world.has_component(ent, cmp.ComboTauntFlattery)
            ):
            if dice.roll(20) <= 5 + speech//5:
                reaction += 40
                intensity += 0.1
                rog.world().add_component(ent, cmp.ComboTauntFlattery())
                diabetes(ent) # gives more diabetes than usual flattery
    elif persuasion_type==TALK_TAUNT:
        speech_mod = 1.2*speech_mod
        reaction -= 0.01*DMAX
        intensity = 1.5 * intensity
    elif persuasion_type==TALK_SMALLTALK:
        speech_mod = 0.75*speech_mod
        reaction += 5
        intensity = 0.5 * intensity
    elif persuasion_type==TALK_GREETING:
        reaction += 1
        intensity = 0.25 * intensity
    
        # ---- attraction ---- #
            
    attraction = 0
    pc_isfemale = rog.get_gender(pc)=="female"
    pc_ismale = rog.get_gender(pc)=="male"
    
    # Sexual Attraction to Women
    if (ent_cansee and pc_isfemale
        and world.has_component(ent, cmp.AttractedToWomen)
        ):
        intensity += 1
        attraction += get_attraction_feminine(pc_bea)
    # Sexual Attraction to Men
    elif (ent_cansee and pc_ismale
        and world.has_component(ent, cmp.AttractedToMen)
        ):
        intensity += 1
        attraction += get_attraction_masculine(
            pc_bea, pc_idn, pc_cou, pc_str, pc_int
            )
    # end if
    
    # apply attraction reaction
    attraction = rog.around(attraction)
        # flirtation-specific
    if persuasion_type==TALK_FLIRTATION:
        #
            # special cases #
        # sorry hun, I'm taken.
        if world.has_component(ent, cmp.Taken):
            reaction -= 20
        # I don't do sex.
        if world.has_component(ent, cmp.Ascetic):
            reaction -= 40
            #
        #
        # attraction matter more for flirtation than other
        #   types of conversation.
        reaction += attraction
    else:
        # other
        reaction += attraction*0.5
    # end if
        
        # ---- compatibility ---- #
    
    # personality compatibility
    pc_personality = rog.get_personality(pc)
    compat = get_compatibility(personality, pc_personality)
    if compat==1:
        reaction -= 20
    elif compat==2:
        reaction -= 10
    elif compat==3:
        pass
    elif compat==4:
        reaction += 10
    elif compat==5:
        reaction += 20
##    print("personalities: ent: {}, player: {}".format(
##        personality, pc_personality))
##    print("personalities: ent: {}, player: {}".format(
##        PERSONALITIES[personality][0], PERSONALITIES[pc_personality][0]))
##    print("personality compatibility: ", compat)
    
    # likes and dislikes
    likes=_get_likes(personality)
    dislikes=_get_dislikes(personality)
    if persuasion_type == likes[0]:
        reaction += ( 0.01*DMAX * speech_bonus_modf * mx ) * intensity
    elif persuasion_type == dislikes[0]:
        reaction -= ( 0.02*DMAX * speech_penalty_modf * mx ) * intensity
    
    # special cases #
    # intensity and energy level
    if ((personality==PERSON_NONCONFRONTATIONAL
         or personality==PERSON_LOWENERGY)
        and intensity >= 3
        ):
        reaction -= 0.01*DMAX
    elif ((personality==ARGUMENTATIVE
           or personality==PERSON_BUBBLY)
         and intensity >= 3
        ):
        reaction += 0.01*DMAX
    # never accepts bribes
    if (persuasion_type==TALK_BRIBERY
        and world.has_component(ent, cmp.NeverAcceptsBribes)
        ):
        reaction = -0.05*DMAX * mx # set reaction
    # diabetes from too much flattery
    if (persuasion_type==TALK_FLATTERY
        and world.has_component(ent, cmp.StatusDiabetes)
        ):
        reaction = -0.075*DMAX * speech_penalty_modf * mx
    # auxiliary likes/dislikes
    if (persuasion_type==TALK_BEG and personality==PERSON_PROUD):
        reaction -= 0.05*DMAX * mx
    elif (persuasion_type==TALK_INTERROGATE and personality==PERSON_RELAXED):
        reaction -= 0.02*DMAX * mx
    elif (persuasion_type==TALK_CHARM and personality==PERSON_LOWENERGY):
        reaction -= 0.01*DMAX * mx
    elif (persuasion_type==TALK_CHARM and personality==PERSON_BUBBLY):
        reaction += 0.01*DMAX * mx
    elif (persuasion_type==TALK_BOAST and personality==PERSON_PROACTIVE):
        reaction -= 0.01*DMAX * mx
    elif (persuasion_type==TALK_BOAST and personality==PERSON_MOTIVATED):
        reaction += 0.01*DMAX * mx
    
    # creeped out
    if (world.has_component(ent, cmp.StatusCreepedOut)
        and pc==world.component_for_entity(ent, cmp.StatusCreepedOut).entity):
        reaction -= 40 if persuasion_type==TALK_FLIRTATION else 20
    
    # waste my time with 0 value offer -> minus some disp.
    if (persuasion_type==TALK_BRIBERY or persuasion_type==TALK_BARTER):
        if value == 0:
            reaction = min(-10, value)
    
    # add speech modifier
    reaction += speech * speech_mod
    # add element of random chance -- size of dice determined above
    reaction += dice.roll(dice_size)
    
    # trying to charm while already charmed -> loss of disposition
    if persuasion_type==TALK_CHARM:
        if world.has_component(ent, cmp.StatusCharmed):
            reaction = min(reaction - 100, -20)
    elif persuasion_type==TALK_BOAST:
        if world.has_component(ent, cmp.StatusCharmed):
            reaction = min(reaction - 100, -20)
    
    # people who have a hard time learning to like/trust others
    if (disposition >= 0.5*DMAX # lose reaction once disp crosses a threshold
        and world.has_component(ent, cmp.Untrusting)):
        reaction -= 20
    if (world.has_component(ent, cmp.Antisocial)):
        reaction -= 10
    
    return math.ceil(abs(reaction)) * rog.sign(reaction)