ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/magic_mapping.ext
Revision: 1.2
Committed: Wed Nov 4 18:17:57 2009 UTC (14 years, 6 months ago) by root
Branch: MAIN
CVS Tags: rel-2_90
Changes since 1.1: +7 -8 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.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) = ($caster->map, $caster->x, $caster->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 root 1.2 $caster->speed_left (-1); $pl->fire_on (0); $pl->run_on (0);
22    
23     my $duration = $who->casting_level ($spell) * 150 / 100;
24 root 1.1
25     $pl->ns->async (sub {
26 root 1.2 while (++$dist < $duration && $bird->valid) {
27 root 1.1 my $phi = 2 * $dist ** .5;
28     my $dx = (sin $phi) * $phi * 2;
29     my $dy = (cos $phi) * $phi * 2;
30    
31 root 1.2 $bird->insert_ob_in_map_at ($map, $caster, cf::INS_ON_TOP, $x + $dx, $y + $dy)
32     or last;
33 root 1.1
34     $pl->set_viewpoint ($bird);
35 root 1.2 $caster->speed_left (-1);
36 root 1.1 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