예제 #1
0
파일: core.py 프로젝트: jcandres/deth
 def drop(self, wearer):
     if not wearer.container:
         return False
     if self.owner.equipment and self.owner.equipment.is_equipped:
         game.log(wearer.name, "can't drop something equipped!")
         game.log_turn()
         return False
     game.log(wearer.name, 'dropped a', self.owner.name)
     wearer.container.inventory.remove(self.owner)
     game.actors.append(self.owner)
     self.owner.x = wearer.x
     self.owner.y = wearer.y
     return True
예제 #2
0
파일: item.py 프로젝트: jcandres/deth
 def use(self, wearer, target):
     d = game.player.ai.choose_direction()
     if d is None:
         return False
     
     dist = self.length + wearer.power / 3
     tx =  wearer.x# + d[0]
     ty =  wearer.y# + d[1]
     while dist:
         dist -= 1
         tx += d[0]
         ty += d[1]
         a = map.get_actor_alive(tx, ty)
         if (a and a is not wearer) or map.is_blocked(tx, ty):
             dist = 0
     target_x = tx#wearer.x + (d[0] * self.throw)
     target_y = ty#wearer.y + (d[1] * self.throw)
     
     game.log(wearer.name,"threw the", self.owner.name+'!')
     game.log_turn()
     game.log('BOOOM!!')
     game.log_turn()
     did_hole = False
     for x in range(target_x-self.radius+1, target_x+self.radius):
         for y in range(target_y-self.radius+1, target_y+self.radius):
             if map.is_diggable(x, y):
                 map.set_wall(x, y, False, False)
                 did_hole = True
             if not map.is_wall(x, y):
                 if map.get_distance_coord(target_x, target_y, x, y) < self.radius:
                     s = ent.Smoke(x, y, tcod.random_get_int(0, 0, game.NORMAL_SPEED*5),
                                   was_visible=not map.is_wall(x,y))
                     game.actors.append(s)
                     s = ent.Projectile(x, y, self.damage, wearer, name='explosion', self_remove=True)
                     game.actors.append(s)
                     
     if did_hole:
         game.log("the", self.owner.name, 'made a huge hole in the walls!')
     map.fov_recompute(game.player.x, game.player.y)
     if wearer and wearer.container:
         wearer.container.inventory.remove(self.owner)
         pass
     return True
예제 #3
0
파일: ai.py 프로젝트: jcandres/deth
 def handle_action_key(self, key):
     #debug
     '''
     if key == ord(">"):
         game.game_state = enum.GameS.STAIRS_DOWN
         game.log("you descend into the darkness..")
     if key == ord("<"):
         game.game_state = enum.GameS.STAIRS_UP
         game.log("you climb up the stairs..")
     '''#stairs
     if key == ord(">"):
         if self.owner.x == game.stairs_down.x and self.owner.y == game.stairs_down.y:
             game.game_state = enum.GameS.STAIRS_DOWN
             game.log("you descend into the darkness..")
         else:
             game.log("you can't go down here")
             game.log_turn()
     if key == ord("<"):
         if self.owner.x == game.stairs_up.x and self.owner.y == game.stairs_up.y:
             game.game_state = enum.GameS.STAIRS_UP
             game.log("you climb up..")
         else:
             game.log("you can't go up here")
             game.log_turn()
     #repeat
     if key == ord("x") and self.last_command:
         found = False
         for item in self.owner.container.inventory:
             if item == self.last_command:
                 found = True
         if found:
             self.last_command.pickable.use(self.owner, self.owner)
             game.game_state = enum.GameS.NEW_TURN
         else:
             self.last_command = None
             game.log("you don't have that object anymore..")
             game.log_turn()
     #inventory
     if key == ord("i"):
         gui.draw_inventory(0, self.owner.container.inventory, 'inventory')
         item = self.choose_from_inventory(self.owner.container.inventory)
         if item is not None:
             if item.pickable.use(self.owner, self.owner):
                 game.game_state = enum.GameS.NEW_TURN
                 self.last_command = item
             else:
                 game.log("that's a silly thing to use")
                 game.log_turn()
     #drop items
     if key == ord("d"):
         gui.draw_inventory(0, self.owner.container.inventory, 'drop an object')
         item = self.choose_from_inventory(self.owner.container.inventory)
         if item is not None:
             if item.pickable.drop(self.owner):
                 game.game_state = enum.GameS.NEW_TURN
     #equip / dequip stuff
     if key == ord("e"):
         gui.draw_equipment(0, self.owner.container.inventory, 'equipment')
         item = self.choose_from_inventory(self.owner.container.inventory)
         if item is not None and item.equipment:
             item.equipment.toggle_equip(self.owner)
             #game.log('ai player - equip', item.name)
             game.game_state = enum.GameS.NEW_TURN
     #grab
     elif key == ord("g"):
         self.owner.send_front()
         e = map.get_actor_pickable(self.owner.x, self.owner.y)
         if e and e.pickable:
             if e.pickable.pick(self.owner):
                 game.log('you pick a', e.name)
                 game.game_state = enum.GameS.NEW_TURN #
             else:
                 game.log("you can't carry more")
                 game.log_turn()
     #look
     elif key == ord(";"):
         self.owner.send_front() #will be checked the last 
         e = map.get_actor(self.owner.x, self.owner.y)
         if e and e is not self.owner:
             game.log('you see a', e.name, 'here')
         else:
             game.log("there's nothing of interest here")
         game.game_state = enum.GameS.NEW_TURN #
         self.owner.action_points -= 100