예제 #1
0
def irritate(obj, dmg):
    res = obj.stats.resbio
    dmg = int(dmg * (1 - (res / 100)) / 10)
    obj.stats.expo += max(0, dmg)
    if obj.stats.expo >= 100:
        obj.stats.expo = 50  #leave some exposure
        rog.set_status(obj, IRRIT)
예제 #2
0
    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()
예제 #3
0
    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()
예제 #4
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())
예제 #5
0
def cough(obj, dmg):
    res = obj.stats.get('resbio')
    dmg = int(dmg * (1 - (res / 100)) / 10)
    obj.stats.expo += max(0, dmg)
    if obj.stats.expo >= 100:
        obj.stats.expo = 0  #reset exposure meter
        rog.set_status(obj, COUGH)
예제 #6
0
def vomit(obj, dmg):
    res = obj.stats.resbio
    dmg = int(dmg * (1 - (res / 100)) / 10)
    obj.stats.expo += max(0, dmg)
    if obj.stats.expo >= 100:
        obj.stats.expo = 0  #reset exposure meter
        rog.set_status(obj, VOMIT)
예제 #7
0
def intoxicate(obj, dmg):
    res = obj.stats.resbio
    #increase sickness meter
    dmg = int(dmg * (1 - (res / 100)))
    obj.stats.sick += max(0, dmg)
    if obj.stats.sick >= 100:
        obj.stats.sick = 100  #cap out sickness meter
        rog.set_status(obj, DRUNK)
예제 #8
0
def disease(obj, dmg):
    res = obj.stats.get('resbio')
    #increase sickness meter
    dmg = int(dmg * (1 - (res / 100)))
    obj.stats.sick += max(0, dmg)
    if obj.stats.sick >= 100:
        obj.stats.sick = 100  #cap out sickness meter
        rog.set_status(obj, SICK)
예제 #9
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)
예제 #10
0
    def process(self):
        for ent, (body, meters) in world.get_components(cmp.Body, cmp.Meters):

            # get body temperature information based on body plan
            bodytemp, plus, minus = BODY_TEMP.get[body.plan]
            bloodpc, bloodratio = BODY_BLOOD.get[body.plan]

            # too thirsty? (too little hydration?/too dehydrated?)
            if body.hydration <= body.hydrationMax * 0.9:  # hyper-critical
                entities.dehydrate(ent)
            # too hungry? (too little calories?)
            if body.satiation <= 0:  # hyper-critical
                entities.starve(ent)
            # too hot?
            if meters.temp > bodytemp + plus:  # hyper-critical
                rog.set_status(ent, cmp.StatusHyperthermia())
            # too cold?
            if meters.temp < bodytemp + minus:  # hyper-critical
                rog.set_status(ent, cmp.StatusHypothermia())
            # too little blood?
            if body.blood <= body.bloodMax * bloodratio:  # hyper-critical
                rog.set_status(ent, cmp.StatusExsanguination())
            elif body.blood <= body.bloodMax * (  # critical
                    bloodratio + (1 - bloodratio) * 0.5):
                rog.set_status(ent, cmp.StatusHazy())
예제 #11
0
def burn(obj, dmg, maxTemp):
    #get obj resistance
    res = obj.stats.resfire
    if rog.on(obj, WET):
        rog.clear_status(obj, WET)  #wet things get dried
        #steam=stuff.create("steam", obj.x, obj.y)
    #increase temperature
    dmg = int(dmg * (1 - (res / 100)))
    obj.stats.temp += max(0, dmg)
    obj.stats.temp = min(maxTemp, obj.stats.temp)
    #set burning status
    if (not rog.on(obj, FIRE)
            and obj.stats.temp >= FIRE_TEMP):  #should depend on material?
        rog.set_status(obj, FIRE)
예제 #12
0
    def process(self):
        world = self.world
        for ent, (body, meters) in world.get_components(cmp.Body, cmp.Meters):

            # maintain heat equilibrium
            meters = self.world.component_for_entity(ent, cmp.Meters)
            if meters.temp > BODY_TEMP + 1:
                rog.set_status(ent, cmp.StatusSweat())
            elif meters.temp < BODY_TEMP - 1:
                rog.set_status(ent, cmp.StatusShiver())

            # TODO: Hot and Chilly/Cold statuses

            # digestion: get calories (satiation) from food consumed

            # TODO: when you eat, get StatusDigest status

        for ent, (body,
                  status) in world.get_components(cmp.Body, cmp.StatusDigest):

            # satiation ++, caloriesAvailableInFood --
            metabolic_rate = stats.mass / MULT_MASS
            caloric_value = min(metabolic_rate, status.quantity)
            status.quantity -= caloric_value
            body.satiation += caloric_value
            # excess Calories -> fat
            if body.satiation > body.satiationMax:
                rog.set_status(ent, cmp.StatusFull())
                # 9 Calories per gram of fat (1/9 == 0.1111...)
                ##                df = body.satiationMax - body.satiation
                caltofat = 1000  #df / MULT_MASS *0.11111111
                body.bodyfat += caltofat * 0.5
                body.satiation -= caltofat
                # end class
                ''' only commented out code below '''
