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

Comparing cf.schmorp.de/maps/perl/schmorp-neko.ext (file contents):
Revision 1.10 by root, Fri Feb 17 19:36:36 2006 UTC vs.
Revision 1.21 by root, Fri Aug 25 15:24:54 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines