def run(self): super(Manager_SoundsHeard,self).run() atLeastOneMsg=False text="You hear " for k,v in self.sounds.items(): vol,lis=v if not vol: continue if vol > VOLUME_DEAFEN: rog.set_status(rog.pc(), DEAF) #super hearing if rog.pc().stats.get("hearing") >= SUPER_HEARING: volTxt=self.get_volume_name(vol) dirStr=DIRECTIONS_TERSE[k] if not dirStr == "self": text += "<{d}>".format(d=dirStr) text += "({v}) ".format(v=volTxt) #combine strings with commas for strng in lis: text += "{s}, ".format(s=strng) #terminate with a period text=text[:-2] + "." atLeastOneMsg=True if atLeastOneMsg: rog.msg(text) self.init_sounds()
def update(self): clearMsg = False #activate_all_necessary_updates() if self.updates[Update.U_HUD] : rog.render_hud(rog.pc()); if self.updates[Update.U_GAME] : rog.render_gameArea(rog.pc()); if self.updates[Update.U_MSG] : rog.logNewEntry(); clearMsg=True; if self.updates[Update.U_FINAL] : rog.blit_to_final( rog.con_game(),0,0); if self.updates[Update.U_BASE] : rog.refresh(); if clearMsg: rog.msg_clear() self.set_all_to_false()
def greet(ent:int, style=0) -> int: # attempt to init conversation pc=rog.pc() world=rog.world() personality=world.component_for_entity(ent,cmp.Personality).personality dispcompo=world.component_for_entity(ent,cmp.Disposition) # new disposition after dialogue concludes new_disposition = dispcompo.disposition # effective disposition during this dialogue (not the new disposition) ed = dispcompo.disposition + _get_reaction( ent, TALK_GREETING, personality, dispcompo.disposition, style=style, mx=0.5 ) reaction = rog.sign(ed) # just nudge disposition fdisp = ed / MAX_DISPOSITION # roll for speech success speech_bonus = rog.getskill(pc, SKL_PERSUASION) roll=dice.roll(100) + speech_bonus if fdisp < 0.4: roll -= 8/fdisp else: roll += 100*fdisp # cases if roll <= 0: _response(ent, RESPONSE_REJECTION) else: _response(ent, RESPONSE_ACCEPT) return reaction
def run(self): super(Manager_SoundsHeard, self).run() pc = rog.pc() atLeastOneMsg = False text = "You hear " skills = rog.world().component_for_entity(pc, cmp.Skills) for k, v in self.sounds.items(): vol, lis = v if not vol: continue if vol > VOLUME_DEAFEN: rog.set_status(pc, DEAF) #super hearing ## if SKL_SUPERHEARING in skills.skills: ## volTxt=self.get_volume_name(vol) ## dirStr=DIRECTIONS_TERSE[k] ## if not dirStr == "self": ## text += "<{d}>".format(d=dirStr) ## text += "({v}) ".format(v=volTxt) #combine strings with commas for strng in lis: text += "{s}, ".format(s=strng) #terminate with a period text = text[:-2] + "." atLeastOneMsg = True if atLeastOneMsg: rog.msg(text) self.init_sounds()
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())
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))
def __icomp(): # TODO: new dialogue pool for if you're fully naked; # will never call this function in that case. lis = rog.list_equipment(rog.pc()) if lis: ent = random.choice(lis) return rog.getname(ent) else: return "pubes"
def __init__(self, xs, ys, view, con): super(Manager_AimFindTarget, self).__init__() self.cursor = IO.Cursor(0, 0, rate=0.3) self.set_pos(rog.getx(xs), rog.gety(ys)) self.view = view self.con = con self.targets = None # [(entity, distance,),] self.targeted_index = 0 self.create_targetList(rog.pc()) self.select_hiscore()
def talk_debate(ent:int, personality:int, disposition:int, value=0, style=0) -> tuple: ttype = TALK_DEBATE reaction=_get_reaction(ent, ttype, personality, disposition, style=style) success = (reaction > 0) _change_disposition(ent, reaction, PERSUASION[ttype][2]) if (success and rog.world().has_component(ent,cmp.GetsAngry)): # success of anger roll depends on speech skill tobeat = 10 + rog.getskill(rog.pc(),SKL_PERSUASION)//10 # the following personalities anger people more easily in debate: if (rog.get_personality(rog.pc())==PERSON_APATHETIC or rog.get_personality(rog.pc())==PERSON_PROUD or rog.get_personality(rog.pc())==PERSON_ARGUMENTATIVE ): tobeat -= 10 # roll if dice.roll(20) >= tobeat: anger(ent, reaction) # end if annoy(ent, 10) return _talk(ent, success, ttype, personality, disposition, 900)
def talk_flirt(ent:int, personality:int, disposition:int, value=0, style=0) -> tuple: ttype = TALK_FLIRTATION reaction=_get_reaction(ent, ttype, personality, disposition, style=style) success = (reaction > 0) if not success: sb = rog.getskill(rog.pc(), SKL_PERSUASION)//5 if dice.roll(20) > (10 + sb + reaction//4): creepout(ent) _change_disposition(ent, reaction, PERSUASION[ttype][2]) annoy(ent, 5) return _talk(ent, success, ttype, personality, disposition, 600)
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)
def _apply_compatibility_modifier_pseudostatus(ent, amt, factor=2): personality = rog.get_personality(ent) pc_personality = rog.get_personality(rog.pc()) compat = get_compatibility(personality, pc_personality) if compat==1: amt *= factor elif compat==2: amt *= (factor*0.75) elif compat==4: amt /= (factor*0.75) elif compat==5: amt /= factor return amt
def _offer_menu( ent:int, personality:int, disposition:int, pc_offer:list, style=0 ): def givefunc(pc, item): # context-sensitive removal of item from your person rog.remove_equipment(pc, item) if rog.world().has_component(item, cmp.Carried): rog.take(pc, item) # give to NPC rog.give(pc, item) item = action._inventory_pc(rog.pc()) if item==-1: return False
def _talk( ent:int, success:bool, ttype:int, personality:int, disposition:int, exp:int, padding=0.2 ) -> tuple: world = rog.world() ed = get_effective_disposition(ent, disposition) pts = exp if success else 0.5*exp rog.train(rog.pc(), SKL_PERSUASION, pts) # get list of potential string responses possible = _get_possible_responses(ttype, personality, ed, padding) if (not possible[0] and not possible[1]): response = "*NO MESSAGE IMPLEMENTED*" else: response = _substitute_tags(ent, _get_response(possible, success)) return (response, success,)
def _apply_rendered_bgcol(self, x, y, ent): ''' get and apply the proper background color for the tile containing a thing ''' bgTile=self.get_bgcolor(x, y) #terrain, fires bgCol=bgTile if not rog.fireat(x,y): if self.nthings(x, y) >= 2: bgCol=COL['dkgreen'] elif (ent==rog.pc() and rog.settings().highlightPC ): bgCol=COL[rog.settings().highlightColor] elif not bgTile == self.BG_COLOR_MAIN: bgCol=bgTile else: bgCol=rog.world().component_for_entity(ent, cmp.Draw).bgcol libtcod.console_set_char_background(self.con_map_state, x,y, bgCol)
def _get_transaction_value( ent:int, personality:int, disposition:int, pc_offer:BarterOffer, npc_offer:BarterOffer, style=0 ) -> int: world = rog.world() pc = rog.pc() DMAX = MAX_DISPOSITION total = 0 # modifiers my_base = 2 # by default, I value my own things more highly pc_base = 0.5 # other people's stuff is much less valuable my_modf = PERSONALITIES[personality][3] pc_modf = PERSONALITIES[personality][4] # disposition disp_influence = 0.5 # how much does disp. affect perceived value? dr = (disposition - 0.5*DMAX)/DMAX my_disp_modf = 1 - dr*disp_influence pc_disp_modf = 1 + dr*disp_influence # speech skill level speech_influence = 1 # how much does speech affect perceived value? pc_speech = rog.getskill(pc, SKL_PERSUASION) my_speech = rog.getskill(ent, SKL_PERSUASION) sr = (my_speech - pc_speech)/MAX_SKILL my_speech_modf = 1 - sr*speech_influence pc_speech_modf = 1 + sr*speech_influence # PC offer total += pc_offer.money # money for item in pc_offer.items: # items value = world.component_for_entity(item, cmp.Form).value total += value*pc_base*pc_modf*pc_disp_modf*pc_speech_modf # NPC offer total += npc_offer.money # money for item in npc_offer.items: # items value = world.component_for_entity(item, cmp.Form).value total -= value*my_base*my_modf*my_disp_modf*my_speech_modf return int(total)
def say(ent:int, string:str, ttype=-1, success=False, ): ''' converse with an entity and msg out that entity's response ''' # TODO: elapse time while talking as interruptable delayed action # temporary: just do a one-time AP cost for each thing said rog.spendAP(rog.pc(), NRG_TALK) rog.spendAP(ent, NRG_TALK) if ttype==-1: message = "{}: {}".format(rog.getname(ent), string) else: talk_string = PERSUASION[ttype][1] success_string = "success" if success else "failure" disposition = get_effective_disposition( ent, rog.get_disposition(ent)) message = "<{} {}> {}: {} Disposition: {} / {}".format( talk_string, success_string, rog.getname(ent), string, disposition//10, MAX_DISPOSITION//10 ) rog.alert(message) # just in case it doesn't get displayed right away. rog.msg(message)
def _get_gift_for(ent:int) -> tuple: opt = rog.prompt( 0,0,rog.window_w(),4,q='Offer money or possessions? $/i', mode='wait',default='$' ) if opt=='$': value = rog.prompt( 0,0,rog.window_w(),4,q='Offer how much money?', mode='wait',default=0 ) elif opt=='i': options = { "cancel" : 0, "item from inventory" : -100, } body = world.component_for_entity(rog.pc(), cmp.Body) i=-1 for arm in body.parts[cmp.BPC_Arms].arms: i+=1 if (arm and arm.hand.held.item): options.update({"{}".format(item) : item}) opt = rog.menu("Offer what item?",0,0,menu) if opt==-1: return ("money",0,) item = options[opt] if item==0: return ("money",0,) if item==-100: # temporary # TODO: get from inventory return ("money",0,) itemn = world.component_for_entity(item, cmp.Name) entn = world.component_for_entity(ent, cmp.Name) ans = rog.prompt( "Offer {ti}{i} to {tn}{n}?".format( i=itemn.name,n=entn.name, it=TITLES[itemn.title], tn=TITLES[entn.title] ), 0,0, mode='wait' ) if ans=='y': return ("item",item,) return ("money",0,) # if we made it this far
def run(self): super(Manager_SightsSeen, self).run() pc = rog.pc() atLeastOneMsg = False text = "" for k, v in self.sights.items(): if not v: continue atLeastOneMsg = True lis = v dirStr = DIRECTIONS_TERSE[k] if not dirStr == "self": text += "<{d}> ".format(d=dirStr) for strng in lis: text += "{}{} ".format(strng[0].upper(), strng[1:]) if atLeastOneMsg: rog.msg(text) self.init_sights()
def quaff(ent, drink): world = rog.world() pos = world.component_for_entity(ent, cmp.Position) quaffable=world.component_for_entity(drink, cmp.Quaffable) entn = world.component_for_entity(ent, cmp.Name) drinkn = world.component_for_entity(drink, cmp.Name) #quaff function quaffable.func(ent) # TODO: do delayed action instead of immediate action. rog.drain(ent, 'nrg', quaffable.timeToConsume) rog.givemp(ent, quaffable.hydration) #events - sight if ent == rog.pc(): rog.msg("It tastes {t}".format(t=quaffable.taste)) else: rog.event_sight(pos.x,pos.y, "{t}{n} quaffs a {p}.".format( t=entn.title, n=entn.name, p=drinkn.name)) #events - sound rog.event_sound(pos.x,pos.y, SND_QUAFF) # TODO: make sure this works... world.delete_entity(drink)
def add(self, ev): k = self.get_direction(rog.pc(), ( ev.x, ev.y, )) self.sights[k].append(ev.text)
def main(): #------------------------------------------------# # INIT #------------------------------------------------# rog.Rogue.create_settings() # later controllers may depend on settings rog.Rogue.create_window() rog.Rogue.create_consoles() rog.Rogue.create_world() rog.Rogue.create_controller() rog.Rogue.create_data() rog.Rogue.create_map(ROOMW, ROOMH) ## rog.Rogue.create_fov_maps() rog.Rogue.create_clock() rog.Rogue.create_updater() rog.Rogue.create_view() rog.Rogue.create_log() rog.Rogue.create_savedGame() # TODO: learn/use Pickle. rog.Rogue.create_processors() rog.Rogue.create_perturn_managers() rog.Rogue.create_const_managers() rog.Rogue.create_const_entities() rog.init_keyBindings() #map generation rog.getmap(rog.dlvl()).init_specialGrids( ) # inits fov_map; do this before you init terrain rog.getmap(rog.dlvl()).init_terrain(WALL) # clear the map to all walls rog.getmap(rog.dlvl()).generate_dlvl(rog.dlvl()) # init player # TESTING THIS IS ALL TEMPORARY!!! # temporary: find a position to place the player xpos = 15 ypos = 15 _borders = 10 while rog.getmap(rog.dlvl()).tileat(xpos, ypos) == WALL: xpos += 1 if xpos >= ROOMW - _borders: xpos = _borders ypos += 1 if ypos >= ROOMH: print("~~ ! FATAL ERROR ! Failed to place player in the map!") break rog.Rogue.create_player(xpos, ypos) # create player pc = rog.pc() # TESTING # HELP THE PLAYER TO SEE rog.create_envlight(16) ## rog.make(rog.pc(), NVISION) # w = rog.create_monster('W', xpos, ypos - 1) ## rog.world().add_component(w, cmp.AttractedToMen()) ## rog.world().add_component(w, cmp.AttractedToWomen()) ## ## #testing speech ## rog.init_person(w) # ## w2=rog.create_monster('W',xpos,ypos+1) ## w3=rog.create_monster('W',xpos,ypos+2) ## rog.setskill(pc, SKL_BOXING, 100) ## rog.setskill(pc, SKL_PERSUASION, 0) ## rog.setskill(pc, SKL_ARMOR, 100) ## rog.sets(pc, 'dex', 12*MULT_STATS) ## rog.sets(pc, 'int', 4*MULT_STATS) ## rog.setskill(pc, SKL_UNARMORED, 40) ## for x in range(20): ## rog.create_monster("L", 1+x*5,1) ## rog.alts(pc, 'sight', 50) weap = rog.create_weapon("sword", xpos, ypos, mat=MAT_METAL) weap = rog.create_weapon("buckler", xpos, ypos, mat=MAT_METAL) ## ## rog.wound(pc, WOUND_BURN, 2) ## rog.damage(weap, 200) ## rog.fitgear(weap, pc) ## print(rog.equip( ## pc,weap,EQ_MAINHANDW ## )) ## rog.create_weapon("wooden club", xpos,ypos) ## rog.create_weapon("estoc", xpos-1,ypos) ## shield=rog.create_weapon("metal shield", 0,0) ## rog.equip( ## pc,shield,EQ_OFFHAND ## ) ## rog.fitgear(shield, pc) ## armor=rog.create_armor("metal gear", 0,0) ## rog.equip( ## pc,armor,EQ_FRONT ## ) ## rog.fitgear(armor, pc) ## helm=rog.create_headwear("metal helm", 0,0) ## rog.equip( ## pc,helm,EQ_MAINHEAD ## ) ## rog.fitgear(helm, pc) ## leg1=rog.create_legwear("metal mail legging", 0,0) ## rog.equip( ## pc,leg1,EQ_MAINLEG ## ) ## rog.fitgear(leg1, pc) ## leg2=rog.create_legwear("metal mail legging", 0,0) ## rog.equip( ## pc,leg2,EQ_OFFLEG ## ) ## rog.fitgear(leg2, pc) ## arm1=rog.create_armwear("metal vambrace", 0,0) ## rog.equip( ## pc,arm1,EQ_MAINARM ## ) ## rog.fitgear(arm1, pc) ## arm2=rog.create_armwear("metal vambrace", 0,0) ## rog.equip( ## pc,arm2,EQ_OFFARM ## ) ## rog.fitgear(arm2, pc) ## foot1=rog.create_footwear("metal boot", 0,0) ## rog.equip( ## pc,foot1,EQ_MAINFOOT ## ) ## rog.fitgear(foot1, pc) ## foot2=rog.create_footwear("metal boot", 0,0) ## rog.equip( ## pc,foot2,EQ_OFFFOOT ## ) ## rog.fitgear(foot2, pc) # # create light so player can see ## log=rog.create_rawmat("log", 18,18) ## rog.burn(log,500) # # /TESTING /TEMPORARY # # TODO?: observer for player ## obs=observer.Observer_playerChange() ## pc.observer_add(obs) #-----------------------------------------------# # # MAIN GAME LOOP # # #-----------------------------------------------# rog.game_set_state("normal") while rog.game_is_running(): # manually close game # if libtcod.console_is_window_closed(): rog.end() # defeat conditions # if rog.on(rog.pc(), DEAD): rog.game_set_state("game over") # get input # pcInput = IO.get_raw_input() pcAct = IO.handle_mousekeys(pcInput).items() # commands that are available from anywhere # player.commands_const(rog.pc(), pcAct) # Finally record game state after any/all changes # gameState = rog.game_state() #----------# # PLAY # #----------# # # normal game play # if gameState == "normal": game.play(pc, pcAct) # # manager game states # # elif gameState == "manager": manager = rog.get_active_manager() manager.run(pcAct) if manager.result: rog.close_active_manager() # elif gameState == "game over": rog.msg("You died...")
def _substitute_tags(ent:int, message:str) -> str: pc=rog.pc() world=rog.world() # component data which may or may not exist pcgsib = "sister" if rog.get_gender_id(pc)==GENDER_FEMALE else "brother" if world.has_component(ent,cmp.Gender): npcgg=rog.get_pronoun_generic(ent) else: npcgg="&person" # temporary (remove & -- that's a flag to indicate where in the code this string is) if world.has_component(ent,cmp.Job): compo=world.component_for_entity(ent,cmp.Job) npcc=CLASSES[compo.job] else: npcc="hobo" # return message.format( # NPC data npcc=npcc, npct=TITLES[world.component_for_entity(ent,cmp.Name).title], npcn=world.component_for_entity(ent,cmp.Name).name, npcgg=npcgg, # PC data pct=TITLES[world.component_for_entity(pc,cmp.Name).title], pcn=world.component_for_entity(pc,cmp.Name).name, pcc=CLASSES[world.component_for_entity(pc,cmp.Job).job], pcgg=rog.get_pronoun_generic(pc), pcgp=rog.get_pronoun_polite(pc), pcgpos=rog.get_pronoun_possessive(pc), pcgsib=pcgsib, pcgs=rog.get_pronoun_subject(pc), pcgo=rog.get_pronoun_object(pc), pcgi=rog.get_pronoun_informal(pc), # other nc=__nc(), anc=__anc(), ncs=__ncs(), slur=__slur(), slurs=__aslur(), aslur=__slurs(), cuss=__cuss(), flirt=__flirt(), tod=__tod(), tof=__tof(), toe=__toe(), gcomp=__gcomp(), wcomp=__wcomp(), icomp=__icomp(), comp=__comp(), insult=__insult(), # capitalized Nc=__cap(__nc()), Anc=__cap(__anc()), Ncs=__cap(__ncs()), Slur=__cap(__slur()), Slurs=__cap(__aslur()), Aslur=__cap(__slurs()), Cuss=__cap(__cuss()), Flirt=__cap(__flirt()), Tod=__cap(__tod()), Tof=__cap(__tof()), Toe=__cap(__toe()), Gcomp=__cap(__gcomp()), Wcomp=__cap(__wcomp()), Icomp=__cap(__icomp()), Comp=__cap(__comp()), Insult=__cap(__insult()), )
def get_map_state(self): self._recall_memories( 0,0,ROOMW,ROOMH) self._draw_what_player_sees(rog.pc(), rog.getms(rog.pc(),'sight')) return self.con_map_state
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)
def creepout(ent): # creep out world = rog.world() if world.has_component(ent, cmp.GetsCreepedOut): rog.set_status(ent, cmp.StatusCreepedOut, target=rog.pc())
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)
def __tof(): pcgender = rog.get_gender(rog.pc()) return random.choice(messages.TERM_OF_FRIENDSHIP[pcgender])
def charm(ent, amt): rog.set_status(ent, cmp.StatusCharmed, q=amt, target=rog.pc())
def __flirt(): pcgender = rog.get_gender(rog.pc()) return random.choice(messages.TERM_OF_FLIRTATION[pcgender])