--- deliantra/server/ext/commands.ext 2008/09/23 00:24:52 1.71 +++ deliantra/server/ext/commands.ext 2010/04/05 03:22:25 1.74 @@ -80,67 +80,64 @@ cf::register_command body => sub { my ($ob) = @_; + my $observe = $ob->contr->observe; + # Too hard to try and make a header that lines everything up, so just # give a description. (comment from C++) my $reply = "The first column is the name of the body location.\r" . "The second column is how many of those locations your body has.\r" - . "The third column is how many slots in that location are available.\n\n"; + . "The third column is how many slots in that location are available.\r" + . "The last column shows the items currently using the slot\n\n"; + + # first process all applied items and hash them into their slots + my @slot; - $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail"; + for my $item (grep $_->flag (cf::FLAG_APPLIED), $observe->inv) { + $item->slot_info ($_) + and push @{ $slot[$_] }, $item + for 0 .. cf::NUM_BODY_LOCATIONS-1; + } + + $reply .= sprintf " %-20s %3s %5s %s\n", "Location", "You", "Avail", "What"; for (0 .. cf::NUM_BODY_LOCATIONS - 1) { my $msg = cf::object::slot_nonuse_name $_; $msg =~ s/^.*? a //; - $reply .= sprintf " %-20s %3d %5d\n", $msg, $ob->slot_info ($_), $ob->slot_used ($_) - if $ob->slot_info ($_) or $ob->slot_used ($_); + $reply .= sprintf " %-20s %3d %5d %s\n", + $msg, + $observe->slot_info ($_), + $observe->slot_used ($_), + join ", ", map $_->query_short_name, @{ $slot[$_] } + if $observe->slot_info ($_) || $observe->slot_used ($_); } $reply .= "You are not allowed to wear armor\r" - unless $ob->flag (cf::FLAG_USE_ARMOUR); + unless $observe->flag (cf::FLAG_USE_ARMOUR); $reply .= "You are not allowed to use weapons\r" - unless $ob->flag (cf::FLAG_USE_WEAPON); - - $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY); -}; - -cf::register_command mark => sub { - my ($pl, $arg) = @_; - - if (length $arg) { - my $ob = $pl->find_best_object_match ($arg); + unless $observe->flag (cf::FLAG_USE_WEAPON); - return $pl->reply (undef, "Could not find an object that matches $arg") - unless $ob; - - $pl->contr->mark ($ob); - $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title)); - } else { - my $ob = $pl->find_marked_object; - - $pl->reply (undef, $ob - ? (sprintf "%s %s * is marked.", $ob->name, $ob->title) - : "You have no marked object."); - } + $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY | cf::NDI_CLEAR); }; -for my $cmd ("run", "fire") { - my $oncmd = "${cmd}_on"; - cf::register_command $cmd => sub { - my ($ob, $arg) = @_; - - $ob->reply (undef, "Can't $cmd into a non adjacent square.") - if $arg < 0 or $arg >= 9; - - $ob->contr->$oncmd (1); - $ob->move_player ($arg); - }; - - cf::register_command "${cmd}_stop" => sub { - my ($ob) = @_; - - $ob->contr->$oncmd (0); - }; -} +#cf::register_command mark => sub { +# my ($pl, $arg) = @_; +# +# if (length $arg) { +# my $ob = $pl->find_best_object_match ($arg); +# +# return $pl->reply (undef, "Could not find an object that matches $arg") +# unless $ob; +# +# $pl->contr->mark ($ob); +# $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title)); +# } else { +# my $ob = $pl->find_marked_object; +# +# $pl->reply (undef, $ob +# ? (sprintf "%s %s * is marked.", $ob->name, $ob->title) +# : "You have no marked object."); +# } +#}; cf::register_command mapinfo => sub { my ($ob) = @_;