| 1 |
root |
1.5 |
#! perl # depends=irc |
| 2 |
root |
1.1 |
|
| 3 |
|
|
# archetype nekosan |
| 4 |
|
|
|
| 5 |
|
|
sub find_target_player { |
| 6 |
|
|
my ($obj) = @_; |
| 7 |
|
|
|
| 8 |
root |
1.9 |
my ($time, $pl) = (AE::now + 120, undef); |
| 9 |
root |
1.1 |
|
| 10 |
|
|
for (map $_->ob, cf::player::list) { |
| 11 |
|
|
next unless $obj->on_same_map_as ($_); |
| 12 |
|
|
|
| 13 |
|
|
my $ptime = List::Util::max $_->{neko_next_pester}, $_->{neko_next_cast}; |
| 14 |
|
|
|
| 15 |
|
|
($time, $pl) = ($ptime, $_) |
| 16 |
|
|
if $time > $ptime; |
| 17 |
|
|
} |
| 18 |
|
|
|
| 19 |
|
|
$pl |
| 20 |
|
|
} |
| 21 |
|
|
|
| 22 |
|
|
sub on_monster_move { |
| 23 |
|
|
my ($self, $enemy) = @_; |
| 24 |
|
|
|
| 25 |
|
|
if (my $pl = find_target_player $self) { |
| 26 |
|
|
my ($d, undef, undef, $dir, undef) = $self->rangevector ($pl); |
| 27 |
|
|
|
| 28 |
|
|
if ($d < 1.5) { |
| 29 |
|
|
if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) { |
| 30 |
|
|
# she likes us! |
| 31 |
root |
1.9 |
if ($pl->{neko_next_pester} < AE::now) { |
| 32 |
|
|
$pl->{neko_next_pester} = AE::now + 120 + cf::rndm 300; |
| 33 |
root |
1.1 |
$pl->message ("Purr. (Purr)"); |
| 34 |
|
|
} |
| 35 |
|
|
|
| 36 |
root |
1.9 |
if ($pl->{neko_next_cast} < AE::now) { |
| 37 |
|
|
$pl->{neko_next_cast} = AE::now + 40 + cf::rndm 60; |
| 38 |
root |
1.1 |
|
| 39 |
|
|
# so heal her |
| 40 |
|
|
my $spell = cf::object::new "spell_heal"; |
| 41 |
|
|
|
| 42 |
|
|
$spell->stats->sp (0); # makes casting work |
| 43 |
|
|
$spell->stats->grace (0); # on unholy/nomagic ground |
| 44 |
|
|
|
| 45 |
|
|
$spell->stats->hp (0); |
| 46 |
|
|
$spell->stats->dam (($pl->stats->maxhp - $pl->stats->hp) * 0.5); # normal hp heal |
| 47 |
|
|
$spell->stats->food (50); # fill food |
| 48 |
|
|
$spell->last_sp (100); # fill sp |
| 49 |
|
|
$spell->last_grace (100); # fill gr |
| 50 |
|
|
$spell->attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE); |
| 51 |
|
|
|
| 52 |
|
|
$pl->message ("(Neko-san makes strange noises)"); |
| 53 |
root |
1.3 |
$pl->cast_heal ($self, $spell, 0); |
| 54 |
root |
1.1 |
|
| 55 |
|
|
$spell->destroy; |
| 56 |
|
|
} |
| 57 |
|
|
|
| 58 |
|
|
} else { |
| 59 |
|
|
# check for fish in his inv and steal it |
| 60 |
root |
1.6 |
if (my $fish = (grep $_->arch->archname eq "fishfood", $pl->inv)[0]) { |
| 61 |
root |
1.1 |
# add force |
| 62 |
|
|
my $gave_fish = cf::object::new "force"; |
| 63 |
|
|
$gave_fish->slaying ("schmorp-neko-gave-fish"); |
| 64 |
|
|
$gave_fish->speed (0); |
| 65 |
root |
1.7 |
$pl->insert ($gave_fish); |
| 66 |
root |
1.1 |
|
| 67 |
|
|
# remove fish |
| 68 |
|
|
$fish->destroy; |
| 69 |
|
|
|
| 70 |
|
|
# be nice |
| 71 |
|
|
$pl->message ("Meoww! (Thank you)"); |
| 72 |
|
|
|
| 73 |
|
|
} else { |
| 74 |
|
|
# pester user |
| 75 |
root |
1.9 |
if ($pl->{neko_next_pester} < AE::now) { |
| 76 |
|
|
$pl->{neko_next_pester} = AE::now + 60 + cf::rndm 300; |
| 77 |
root |
1.1 |
$pl->message ("Meow. (Please bring me fish)"); |
| 78 |
|
|
} |
| 79 |
|
|
} |
| 80 |
|
|
} |
| 81 |
|
|
|
| 82 |
|
|
# circular movement |
| 83 |
|
|
$dir = $dir % 8 + 1 unless $d > 1.5; |
| 84 |
|
|
} |
| 85 |
|
|
|
| 86 |
|
|
$self->move ($dir); |
| 87 |
|
|
} |
| 88 |
|
|
|
| 89 |
|
|
cf::override; |
| 90 |
|
|
} |
| 91 |
|
|
|
| 92 |
|
|
sub on_attack { |
| 93 |
|
|
my ($self, $hitter) = @_; |
| 94 |
|
|
|
| 95 |
|
|
if ($hitter->type == cf::PLAYER) { |
| 96 |
root |
1.9 |
if ($hitter->{neko_last_attack} < AE::now - 300) { |
| 97 |
root |
1.1 |
$hitter->{neko_attack} = 0; |
| 98 |
|
|
} |
| 99 |
|
|
|
| 100 |
root |
1.9 |
$hitter->{neko_last_attack} = AE::now; |
| 101 |
root |
1.1 |
$hitter->{neko_attack}++ |
| 102 |
root |
1.10 |
or ext::irc::do_notice "Neko-san was attacked by " . $hitter->name . "!\n"; |
| 103 |
root |
1.1 |
|
| 104 |
|
|
$hitter->message ("Meoow! (Please do not hurt me)") |
| 105 |
|
|
if !($hitter->{neko_attack} & 15); |
| 106 |
|
|
|
| 107 |
|
|
if ($hitter->{neko_attack} > 512) { |
| 108 |
|
|
$hitter->{neko_attack} -= 128; |
| 109 |
|
|
$hitter->message ("Neko-san is suddenly gone!"); |
| 110 |
root |
1.8 |
$hitter->goto ("/scorn/misc/scorn_illusions", 15, 7); |
| 111 |
root |
1.1 |
$hitter->message ("You hear strange noises all around you..."); |
| 112 |
|
|
$hitter->message ("You feel dumb."); |
| 113 |
|
|
} |
| 114 |
|
|
} else { |
| 115 |
|
|
# $hitter->stats->hp (-1); |
| 116 |
|
|
# $hitter->kill_object; |
| 117 |
|
|
} |
| 118 |
|
|
|
| 119 |
|
|
cf::override; |
| 120 |
|
|
} |
| 121 |
|
|
|
| 122 |
|
|
sub on_say { |
| 123 |
|
|
my ($self, $pl, $msg) = @_; |
| 124 |
|
|
|
| 125 |
root |
1.4 |
ext::irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $pl->ob->name, $msg); |
| 126 |
root |
1.1 |
} |
| 127 |
|
|
|
| 128 |
root |
1.10 |
sub on_infect { |
| 129 |
|
|
my ($self, $type, $disease) = @_; |
| 130 |
|
|
|
| 131 |
|
|
my $owner = $disease->owner; |
| 132 |
|
|
|
| 133 |
|
|
if ($owner && $owner->type == cf::PLAYER) { |
| 134 |
|
|
ext::irc::do_notice "Neko-san was diseased by " . $owner->name . " with " . $type->name . "!\n"; |
| 135 |
|
|
warn "Neko-san was diseased by " . $owner->name . " with " . $type->name . "!\n"; |
| 136 |
|
|
$disease->remove; |
| 137 |
|
|
$disease->level ($disease->level + 10); |
| 138 |
|
|
$disease->magic (0); |
| 139 |
|
|
$disease->stats->maxsp (1); |
| 140 |
|
|
$disease->last_heal (1); |
| 141 |
|
|
$disease->set_owner (undef); |
| 142 |
|
|
$owner->insert ($disease); |
| 143 |
|
|
$owner->message ("You have a funny feeling."); |
| 144 |
|
|
} else { |
| 145 |
|
|
$disease->destroy; |
| 146 |
|
|
} |
| 147 |
|
|
|
| 148 |
|
|
cf::override; |
| 149 |
|
|
} |
| 150 |
|
|
|
| 151 |
root |
1.2 |
cf::object::attachment "Nekosan", package => __PACKAGE__; |
| 152 |
root |
1.1 |
|