--- cf.schmorp.de/maps/perl/schmorp-neko.ext 2006/03/31 22:47:20 1.16 +++ cf.schmorp.de/maps/perl/schmorp-neko.ext 2006/08/27 15:39:17 1.23 @@ -2,8 +2,6 @@ # archetype nekosan -use Data::Dumper; - sub teleport { my ($pl, $map, $x, $y) = @_; @@ -36,10 +34,10 @@ } sub on_move { - my ($event, $who) = @_; + my ($self, $enemy) = @_; - if (my $pl = find_target_player $who) { - my ($d, undef, undef, $dir, undef) = $who->rangevector ($pl); + if (my $pl = find_target_player $self) { + my ($d, undef, undef, $dir, undef) = $self->rangevector ($pl); if ($d < 1.5) { if (grep $_->type == cf::FORCE && $_->slaying eq "schmorp-neko-gave-fish", $pl->inv) { @@ -66,7 +64,7 @@ $spell->set_attacktype (cf::AT_CONFUSION | cf::AT_POISON | cf::AT_BLIND | cf::AT_DISEASE); $pl->message ("(Neko-san makes strange noises)"); - $pl->cast_spell ($who, $dir, $spell); + $pl->cast_spell ($self, $dir, $spell); $spell->free; } @@ -100,35 +98,43 @@ $dir = $dir % 8 + 1 unless $d > 1.5; } - $who->move ($dir); + $self->move ($dir); } - 1 + cf::override; } sub on_attack { - my ($event, $ob, $who) = @_; - - $who->{neko_attack}++ - or cf::LOG cf::llevDebug, sprintf "QBERT Neko-san was attacked by %s!\n", $who->name; + my ($self, $hitter) = @_; - $who->message ("Meoow! (Please do not hurt me)") - if !($who->{neko_attack} & 15); + if ($hitter->{neko_last_attack} < time - 300) { + $hitter->{neko_attack} = 0; + } - if ($who->{neko_attack} > 512) { - $who->{neko_attack} -= 128; - $who->message ("Neko-san is suddenly gone!"); - teleport $who, "/scorn/misc/scorn_illusions", 15, 7; - $who->message ("You hear strange noises all around you..."); - $who->message ("You feel dumb."); + $hitter->{neko_last_attack} = time; + $hitter->{neko_attack}++ + or ext::schmorp_irc::do_notice "Neko-san was attacked by ". $hitter->name . "!\n"; + + $hitter->message ("Meoow! (Please do not hurt me)") + if !($hitter->{neko_attack} & 15); + + if ($hitter->{neko_attack} > 512) { + $hitter->{neko_attack} -= 128; + $hitter->message ("Neko-san is suddenly gone!"); + teleport $hitter, "/scorn/misc/scorn_illusions", 15, 7; + $hitter->message ("You hear strange noises all around you..."); + $hitter->message ("You feel dumb."); } - 1 + cf::override; } -sub on_say { +sub on_listen { my ($event, $ob, $who, $msg) = @_; cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $who->name, $msg; + ext::schmorp_irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $who->name, $msg); } +cf::register_attachment "Nekosan", package => __PACKAGE__; +