Exemple #1
0
def _dosimeter(tt):
    #use function two options: 1) toggles on/off. 2) displays a reading only when you use it.
    rog.make(tt, WATERKILLS)
    rog.make(tt, CANUSE)
    rog.makeEquip(tt, EQ_MAINHAND)
    tt.statMods = {
        "range": 3,
        "atk": 2,
        "dmg": 1,
    }

    def funcPlayer(self, obj):
        xx = obj.x
        yy = obj.y
        reading = rog.radsat(xx, yy)
        rog.msg("The geiger counter reads '{} RADS'".format(reading))
        #could do, instead:
        # use turns it on, activates an observer.
        # updates when rad damage received by player. Adds rad value to dosimeter
        # when you use again, you can either read it or turn it off.
        rog.drain(obj, 'nrg', NRG_USE)

    def funcMonster(self, obj):
        rog.drain(obj, 'nrg', NRG_USE)
        rog.event_sight(obj.x, obj.y, "{t}{n} looks at a geiger counter.")

    def funcDeath(self):
        rog.explosion(self.name, self.x, self.y, 1)

    tt.useFunctionPlayer = funcPlayer
    tt.useFunctionMonster = funcMonster
    tt.deathFunction = funcDeath
def create_weapon(name, x, y):
    weap = thing.Thing()
    weap.name = name
    weap.x = x
    weap.y = y

    data = WEAPONS[name]
    weap.name = name
    weap.type = data[0]
    weap.mask = weap.type
    weap.value = data[1]  # $$$
    weap.stats.mass = data[2]  # kg
    weap.stats.hpmax = data[3]  # durability
    weap.stats.hp = data[3]  # durability
    weap.material = data[4]
    weap.statMods = {}  # stat modifiers for equipping
    if data[5][0]: weap.statMods.update({'range': data[5][0]})
    if data[5][1]: weap.statMods.update({'atk': data[5][1]})
    if data[5][2]: weap.statMods.update({'dmg': data[5][2]})
    if data[5][3]: weap.statMods.update({'dfn': data[5][3]})
    if data[5][4]: weap.statMods.update({'arm': data[5][4]})
    if data[5][5]: weap.statMods.update({'asp': data[5][5]})
    if data[5][6]: weap.statMods.update({'msp': data[5][6]})
    if data[5][7]: weap.statMods.update({'element': data[5][7]})
    weap.ammoType = data[6]
    #for mod in data[7]:
    #    weap.mods.append(mod)

    weap.color = COL['white']
    weap.equipType = EQ_MAINHAND
    rog.make(weap, CANEQUIP)

    return weap
Exemple #3
0
def create_stuff(ID, x, y):
    name,typ,mat,val,fgcol,hp,kg,solid,push,script = STUFF[ID]
    world = rog.world()
    if fgcol == "random":
        fgcol = random.choice(list(COL.keys()))
##    tt = thing.Thing(x,y, _type=typ,name=name,color=COL[fgcol])
##    tt.mass = kg
##    tt.material=mat
##    if lo: _hp(tt, lo)
##    tt.isSolid = solid
##    if push: rog.make(tt, CANPUSH)
##    #_applyResistancesFromMaterial(tt, mat)
##    return tt
    ent = world.create_entity(
        cmp.Name(name),
        cmp.Position(x,y),
        cmp.Draw(typ, fgcol=fgcol),
        cmp.Form(mass=kg, mat=mat, val=val),
        cmp.BasicStats(hp=hp,mp=hp),
        )
    if solid:
        rog.make(ent, ISSOLID)
    if push:
        rog.add_component(ent, cmp.Pushable())
    script(ent)
    return ent
Exemple #4
0
def _towel(tt):
    rog.make(tt, CANWET)
    rog.make(tt, CANUSE)
    rog.makeEquip(tt, EQ_BODY)
    tt.statMods={"rescold":20,}
    tt.useFunctionPlayer = action.towel_pc
    tt.useFunctionMonster = action.towel
Exemple #5
0
def _extinguisher(tt):
    rog.make(tt, CANUSE)
    ##    tt.useFunctionPlayer = action.extinguisher_pc
    ##    tt.useFunctionMonster = action.extinguisher
    rog.makeEquip(tt, EQ_MAINHAND)
    tt.statMods = {
        "dmg": 5,
        "asp": -33,
    }
Exemple #6
0
def create(x, y, ID):
    name, typ, mat, fgcol, lo, kg, solid, push, script = STUFF[ID]
    tt = thing.Thing(x, y, _type=typ, name=name, color=COL[fgcol])
    tt.mass = kg
    tt.material = mat
    if lo: hp(tt, lo)
    tt.isSolid = solid
    if push: rog.make(tt, CANPUSH)
    #_applyResistancesFromMaterial(tt, mat)
    return tt
 def add(self, obj, status, dur=-1):
     if dur == 0: return False
     if dur == -1:   #default duration
         dur = self._get_default_duration(status)
     curDur = self.statuses[status].get(obj, 0)
     if curDur:
         if dur <= curDur:   #don't override effect with a lesser duration
             return False    # but you CAN override with a greater duration
         self.remove(obj, status) #remove current status before overriding
     
     #apply the status effect
     self.statuses[status].update( {obj : dur} )
     rog.make(obj, status)   #add flag
     self._apply_statMods(obj, status) # apply attribute modifiers
     self._apply_auxEffects(obj, status) # auxiliary status effects
     self._apply_message(obj, status) #send a message
     return True
Exemple #8
0
def _still(tt):
    rog.make(tt, HOLDSFLUID)
    rog.make(tt, INTERACT)
Exemple #9
0
def _safe(tt):
    rog.init_inventory(tt, 200)
    rog.make(tt, CANOPEN)
    rog.make(tt, INTERACT)  #interact to lock or unlock
    def process(self):

        # TODO: interface heat exchange btn entities equipping or
        #  holding items in inventory
        #  I think we need a component for Equipped or InContainer to handle this.
        '''
            interface with environment
                (e.g. in cases of heat exchange with the air)
            and take effects from internal state
        '''
        # special meter components
        for ent, compo in self.world.get_component(cmp.GetsAngry):
            if compo.anger > 0:
                compo.anger -= 1
        #

        # ambient temperature
        for ent, (meters,
                  pos) in self.world.get_components(cmp.Meters, cmp.Position):
            pass
##            ambient_temp = Fires.tempat(pos.x, pos.y)

# TODO: FIX THIS!!!!!!!
#print(thing.name," is exchanging heat with the environment...") #TESTING
# cool down temperature meter if not currently burning
##            if (abs(meters.temp - ambient_temp) >= 1):
##                # TODO: take insulation into account for deltatemp
##                #   as well as the actual difference in temperature
##            # TODO: also take into account the material of the entity (metal is faster to gain/lose heat)
##                deltatemp = rog.sign(ambient_temp - meters.temp)
##                meters.temp = meters.temp + deltatemp
##                ambientdelta = _getambd(deltatemp, rog.getms(ent,"mass"))
##                Fires.add_heat(pos.x, pos.y, ambientdelta)
####                print("adding heat {} to pos {} {} (mass {}) (heat={})".format(ambientdelta, pos.x, pos.y, rog.getms(ent,"mass"), Fires.tempat(pos.x,pos.y)))
##                if (not rog.get_status(ent, cmp.StatusFire) and
##                    meters.temp >= FIRE_THRESHOLD):
##                    rog.set_status(ent, cmp.StatusFire)
##                elif (not rog.get_status(ent, cmp.StatusFrozen) and
##                    meters.temp <= FREEZE_THRESHOLD):
##                    rog.set_status(ent, cmp.StatusFrozen)
#

        for ent, compo in self.world.get_component(cmp.Meters):
            if (compo.expo > 0):
                rog.make(ent, DIRTY_STATS)
                compo.expo = max(0, compo.expo - CHEM_METERLOSS)
        for ent, compo in self.world.get_component(cmp.GetsSick):
            if (compo.sick > 0):
                rog.make(ent, DIRTY_STATS)
                compo.sick = max(0, compo.sick - BIO_METERLOSS)
        for ent, compo in self.world.get_component(cmp.FeelsPain):
            if (compo.pain > 0):
                rog.make(ent, DIRTY_STATS)
                compo.pain = max(0, compo.pain - PAIN_METERLOSS)
        for ent, compo in self.world.get_component(cmp.FeelsFear):
            if (compo.fear > 0):
                rog.make(ent, DIRTY_STATS)
                compo.fear = max(0, compo.fear - FEAR_METERLOSS)
        for ent, compo in self.world.get_component(cmp.Bleeds):
            if (compo.bleed > 0):
                rog.make(ent, DIRTY_STATS)
                compo.bleed = max(0, compo.bleed - BLEED_METERLOSS)
Exemple #11
0
def _torch(tt):
    rog.make(tt, CANEQUIP)
    tt.equipType=EQ_OFFHAND
Exemple #12
0
def _food_poison(tt):
    _edible(tt, RATIONFOOD, TASTE_SWEET)  #deceptively sweet
    rog.make(tt, SICK)  #makes you sick when you eat it
Exemple #13
0
def _edible(tt, nutrition, taste):
    rog.make(tt, EDIBLE)
    rog.taste = taste
    tt.nutrition = nutrition
Exemple #14
0
def _cloak(tt):
    rog.make(tt, CANEQUIP)
Exemple #15
0
def _oily(actor, n):
    if n>=10:
        rog.make(actor, OILY)
Exemple #16
0
def _bloody(actor, n):
    if n>=10:
        rog.make(actor, BLOODY)
Exemple #17
0
def _wood(tt):
    rog.make(tt, CANWET)
Exemple #18
0
def _clayPot(tt):
    rog.make(tt, HOLDSFLUID)
    tt.capacity = 20
Exemple #19
0
def _gunpowder(tt):
    rog.make(tt, WATERKILLS)
Exemple #20
0
def create_weapon(name, x,y):
    world = rog.world()
    ent = world.create_entity()
    
    data = WEAPONS[name]
    _type       = get_weapon_type(data)
    value       = get_weapon_value(data)
    mass        = get_weapon_mass(data)
    hpmax       = get_weapon_hpmax(data)
    capacity    = get_weapon_capacity(data)
    reloadTime  = get_weapon_rt(data)
    jamChance   = get_weapon_jam(data)
    material    = get_weapon_mat(data)
    rng         = get_weapon_range(data)
    atk         = get_weapon_atk(data)
    dmg         = get_weapon_dmg(data)
    _pow        = get_weapon_pow(data)
    dfn         = get_weapon_dfn(data)
    arm         = get_weapon_arm(data)
    asp         = get_weapon_asp(data)
    msp         = get_weapon_msp(data)
    elem        = get_weapon_elem(data)
    ammo        = get_weapon_ammo(data)
    flags       = get_weapon_flags(data)
    script      = get_weapon_script(data)
    physDmg = dmg if elem == ELEM_PHYS else 0
    
    color = COL['accent']
    bgcol = COL['deep']
    
    world.add_component(ent, cmp.Name(name))
    world.add_component(ent, cmp.Position(x, y))
    world.add_component(ent, cmp.Draw( char=_type, color=color, bgcol=bgcol ))
    world.add_component(ent, cmp.Form( mass=mass, material=material, value=value ))
    world.add_component(ent, cmp.BasicStats(
        hp=hpmax,mp=hpmax,
        #resfire=resfire,resbio=resbio,reselec=reselec,resphys=resphys
        ))

    ammoDict={}
    mainhandDict={}
    elementalDict={}
    if ammoType: ammoDict.update({'ammoType':ammoType})
    if capacity: ammoDict.update({'capacity':capacity})
    if reloadTime: ammoDict.update({'reloadTime':reloadTime})
    if jamChance: ammoDict.update({'jamChance':jamChance})
    if rng: mainhandDict.update({'rng':rng})
    if atk: mainhandDict.update({'atk':atk})
    if dmg: mainhandDict.update({'dmg':dmg})
    if _pow: mainhandDict.update({'pow':_pow})
    if dfn: mainhandDict.update({'dfn':dfn})
    if arm: mainhandDict.update({'arm':arm})
    if asp: mainhandDict.update({'asp':asp})
    if msp: mainhandDict.update({'msp':msp})
    if elem: elementalDict.update({'element':elem})

    modDict={}
    if not ammoDict == {}: modDict.update({cmp.Ammo : ammoDict})
    if not mainhandDict == {}: modDict.update({cmp.CombatStats : mainhandDict})
    world.add_component(ent, cmp.CanEquipInMainhand(modDict))
    if not elementalDict == {}: world.add_component(ent, cmp.ElementalDamage(elementalDict))
    
    for flag in flags:
        rog.make(ent, flag)

    if script: script(weap)
    return weap
