ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/commands.ext
(Generate patch)

Comparing deliantra/server/ext/commands.ext (file contents):
Revision 1.70 by root, Mon Sep 22 01:33:09 2008 UTC vs.
Revision 1.74 by root, Mon Apr 5 03:22:25 2010 UTC

53}; 53};
54 54
55cf::register_command seen => sub { 55cf::register_command seen => sub {
56 my ($pl, $args) = @_; 56 my ($pl, $args) = @_;
57 57
58 cf::async {
58 if (my ($login) = $args =~ /(\S+)/) { 59 if (my ($login) = $args =~ /(\S+)/) {
59 if ($login eq $pl->name) { 60 if ($login eq $pl->name) {
60 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY); 61 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY);
61 } elsif (cf::player::find_active $login) { 62 } elsif (cf::player::find_active $login) {
62 $pl->message ("$login is right here on this server!", cf::NDI_REPLY); 63 $pl->message ("$login is right here on this server!", cf::NDI_REPLY);
63 } elsif (cf::player::exists $login 64 } elsif (cf::player::exists $login
64 and stat cf::player::path $login) { 65 and stat cf::player::path $login) {
65 my $time = (stat _)[9]; 66 my $time = (stat _)[9];
66 67
67 $pl->message ("$login was last seen here " 68 $pl->message ("$login was last seen here "
68 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) 69 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
69 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY); 70 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY);
71 } else {
72 $pl->message ("No player named $login is known to me.", cf::NDI_REPLY);
73 }
70 } else { 74 } else {
71 $pl->message ("No player named $login is known to me.", cf::NDI_REPLY); 75 $pl->message ("Usage: seen <player>", cf::NDI_REPLY);
72 } 76 }
73 } else {
74 $pl->message ("Usage: seen <player>", cf::NDI_REPLY);
75 } 77 };
76}; 78};
77 79
78cf::register_command body => sub { 80cf::register_command body => sub {
79 my ($ob) = @_; 81 my ($ob) = @_;
82
83 my $observe = $ob->contr->observe;
80 84
81 # Too hard to try and make a header that lines everything up, so just 85 # Too hard to try and make a header that lines everything up, so just
82 # give a description. (comment from C++) 86 # give a description. (comment from C++)
83 my $reply = 87 my $reply =
84 "The first column is the name of the body location.\r" 88 "The first column is the name of the body location.\r"
85 . "The second column is how many of those locations your body has.\r" 89 . "The second column is how many of those locations your body has.\r"
86 . "The third column is how many slots in that location are available.\n\n"; 90 . "The third column is how many slots in that location are available.\r"
91 . "The last column shows the items currently using the slot\n\n";
87 92
93 # first process all applied items and hash them into their slots
94 my @slot;
95
96 for my $item (grep $_->flag (cf::FLAG_APPLIED), $observe->inv) {
97 $item->slot_info ($_)
98 and push @{ $slot[$_] }, $item
99 for 0 .. cf::NUM_BODY_LOCATIONS-1;
100 }
101
88 $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail"; 102 $reply .= sprintf " %-20s %3s %5s %s\n", "Location", "You", "Avail", "What";
89 for (0 .. cf::NUM_BODY_LOCATIONS - 1) { 103 for (0 .. cf::NUM_BODY_LOCATIONS - 1) {
90 my $msg = cf::object::slot_nonuse_name $_; 104 my $msg = cf::object::slot_nonuse_name $_;
91 $msg =~ s/^.*? a //; 105 $msg =~ s/^.*? a //;
92 $reply .= sprintf " %-20s %3d %5d\n", $msg, $ob->slot_info ($_), $ob->slot_used ($_) 106 $reply .= sprintf " %-20s %3d %5d %s\n",
107 $msg,
108 $observe->slot_info ($_),
109 $observe->slot_used ($_),
110 join ", ", map $_->query_short_name, @{ $slot[$_] }
93 if $ob->slot_info ($_) or $ob->slot_used ($_); 111 if $observe->slot_info ($_) || $observe->slot_used ($_);
94 } 112 }
95 113
96 $reply .= "You are not allowed to wear armor\r" 114 $reply .= "You are not allowed to wear armor\r"
97 unless $ob->flag (cf::FLAG_USE_ARMOUR); 115 unless $observe->flag (cf::FLAG_USE_ARMOUR);
98 $reply .= "You are not allowed to use weapons\r" 116 $reply .= "You are not allowed to use weapons\r"
99 unless $ob->flag (cf::FLAG_USE_WEAPON); 117 unless $observe->flag (cf::FLAG_USE_WEAPON);
100 118
101 $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY); 119 $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY | cf::NDI_CLEAR);
102}; 120};
103 121
104cf::register_command mark => sub { 122#cf::register_command mark => sub {
105 my ($pl, $arg) = @_; 123# my ($pl, $arg) = @_;
106 124#
107 if (length $arg) { 125# if (length $arg) {
108 my $ob = $pl->find_best_object_match ($arg); 126# my $ob = $pl->find_best_object_match ($arg);
109 127#
110 return $pl->reply (undef, "Could not find an object that matches $arg") 128# return $pl->reply (undef, "Could not find an object that matches $arg")
111 unless $ob; 129# unless $ob;
112 130#
113 $pl->contr->mark ($ob); 131# $pl->contr->mark ($ob);
114 $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title)); 132# $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title));
115 } else { 133# } else {
116 my $ob = $pl->find_marked_object; 134# my $ob = $pl->find_marked_object;
117 135#
118 $pl->reply (undef, $ob 136# $pl->reply (undef, $ob
119 ? (sprintf "%s %s * is marked.", $ob->name, $ob->title) 137# ? (sprintf "%s %s * is marked.", $ob->name, $ob->title)
120 : "You have no marked object."); 138# : "You have no marked object.");
121 } 139# }
122}; 140#};
123
124for my $cmd ("run", "fire") {
125 my $oncmd = "${cmd}_on";
126 cf::register_command $cmd => sub {
127 my ($ob, $arg) = @_;
128
129 $ob->reply (undef, "Can't $cmd into a non adjacent square.")
130 if $arg < 0 or $arg >= 9;
131
132 $ob->contr->$oncmd (1);
133 $ob->move_player ($arg);
134 };
135
136 cf::register_command "${cmd}_stop" => sub {
137 my ($ob) = @_;
138
139 $ob->contr->$oncmd (0);
140 };
141}
142 141
143cf::register_command mapinfo => sub { 142cf::register_command mapinfo => sub {
144 my ($ob) = @_; 143 my ($ob) = @_;
145 144
146 my $observe = $ob->contr->observe; 145 my $observe = $ob->contr->observe;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines