ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/schmorp-neko.ext
(Generate patch)

Comparing deliantra/maps/perl/schmorp-neko.ext (file contents):
Revision 1.9 by root, Fri Feb 17 15:21:21 2006 UTC vs.
Revision 1.31 by root, Wed Sep 13 00:29:46 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines