Building & Scripting > Scripting Board

Advanced Scripts

<< < (4/10) > >>

Kvetch:
15. MULTIPLE RECEIVE

This is useful for Quest where a mob requires you to bring several items.

You should put some message in when he receives each item, so the player

will know that he is on the right track.

Two things are important in receive scripts:

1. To put a small delay before the actions in the script.

2. To ensure that the mob gives back any items that are not part of the

   quest.

   The loop below is one way to do this:



 else

  wait 1

  drop %object%

  say I have no use for this.

 endif



or

else

 return 0

 %echo% %self.name% refuses the gift.

endif



(In the second example, note that there is no delay before the return 0).



EXAMPLE 1

This is used for the mob to receive 6 of the same object before handing

out the reward.



Commands:

context %actor.id%

if %object.vnum% == 1411

 wait 1

 eval Bag_Count %Bag_Count% + 1

 global Bag_Count

 mpurge dust

 say Thank you. I need a total of six bags to pay you a 100 $ bill.

 if %Bag_Count% == 6

  %load% obj 3307

  wait 1

  say thank you, %actor.name%! There ya go!

  give bill %actor.name%

  set Bag_Count 0

  global Bag_Count

  unset Bag_Count

 endif

else

 wait 1

 give %object% %actor.name%

 say Sorry, I cannot accept this.

endif



EXAMPLE 2

This example will make the mob hand out a reward after receiving

three different objects. The order doesn't count. The Quest will have

to be carried out in one session. If the objects are numerous and hard

to get, it would be better to use remote flags. Be sure to remove them

from the player.id after the Quest is performed.



Commands:

if %object.vnum% == 110

 wait 1

 eval obj1 %obj1% + 1

 global obj1

 mjunk needle

 say I need two buttons and a thread too.

elseif %object.vnum% == 111

 wait 1

 eval obj2 %obj2% + 1

 global obj2

 mjunk button

 say I need a thread and a needle too.

elseif %object.vnum% == 112

 wait 1

 eval obj3 %obj3% + 1

 global obj3

 mjunk thread

 say I need two buttons and a needle too.

else

 return 0

 wait 1

 say Nice try. Wrong item

endif

if (%obj1% >= 1) && (%obj2% >= 2) && (%obj3% >= 1)

 emote deftly sows the buttons back on the coat.

 say Here, you can have my lucky thimble as thanks for the help.

 %load% obj 4114 %actor%

 %send% %actor% %self.name% gives you a thimble.

 %echoaround% %actor% %self.name% gives a thimble to %actor.name%

 unset obj1

 unset obj2

 unset obj3

endif

--

Kvetch:
16. AVOID THE USE OF CHARMED MOBS IN RESTRICTED QUESTS

Use either of the following loops to avoid this mischief:



if %actor.vnum% < 0

 say Get lost, cheater!

else

 <hand out the reward, etc.>

endif



if %actor.is_pc%

 <hand out the reward, etc.>

else

 mkill %actor.master%

 mslay %actor%

endif

Kvetch:
17. MULTIPLE ANSWERS

Sometimes it can be very frustrating for a player, if he is convinced

that he answered a riddle correctly, but still didn't get the reward.

Below is a script to make the mob accept multiple answers to a riddle,

where both the answers 'ring' and 'a ring' or even 'a ring ping huzzah'

should be regarded as correct.

The argument needs to be set as *



if (%speech%/=ring)

 wait 2s

 em growls fiercely at you.

 %load% obj 14642

 give ring %actor.name%

else

 whisper %actor.name% Wrong answer!  Now it's DINNER time!

 mkill %actor.name%

endif



You can also use the phrase

 

