#! perl # mandatory # wizard commands sub dm($) { my ($ob) = @_; if ($ob->flag (cf::FLAG_WIZ)) { $ob->reply (undef, "You are already the Dungeon Master!"); return 0; } else { $ob->flag (cf::FLAG_WIZ , 1); $ob->flag (cf::FLAG_WIZPASS, 1); $ob->flag (cf::FLAG_WIZCAST, 1); $ob->flag (cf::FLAG_WIZLOOK, 1); $ob->contr->do_los (1); $ob->contr->ns->update_command_faces; $ob->reply (undef, "Ok, you are the Dungeon Master!"); return 1; } } sub hide($) { my ($ob) = @_; if ($ob->contr->hidden) { $ob->contr->hidden (0); # $ob->invisible (1); $ob->reply (undef, "You are no longer hidden!"); } else { $ob->contr->hidden (1); $ob->reply (undef, "You are now hidden!"); } } cf::register_command dm => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_dm"); dm $ob and $ob->reply (undef, "The Dungeon Master has arrived!", cf::NDI_UNIQUE | cf::NDI_ALL | cf::NDI_LT_GREEN); 1 }; cf::register_command dmhide => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_dm"); dm $ob and hide $ob; 1 }; cf::register_command hide => sub { my ($ob, $arg) = @_; return $ob->reply (undef, "Sorry, you are not the DM!") unless $ob->flag (cf::FLAG_WIZ); hide $ob; 1 }; cf::register_command nodm => sub { my ($ob, $arg) = @_; return $ob->reply (undef, "Sorry, you are not the DM!") unless $ob->flag (cf::FLAG_WIZ); $ob->contr->hidden and hide $ob; $ob->flag (cf::FLAG_WIZ , 0); $ob->flag (cf::FLAG_WIZPASS, 0); $ob->flag (cf::FLAG_WIZCAST, 0); $ob->flag (cf::FLAG_WIZLOOK, 0); $ob->contr->do_los (1); $ob->contr->ns->update_command_faces; 1 }; cf::register_command shutdown => sub { my ($ob, $arg) = @_; return $ob->reply (undef, "Sorry, you can't shutdown the server.") unless $ob->flag (cf::FLAG_WIZ); my $name = $ob->name; cf::cleanup ("dm '$name' initiated shutdown" . ($arg ? " with reason: $arg" : "."), 0); 1 }; cf::register_command kick => sub { my ($ob, $arg) = @_; return unless $ob->flag (cf::FLAG_WIZ); my $other = cf::player::find_active $arg or return 0; $other->kick ($ob); $ob->reply (undef, "$arg is kicked out of the game.", cf::NDI_UNIQUE | cf::NDI_ALL | cf::NDI_RED); 1 }; cf::register_command goto => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_goto"); my ($path, $x, $y) = split /\s+/, $arg, 3; $ob->goto ($path, $x, $y); 1 }; cf::register_command teleport => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_teleport"); cf::async { $Coro::current->{desc} = "teleport $arg"; my $other = cf::player::find $arg or return $ob->reply (undef, "$arg: no such player."); $ob->goto ($other->maplevel, $other->ob->x, $other->ob->y); }; 1 }; cf::register_command wizpass => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_wizpass"); my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZPASS); $ob->flag (cf::FLAG_WIZPASS, $new_val); $ob->reply (undef, $new_val ? "You will now walk through walls.\n" : "You will now be stopped by walls.\n", ); 1 }; cf::register_command wizcast => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_wizcast"); my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZCAST); $ob->flag (cf::FLAG_WIZCAST, $new_val); $ob->reply (undef, $new_val ? "You can now cast spells anywhere." : "You now cannot cast spells in no-magic areas.", ); 1 }; cf::register_command wizlook => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_wizlook"); my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZLOOK); $ob->flag (cf::FLAG_WIZLOOK, $new_val); $ob->contr->do_los (1); $ob->reply (undef, $new_val ? "You can now look through walls." : "You will now see the same thing as you would normally.", ); 1 }; cf::register_command reset => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_reset"); my $unique = $arg =~ s/^\s*--unique\s*//; my $map = $ob->map; my @pl = $map->players; $_->enter_link for @pl; cf::async { my $name = $map->visible_name; $Coro::current->{desc} = "reset $name"; $map->clear_unique_items if $unique; $map->reset; $_->leave_link for @pl; $ob->reply (undef, "$name was reset."); }; 1 }; cf::register_command observe => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_observe"); my $other = cf::player::find_active $arg; $ob->contr->set_observe ($other ? $other->ob : undef); 1 }; for my $command (qw(summon arrest banish)) { my $method = "command_$command"; cf::register_command $command => sub { my ($ob, $arg) = @_; return unless $ob->may ($method); $ob->$method ($arg) }; }