/
roa/
roa/lib/boards/
roa/lib/config/
roa/lib/edits/
roa/lib/help/
roa/lib/misc/
roa/lib/plrobjs/
roa/lib/quests/
roa/lib/socials/
roa/lib/www/
roa/lib/www/LEDSign/
roa/lib/www/LEDSign/fonts/
roa/lib/www/LEDSign/scripts/
roa/src/s_inc/
roa/src/sclient/
roa/src/sclient/binary/
roa/src/sclient/text/
roa/src/util/
MTARGET

-=mobproc command=-
-=mtarget <char> <pc | npc | any> <%6N%0th char number>=-
-=mtarget <obj> <%6N%0th object number>=-
-=mtargetroom works as mtarget=-
-=mtargetzone works as mtargetroom but zone wide=-

This command is used in SPC_MOBPROC mobs.  It is used to have a mob target
either a character or an object in its particular room.  Once a target is
set using this command, certain substitutions can be made for that target
as the target is saved on the mob until another target is set or the mob
dies.  This command is a %6%Bvital%0 command and is very powerful in the
mobproc language.  

Argument requirements:
	Arg 1: 	must be either %6char%0 or %6obj%0.

	Arg 2:if %6char%0 targetted - must be %6pc%0, %6npc%0, or %6any%0.
	      if %6obj%0 targetted - Nth obj to target, %60%0 specifies 
	      %6random%0.

	Arg 3: 	Only valid when %6char%0 targetted,  Nth char to target,
		%60%0 specifies %6random%0.

Below are some examples to get you a bit familiar with the syntax.

...
mtarget char pc 0		<- picks a random pc in the room
mtarget char npc 0		<- picks a random npc in the room
mtarget char any 0		<- picks a random char (npc or pc) in room
mtarget char pc 5		<- picks the 5th pc in room
mtarget char npc 4		<- picks the 4th npc in room
mtargetroom char npc 4		<- picks the 4th npc in room

mtargetzone char npc 4		<- picks the 4th npc in zone

mtarget obj 0			<- picks a random object in the room
mtarget obj 4			<- picks the 4th object in the room
mtargetroom obj 4		<- picks the 4th object in the room

mtargetzone obj 4		<- picks the 4th object in the zone
...

In the above examples, the word 'picks' simply means that that particular
character or object has been targetted.  If the target fails, i.e., if a
mob tried to pick the 5th npc, but there was only 3 in the room, then the
%6character target%0 of that mob is still NULL.  Any subsequent calls to
%6mif%0 with a %6tarchar%0 prefix would return false.

Let's look at another example:

mtag begin                      <- set up begin tag
mtargetroom char pc 1		<- pick 1st pc in room  
mif tarcharroom
{
  say Hello, +C.  How are you this fine day?
  mgoto begin
}
say Drat, there are no players to play with in this room... :(
say I give up.
sniff
mend

In this example, we can see how %6mtargets%0 and %6mifs%0 work together.
Mob tries to target the 1st pc in the room.  If he was successful in
setting his target, the following %6mif%0 will return true and the block
will be executed, hence the mob will:

  say Hello, +C.  How are you this fine day?
  mgoto begin

However, if he was not successful in setting the target, because of
whatever reason (no pcs in room, or cant see them, pc that was targetted
has left before the mif was executed, etc) then the %6mif%0 block is
skipped and the mob will:

  say Drat, there are no players to play with in this room... :(
  say I give up.
  sniff
  mend

A note on + substitution characters:

	+N
	+n
	+C	: substitutes mob's %6character target%0 for +C, +N, or +n
		: Note, shopkeep subs will soon be in use with mobprocs
		  such as +r race, +h hometown, etc... when they are in,
		  this file will be updated to show you the exact subs.

	+O	: substitutes mob's %6object target%0 for +O, or +o

	Note: It is not useful to use subs _unless_ you are sure those
	      subs will be meaningful.  It's always wise to run an %6mif%0
	      test before you use a sub.  Refer again to the above example
	      and note how before +C is ever used, mob does an
		%6mif tarcharroom%0
	      before it tries to sub for +C.  In other words, it makes
	      sure that Vall is in the room before it tries to use his
	      name.  It doesn't hurt not to use these safe checks, and in
	      certain circumstances, you don't really want to, but it's
	      usually wise to do so.

Similar commands: MTARGETSET, MIF