--- deliantra/server/lib/cf/match.pm 2010/08/28 00:05:33 1.28 +++ deliantra/server/lib/cf/match.pm 2017/01/29 02:47:05 1.37 @@ -1,22 +1,22 @@ # # This file is part of Deliantra, the Roguelike Realtime MMORPG. -# -# Copyright (©) 2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team -# +# +# Copyright (©) 2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team +# # Deliantra is free software: you can redistribute it and/or modify it under # the terms of the Affero GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the Affero GNU General Public License # and the GNU General Public License along with this program. If not, see # . -# +# # The authors can be reached via e-mail to # @@ -36,7 +36,7 @@ slaying = "key1" -Match the object if it has an object with name C and +Match the object if it has an object with name C and slaying C in it's inventory: has (name = "force" and slaying = "poison") @@ -270,7 +270,7 @@ Object attributes that consist of a single value (C, C, C<value> and so on) can be specified by simply using their name, in which -acse their corresponding value is used. +case their corresponding value is used. =item array objects attributes @@ -284,7 +284,7 @@ =item functions Some additional functions with or without arguments in parentheses are -available. +available. They are documented in their own section, below. =item { BLOCK } @@ -334,6 +334,27 @@ This simply evaluates to false, and simply makes matching I<never> a bit easier to read. +=item archname + +The same as C<< { $_->arch->archname } >> - the archetype name is commonly +used to match items, so this shortcut is provided. + +=item resist_xxx + +Resistancy values such as C<resist_physical>, C<resist_magic>, +C<resists_fire> etc. are directly available (but can also be accessed via +array syntax, i.e. C<resists[ATNR_FIRE]>). + +=item body_xxx_info and body_xxx_used + +Every body location (e.g. C<body_neck_info>, C<body_arm_used> etc.) can +be accessed via these functions (these are aliases to more cumbersome C<< { +$_->slot_info (body_xxx) } >> and C<slot_used> method calls). + +Example: (e.g. on a door) match only players that have no arms. + + match type=PLAYER and body_arm_info=0 + =item has(condition) True iff the object has a matching inventory object. @@ -461,8 +482,24 @@ none => sub { 0 }, + archname => sub { + '$_->arch->archname' + }, ); + # resist_xxx + for my $atnr (0 .. cf::NROFATTACKS - 1) { + $special{"resist_" . cf::attacktype_name ($atnr)} = sub { "\$_->resist ($atnr)" }; + } + + # body_xxx_info and _used + for my $slot (0 .. cf::NUM_BODY_LOCATIONS - 1) { + my $name = cf::object::slot_name $slot; + + $special{"body_$name\_info"} = sub { "\$_->slot_info ($slot)" }; + $special{"body_$name\_used"} = sub { "\$_->slot_used ($slot)" }; + } + sub constant { ws; @@ -477,8 +514,6 @@ our $flag = $cf::REFLECT{object}{flags}; our $sattr = $cf::REFLECT{object}{scalars}; - # quick hack to support archname, untested - $sattr->{archname} = "W"; our $aattr = $cf::REFLECT{object}{arrays}; our $lattr = $cf::REFLECT{living}{scalars}; @@ -718,7 +753,7 @@ } if (0) {#d# - die parse 1, 'stats.pow'; + die parse 1, 'type=PLAYER and body_arm_info=0'; exit 0; }