ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/schmorp-neko.ext
Revision: 1.34
Committed: Fri Dec 15 19:11:47 2006 UTC (17 years, 5 months ago) by root
Branch: MAIN
CVS Tags: HEAD
Changes since 1.33: +0 -0 lines
State: FILE REMOVED
Log Message:
move .ext to server

File Contents

# User Rev Content
1 root 1.1 #! perl
2    
3 root 1.2 # archetype nekosan
4 root 1.1
5     sub teleport {
6     my ($pl, $map, $x, $y) = @_;
7    
8 root 1.10 my $portal = cf::object::new "exit";
9 root 1.1
10 root 1.29 $portal->slaying ($map);
11     $portal->stats->hp ($x);
12     $portal->stats->sp ($y);
13 root 1.1
14     $portal->apply ($pl);
15    
16 root 1.33 $portal->destroy;
17 root 1.1 }
18    
19 root 1.12 sub find_target_player {
20     my ($obj) = @_;
21    
22 root 1.14 my ($time, $pl) = (time + 120, undef);
23 root 1.12
24     for (map $_->ob, cf::player::list) {
25     next unless $obj->on_same_map_as ($_);
26    
27     my $ptime = List::Util::max $_->{neko_next_pester}, $_->{neko_next_cast};
28    
29 root 1.13 ($time, $pl) = ($ptime, $_)
30 root 1.12 if $time > $ptime;
31     }
32    
33     $pl
34     }
35    
36 root 1.24 sub on_monster_move {
37 root 1.22 my ($self, $enemy) = @_;
38 root 1.1
39 root 1.22 if (my $pl = find_target_player $self) {
40     my ($d, undef, undef, $dir, undef) = $self->rangevector ($pl);
41 root 1.9
42 root 1.10 if ($d < 1.5) {
43     if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) {
44     # she likes us!
45 root 1.12 if ($pl->{neko_next_pester} < time) {
46     $pl->{neko_next_pester} = time + 120 + rand 300;
47 root 1.10 $pl->message ("Purr. (Purr)");
48     }
49    
50 root 1.12 if ($pl->{neko_next_cast} < time) {
51     $pl->{neko_next_cast} = time + 40 + rand 60;
52    
53     # so heal her
54     my $spell = cf::object::new "spell_heal";
55 root 1.10
56 root 1.29 $spell->stats->sp (0); # makes casting work
57     $spell->stats->grace (0); # on unholy/nomagic ground
58 root 1.10
59 root 1.29 $spell->stats->hp (0);
60     $spell->stats->dam (($pl->stats->maxhp - $pl->stats->hp) * 0.5); # normal hp heal
61     $spell->stats->food (50); # fill food
62 root 1.28 $spell->last_sp (100); # fill sp
63     $spell->last_grace (100); # fill gr
64     $spell->attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE);
65 root 1.12
66     $pl->message ("(Neko-san makes strange noises)");
67 root 1.22 $pl->cast_spell ($self, $dir, $spell);
68 root 1.12
69 root 1.33 $spell->destroy;
70 root 1.10 }
71    
72     } else {
73     # check for fish in his inv and steal it
74 root 1.30 if (my $fish = (grep $_->arch->name eq "fishfood", $pl->inv)[0]) {
75 root 1.10 # add force
76     my $gave_fish = cf::object::new "force";
77 root 1.28 $gave_fish->slaying ("schmorp-neko-gave-fish");
78     $gave_fish->speed (0);
79 root 1.10 $gave_fish->insert_ob_in_ob ($pl);
80    
81     # remove fish
82 root 1.33 $fish->destroy;
83 root 1.10
84     # be nice
85     $pl->message ("Meoww! (Thank you)");
86    
87     } else {
88     # pester user
89 root 1.12 if ($pl->{neko_next_pester} < time) {
90     $pl->{neko_next_pester} = time + 60 + rand 300;
91 root 1.10 $pl->message ("Meow. (Please bring me fish)");
92     }
93     }
94     }
95    
96     # circular movement
97     $dir = $dir % 8 + 1 unless $d > 1.5;
98     }
99 root 1.9
100 root 1.22 $self->move ($dir);
101 root 1.1 }
102    
103 root 1.22 cf::override;
104 root 1.1 }
105    
106     sub on_attack {
107 root 1.23 my ($self, $hitter) = @_;
108 root 1.1
109 root 1.25 if ($hitter->type == cf::PLAYER) {
110     if ($hitter->{neko_last_attack} < time - 300) {
111     $hitter->{neko_attack} = 0;
112     }
113    
114     $hitter->{neko_last_attack} = time;
115     $hitter->{neko_attack}++
116     or ext::schmorp_irc::do_notice "Neko-san was attacked by ". $hitter->name . "!\n";
117    
118     $hitter->message ("Meoow! (Please do not hurt me)")
119     if !($hitter->{neko_attack} & 15);
120    
121     if ($hitter->{neko_attack} > 512) {
122     $hitter->{neko_attack} -= 128;
123     $hitter->message ("Neko-san is suddenly gone!");
124     teleport $hitter, "/scorn/misc/scorn_illusions", 15, 7;
125     $hitter->message ("You hear strange noises all around you...");
126     $hitter->message ("You feel dumb.");
127     }
128     } else {
129 root 1.32 # $hitter->stats->hp (-1);
130     # $hitter->kill_object;
131 root 1.4 }
132    
133 root 1.22 cf::override;
134 root 1.1 }
135    
136 root 1.26 sub on_say {
137     my ($self, $pl, $msg) = @_;
138 root 1.1
139 root 1.26 ext::schmorp_irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $pl->ob->name, $msg);
140 root 1.1 }
141    
142 root 1.22 cf::register_attachment "Nekosan", package => __PACKAGE__;
143