def use(self, wearer, target): d = game.player.ai.choose_direction() if d is None: return False target_x = wearer.x + (d[0] * self.throw) target_y = wearer.y + (d[1] * self.throw) 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 not map.is_wall(x, y) and 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)) game.actors.append(s) map.fov_recompute(game.player.x, game.player.y) game.log(wearer.name,"threw the", self.owner.name) game.log("a really dense gas expands quickly! vision is difficult") if wearer and wearer.container: wearer.container.inventory.remove(self.owner) 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