def move(self, dx, dy): if map.is_wall(self.x+dx, self.y+dy) or map.is_blocked(self.x+dx, self.y+dy): return False else: self.x += dx self.y += dy return True
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 dist = self.length + wearer.power / 3 x = wearer.x# + d[0] y = wearer.y# + d[1] while dist: dist -= 1 x += d[0] y += d[1] a = map.get_actor_alive(x, y) if (a and a is not wearer) or map.is_blocked(x, y): dist = 0 if map.is_wall(x, y): x -= d[0] y -= d[1] p = ent.Projectile(x, y, self.damage, wearer) game.actors.append(p) return True