… | |
… | |
5 | use Data::Dumper; |
5 | use Data::Dumper; |
6 | |
6 | |
7 | sub teleport { |
7 | sub teleport { |
8 | my ($pl, $map, $x, $y) = @_; |
8 | my ($pl, $map, $x, $y) = @_; |
9 | |
9 | |
10 | my $portal = cf::object::new ("exit"); |
10 | my $portal = cf::object::new "exit"; |
11 | |
11 | |
12 | $portal->set_slaying ($map); |
12 | $portal->set_slaying ($map); |
13 | $portal->set_hp ($x); |
13 | $portal->set_hp ($x); |
14 | $portal->set_sp ($y); |
14 | $portal->set_sp ($y); |
15 | |
15 | |
… | |
… | |
20 | |
20 | |
21 | sub on_move { |
21 | sub on_move { |
22 | my ($data) = @_; |
22 | my ($data) = @_; |
23 | |
23 | |
24 | if (my $pl = $data->{who}->nearest_player) { |
24 | if (my $pl = $data->{who}->nearest_player) { |
25 | if ($pl->level >= 10) { |
|
|
26 | my (undef, undef, undef, $dir, undef) = $data->{who}->direction ($pl); |
25 | my ($d, undef, undef, $dir, undef) = $data->{who}->rangevector ($pl); |
27 | $data->{who}->move ($data->{who}, $dir); |
26 | |
|
|
27 | if ($d < 1.5) { |
|
|
28 | if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) { |
|
|
29 | # she likes us! |
|
|
30 | if ($pl->{neko_fish} < time) { |
|
|
31 | $pl->{neko_fish} = time + 120 + rand 300; |
|
|
32 | $pl->message ("Purr. (Purr)"); |
|
|
33 | } |
|
|
34 | |
|
|
35 | # so heal her |
|
|
36 | my $spell = cf::object::new "spell_heal"; |
|
|
37 | |
|
|
38 | $spell->set_hp (0); |
|
|
39 | $spell->set_dam (0); # normal hp heal (none to aovid message) |
|
|
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 | |
|
|
45 | if ($data->{who}->cast_spell ($data->{who}, $dir, $spell)) { |
|
|
46 | $pl->message ("... (Neko-san makes strange noises)"); |
|
|
47 | } |
|
|
48 | |
|
|
49 | $spell->free; |
|
|
50 | |
|
|
51 | } else { |
|
|
52 | # check for fish in his inv and steal it |
|
|
53 | if (my $fish = (grep $_->archetype->name eq "fishfood", $pl->inv)[0]) { |
|
|
54 | # add force |
|
|
55 | my $gave_fish = cf::object::new "force"; |
|
|
56 | $gave_fish->set_slaying ("schmorp-neko-gave-fish"); |
|
|
57 | $gave_fish->set_speed (0); |
|
|
58 | $gave_fish->insert_ob_in_ob ($pl); |
|
|
59 | |
|
|
60 | # remove fish |
|
|
61 | $fish->remove; |
|
|
62 | $fish->free; |
|
|
63 | |
|
|
64 | # be nice |
|
|
65 | $pl->message ("Meoww! (Thank you)"); |
|
|
66 | |
|
|
67 | } else { |
|
|
68 | # pester user |
|
|
69 | if ($pl->{neko_fish} < time) { |
|
|
70 | $pl->{neko_fish} = time + 60 + rand 300; |
|
|
71 | $pl->message ("Meow. (Please bring me fish)"); |
|
|
72 | } |
|
|
73 | } |
|
|
74 | } |
|
|
75 | |
|
|
76 | # circular movement |
|
|
77 | $dir = $dir % 8 + 1 unless $d > 1.5; |
28 | } |
78 | } |
|
|
79 | |
|
|
80 | $data->{who}->move ($dir); |
29 | } |
81 | } |
30 | |
82 | |
31 | 1 |
83 | 1 |
32 | } |
84 | } |
33 | |
85 | |
34 | sub on_attack { |
86 | sub on_attack { |
35 | my ($data) = @_; |
87 | my ($data) = @_; |
36 | |
88 | |
|
|
89 | $data->{activator}{neko_attack}++ |
37 | cf::LOG cf::llevDebug, sprintf "QBERT Neko-san was attacked by %s!", $data->{activator}->name; |
90 | or cf::LOG cf::llevDebug, sprintf "QBERT Neko-san was attacked by %s!\n", $data->{activator}->name; |
38 | |
91 | |
39 | $data->{activator}->message ("Neko-san is suddenly gone!"); |
92 | $data->{activator}->message ("Meoow! (Please do not hurt me)") |
40 | teleport $data->{activator}, "/scorn/misc/scorn_illusions", 15, 7; |
93 | if !($data->{activator}{neko_attack} & 15); |
41 | $data->{activator}->message ("You hear strange noises all around you..."); |
|
|
42 | $data->{activator}->message ("You feel dumb."); |
|
|
43 | |
94 | |
|
|
95 | if ($data->{activator}{neko_attack} > 512) { |
|
|
96 | $data->{activator}{neko_attack} -= 128; |
|
|
97 | $data->{activator}->message ("Neko-san is suddenly gone!"); |
|
|
98 | teleport $data->{activator}, "/scorn/misc/scorn_illusions", 15, 7; |
|
|
99 | $data->{activator}->message ("You hear strange noises all around you..."); |
|
|
100 | $data->{activator}->message ("You feel dumb."); |
44 | 0 |
101 | } |
|
|
102 | |
|
|
103 | 1 |
45 | } |
104 | } |
46 | |
105 | |
47 | sub on_say { |
106 | sub on_say { |
48 | my ($data) = @_; |
107 | my ($data) = @_; |
49 | |
108 | |
50 | cf::LOG cf::llevDebug, "QBERT [Neko-fon] $data->{message}"; |
109 | cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $data->{activator}->name, $data->{message}; |
51 | |
110 | |
52 | 0 |
111 | 0 |
53 | } |
112 | } |
54 | |
113 | |