Exemple #21
0
def create_monster(typ, x, y, col, mutate=3):

    # get generic monster attributes #

    monData = bestiary[typ]

    name = monData[0]
    monst = thing.create_creature(name, typ, x, y, col)
    monst.job = name
    i = 1
    j = 0
    monst.stats.hpmax = monData[i][j]
    j += 1
    monst.stats.mpmax = monData[i][j]
    j += 1
    monst.stats.atk = monData[i][j]
    j += 1
    monst.stats.dmg = monData[i][j]
    j += 1
    monst.stats.dfn = monData[i][j]
    j += 1
    monst.stats.arm = monData[i][j]
    j += 1
    monst.stats.spd = monData[i][j]
    j += 1
    monst.stats.msp = monData[i][j]
    j += 1
    monst.stats.asp = monData[i][j]
    j += 1
    monst.stats.resfire = monData[i][j]
    j += 1
    monst.stats.resbio = monData[i][j]
    j += 1
    monst.stats.sight = monData[i][j]
    j += 1
    monst.stats.hearing = monData[i][j]
    j += 1
    monst.stats.carry = monData[i][j]
    j += 1
    monst.mass = monData[i][j]
    j += 1
    monst.purse = monData[i][j]
    j += 1
    i += 1
    for flag in monData[i]:
        rog.make(monst, flag)  #flags
    #i+=1
    #for item in monData[i]:     rog.give(monst,item) #items

    # possibly randomly alter some attributes #
    times = 0
    maxgainz = mutate
    chance = 2
    while (dice.roll(10) <= chance and times < maxgainz):
        times += 1
        r = dice.roll(6)
        if r == 1: rog.gain(monst, 'atk')
        elif r == 2: rog.gain(monst, 'dmg')
        elif r == 3: rog.gain(monst, 'arm')
        elif r == 4: rog.gain(monst, 'dfn')
        elif r == 5: rog.gain(monst, 'hpmax')
    times = 0
    maxdrains = mutate
    chance = 2
    while (dice.roll(10) <= chance and times < maxdrains):
        times += 1
        r = dice.roll(6)
        if r == 1: rog.drain(monst, 'atk')
        elif r == 2: rog.drain(monst, 'dmg')
        elif r == 3: rog.drain(monst, 'arm')
        elif r == 4: rog.drain(monst, 'dfn')
        elif r == 5: rog.drain(monst, 'hpmax')

    #

    #

    # ai
    #TEMPORARY
    monst.ai = ai.stateless

    return monst