--- cf.schmorp.de/maps/perl/schmorp-neko.ext 2006/08/10 23:25:11 1.19 +++ cf.schmorp.de/maps/perl/schmorp-neko.ext 2006/08/30 08:36:08 1.27 @@ -2,8 +2,6 @@ # archetype nekosan -use Data::Dumper; - sub teleport { my ($pl, $map, $x, $y) = @_; @@ -35,11 +33,11 @@ $pl } -sub on_move { - my ($event, $who) = @_; +sub on_monster_move { + 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,41 +98,47 @@ $dir = $dir % 8 + 1 unless $d > 1.5; } - $who->move ($dir); + $self->move ($dir); } - 1 + cf::override; } sub on_attack { - my ($event, $ob, $who) = @_; + my ($self, $hitter) = @_; - if ($who->{neko_last_attack} < time - 300) { - $who->{neko_attack} = 0; - } + if ($hitter->type == cf::PLAYER) { + if ($hitter->{neko_last_attack} < time - 300) { + $hitter->{neko_attack} = 0; + } - $who->{neko_last_attack} = time; - $who->{neko_attack}++ - or cf::ext::schmorp_irc::do_notice "Neko-san was attacked by ". $who->name . "!\n"; - - $who->message ("Meoow! (Please do not hurt me)") - if !($who->{neko_attack} & 15); - - 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."); + } + } else { + $hitter->hp (-1); + $hitter->kill_object; } - 1 + cf::override; } sub on_say { - my ($event, $ob, $who, $msg) = @_; + my ($self, $pl, $msg) = @_; - cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $who->name, $msg; - cf::ext::schmorp_irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $who->name, $msg); + ext::schmorp_irc::do_notice (sprintf "[Neko-fon] %s: %s\n", $pl->ob->name, $msg); } +cf::register_attachment "Nekosan", package => __PACKAGE__; +