#! perl # this module implements the part of the magic mapping spell that works on the world map # only. cf::object->attach ( type => cf::SPELL, subtype => cf::SP_MAGIC_MAPPING, on_cast_spell => sub { my ($spell, $who, $caster, $dir, $arg) = @_; my $pl = $caster->contr or return; my ($map, $x, $y) = ($who->map, $who->x, $who->y); # dirty check, should maybe allow tiled outdoor maps? $map->path =~ m%/world/world_% or return; my $bird = cf::object::new "magic_mapper"; my $dist = 0; $caster->speed_left (-1); $pl->fire_on (0); $pl->run_on (0); my $duration = $caster->casting_level ($spell) * 150 / 100; $pl->ns->async (sub { while (++$dist < $duration && $bird->valid) { my $phi = 2 * $dist ** .5; my $dx = (sin $phi) * $phi * 2; my $dy = (cos $phi) * $phi * 2; $bird->insert_ob_in_map_at ($map, $caster, cf::INS_ON_TOP, $x + $dx, $y + $dy) or last; $pl->set_viewpoint ($bird); $caster->speed_left (-1); $cf::WAIT_FOR_TICK->wait; } $pl->set_viewpoint (undef); $caster->speed_left (0); $bird->destroy; }); cf::override 1; }, );