ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/magic_mapping.ext
Revision: 1.5
Committed: Wed May 4 19:04:44 2011 UTC (13 years ago) by root
Branch: MAIN
CVS Tags: rel-3_1, HEAD
Changes since 1.4: +1 -1 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 $pl = $caster->contr
13 or return;
14
15 my ($map, $x, $y) = ($who->map, $who->x, $who->y);
16
17 # dirty check, should maybe allow tiled outdoor maps?
18 $map->path =~ m%/world/world_%
19 or return;
20
21 my $bird = cf::object::new "magic_mapper";
22 my $dist = 0;
23 $caster->speed_left (-1); $pl->fire_on (0); $pl->run_on (0);
24
25 my $duration = $caster->casting_level ($spell) * 150 / 100;
26
27 $pl->ns->async (sub {
28 while (++$dist < $duration && $bird->valid) {
29 my $phi = 2 * $dist ** .5;
30 my $dx = (sin $phi) * $phi * 2;
31 my $dy = (cos $phi) * $phi * 2;
32
33 $bird->insert_ob_in_map_at ($map, $caster, cf::INS_ON_TOP, $x + $dx, $y + $dy)
34 or last;
35
36 $pl->set_viewpoint ($bird);
37 $caster->speed_left (-1);
38 $cf::WAIT_FOR_TICK->wait;
39 }
40
41 $pl->set_viewpoint (undef);
42 $caster->speed_left (0);
43 $bird->destroy;
44 });
45
46 cf::override 1;
47 },
48 );
49