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
def use(self, wearer, target): if not wearer.ai: return False d = wearer.ai.choose_direction() if d is None: return False dx = wearer.x + d[0] dy = wearer.y + d[1] if map.is_wall(dx, dy): if map.is_diggable(dx, dy): map.set_wall(dx, dy, False, False) game.log('with great effort,', wearer.name, 'dig into the solid rock') wearer.action_points -= game.NORMAL_SPEED*10 else: game.log('this rock is too hard for', wearer.name, 'to dig..') else: game.log(wearer.name, "can't dig here") return True