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.12 by root, Fri Feb 17 21:10:18 2006 UTC vs.
Revision 1.17 by root, Mon Apr 10 08:34:07 2006 UTC

19} 19}
20 20
21sub find_target_player { 21sub find_target_player {
22 my ($obj) = @_; 22 my ($obj) = @_;
23 23
24 my ($time, $pl) = (time + 30, undef); 24 my ($time, $pl) = (time + 120, undef);
25 25
26 for (map $_->ob, cf::player::list) { 26 for (map $_->ob, cf::player::list) {
27 next unless $obj->on_same_map_as ($_); 27 next unless $obj->on_same_map_as ($_);
28 28
29 my $ptime = List::Util::max $_->{neko_next_pester}, $_->{neko_next_cast}; 29 my $ptime = List::Util::max $_->{neko_next_pester}, $_->{neko_next_cast};
30 30
31 ($time, $pl) = ($ptime, $_); 31 ($time, $pl) = ($ptime, $_)
32 if $time > $ptime; 32 if $time > $ptime;
33 } 33 }
34 34
35 $pl 35 $pl
36} 36}
37 37
38sub on_move { 38sub on_move {
39 my ($data) = @_; 39 my ($event, $who) = @_;
40 40
41 if (my $pl = find_target_player $data->{who}) { 41 if (my $pl = find_target_player $who) {
42 my ($d, undef, undef, $dir, undef) = $data->{who}->rangevector ($pl); 42 my ($d, undef, undef, $dir, undef) = $who->rangevector ($pl);
43 43
44 if ($d < 1.5) { 44 if ($d < 1.5) {
45 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) {
46 # she likes us! 46 # she likes us!
47 if ($pl->{neko_next_pester} < time) { 47 if ($pl->{neko_next_pester} < time) {
53 $pl->{neko_next_cast} = time + 40 + rand 60; 53 $pl->{neko_next_cast} = time + 40 + rand 60;
54 54
55 # so heal her 55 # so heal her
56 my $spell = cf::object::new "spell_heal"; 56 my $spell = cf::object::new "spell_heal";
57 57
58 $spell->set_sp (0); # makes casting work 58 $spell->set_sp (0); # makes casting work
59 $spell->set_gp (0); # on unholy/nomagic ground 59 $spell->set_gp (0); # on unholy/nomagic ground
60 60
61 $spell->set_hp (0); 61 $spell->set_hp (0);
62 $spell->set_dam ($pl->maxhp - $pl->hp); # normal hp heal 62 $spell->set_dam (($pl->maxhp - $pl->hp) * 0.5); # normal hp heal
63 $spell->set_food (999); # fill food 63 $spell->set_food (50); # fill food
64 $spell->set_last_sp (9999); # fill sp 64 $spell->set_last_sp (100); # fill sp
65 $spell->set_last_grace (9999); # fill gr 65 $spell->set_last_grace (100); # fill gr
66 $spell->set_attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE); 66 $spell->set_attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE);
67 67
68 $pl->message ("(Neko-san makes strange noises)"); 68 $pl->message ("(Neko-san makes strange noises)");
69 $pl->cast_spell ($data->{who}, $dir, $spell); 69 $pl->cast_spell ($who, $dir, $spell);
70 70
71 $spell->free; 71 $spell->free;
72 } 72 }
73 73
74 } else { 74 } else {
98 98
99 # circular movement 99 # circular movement
100 $dir = $dir % 8 + 1 unless $d > 1.5; 100 $dir = $dir % 8 + 1 unless $d > 1.5;
101 } 101 }
102 102
103 $data->{who}->move ($dir); 103 $who->move ($dir);
104 } 104 }
105 105
106 1 106 1
107} 107}
108 108
109sub on_attack { 109sub on_attack {
110 my ($data) = @_; 110 my ($event, $ob, $who) = @_;
111 111
112 $data->{activator}{neko_attack}++ 112 if ($who->{neko_last_attack} < time - 300) {
113 or cf::LOG cf::llevDebug, sprintf "QBERT Neko-san was attacked by %s!\n", $data->{activator}->name; 113 $who->{neko_attack} = 0;
114 }
114 115
115 $data->{activator}->message ("Meoow! (Please do not hurt me)") 116 $who->{neko_last_attack} = time;
116 if !($data->{activator}{neko_attack} & 15); 117 $who->{neko_attack}++
118 or cf::LOG cf::llevDebug, sprintf "QBERT Neko-san was attacked by %s!\n", $who->name;
117 119
120 $who->message ("Meoow! (Please do not hurt me)")
121 if !($who->{neko_attack} & 15);
122
118 if ($data->{activator}{neko_attack} > 512) { 123 if ($who->{neko_attack} > 512) {
119 $data->{activator}{neko_attack} -= 128; 124 $who->{neko_attack} -= 128;
120 $data->{activator}->message ("Neko-san is suddenly gone!"); 125 $who->message ("Neko-san is suddenly gone!");
121 teleport $data->{activator}, "/scorn/misc/scorn_illusions", 15, 7; 126 teleport $who, "/scorn/misc/scorn_illusions", 15, 7;
122 $data->{activator}->message ("You hear strange noises all around you..."); 127 $who->message ("You hear strange noises all around you...");
123 $data->{activator}->message ("You feel dumb."); 128 $who->message ("You feel dumb.");
124 } 129 }
125 130
126 1 131 1
127} 132}
128 133
129sub on_say { 134sub on_say {
130 my ($data) = @_; 135 my ($event, $ob, $who, $msg) = @_;
131 136
132 cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $data->{activator}->name, $data->{message}; 137 cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $who->name, $msg;
133
134 0
135} 138}
136 139

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines