ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/server/ext/magic_mapping.ext
Revision: 1.1
Committed: Wed Nov 4 17:24:00 2009 UTC (16 years, 11 months ago) by root
Branch: MAIN
Log Message:
interim checkin, new spell

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     $caster->speed_left (-1000);
22    
23     $pl->ns->async (sub {
24     while (++$dist < 100) {
25     my $phi = 2 * $dist ** .5;
26     my $dx = (sin $phi) * $phi * 2;
27     my $dy = (cos $phi) * $phi * 2;
28    
29     warn "a\n";#d#
30     warn $bird->insert_ob_in_map_at ($map, $caster, cf::INS_ON_TOP, $x + $dx, $y + $dy);
31     warn "b\n";#d#
32     last unless $bird->valid;
33     warn "c\n";#d#
34    
35     $pl->set_viewpoint ($bird);
36     $caster->speed_left (-1000);
37     cf::wait_for_tick;
38     }
39    
40     $pl->set_viewpoint (undef);
41     $caster->speed_left (0);
42     $bird->destroy;
43     });
44    
45     cf::override 1;
46     },
47     );
48