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.11 by root, Fri Feb 17 19:39:11 2006 UTC vs.
Revision 1.18 by elmex, Wed Aug 2 16:59:48 2006 UTC

16 $portal->apply ($pl); 16 $portal->apply ($pl);
17 17
18 $portal->free; 18 $portal->free;
19} 19}
20 20
21sub find_target_player {
22 my ($obj) = @_;
23
24 my ($time, $pl) = (time + 120, undef);
25
26 for (map $_->ob, cf::player::list) {
27 next unless $obj->on_same_map_as ($_);
28
29 my $ptime = List::Util::max $_->{neko_next_pester}, $_->{neko_next_cast};
30
31 ($time, $pl) = ($ptime, $_)
32 if $time > $ptime;
33 }
34
35 $pl
36}
37
21sub on_move { 38sub on_move {
22 my ($data) = @_; 39 my ($event, $who) = @_;
23 40
24 if (my $pl = $data->{who}->nearest_player) { 41 if (my $pl = find_target_player $who) {
25 my ($d, undef, undef, $dir, undef) = $data->{who}->rangevector ($pl); 42 my ($d, undef, undef, $dir, undef) = $who->rangevector ($pl);
26 43
27 if ($d < 1.5) { 44 if ($d < 1.5) {
28 if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) { 45 if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) {
29 # she likes us! 46 # she likes us!
30 if ($pl->{neko_fish} < time) { 47 if ($pl->{neko_next_pester} < time) {
31 $pl->{neko_fish} = time + 120 + rand 300; 48 $pl->{neko_next_pester} = time + 120 + rand 300;
32 $pl->message ("Purr. (Purr)"); 49 $pl->message ("Purr. (Purr)");
33 } 50 }
34 51
35 # so heal her 52 if ($pl->{neko_next_cast} < time) {
36 my $spell = cf::object::new "spell_heal"; 53 $pl->{neko_next_cast} = time + 40 + rand 60;
37 54
38 $spell->set_hp (0); 55 # so heal her
39 $spell->set_dam (0); # normal hp heal (none to avoid message) 56 my $spell = cf::object::new "spell_heal";
40 $spell->set_food (999); # fill food
41 $spell->set_last_sp (9999); # fill sp
42 $spell->set_last_grace (9999); # fill gr
43 $spell->set_attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE);
44 57
45 if ($data->{who}->cast_spell ($data->{who}, $dir, $spell)) { 58 $spell->set_sp (0); # makes casting work
59 $spell->set_gp (0); # on unholy/nomagic ground
60
61 $spell->set_hp (0);
62 $spell->set_dam (($pl->maxhp - $pl->hp) * 0.5); # normal hp heal
63 $spell->set_food (50); # fill food
64 $spell->set_last_sp (100); # fill sp
65 $spell->set_last_grace (100); # fill gr
66 $spell->set_attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE);
67
46 $pl->message ("... (Neko-san makes strange noises)"); 68 $pl->message ("(Neko-san makes strange noises)");
69 $pl->cast_spell ($who, $dir, $spell);
70
71 $spell->free;
47 } 72 }
48
49 $spell->free;
50 73
51 } else { 74 } else {
52 # check for fish in his inv and steal it 75 # check for fish in his inv and steal it
53 if (my $fish = (grep $_->archetype->name eq "fishfood", $pl->inv)[0]) { 76 if (my $fish = (grep $_->archetype->name eq "fishfood", $pl->inv)[0]) {
54 # add force 77 # add force
64 # be nice 87 # be nice
65 $pl->message ("Meoww! (Thank you)"); 88 $pl->message ("Meoww! (Thank you)");
66 89
67 } else { 90 } else {
68 # pester user 91 # pester user
69 if ($pl->{neko_fish} < time) { 92 if ($pl->{neko_next_pester} < time) {
70 $pl->{neko_fish} = time + 60 + rand 300; 93 $pl->{neko_next_pester} = time + 60 + rand 300;
71 $pl->message ("Meow. (Please bring me fish)"); 94 $pl->message ("Meow. (Please bring me fish)");
72 } 95 }
73 } 96 }
74 } 97 }
75 98
76 # circular movement 99 # circular movement
77 $dir = $dir % 8 + 1 unless $d > 1.5; 100 $dir = $dir % 8 + 1 unless $d > 1.5;
78 } 101 }
79 102
80 $data->{who}->move ($dir); 103 $who->move ($dir);
81 } 104 }
82 105
83 1 106 1
84} 107}
85 108
86sub on_attack { 109sub on_attack {
87 my ($data) = @_; 110 my ($event, $ob, $who) = @_;
88 111
89 $data->{activator}{neko_attack}++ 112 if ($who->{neko_last_attack} < time - 300) {
90 or cf::LOG cf::llevDebug, sprintf "QBERT Neko-san was attacked by %s!\n", $data->{activator}->name; 113 $who->{neko_attack} = 0;
114 }
91 115
92 $data->{activator}->message ("Meoow! (Please do not hurt me)") 116 $who->{neko_last_attack} = time;
93 if !($data->{activator}{neko_attack} & 15); 117 $who->{neko_attack}++
118 or do {
119 cf::LOG cf::llevDebug, my $n = sprintf "QBERT Neko-san was attacked by %s!\n", $who->name;
120 cf::ext::schmorp_irc::do_notice ($n);
121 };
94 122
123 $who->message ("Meoow! (Please do not hurt me)")
124 if !($who->{neko_attack} & 15);
125
95 if ($data->{activator}{neko_attack} > 512) { 126 if ($who->{neko_attack} > 512) {
96 $data->{activator}{neko_attack} -= 128; 127 $who->{neko_attack} -= 128;
97 $data->{activator}->message ("Neko-san is suddenly gone!"); 128 $who->message ("Neko-san is suddenly gone!");
98 teleport $data->{activator}, "/scorn/misc/scorn_illusions", 15, 7; 129 teleport $who, "/scorn/misc/scorn_illusions", 15, 7;
99 $data->{activator}->message ("You hear strange noises all around you..."); 130 $who->message ("You hear strange noises all around you...");
100 $data->{activator}->message ("You feel dumb."); 131 $who->message ("You feel dumb.");
101 } 132 }
102 133
103 1 134 1
104} 135}
105 136
106sub on_say { 137sub on_say {
107 my ($data) = @_; 138 my ($event, $ob, $who, $msg) = @_;
108 139
109 cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $data->{activator}->name, $data->{message}; 140 cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $who->name, $msg;
110 141 cf::ext::schmorp_irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $who->name, $msg);
111 0
112} 142}
113 143

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines