… | |
… | |
16 | $portal->apply ($pl); |
16 | $portal->apply ($pl); |
17 | |
17 | |
18 | $portal->free; |
18 | $portal->free; |
19 | } |
19 | } |
20 | |
20 | |
|
|
21 | sub find_target_player { |
|
|
22 | my ($obj) = @_; |
|
|
23 | |
|
|
24 | my ($time, $pl) = (time + 30, 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 | |
21 | sub on_move { |
38 | sub on_move { |
22 | my ($data) = @_; |
39 | my ($data) = @_; |
23 | |
40 | |
24 | if (my $pl = $data->{who}->nearest_player) { |
41 | if (my $pl = find_target_player $data->{who}) { |
25 | my ($d, undef, undef, $dir, undef) = $data->{who}->rangevector ($pl); |
42 | my ($d, undef, undef, $dir, undef) = $data->{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); # normal hp heal |
|
|
63 | $spell->set_food (999); # fill food |
|
|
64 | $spell->set_last_sp (9999); # fill sp |
|
|
65 | $spell->set_last_grace (9999); # 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 ($data->{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 | |