Building & Scripting > Scripting Board

Advanced Scripts

<< < (6/10) > >>

Kvetch:
25. CONTAINER SCRIPTS



It is now possible for mobs to detect

1. whether a certain item is in a container, and

2. whether a certain number of that item are in a container.

This should be extremely useful in Quest scripts.

You can make it look both for vnums and alias. The variables are

if (%object.count(vnum)% == #)

if (%object.count(alias)% == #)

* 'count' will give you a value of the amount of that item.

if %object.has_in(vnum)%

if %object.has_in(alias)%

* 'has_in' will give you a value of 0 or 1



The vnum option is more exact, but the alias can be used in certain

quests, for instance if you want the mob to accept several different

objects with the alias 'sword'.



Below is an example with explanations:



EXAMPLE

eval objname %object.name%           *1)

wait 3

if %object.vnum% == 6341             *2)

 if (%object.count(6345)% == 10)     *3)

  wait 1 s

  say Thank you, %actor.name%, but you must bring that to Delinda.

  say She is in charge of the blue grapes.

  give basket %actor.name%

 elseif %object.count(6346)% == 10    *4)

  wait 1 s

  say thank you, %actor.name%.

  %purge% basket

  emote empties the basket into the bowl of the scale.

  wait 2

  %load% obj 6341

  give basket %actor.name%

  %load% obj 6349

  give brandy %actor.name%

  say There you go, now don't you drink it all at once.

  chuck

  say You can actually sell it in the ICTGs.

 else                              *5)

  wait 1 s

  say Hey! I can only take full baskets, or the weighing will be messed up.

  say All grapes have to be of the same kind too!

  wait 2 s

  give basket %actor.name%

  say You go and fill it up, and then come back again.

 endif

else                                 *6)

 say I cannot accept this.

 say You have to use our special baskets, or the grapes will be bruised.

 give %objname.car% %actor.name%      *7)

endif



*1) get the name of the object that was given

*2) is this the right container?   YES

*3) are they the right grapes?     NO

*4) do they have enough grapes?    YES

*5) only accept if they are the right ones and you have enough

*6) else give the container back

*7) ensure that the actor gets the right object back

    One reason why give scripts sometimes screw up is that many objects

    have more than one alias.

    So if you put the line 'give %object.name% %actor.name%' in a script,

    it might come out as   'give bag green' instead of 'give bag %actor%'.

    The way to avoid this error is to use the following lines:

      eval objname %object.name%

      give %objname.car% %actor.name%

    %objname.car% ensures that only the first word of the alias list is used.

    (Of course using just %object% does the same thing with the code update).

Kvetch:
26. MAKE A MOB HUNT A CERTAIN PLAYER

Having a mob hunting a certain player can be very useful, and even quite

realistic. The mob will continue hunting, even after the player logs out

and on again, right until the mud reboots or either the mob or the player

is dead.

This should be used with caution, at least if the mob is high level,

since the hunter is almost impossible to get away from. It is advisable

to make a return script for the mob, where it returns to its home after

a given time, or this could turn out too irritating.



Trigger Intended Assignment: Mobiles

Trigger Type: Enter, Numeric Arg: 100, Arg list: None

Commands:

   %echo% The dog barks loudly, straining at its chain.

   wait 10 s

   %echo% The chain suddenly snaps! The dog is free!

   mhunt %actor%

   wait 2 s

   %echo% Woof! Woof! Woof...


Kvetch:
27. TIME SCRIPTS

You can make a time script trigger any time of day, several times a day

by using time triggers with delays. The options are:

wait 1   = (almost immediate result)

wait 1s  = (1 seconds delay)

wait 1t  = (one ticks delay = 71 s)



You can also make an event occur once a day, once a week or once a year.

The options in the mud are:

hour   = 0-23

day    = 1-35

week   = 1-7

month  = 0-15

year   = 560 days

There are even names on the weekdays and months, if you want to make

things more 'realistic'.



The variables to use are:

%time.hour%

%time.day%

%time.week%

%time.month%

%time.year%



EXAMPLE 1:

%echo% Today is the %time.day%th of the %time.month%th month.



EXAMPLE 2:

if (%time.hour% == 10)&&(%time.day% == 30)&&(%time.month% == 5)

%echo% The time is now 10 am on the 30th of the 5th month of the year.

end


Kvetch:
28. NUM ARG ON OBJECT SCRIPTS



The num arg is different in scripts for objects if the trigger is a

COMMAND thrigger. It is important to set this num arg correctly.

Command scripts work differently if the object is on the floor, in

inventory or worn, depending on how you set the num arg.



1 = held or worn

2 = in inventory

4 = room

3 = 1 and 2

5 = 1 and 4

6 = 2 and 4

7 = 1 and 2 and 4



so 3 will work both if the object is in the room or in the inventory,

7 will work in all positions.

Kvetch:
29. DAMAGE ACTOR IN PROPORTION TO HITPOINTS

Sometimes it can be useful not to have a set damage amount, but one

that is in proportion to the actors hp. This way a newbie takes less

damage than an old player. The following lines will damage the actor

to half their hitpoint:



eval amount (%actor.hitp%/2)

%damage% %actor% %amount%

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version