예제 #13
0
def creepout(ent): # creep out
    world = rog.world()
    if world.has_component(ent, cmp.GetsCreepedOut):
        rog.set_status(ent, cmp.StatusCreepedOut, target=rog.pc())
예제 #14
0
def _wet(actor, n):
    if n>=10:
        rog.set_status(actor, WET)
예제 #15
0
def sprint(ent):
    entn = rog.world().component_for_entity(ent, cmp.Name)
    #if sprint cooldown elapsed
    rog.set_status(ent, SPRINT)
    rog.msg("{n} begins sprinting.".format(n=entn.name))
예제 #16
0
def charm(ent, amt):
    rog.set_status(ent, cmp.StatusCharmed, q=amt, target=rog.pc())
예제 #17
0
def _random_chemical_effect(obj):
    roll = dice.roll(6)
    if roll == 1:
        power = CHEM_BLIND_POWER
        if power >= res:
            duration = dice.roll(CHEM_BLIND_TIME)
            rog.set_status(obj, BLIND, duration)
    elif roll == 2:
        power = CHEM_PARAL_POWER
        if power >= res:
            duration = dice.roll(CHEM_PARAL_TIME)
            rog.set_status(obj, PARAL, duration)
    elif roll == 3:
        power = CHEM_COUGH_POWER
        if power >= res:
            duration = dice.roll(CHEM_COUGH_TIME)
            rog.set_status(obj, COUGH, duration)
    elif roll == 4:
        power = CHEM_VOMIT_POWER
        if power >= res:
            duration = dice.roll(CHEM_VOMIT_TIME)
            rog.set_status(obj, VOMIT, duration)
    elif roll == 5:
        power = CHEM_CONFU_POWER
        if power >= res:
            duration = dice.roll(CHEM_CONFU_TIME)
            rog.set_status(obj, CONFU, duration)
    elif roll == 6:
        power = CHEM_IRRIT_POWER
        if power >= res:
            duration = dice.roll(CHEM_IRRIT_TIME)
            rog.set_status(obj, IRRIT, duration)
예제 #18
0
def commands(pc, pcAct):
    world = rog.world()

    directional_command = 'move'
    
    for act,arg in pcAct:

##        print(act)
##        print(arg)
        
        rog.update_base()
        
        #----------------#
        # convert action #
        #----------------#
        
        if act =='context-dir':
            act=directional_command
##        if act =='context':
##            pass
        # moving using the menu move keys
        if (act =='menu-nav' and rog.game_state()=="normal"):
            act=directional_command
        
        
        #----------------#
        # perform action #
        #----------------#
#-----------MOUSE ACTION----------------------------#
        
        if act == 'lclick':
            mousex,mousey,z=arg
            if rog.wallat(mousex,mousey):
                return
            pos = world.component_for_entity(pc, cmp.Position)
            print("Left click unimplemented")
##            rog.path_compute(pc.path, pos.x,pos.y, rog.mapx(mousex), rog.mapy(mousey))
            #rog.occupation_set(pc,'path')

        if act == 'rclick':
            pass
        
