示例#1
0
def cough(ent):
    world = rog.world()
    pos = world.component_for_entity(ent, cmp.Position)
    entn = world.component_for_entity(ent, cmp.Name)
    wait(ent)
    rog.event_sound(pos.x,pos.y, SND_COUGH)
    rog.event_sight(pos.x,pos.y, "{t}{n} hacks up a lung.".format(
        t=entn.title,n=entn.name))
示例#2
0
def fight(attkr,dfndr,adv=0):
##    TODO: when you attack, look at your weapon entity to get:
        #-material of weapon
        #-element of weapon
        #-flags of weapon
    world = rog.world()
    cstats = world.component_for_entity(attkr, cmp.CombatStats)
    dpos = world.component_for_entity(dfndr, cmp.Position)
    element = ELEM_PHYS #****TEMPORARY!!!! has_component...
    nrg_cost = round( NRG_ATTACK*AVG_SPD/max(1, cstats.asp) )
    cstats.ap -= nrg_cost

    die=COMBATROLL
    acc=cstats.atk
    dv=cstats.dfn
    hit = False
    rol = dice.roll(die + acc + adv - dv) - dice.roll(die)
    if (rol >= 0): # HIT!!!
        hit = True
        
        #type of damage dealt depends on the element attacker is using
        if element == ELEM_PHYS:
            #high attack values can pierce armor
##            if rol > ATK_BONUS_DMG_CUTOFF:
##                pierce = int( (rol - ATK_BONUS_DMG_CUTOFF)/2 )
##            else:
##                pierce = 0
            armor = dfndr.stats.get('arm') #max(0, dfndr.stats.get('arm') - pierce)
            dmg = max(0, attkr.stats.get('dmg') - armor)
            rog.hurt(dfndr, dmg)
        elif element == ELEM_FIRE:
            rog.burn(dfndr, dmg)
        elif element == ELEM_BIO:
            rog.disease(dfndr, dmg)
        elif element == ELEM_ELEC:
            rog.electrify(dfndr, dmg)
        elif element == ELEM_CHEM:
            rog.exposure(dfndr, dmg)
        elif element == ELEM_RADS:
            rog.irradiate(dfndr, dmg)
        
        killed = rog.on(dfndr,DEAD) #...did we kill it?
    #
    
    message = True
    a=attkr.name; n=dfndr.name; t1=attkr.title; t2=dfndr.title; x='.';
    
    # make a message describing the fight
    if message:
        if hit==False: v="misses"
        elif dmg==0: v="cannot penetrate"; x="'s armor!"
        elif killed: v="defeats"
        else: v="hits"
        rog.event_sight(
            dfndr.x,dfndr.y,
            "{t1}{a} {v} {t2}{n}{x}".format(a=a,v=v,n=n,t1=t1,t2=t2,x=x)
        )
        rog.event_sound(dpos.x,dpos.y, SND_FIGHT)
示例#3
0
def fight(attkr,dfndr,adv=0):
    nrg_cost = round( NRG_ATTACK*AVG_SPD/max(1, attkr.stats.get('asp')) )
    attkr.stats.nrg -= nrg_cost

    die=COMBATROLL
    acc=attkr.stats.get('atk')
    dv=dfndr.stats.get('dfn')
    hit = False
    rol = dice.roll(die + acc + adv - dv) - dice.roll(die)
    if (rol >= 0): # HIT!!!
        hit = True
        
        #type of damage dealt depends on the element attacker is using
        if attkr.stats.element == ELEM_PHYS:
            #high attack values can pierce armor
