ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/magic_mapping.ext
Revision: 1.3
Committed: Mon Nov 9 00:14:48 2009 UTC (14 years, 6 months ago) by root
Branch: MAIN
CVS Tags: rel-3_0, rel-2_92, rel-2_93
Changes since 1.2: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #! perl
2
3 # this module implements the part of the magic mapping spell that works on the world map
4 # only.
5
6 cf::object->attach (
7 type => cf::SPELL,
8 subtype => cf::SP_MAGIC_MAPPING,
9 on_cast_spell => sub {
10 my ($spell, $who, $caster, $dir, $arg) = @_;
11
12 my ($map, $x, $y) = ($who->map, $who->x, $who->y);
13
14 # dirty check, should maybe allow tiled outdoor maps?
15 $map->path =~ m%/world/world_%
16 or return;
17
18 my $bird = cf::object::new "magic_mapper";
19 my $pl = $caster->contr;
20 my $dist = 0;
21 $caster->speed_left (-1); $pl->fire_on (0); $pl->run_on (0);
22
23 my $duration = $caster->casting_level ($spell) * 150 / 100;
24
25 $pl->ns->async (sub {
26 while (++$dist < $duration && $bird->valid) {
27 my $phi = 2 * $dist ** .5;
28 my $dx = (sin $phi) * $phi * 2;
29 my $dy = (cos $phi) * $phi * 2;
30
31 $bird->insert_ob_in_map_at ($map, $caster, cf::INS_ON_TOP, $x + $dx, $y + $dy)
32 or last;
33
34 $pl->set_viewpoint ($bird);
35 $caster->speed_left (-1);
36 cf::wait_for_tick;
37 }
38
39 $pl->set_viewpoint (undef);
40 $caster->speed_left (0);
41 $bird->destroy;
42 });
43
44 cf::override 1;
45 },
46 );
47