#------------OTHER ACTION--------------------------#
        
        if act == 'help':
            rog.help()

        # "move-prompt" : True
        # prompt for a direction
        #   and then perform the move action in that direction
        if act == 'move-prompt':
            pass

        # "attack-prompt" : True
        # prompt for a direction
        #   and then perform the attack action in that direction
        if act == 'attack-prompt':
            pass
        
        # "move" : (x_change, y_change, z_change,)
        if act == 'move':
            _Update()
            dx,dy,dz=arg
            pos = world.component_for_entity(pc, cmp.Position)
            actor = world.component_for_entity(pc, cmp.Actor)
            xto=pos.x + dx
            yto=pos.y + dy

            # wait
            if (xto==pos.x and yto==pos.y):
                actor.ap = 0
                return

            # out of bounds
            if ( not rog.is_in_grid_x(xto) or not rog.is_in_grid_y(yto) ):
                return

            # warning for slow move speed
            if rog.allow_warning_msp():
                msp=rog.getms(pc, 'msp')
                if msp <= 10:
                    inp=rog.prompt(
                        0,0,rog.window_w(), 6, mode='wait',
                        q='''Warning: your movement speed is critically slow
(MSP: {}). Are you sure you want to move? y/n'''.format(msp)
                        )
                    if inp!='y':
                        return
                    else:
                        rog.expire_warning_msp() #TODO: when is best time to reset this warning?
            # end if
            
            # choose context-sensitive action #
            
            # fight if there is a monster present
            mon = rog.monat(xto,yto)
            if mon: # and mon != pc):
                action.fight(pc,mon)
            # or move
            elif not rog.solidat(xto,yto):
                # space is free, so we can move
                if action.move(pc, dx,dy):
                    rog.view_center_player()
            else:
                rog.alert("That space is occupied.")
        # end conditional
        
        # "attack" : (x, y, z,)
        if act == 'attack':
            _Update()
            xto,yto,zto=arg
            pos = world.component_for_entity(pc, cmp.Position)
            actor = world.component_for_entity(pc, cmp.Actor)

            # out of bounds
            if ( not rog.is_in_grid_x(xto) or not rog.is_in_grid_y(yto) ):
                return
            
            # fight if there is a monster present
            mon = rog.monat(xto,yto)
            # ... but don't attack yourself!
            if mon == pc:
                rog.alert("You can't fight yourself!")
                return
            
            if mon:
                action.fight(pc,mon)
            else:
                ent = rog.thingat(xto,yto)
                if ent:
                    action.fight(pc,ent)
                else:
                    rog.msg("You strike out at thin air, losing your balance.")
                    actor.ap = 0
                    rog.set_status(
                        pc, cmp.StatusOffBalance,
                        t=2, q=-MISS_BAL_PENALTY
                        )
        # end conditional

        # chat with closest speaking entity;
        #   if multiple good options, prompt for which one.
        if act == "chat-context":
            action.chat_context(pc)
            _Update()
            return
        if act == "change-pos": # change body position
            action.change_bodypos_pc(pc)
            _Update()
            return
        if act == "change-msp": # change speed of movement (walking, running, jogging, etc.)
            action.change_speed_pc(pc)
            _Update()
            return
        if act == "msp-up": # change from walk to powerwalk, to trot, jog, etc.
            action.speed_up_pc(pc)
            _Update()
            return
        if act == "msp-down": # change from sprint to run, to jog, to trot, etc.
            action.slow_down_pc(pc)
            _Update()
            return
        if act == "target-prompt": #target entity + fire / throw / attack
            action.target_pc_generic(pc)
            _Update()
            return
        if act == "get-prompt":
            action.pickup_pc(pc)
            _Update()
            return
        if act == "openclose-prompt": #open or close
            action.open_pc(pc)
            _Update()
            return
        if act == "open-prompt": #open or close
            action.open_pc(pc)
            _Update()
            return
        if act == "close-prompt": #open or close
            action.open_pc(pc)
            _Update()
            return
        if act == "jog": #begin jogging
            action.jog_pc(pc)
            _Update()
            return
        if act == "run": #begin running
            action.run_pc(pc)
            _Update()
            return
        if act == "sprint": #begin sprinting
            action.sprint_pc(pc)
            _Update()
            return

        #unused actions
        '''if act == "bomb":
            action.bomb_pc(pc)
            return'''
        
        #
        #
        # special actions #
        #
        
        if act == 'find player': #useful to immediately show where the player is
            pos = world.component_for_entity(pc, cmp.Position)
            rog.view_center_player()
            rog.update_game()
            rog.update_final()
            rog.game_update() #call all the updates
            rog.alert('press any key to continue...')
            rog.Input(rog.getx(pos.x), rog.gety(pos.y), mode='wait')
            rog.update_base()
            rog.alert('')
            return
        if act == "look":
            pos = world.component_for_entity(pc, cmp.Position)
            rog.routine_look(pos.x,pos.y)
            return
        if act == "move view":
            rog.routine_move_view()
            return
        if act == "fixed view":
            rog.fixedViewMode_toggle()
            return  
        if act == 'select':
            # TESTING
            print(rog.Input(0,0,20))
            return
        if act == 'exit':
            return
예제 #19
0
def sprint(obj):
    #if sprint cooldown elapsed
    rog.set_status(obj, SPRINT)
    rog.msg("{n} begins sprinting.".format(n=obj.name))