… | |
… | |
78 | }; |
78 | }; |
79 | |
79 | |
80 | cf::register_command body => sub { |
80 | cf::register_command body => sub { |
81 | my ($ob) = @_; |
81 | my ($ob) = @_; |
82 | |
82 | |
|
|
83 | my $observe = $ob->contr->observe; |
|
|
84 | |
83 | # 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 |
84 | # give a description. (comment from C++) |
86 | # give a description. (comment from C++) |
85 | my $reply = |
87 | my $reply = |
86 | "The first column is the name of the body location.\r" |
88 | "The first column is the name of the body location.\r" |
87 | . "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" |
88 | . "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"; |
89 | |
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 | |
90 | $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail"; |
102 | $reply .= sprintf " %-20s %3s %5s %s\n", "Location", "You", "Avail", "What"; |
91 | for (0 .. cf::NUM_BODY_LOCATIONS - 1) { |
103 | for (0 .. cf::NUM_BODY_LOCATIONS - 1) { |
92 | my $msg = cf::object::slot_nonuse_name $_; |
104 | my $msg = cf::object::slot_nonuse_name $_; |
93 | $msg =~ s/^.*? a //; |
105 | $msg =~ s/^.*? a //; |
94 | $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[$_] } |
95 | if $ob->slot_info ($_) or $ob->slot_used ($_); |
111 | if $observe->slot_info ($_) || $observe->slot_used ($_); |
96 | } |
112 | } |
97 | |
113 | |
98 | $reply .= "You are not allowed to wear armor\r" |
114 | $reply .= "You are not allowed to wear armor\r" |
99 | unless $ob->flag (cf::FLAG_USE_ARMOUR); |
115 | unless $observe->flag (cf::FLAG_USE_ARMOUR); |
100 | $reply .= "You are not allowed to use weapons\r" |
116 | $reply .= "You are not allowed to use weapons\r" |
101 | unless $ob->flag (cf::FLAG_USE_WEAPON); |
117 | unless $observe->flag (cf::FLAG_USE_WEAPON); |
102 | |
118 | |
103 | $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY); |
119 | $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY | cf::NDI_CLEAR); |
104 | }; |
120 | }; |
105 | |
121 | |
106 | cf::register_command mark => sub { |
122 | #cf::register_command mark => sub { |
107 | my ($pl, $arg) = @_; |
123 | # my ($pl, $arg) = @_; |
108 | |
124 | # |
109 | if (length $arg) { |
125 | # if (length $arg) { |
110 | my $ob = $pl->find_best_object_match ($arg); |
126 | # my $ob = $pl->find_best_object_match ($arg); |
111 | |
127 | # |
112 | 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") |
113 | unless $ob; |
129 | # unless $ob; |
114 | |
130 | # |
115 | $pl->contr->mark ($ob); |
131 | # $pl->contr->mark ($ob); |
116 | $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title)); |
132 | # $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title)); |
117 | } else { |
133 | # } else { |
118 | my $ob = $pl->find_marked_object; |
134 | # my $ob = $pl->find_marked_object; |
119 | |
135 | # |
120 | $pl->reply (undef, $ob |
136 | # $pl->reply (undef, $ob |
121 | ? (sprintf "%s %s * is marked.", $ob->name, $ob->title) |
137 | # ? (sprintf "%s %s * is marked.", $ob->name, $ob->title) |
122 | : "You have no marked object."); |
138 | # : "You have no marked object."); |
123 | } |
139 | # } |
124 | }; |
140 | #}; |
125 | |
|
|
126 | for my $cmd ("run", "fire") { |
|
|
127 | my $oncmd = "${cmd}_on"; |
|
|
128 | cf::register_command $cmd => sub { |
|
|
129 | my ($ob, $arg) = @_; |
|
|
130 | |
|
|
131 | $ob->reply (undef, "Can't $cmd into a non adjacent square.") |
|
|
132 | if $arg < 0 or $arg >= 9; |
|
|
133 | |
|
|
134 | $ob->contr->$oncmd (1); |
|
|
135 | $ob->move_player ($arg); |
|
|
136 | }; |
|
|
137 | |
|
|
138 | cf::register_command "${cmd}_stop" => sub { |
|
|
139 | my ($ob) = @_; |
|
|
140 | |
|
|
141 | $ob->contr->$oncmd (0); |
|
|
142 | }; |
|
|
143 | } |
|
|
144 | |
141 | |
145 | cf::register_command mapinfo => sub { |
142 | cf::register_command mapinfo => sub { |
146 | my ($ob) = @_; |
143 | my ($ob) = @_; |
147 | |
144 | |
148 | my $observe = $ob->contr->observe; |
145 | my $observe = $ob->contr->observe; |