def process(self): # just query some components that match entities # stamina regen for ent, (stats, creat) in self.world.get_components(cmp.Stats, cmp.Creature): ## print("mp regen ", rog.getms(ent, 'mpregen')) rog.givemp(ent, rog.getms(ent, 'mpregen') // MULT_STATS) rog.givehp(ent, rog.getms(ent, 'hpregen') // MULT_STATS) # pseudo statuses' meters # for ent, compo in self.world.get_component(cmp.SmallTalked): if dice.roll(20) <= 1: self.world.remove_component(ent, cmp.SmallTalked) for ent, compo in self.world.get_component(cmp.Taunted): if dice.roll(20) <= 5: self.world.remove_component(ent, cmp.Taunted) for ent, compo in self.world.get_component(cmp.ComboTauntFlattery): if dice.roll(20) <= 1: self.world.remove_component(ent, cmp.ComboTauntFlattery) for ent, compo in self.world.get_component(cmp.GetsAngry): if dice.roll(20) > 5: continue self.world.component_for_entity(ent, cmp.GetsAngry).anger -= 1 for ent, compo in self.world.get_component(cmp.GetsAnnoyed): if dice.roll(20) > 2: continue self.world.component_for_entity(ent, cmp.GetsAnnoyed).annoyance -= 1 for ent, compo in self.world.get_component(cmp.GetsDiabetes): if dice.roll(20) > 1: continue self.world.component_for_entity(ent, cmp.GetsDiabetes).diabetes -= 1
def init(pc): # register for sense events for the message log rog.add_listener_sights(pc) rog.add_listener_sounds(pc) rog.view_center(pc) rog.givehp(pc) rog.givemp(pc)
def init(pc): # register for sense events for the message log ## rog.add_listener_sights(pc) # TODO: implement this... There is a distinction btn. Events object for regular listening events of sights/sounds, and also two more classes for sights seen and sounds heard by the player. These should probably work differently... ## rog.add_listener_sounds(pc) rog.fov_init(pc) rog.view_center(pc) rog.givehp(pc) rog.givemp(pc)
def create_corpse(obj): corpse = Thing() corpse.name = "corpse of {}".format(obj.name) corpse.type = "%" corpse.mask = corpse.type corpse.x = obj.x corpse.y = obj.y corpse.color = obj.color corpse.material = obj.material corpse.stats.hpmax = int(obj.mass) + 1 corpse.stats.resfire = obj.stats.resfire corpse.stats.resbio = obj.stats.resbio corpse.stats.reselec = obj.stats.reselec corpse.stats.temp = obj.stats.temp #copy status effects? rog.copyflags(corpse, obj, copyStatusFlags=False) rog.givehp(corpse) return corpse
def hp(tt, value): #give a Thing a specified amount of HP and fully heal them tt.stats.hpmax = value rog.givehp(tt)
def main(): #------------------------------------------------# # INIT #------------------------------------------------# # init settings settings = rog.init_settings() rog.init_keyBindings() # init global controllers rog.create_window(settings.window_width, settings.window_height) rog.create_consoles() rog.create_map() rog.create_data() rog.create_view() rog.create_clock() rog.create_log() rog.create_update() rog.create_environment() rog.create_controller() rog.create_savedGame() # init managers rog.create_const_managers() rog.create_perturn_managers() #map generation rog.map_generate(rog.map(), rog.dlvl()) # init player object pc = rog.create_player(15, 15) obs = observer.Observer_playerChange() pc.observer_add(obs) rog.view_center(pc) ##TESTING rog.gain(pc, "hpmax", 100) log = rog.create_stuff(THG.LOG, 18, 18) rog.burn(log, 200) box = rog.create_stuff(THG.BOX, 20, 18) #fluids.smoke(16,16) '''pc.stats.hpmax = 20 pc.stats.mpmax = 20 pc.stats.sight = 20 pc.stats.spd = 100 pc.stats.nvision = False''' #LIGHT pc.light = rog.create_light(pc.x, pc.y, 5, owner=pc) #HEAL rog.givehp(pc) rog.givemp(pc) #EQUIP #print(pc.stats.get('atk')) #item=gear.create_weapon("sword",pc.x,pc.y) #rog.equip(pc, item, EQ_MAINHAND) #print(pc.stats.get('atk')) #rog.deequip(pc,EQ_MAINHAND) #print(pc.stats.get('atk')) #BUFF #rog.effect_add(pc,{'atk':5}) #rog.effect_add(pc,{'dmg':5}) #rog.effect_add(pc,{'arm':0}) #rog.effect_add(pc,{'msp':15}) #rog.effect_add(pc,{'msp':-50})''' ''' z = rog.create_monster('Z',15,16) rog.effect_add(z,{'arm':1}) rog.effect_add(z,{'dfn':4}) rog.effect_add(z,{'atk':3}) rog.effect_add(z,{'dmg':3}) rog.givehp(z)''' z = rog.create_monster('z', 13, 19, COL['ltblue']) a = rog.create_monster('a', 12, 13, COL['scarlet']) o = rog.create_monster('U', 19, 18, COL['red']) a = rog.create_monster('a', 15, 17, COL['scarlet']) W = rog.create_monster('W', 20, 15, COL['purple']) '''import dice for x in range(ROOMW): for y in range(ROOMH): if dice.roll(100) > 98: if not (rog.wallat(x,y) or rog.monat(x,y) ): r=rog.create_monster('r',x,y) r.color=COL['ltgray'] print("num monsters: ", len(rog.list_creatures())) ''' #create a create_thing function for specific items. #make list of items, etc. yyy = Thing() yyy.x = 16 yyy.y = 13 yyy.mask = '4' yyy.name = 'the four of destiny' yyy.color = COL['gold'] rog.register_inanimate(yyy) ## yyy = Thing() yyy.x = 17 yyy.y = 13 yyy.mask = '*' yyy.name = 'blood clot' yyy.color = COL['dkmagenta'] rog.register_inanimate(yyy) ## ''' yyy=Thing() yyy.name="wood" yyy.mask=chr(15) yyy.material=MAT_WOOD yyy.x=20 yyy.y=12 yyy.mass=20 yyy.stats.hp=1250 yyy.color=COL['brown'] rog.register_inanimate(yyy) rog.set_status(yyy, FIRE) yyy=Thing() yyy.name="wood" yyy.mask=chr(15) yyy.material=MAT_WOOD yyy.x=10 yyy.y=19 yyy.mass=12 yyy.stats.hp=400 yyy.color=COL['brown'] rog.register_inanimate(yyy) rog.set_status(yyy, FIRE)''' ''' yyy=rog.create_light(25,25, 15) yyy=rog.create_light(14,11, 7)''' #-----------------------------------------------# # # MAIN GAME LOOP # # #-----------------------------------------------# rog.game_set_state("normal") # initialize fov for creatures with sight for creat in rog.list_creatures(): if creat.stats.sight > 0: rog.fov_compute(creat) while rog.game_is_running(): # manually close game # if libtcod.console_is_window_closed(): rog.end() # defeat conditions # if rog.on(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(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) # # other game states # # elif (gameState == "move view" or gameState == "look" or gameState == "busy" or gameState == "message history"): manager = rog.get_active_manager() manager.run(pcAct) if manager.result: rog.close_active_manager() # elif gameState == "game over": rog.msg("You died...")