##            if rol > ATK_BONUS_DMG_CUTOFF:
##                pierce = int( (rol - ATK_BONUS_DMG_CUTOFF)/2 )
##            else:
##                pierce = 0
            armor = dfndr.stats.get('arm') #max(0, dfndr.stats.get('arm') - pierce)
            dmg = max(0, attkr.stats.get('dmg') - armor)
            rog.hurt(dfndr, dmg)
        elif attkr.stats.element == ELEM_FIRE:
            rog.burn(dfndr, dmg)
        elif attkr.stats.element == ELEM_BIO:
            rog.disease(dfndr, dmg)
        elif attkr.stats.element == ELEM_ELEC:
            rog.electrify(dfndr, dmg)
        elif attkr.stats.element == ELEM_CHEM:
            rog.exposure(dfndr, dmg)
        elif attkr.stats.element == ELEM_RADS:
            rog.irradiate(dfndr, dmg)
        
        killed = rog.on(dfndr,DEAD) #...did we kill it?
    #
    
    message = True
    a=attkr.name; n=dfndr.name; t1=attkr.title; t2=dfndr.title; x='.';
    
    # make a message describing the fight
    if message:
        if hit==False: v="misses"
        elif dmg==0: v="cannot penetrate"; x="'s armor!"
        elif killed: v="defeats"
        else: v="hits"
        rog.event_sight(
            dfndr.x,dfndr.y,
            "{t1}{a} {v} {t2}{n}{x}".format(a=a,v=v,n=n,t1=t1,t2=t2,x=x)
        )
        rog.event_sound(dfndr.x,dfndr.y, SND_FIGHT)
示例#4
0
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)
示例#5
0
    def process(self):
        super(FiresProcessor, self).run()

        self.removeList = []
        self.soundsList = {}
        for fx, fy in self.fires:
            #print("running fire manager for fire at {},{}".format(x,y))
            _fluids = rog.fluidsat(fx, fy)
            _things = rog.thingsat(fx, fy)
            _exit = False

            #tiles that put out fires or feed fires
            '''
            wet floor flag


            '''

            #fluids that put out fires or feed fires
            '''for flud in _fluids:
                if flud.extinguish:
                    self.remove(fx,fy)
                    _exit=True
                    continue
                if flud.flammable:
                    self.fire_spread(fx,fy)
                    continue
                    '''

            if _exit: continue

            #check for no fuel condition
            if not _things:
                #print("no things to burn. Removing fire at {},{}".format(x,y))
                self.removeList.append((
                    fx,
                    fy,
                ))
                continue

            #BURN THINGS ALIVE (or dead)
            food = 0  #counter for amount of fuel gained by the fire
            for ent in _things:  #things that might fuel the fire (or put it out)
                textSee = ""
                rog.burn(ent, FIRE_BURN)
                if rog.on(ent, FIRE):
                    food += self._gobble(ent)

            _FOOD_THRESHOLD = 5
            '''if food < _FOOD_THRESHOLD:
                if dice.roll(food) == 1:
                    print("not enough food. Removing fire at {},{}".format(fx,fy))
                    self.removeList.append((fx,fy,))
            else:'''
            if food >= _FOOD_THRESHOLD:
                iterations = 1 + int((food - _FOOD_THRESHOLD) / 3)
                self._spread(fx, fy, iterations)
            elif food == 0:
                self.removeList.append((
                    fx,
                    fy,
                ))
                continue

        #end for (fires)

        #add new fires
        self._fuseGrids()

        #remove fires
        for xx, yy in self.removeList:
            #print("fire at {},{} is to be removed...".format(xx,yy))
            self.remove(xx, yy)
            '''doNotDie=False
            #don't let the fire die if something in this tile is still burning.
            for tt in _things:
                if rog.on(tt, FIRE):
                    doNotDie=True
            if doNotDie == False:'''

        #sounds
        for k, v in self.soundsList.items():
            xx, yy = k
            snd = v
            rog.event_sound(xx, yy, snd)
示例#6
0
def quaff(obj, drink):
    rog.drain(pc, 'nrg', NRG_QUAFF) 
    drink.quaff(obj)
    rog.event_sight(obj.x,obj.y, "{t}{n} quaffs a {p}.".format(
        t=obj.title,n=obj.name,p=drink))
    rog.event_sound(obj.x,obj.y, SND_QUAFF)
示例#7
0
def cough(obj):
    wait(obj)
    rog.event_sound(obj.x,obj.y, SND_COUGH)
    rog.event_sight(obj.x,obj.y, "{t}{n} hacks up a lung.".format(
        t=obj.title,n=obj.name))