if (%speech.contains(ring)%

Kvetch:
18. EXPERIENCE SCRIPT AND ONCE PER REBOOT SCRIPT

The reward for a Quest does not always have to be tokens or Quest Equip.

For all quests you should also get an amount of exp, and if the Quest

is a very large one, consisting of several parts, you should get some

exp each time you finish one of the parts.

You could also get exp for finding hidden exits or containers, for

getting to very remote places, for climbing trees, etc.

Below is a script that ensures that the same player only get this exp

once per reboot, while other players can still perform the same task

and get the exp. (This is to stop cheating with Quests by using bots).

The exp you get is also somewhat level related, so higher level players

get more exp than lower.

You can use this script on most trigger types, but NOT on mob scripts,

(at least if the mob is killable or purges itself at the end of the

script, that means the flag will be gone when the zone resets).

And NOT on RANDOM or TIMER or TIME scripts. (There has to be an %actor%).



context %actor.id%

if !%done%

  eval exp_amount %actor.level% * 10000

  *That is 500k for a level 50 player, and 100k for a level 10 player

  *Not actually that much, but the multiplyer is flexable.

  *The multiplyer always includes their level, just asa standard.

  *so as to make the quest reusable for higher level players also.

  nop %actor.exp(%exp_amount%)%

  *that just gave them the exp

  *also, if the player is under level 5.

  *You for a big quest, if you make any, you can give them a level.

  *like:

  nop %actor.exp(%actor.exp_needed%)%

  *if you want to give a player exp according to how much they need to level.

  eval ratio_exp %actor.exp_needed%/5

  nop %actor.exp(%ratio_exp%)%

  *then, lets give %done% a value

  set done 1

  global done

end

*and lets reset the context back to 0

context 0



Commands:

context %actor.id%

if !%done%

 eval am (%actor.level%*(2000+%random.200%))

 set ab %%actor.exp(%am%)%%

 eval %ab%

 eval done 1

 global done

endif

context 0



The loop:

context %actor.id%

if !%done%           *<action to be done ONCE per reboot>

 eval done 1

 global done

endif

context 0



is what sets the restriction. The rest of the script is for

calculating the amount of exp given.



To change the amount of exp gained: on a scale of 1 to 6.

[in the 'eval b (%actor.level%*<amount>)' ]

1: 2000  - use for finding hidden items

2: 4000  - use for finding start of a quest

3: 8000  - use for completing small quest tasks

4: 10000 - use for completing large quest tasks

5: 25000 - use for completing big quest.

6: (if quest can be done only once make it 50000)



You can also use the command 'nop' to set gold and exp. Sometimes it might

be logical to set negative amounts, for instance if someone enters an

obvious trap. The commands are for example:

nop %actor.gold(1000)%

nop %actor.exp(-1000)%



nop %actor.trade(10)%





Note that this script cannot be used on mobs, unless they are unkillable.

Once the mob is dead, the global flag is gone too.

Kvetch:
19. FOLLOWER IN RESCUE QUESTS

If you use the variable %actor.follower(name)% it is usually easier

to hand out the reward for a 'rescue quest' than if it's triggered by

the vnum of a certain mob entering a room. The script below also

checks if the follower actually is in the same room as the greeter,

which makes the quest pretty cheat proof.



* Note that the time delay at the start of the script is essential.

  The script won't work without it.



* Also remember that the (name) inside the ( ) is NOT the alias list,

  but the SHORT DESC of the mob.



Script type: Greet

Num arg: 100

Commands:

wait 1 s

if %actor.vnum% < 0

 if %actor.follower(Joe)% && %actor.follower_in_room(Joe)%

  <insert whatever actions you want here>

  %load% obj 3300

  give token %actor%

  drop token

  point token

  emote goes away with her child.

  %purge% Joe

  %purge% self

 else

  <insert whatever actions you want here>

 endif

endif



Here is another script that makes the follower enter portals and vehicles

after the master: It can be used for climb and descend objects too.



Script Type: Command

Num arg: 100

Arg: *

Commands:

if %cmd.mudcommand% == enter

 if %self.master% == %actor.name%

  enter %arg%

 endif

elseif %cmd.mudcommand% == climb

 if %self.master% == %actor.name%

  climb %arg%

 endif

elseif %cmd.mudcommand% == descend

 if %self.master% == %actor.name%

  descend %arg%

 endif

elseif %cmd.mudcommand% == jump

 if %self.master% == %actor.name%

  jump %arg%

 endif

elseif %cmd.mudcommand% == leave

 if %self.master% == %actor.name%

  leave

 endif

else

 return 0

endif

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version