--- cf.schmorp.de/maps/perl/schmorp-neko.ext 2006/02/17 23:01:40 1.14 +++ cf.schmorp.de/maps/perl/schmorp-neko.ext 2006/08/27 15:23:30 1.22 @@ -2,8 +2,6 @@ # archetype nekosan -use Data::Dumper; - sub teleport { my ($pl, $map, $x, $y) = @_; @@ -36,10 +34,11 @@ } sub on_move { - my ($data) = @_; + my ($self, $enemy) = @_; + #warn "move<@_>\n";#d# - if (my $pl = find_target_player $data->{who}) { - my ($d, undef, undef, $dir, undef) = $data->{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 +65,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 ($data->{who}, $dir, $spell); + $pl->cast_spell ($self, $dir, $spell); $spell->free; } @@ -100,37 +99,44 @@ $dir = $dir % 8 + 1 unless $d > 1.5; } - $data->{who}->move ($dir); + $self->move ($dir); } - 1 + cf::override; } sub on_attack { - my ($data) = @_; - - $data->{activator}{neko_attack}++ - or cf::LOG cf::llevDebug, sprintf "QBERT Neko-san was attacked by %s!\n", $data->{activator}->name; + my ($self) = @_; + #warn "attack<@_>\n";#d# - $data->{activator}->message ("Meoow! (Please do not hurt me)") - if !($data->{activator}{neko_attack} & 15); + if ($self->{neko_last_attack} < time - 300) { + $self->{neko_attack} = 0; + } - if ($data->{activator}{neko_attack} > 512) { - $data->{activator}{neko_attack} -= 128; - $data->{activator}->message ("Neko-san is suddenly gone!"); - teleport $data->{activator}, "/scorn/misc/scorn_illusions", 15, 7; - $data->{activator}->message ("You hear strange noises all around you..."); - $data->{activator}->message ("You feel dumb."); + $self->{neko_last_attack} = time; + $self->{neko_attack}++ + or ext::schmorp_irc::do_notice "Neko-san was attacked by ". $self->name . "!\n"; + + $self->message ("Meoow! (Please do not hurt me)") + if !($self->{neko_attack} & 15); + + if ($self->{neko_attack} > 512) { + $self->{neko_attack} -= 128; + $self->message ("Neko-san is suddenly gone!"); + teleport $self, "/scorn/misc/scorn_illusions", 15, 7; + $self->message ("You hear strange noises all around you..."); + $self->message ("You feel dumb."); } - 1 + cf::override; } -sub on_say { - my ($data) = @_; +sub on_listen { + my ($event, $ob, $who, $msg) = @_; - cf::LOG cf::llevDebug, sprintf "QBERT [Neko-fon] %s: %s\n", $data->{activator}->name, $data->{message}; - - 0 + 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__; +