… | |
… | |
29 | on_login => sub { |
29 | on_login => sub { |
30 | my ($pl) = @_; |
30 | my ($pl) = @_; |
31 | |
31 | |
32 | clean_timeouts $pl->ob; |
32 | clean_timeouts $pl->ob; |
33 | }, |
33 | }, |
34 | |
|
|
35 | 1 |
|
|
36 | ); |
34 | ); |
37 | |
35 | |
38 | cf::register_command listen => sub { |
36 | cf::register_command listen => sub { |
39 | my ($who, $msg) = @_; |
37 | my ($pl, $msg) = @_; |
40 | my $player = cf::player::find_active $who->name; |
38 | my $player = cf::player::find_active $pl->name; |
41 | |
39 | |
42 | if ($msg ne "") { |
40 | if ($msg ne "") { |
|
|
41 | $msg = 10 if $msg > 10; |
|
|
42 | |
43 | my $prev_listen = $player->listening; |
43 | my $prev_listen = $player->listening; |
44 | $player->listening ($msg); |
44 | $player->listening ($msg); |
45 | if ($prev_listen == $player->listening) { |
45 | if ($prev_listen == $player->listening) { |
46 | $who->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE); |
46 | $pl->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE); |
47 | } else { |
47 | } else { |
48 | $who->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); |
48 | $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); |
49 | } |
49 | } |
50 | } else { |
50 | } else { |
51 | $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); |
51 | $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); |
52 | } |
52 | } |
|
|
53 | }; |
53 | |
54 | |
|
|
55 | cf::register_command cointoss => sub { |
|
|
56 | my ($pl, $msg) = @_; |
|
|
57 | |
|
|
58 | my $name = $pl->name; |
|
|
59 | |
|
|
60 | if (int rand 2) { |
|
|
61 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
|
|
62 | next |
|
|
63 | if $other->ob == $pl; |
|
|
64 | $other->ob->message ("$name flips a coin.... Heads!", cf::NDI_GREY | cf::NDI_UNIQUE); |
|
|
65 | } |
|
|
66 | |
|
|
67 | $pl->message ("You flip a coin.... Heads!", cf::NDI_GREY | cf::NDI_UNIQUE); |
|
|
68 | } else { |
|
|
69 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
|
|
70 | next |
|
|
71 | if $other->ob == $pl; |
|
|
72 | $other->ob->message ("$name flips a coin.... Tails!", cf::NDI_GREY | cf::NDI_UNIQUE); |
|
|
73 | } |
|
|
74 | |
|
|
75 | $pl->message ("You flip a coin.... Tails!", cf::NDI_GREY | cf::NDI_UNIQUE); |
54 | 1 |
76 | } |
|
|
77 | }; |
|
|
78 | |
|
|
79 | cf::register_command orcknuckle => sub { |
|
|
80 | my ($pl, $msg) = @_; |
|
|
81 | my @orcknuckle = ("none", "beholder", "ghost", "knight", "princess", "dragon", "orc"); |
|
|
82 | |
|
|
83 | my $name = $pl->name; |
|
|
84 | |
|
|
85 | my ($i, $j, $k, $l) = ((int rand 5) + 1, (int rand 5) + 1, (int rand 5) + 1, (int rand 6) + 1); |
|
|
86 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
|
|
87 | |
|
|
88 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
|
|
89 | next |
|
|
90 | if $other->ob == $pl; |
|
|
91 | $other->ob->message ("$name rolls $result!", cf::NDI_GREY | cf::NDI_UNIQUE); |
|
|
92 | } |
|
|
93 | |
|
|
94 | $pl->message ("You roll $result!", cf::NDI_GREY | cf::NDI_UNIQUE); |
55 | }; |
95 | }; |
56 | |
96 | |
57 | my $emotes = { |
97 | my $emotes = { |
58 | growl => { |
98 | growl => { |
59 | noparams => { |
99 | noparams => { |
… | |
… | |
189 | noparams => { |
229 | noparams => { |
190 | other => "<self> winks suggestively.", |
230 | other => "<self> winks suggestively.", |
191 | self => "Have you got something in your eye?", |
231 | self => "Have you got something in your eye?", |
192 | }, |
232 | }, |
193 | params => { |
233 | params => { |
|
|
234 | target => "<self> winks at you.", |
194 | target => "<self> winks at <other>.", |
235 | other => "<self> winks at <other>.", |
195 | self => "You wink suggestively at <other>.", |
236 | self => "You wink suggestively at <other>.", |
196 | }, |
237 | }, |
197 | self => { |
238 | self => { |
198 | other => "<self> winks at himself - something strange is going on...", |
239 | other => "<self> winks at himself - something strange is going on...", |
199 | self => "You wink at yourself?? What are you up to?", |
240 | self => "You wink at yourself?? What are you up to?", |
… | |
… | |
289 | noparams => { |
330 | noparams => { |
290 | other => "<self> is bleeding all over the carpet - got a spare tourniquet?", |
331 | other => "<self> is bleeding all over the carpet - got a spare tourniquet?", |
291 | self => "You bleed all over your nice new armour.", |
332 | self => "You bleed all over your nice new armour.", |
292 | }, |
333 | }, |
293 | params => { |
334 | params => { |
|
|
335 | target => "<self> slashes his wrist and bleeds all over you.", |
294 | target => "<self> slashes his wrist and bleeds all over <other>.", |
336 | other => "<self> slashes his wrist and bleeds all over <other>.", |
295 | self => "You slash your wrist and bleed all over <other>", |
337 | self => "You slash your wrist and bleed all over <other>", |
296 | }, |
338 | }, |
297 | self => { |
339 | self => { |
298 | other => "<self> performs some satanic ritual while wiping his blood on himself.", |
340 | other => "<self> performs some satanic ritual while wiping his blood on himself.", |
299 | self => "Very impressive! You wipe your blood all over yourself.", |
341 | self => "Very impressive! You wipe your blood all over yourself.", |
… | |
… | |
634 | }, |
676 | }, |
635 | }; |
677 | }; |
636 | |
678 | |
637 | for my $emotion (keys %$emotes) { |
679 | for my $emotion (keys %$emotes) { |
638 | cf::register_command $emotion => sub { |
680 | cf::register_command $emotion => sub { |
639 | my ($ob, $tname) = @_; |
681 | my ($pl, $tname) = @_; |
640 | |
682 | |
641 | cf::async { |
683 | cf::async { |
642 | my $name = $ob->name; |
684 | my $name = $pl->name; |
643 | |
685 | |
644 | if ($tname eq $name) { |
686 | if ($tname eq $name) { |
645 | my $emote = $emotes->{$emotion}->{self}; |
687 | my $emote = $emotes->{$emotion}->{self}; |
646 | |
688 | |
647 | $emote->{other} = "You look away from <self>." |
689 | $emote->{other} = "You look away from <self>." |
… | |
… | |
649 | $emote->{self} = "My god! Is that LEGAL?" |
691 | $emote->{self} = "My god! Is that LEGAL?" |
650 | if !$emote->{self}; |
692 | if !$emote->{self}; |
651 | |
693 | |
652 | $emote->{other} =~ s/<self>/$name/; |
694 | $emote->{other} =~ s/<self>/$name/; |
653 | |
695 | |
654 | for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { |
696 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
655 | next |
697 | next |
656 | if $other->ob == $ob; |
698 | if $other->ob == $pl; |
657 | $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); |
699 | $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); |
658 | } |
700 | } |
659 | |
701 | |
660 | $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); |
702 | $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); |
661 | } elsif ($tname) { |
703 | } elsif ($tname) { |
662 | my $target = cf::player::find $tname |
704 | my $target = cf::player::find $tname |
663 | or return $ob->reply (undef, "$tname is not around."); |
705 | or return $pl->reply (undef, "$tname is not around."); |
664 | |
706 | |
665 | my $emote = $emotes->{$emotion}->{params}; |
707 | my $emote = $emotes->{$emotion}->{params}; |
666 | |
708 | |
667 | $emote->{other} = "<self> is eyeing <other> quizzically." |
709 | $emote->{other} = "<self> is eyeing <other> quizzically." |
668 | if !$emote->{other}; |
710 | if !$emote->{other}; |
… | |
… | |
674 | $emote->{self} =~ s/<other>/$tname/; |
716 | $emote->{self} =~ s/<other>/$tname/; |
675 | $emote->{target} =~ s/<self>/$name/; |
717 | $emote->{target} =~ s/<self>/$name/; |
676 | $emote->{other} =~ s/<other>/$tname/; |
718 | $emote->{other} =~ s/<other>/$tname/; |
677 | $emote->{other} =~ s/<self>/$name/; |
719 | $emote->{other} =~ s/<self>/$name/; |
678 | |
720 | |
679 | for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { |
721 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
680 | next |
722 | next |
681 | if $other->ob == $ob or $other == $target; |
723 | if $other->ob == $pl or $other == $target; |
682 | $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); |
724 | $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); |
683 | } |
725 | } |
684 | |
726 | |
685 | $target->ob->message ($emote->{target}, cf::NDI_GREY | cf::NDI_UNIQUE); |
727 | $target->ob->message ($emote->{target}, cf::NDI_GREY | cf::NDI_UNIQUE); |
686 | $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); |
728 | $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); |
687 | } else { |
729 | } else { |
688 | my $emote = $emotes->{$emotion}->{noparams}; |
730 | my $emote = $emotes->{$emotion}->{noparams}; |
689 | $emote->{other} =~ s/<self>/$name/; |
731 | $emote->{other} =~ s/<self>/$name/; |
690 | |
732 | |
691 | $emote->{other} = "<self> dances with glee." |
733 | $emote->{other} = "<self> dances with glee." |
692 | if !$emote->{other}; |
734 | if !$emote->{other}; |
693 | $emote->{self} = "You are a nut." |
735 | $emote->{self} = "You are a nut." |
694 | if !$emote->{self}; |
736 | if !$emote->{self}; |
695 | |
737 | |
696 | for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { |
738 | for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) { |
697 | next |
739 | next |
698 | if $other->ob == $ob; |
740 | if $other->ob == $pl; |
699 | $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); |
741 | $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); |
700 | } |
742 | } |
701 | |
743 | |
702 | $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); |
744 | $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); |
703 | } |
745 | } |
704 | }; |
746 | }; |
705 | }; |
747 | }; |
706 | } |
748 | } |
707 | |
749 | |
708 | cf::register_command me => sub { |
750 | cf::register_command me => sub { |
709 | my ($ob, $msg) = @_; |
751 | my ($pl, $msg) = @_; |
710 | |
752 | |
711 | my $name = $ob->name; |
753 | my $name = $pl->name; |
712 | |
754 | |
713 | $_->ob->message ("* $name $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
755 | $_->ob->message ("* $name $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
714 | for grep $ob->on_same_map_as ($_->ob), cf::player::list; |
756 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
715 | }; |
757 | }; |
716 | |
758 | |
717 | cf::register_command say => sub { |
759 | cf::register_command say => sub { |
718 | my ($who, $msg) = @_; |
760 | my ($pl, $msg) = @_; |
719 | |
761 | |
720 | utf8::decode $msg; |
762 | utf8::decode $msg; |
721 | |
763 | |
722 | return if $who->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
764 | return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
723 | |
765 | |
724 | if ($msg) { |
766 | if ($msg) { |
725 | my $name = $who->name; |
767 | my $name = $pl->name; |
726 | |
768 | |
727 | utf8::encode $msg; # ->message not yet utf8-ified |
769 | utf8::encode $msg; # ->message not yet utf8-ified |
728 | $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
770 | $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
729 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
771 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
730 | utf8::decode $msg; |
772 | utf8::decode $msg; |
731 | |
773 | |
732 | # npcs, magic_ears etc. |
774 | # npcs, magic_ears etc. |
733 | # first find all objects and theirt-level inventories |
775 | # first find all objects and theirt-level inventories |
734 | # within a 5x5 square # that have something resembling |
776 | # within a 5x5 square # that have something resembling |
735 | # dialogue or support on_say. |
777 | # dialogue or support on_say. |
736 | my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); |
778 | my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2); |
737 | |
779 | |
738 | for my $npc ( |
780 | for my $npc ( |
739 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $who->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
781 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
740 | map +($_, $_->inv), |
782 | map +($_, $_->inv), |
741 | grep $_, |
783 | grep $_, |
742 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
784 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
743 | 0..24 |
785 | 0..24 |
744 | ) { |
786 | ) { |
745 | # if some listener teleported us somewhere else, stop right here |
787 | # if some listener teleported us somewhere else, stop right here |
746 | last unless $map->path == $who->map->path; |
788 | last unless $map->path == $pl->map->path; |
747 | |
789 | |
748 | my $dialog = new NPC_Dialogue ob => $who, npc => $npc; |
790 | my $dialog = new NPC_Dialogue ob => $pl, npc => $npc; |
749 | my ($reply, @kw) = $dialog->tell ($msg); |
791 | my ($reply, @kw) = $dialog->tell ($msg); |
750 | |
792 | |
751 | if (defined $reply) { |
793 | if (defined $reply) { |
752 | if ($npc->type == cf::MAGIC_EAR) { |
794 | if ($npc->type == cf::MAGIC_EAR) { |
753 | if (length $reply) { |
795 | if (length $reply) { |
754 | $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) |
796 | $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) |
755 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
797 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
756 | } |
798 | } |
757 | $npc->use_trigger; |
799 | $npc->use_trigger; |
758 | } else { |
800 | } else { |
759 | if (length $reply) { |
801 | if (length $reply) { |
760 | $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) |
802 | $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) |
761 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
803 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
762 | } |
804 | } |
763 | } |
805 | } |
764 | } |
806 | } |
765 | |
807 | |
766 | if (@kw) { |
808 | if (@kw) { |
767 | $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) |
809 | $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) |
768 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
810 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
769 | } |
811 | } |
770 | } |
812 | } |
771 | |
813 | |
772 | } else { |
814 | } else { |
773 | $who->message ("What do you want to say?", cf::NDI_UNIQUE); |
815 | $pl->message ("What do you want to say?", cf::NDI_UNIQUE); |
774 | } |
816 | } |
775 | |
|
|
776 | 1 |
|
|
777 | }; |
817 | }; |
778 | |
818 | |
779 | cf::register_command chat => sub { |
819 | cf::register_command chat => sub { |
780 | my ($who, $msg) = @_; |
820 | my ($pl, $msg) = @_; |
781 | |
821 | |
782 | utf8::decode $msg; |
822 | utf8::decode $msg; |
783 | |
823 | |
784 | return if $who->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
824 | return if $pl->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
785 | |
825 | |
786 | if ($msg) { |
826 | if ($msg) { |
787 | my $name = $who->name; |
827 | my $name = $pl->name; |
788 | my $NOW = time; |
828 | my $NOW = time; |
789 | |
829 | |
790 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
791 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
830 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
792 | ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); |
831 | ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); |
793 | |
832 | |
794 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
833 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
795 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
834 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
796 | |
835 | |
797 | } else { |
836 | } else { |
798 | $who->message ("Chat what?", cf::NDI_UNIQUE); |
837 | $pl->message ("Chat what?", cf::NDI_UNIQUE); |
799 | } |
838 | } |
800 | |
|
|
801 | 1 |
|
|
802 | }; |
839 | }; |
803 | |
840 | |
804 | cf::register_command shout => sub { |
841 | cf::register_command shout => sub { |
805 | my ($who, $msg) = @_; |
842 | my ($pl, $msg) = @_; |
806 | |
843 | |
807 | utf8::decode $msg; |
844 | utf8::decode $msg; |
808 | |
845 | |
809 | return if $who->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); |
846 | return if $pl->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); |
810 | |
847 | |
811 | if ($msg) { |
848 | if ($msg) { |
812 | my $NOW = time; |
849 | my $NOW = time; |
813 | my $name = $who->name; |
850 | my $name = $pl->name; |
814 | |
851 | |
815 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
852 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
816 | ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); |
853 | ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); |
817 | |
854 | |
818 | utf8::encode $msg; # ->message not yet utf8-ified |
855 | utf8::encode $msg; # ->message not yet utf8-ified |
819 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
856 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
820 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
857 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
821 | |
858 | |
822 | } else { |
859 | } else { |
823 | $who->message ("Shout what?", cf::NDI_UNIQUE); |
860 | $pl->message ("Shout what?", cf::NDI_UNIQUE); |
824 | } |
861 | } |
825 | |
|
|
826 | 1 |
|
|
827 | }; |
862 | }; |
828 | |
863 | |
829 | cf::register_command tell => sub { |
864 | cf::register_command tell => sub { |
830 | my ($who, $args) = @_; |
865 | my ($pl, $args) = @_; |
831 | my ($target, $msg) = split /\s+/, $args, 2; |
866 | my ($target, $msg) = split /\s+/, $args, 2; |
832 | |
867 | |
833 | utf8::decode $msg; |
868 | utf8::decode $msg; |
834 | |
869 | |
835 | return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
870 | return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
836 | |
871 | |
837 | my $name = $who->name; |
872 | my $name = $pl->name; |
838 | |
873 | |
839 | if ($target =~ /irc\//) { |
874 | if ($target =~ /irc\//) { |
840 | my (undef, $nick) = split /\//, $target, 2; |
875 | my (undef, $nick) = split /\//, $target, 2; |
841 | $who->message ("You tell $target: $args"); |
876 | $pl->message ("You tell $target: $args"); |
842 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); |
877 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); |
843 | } elsif (my $other = cf::player::find_active $target) { |
878 | } elsif (my $other = cf::player::find_active $target) { |
844 | |
879 | |
845 | if ($msg) { |
880 | if ($msg) { |
846 | if ($target eq $name) { |
881 | if ($target eq $name) { |
847 | $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); |
882 | $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); |
848 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
883 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
849 | $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
884 | $pl->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
850 | } else { |
885 | } else { |
|
|
886 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl->contr, $msg); |
851 | utf8::encode $msg; # ->message not yet utf8-ified |
887 | utf8::encode $msg; # ->message not yet utf8-ified |
852 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
888 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
853 | |
889 | |
854 | $who->message ("You tell $target: $msg"); |
890 | $pl->message ("You tell $target: $msg"); |
855 | $other->ob->message ("$name tells you: $msg"); |
891 | $other->ob->message ("$name tells you: $msg"); |
856 | $other->ob->{ext_last_tell} = $name; |
892 | $other->ob->{ext_last_tell} = $name; |
857 | } |
893 | } |
858 | } else { |
894 | } else { |
859 | $who->message ("What do you want to tell $target?", cf::NDI_UNIQUE); |
895 | $pl->message ("What do you want to tell $target?", cf::NDI_UNIQUE); |
860 | } |
896 | } |
861 | |
897 | |
862 | } else { |
898 | } else { |
863 | $who->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); |
899 | $pl->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); |
864 | } |
900 | } |
865 | |
|
|
866 | 1 |
|
|
867 | }; |
901 | }; |
868 | |
902 | |
869 | cf::register_command reply => sub { |
903 | cf::register_command reply => sub { |
870 | my ($who, $args) = @_; |
904 | my ($pl, $args) = @_; |
871 | my $name = $who->name; |
905 | my $name = $pl->name; |
872 | |
906 | |
873 | utf8::decode $args; |
907 | utf8::decode $args; |
874 | |
908 | |
875 | return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $who->{ext_last_tell}, $args); |
909 | return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args); |
876 | |
910 | |
877 | if ($who->{ext_last_tell} =~ /irc\//) { |
911 | if ($pl->{ext_last_tell} =~ /irc\//) { |
878 | my (undef, $nick) = split /\//, $who->{ext_last_tell}, 2; |
912 | my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2; |
879 | $who->message ("You tell " . $who->{ext_last_tell} . ": $args"); |
913 | $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args"); |
880 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args); |
914 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args); |
881 | } elsif (my $other = cf::player::find_active $who->{ext_last_tell}) { |
915 | } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) { |
882 | |
916 | |
883 | if ($args) { |
917 | if ($args) { |
884 | $other->ob->{ext_ignore_tell}{$name} >= time |
918 | $other->ob->{ext_ignore_tell}{$name} >= time |
885 | or delete $other->ob->{ext_ignore_tell}{$name}; |
919 | or delete $other->ob->{ext_ignore_tell}{$name}; |
886 | |
920 | |
887 | if ($other->ob->{ext_ignore_tell}{$name} < time) { |
921 | if ($other->ob->{ext_ignore_tell}{$name} < time) { |
888 | utf8::encode $args; # ->message not yet utf8-ified |
922 | utf8::encode $args; # ->message not yet utf8-ified |
889 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; |
923 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; |
890 | |
924 | |
891 | $who->message ("You tell " . $other->ob->name . ": $args"); |
925 | $pl->message ("You tell " . $other->ob->name . ": $args"); |
892 | $other->ob->message ("$name tells you: $args"); |
926 | $other->ob->message ("$name tells you: $args"); |
893 | $who->{ext_last_tell} = $other->ob->name; |
927 | $pl->{ext_last_tell} = $other->ob->name; |
894 | } else { |
928 | } else { |
895 | $who->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
929 | $pl->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
896 | } |
930 | } |
897 | } else { |
931 | } else { |
898 | $who->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); |
932 | $pl->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); |
899 | } |
933 | } |
900 | |
934 | |
901 | } else { |
935 | } else { |
902 | $who->message ("Can't reply, player left. Your message: $args".$who->{ext_last_tell}, cf::NDI_UNIQUE); |
936 | $pl->message ("Can't reply, player left. Your message: $args".$pl->{ext_last_tell}, cf::NDI_UNIQUE); |
903 | } |
937 | } |
904 | |
|
|
905 | 1 |
|
|
906 | }; |
938 | }; |
907 | |
939 | |
908 | cf::register_command ignore => sub { |
940 | cf::register_command ignore => sub { |
909 | my ($who, $args) = @_; |
941 | my ($pl, $args) = @_; |
910 | my ($target, $type, $timeout) = split /\s+/, $args; |
942 | my ($target, $type, $timeout) = split /\s+/, $args; |
911 | |
943 | |
912 | if ($args eq "list") { |
944 | if ($args eq "list") { |
913 | clean_timeouts $who; |
945 | clean_timeouts $pl; |
914 | |
946 | |
915 | if ((my @ignored_tell = sort keys %{$who->{ext_ignore_tell}}) |
947 | if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) |
916 | + (my @ignored_shout = sort keys %{$who->{ext_ignore_shout}})) { |
948 | + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { |
917 | $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); |
949 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); |
918 | $who->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE); |
950 | $pl->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE); |
919 | $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); |
951 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); |
920 | $who->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE); |
952 | $pl->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE); |
921 | $who->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE); |
953 | $pl->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE); |
922 | } else { |
954 | } else { |
923 | $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
955 | $pl->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
924 | } |
956 | } |
925 | |
957 | |
926 | } elsif ($target && $type) { |
958 | } elsif ($target && $type) { |
927 | |
959 | |
928 | $timeout ne "" or $timeout = 24; |
960 | $timeout ne "" or $timeout = 24; |
929 | my $absolute_timeout = time + $timeout * 3600; |
961 | my $absolute_timeout = time + $timeout * 3600; |
930 | |
962 | |
931 | if (cf::player::exists $target) { |
963 | if (cf::player::exists $target) { |
932 | if ($type eq "tell") { |
964 | if ($type eq "tell") { |
933 | $who->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE); |
965 | $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE); |
934 | $who->{ext_ignore_tell}{$target} = $absolute_timeout; |
966 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
935 | } elsif ($type eq "shout") { |
967 | } elsif ($type eq "shout") { |
936 | $who->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE); |
968 | $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE); |
937 | $who->{ext_ignore_shout}{$target} = $absolute_timeout; |
969 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
938 | } elsif ($type eq "all") { |
970 | } elsif ($type eq "all") { |
939 | $who->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE); |
971 | $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE); |
940 | $who->{ext_ignore_tell}{$target} = $absolute_timeout; |
972 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
941 | $who->{ext_ignore_shout}{$target} = $absolute_timeout; |
973 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
942 | } else { |
974 | } else { |
943 | $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
975 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
944 | } |
976 | } |
945 | } else { |
977 | } else { |
946 | $who->message ("No such player: $target", cf::NDI_UNIQUE); |
978 | $pl->message ("No such player: $target", cf::NDI_UNIQUE); |
947 | } |
979 | } |
948 | |
980 | |
949 | } else { |
981 | } else { |
950 | $who->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
982 | $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
951 | . "will ignore a player for <timeout> hours.\n" |
983 | . "will ignore a player for <timeout> hours.\n" |
952 | . "Usage: ignore list\n" |
984 | . "Usage: ignore list\n" |
953 | . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); |
985 | . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); |
954 | } |
986 | } |
955 | |
|
|
956 | 1 |
|
|
957 | }; |
987 | }; |
958 | |
988 | |
959 | cf::register_command unignore => sub { |
989 | cf::register_command unignore => sub { |
960 | my ($who, $args) = @_; |
990 | my ($pl, $args) = @_; |
961 | my ($target, $type) = split /\s+/, $args; |
991 | my ($target, $type) = split /\s+/, $args; |
962 | |
992 | |
963 | if ($args eq "") { |
993 | if ($args eq "") { |
964 | if ($who->{ext_ignore_tell}) { |
994 | if ($pl->{ext_ignore_tell}) { |
965 | $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); |
995 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); |
966 | $who->message ((join ", ", sort keys %{ $who->{ext_ignore_tell} }), cf::NDI_UNIQUE); |
996 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_UNIQUE); |
967 | $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); |
997 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); |
968 | $who->message ((join ", ", sort keys %{ $who->{ext_ignore_shout} }), cf::NDI_UNIQUE); |
998 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_UNIQUE); |
969 | } else { |
999 | } else { |
970 | $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
1000 | $pl->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
971 | } |
1001 | } |
972 | } else { |
1002 | } else { |
973 | if (cf::player::exists $target) { |
1003 | if (cf::player::exists $target) { |
974 | if ($type eq "tell") { |
1004 | if ($type eq "tell") { |
975 | $who->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); |
1005 | $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); |
976 | delete $who->{ext_ignore_tell} {$target}; |
1006 | delete $pl->{ext_ignore_tell} {$target}; |
977 | } elsif ($type eq "shout") { |
1007 | } elsif ($type eq "shout") { |
978 | $who->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE); |
1008 | $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE); |
979 | delete $who->{ext_ignore_shout}{$target}; |
1009 | delete $pl->{ext_ignore_shout}{$target}; |
980 | } elsif ($type eq "all") { |
1010 | } elsif ($type eq "all") { |
981 | $who->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE); |
1011 | $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE); |
982 | delete $who->{ext_ignore_tell} {$target}; |
1012 | delete $pl->{ext_ignore_tell} {$target}; |
983 | delete $who->{ext_ignore_shout}{$target}; |
1013 | delete $pl->{ext_ignore_shout}{$target}; |
984 | } else { |
1014 | } else { |
985 | $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
1015 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
986 | } |
1016 | } |
987 | } else { |
1017 | } else { |
988 | $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
1018 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
989 | } |
1019 | } |
990 | } |
1020 | } |
991 | |
|
|
992 | 1 |
|
|
993 | }; |
1021 | }; |
994 | |
1022 | |
995 | cf::register_command seen => sub { |
|
|
996 | my ($who, $args) = @_; |
|
|
997 | |
|
|
998 | if (my ($login) = $args =~ /(\S+)/) { |
|
|
999 | if ($login eq $who->name) { |
|
|
1000 | $who->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); |
|
|
1001 | } elsif (cf::player::find_active $login) { |
|
|
1002 | $who->message ("$login is right here on this server!", cf::NDI_UNIQUE); |
|
|
1003 | } elsif (cf::player::exists $login |
|
|
1004 | and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) { |
|
|
1005 | my $time = (stat _)[9]; |
|
|
1006 | |
|
|
1007 | $who->message ("$login was last seen here " |
|
|
1008 | . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) |
|
|
1009 | . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); |
|
|
1010 | } else { |
|
|
1011 | $who->message ("No player named $login is known to me.", cf::NDI_UNIQUE); |
|
|
1012 | } |
|
|
1013 | } else { |
|
|
1014 | $who->message ("Usage: seen <player>", cf::NDI_UNIQUE); |
|
|
1015 | } |
|
|
1016 | |
|
|
1017 | 1 |
|
|
1018 | }; |
|
|
1019 | |
|
|