--- deliantra/server/ext/commands.ext 2007/03/02 10:43:01 1.21 +++ deliantra/server/ext/commands.ext 2007/03/02 10:54:59 1.23 @@ -89,6 +89,57 @@ 1 }; +cf::register_command applymode => sub { + my ($ob, $arg) = @_; + my @types = ("nochoice", "never", "always"); + my $mapping = { + nochoice => 1, + never => 2, + always => 3, + }; + + my $oldmode = $ob->contr->unapply; + my $oldmode_name = $types[$oldmode]; + + return $ob->reply (undef, "applymode is set to $oldmode_name") + unless $arg; + + return $ob->reply (undef, "applymode: Unknown options '$arg', valid options are @types") + unless $mapping->{$arg}; + + $ob->contr->unapply ($mapping->{$arg} - 1); # HACK: because of the $mapping->{$arg} check before, where $arg should not be 0 + # but $arg would be 0 if a user enters an incorrect value + $ob->reply (undef, "applymode" . ($oldmode == $ob->contr->unapply ? "" : " now") . " set to " . $types[$ob->contr->unapply]); + + 1 +}; + +cf::register_command petmode => sub { + my ($ob, $arg) = @_; + my @types = ("normal", "sad", "defend", "arena"); + my $mapping = { + normal => 1, + sad => 2, + defend => 3, + arena => 4, + }; + + my $oldtype = $ob->contr->petmode; + my $oldtype_name = $types[$oldtype]; + + return $ob->reply (undef, "petmode is set to $oldtype_name") + unless $arg; + + return $ob->reply (undef, "petmode: Unknown options '$arg', valid options are @types") + unless $mapping->{$arg}; + + $ob->contr->petmode ($mapping->{$arg} - 1); # HACK: because of the $mapping->{$arg} check before, where $arg should not be 0 + # but $arg would be 0 if a user enters an incorrect value + $ob->reply (undef, "petmode" . ($oldtype == $ob->contr->petmode ? "" : " now") . " set to " . $types[$ob->contr->petmode]); + + 1 +}; + cf::register_command usekeys => sub { my ($ob, $arg) = @_; my @types = ("inventory", "keyrings", "containers"); @@ -104,12 +155,14 @@ return $ob->reply (undef, "usekeys is set to $oldtype_name") unless $arg; - return $ob->reply (undef, "usekeys: Unknown options '$arg', valid options are inventory, keyrings, containers") + return $ob->reply (undef, "usekeys: Unknown options '$arg', valid options are @types") unless $mapping->{$arg}; $ob->contr->usekeys ($mapping->{$arg} - 1); # HACK: because of the $mapping->{$arg} check before, where $arg should not be 0 # but $arg would be 0 if a user enters an incorrect value $ob->reply (undef, "usekeys" . ($oldtype == $ob->contr->usekeys ? "" : " now") . " set to " . $types[$ob->contr->usekeys]); + + 1 }; cf::register_command afk => sub { @@ -117,6 +170,8 @@ $ob->contr->ns->afk ($ob->contr->ns->afk ? 0 : 1); $ob->reply (undef, $ob->contr->ns->afk ? "You are now AFK" : "You are no longer AFK"); + + 1 }; cf::register_command sound => sub { @@ -124,6 +179,8 @@ $ob->contr->ns->sound ($ob->contr->ns->sound ? 0 : 1); $ob->reply (undef, $ob->contr->ns->sound ? "The sounds are enabled." : "Silence is golden..."); + + 1 }; cf::register_command brace => sub { @@ -131,6 +188,8 @@ $ob->contr->braced ($ob->contr->braced ? 0 : 1); $ob->reply (undef, $ob->contr->braced ? "You are braced." : "Not braced."); + + 1 }; # XXX: This has a bug. After one sets his wimpy level to 0 and resets it to @@ -147,6 +206,8 @@ if $arg =~ /^\d+$/ and $arg <= 100; $ob->reply (undef, "Incorrect parameters for wimpy: $arg"); + + 1 }; cf::register_command peaceful => sub { @@ -159,6 +220,8 @@ #$ob->contr->peaceful ($ob->contr->peaceful ? 0 : 1); #$ob->reply (undef, $ob->contr->peaceful ? "You will attack other players." : "You will not attack other players."); + + 1 };