Building & Scripting > Scripting Board

Advanced Scripts

<< < (5/10) > >>

Kvetch:
20. GOLD SCRIPT

The following script earns you money, by stirring a goldpan. It's a

command trigger, argument 'stir'.

Should only be used with restrictions, like flags or low random success.



If %arg%/=goldpan

 %send% %actor% Hey! You're rich!

 nop %actor.gold(50000)%

else

 %send% %actor% You cant stir that!

endif

Kvetch:

21. HUNT SCRIPT

Intelligent mobs are more interesting and challenging than those that

only stand around to get themselves slaughtered. The script below

makes the mob hunt whoever enters its cave, if they are above a

certain level and hp. It doesn't bother with small fry. The second

script makes it return to its cave after having hunted the intruder

ten times.



A similar script can be used to make the mob hunt down a player after

he fled.

Be careful how you use this! Preferably set it on non-aggros, so they

only bother their original opponent. If the mob is aggro, make sure

that it is set as stay_zone. We don't want a lot of high level aggros

suddenly roaming about in zones that usually are safe for newbies.



Dragon hunt

Commands:

if %actor.vnum% < 0

   Context %actor.id%

   Growl

if %actor.hitp% > 20

  if %actor.level% > 44

    wait 1

    Tell %actor.name% How DARE you disturb me!

    Wait 4s

     If %actor.room% != %self.room%

      %send% %actor% %self.name% yells, 'I'm gonna EAT you!!!'

      eval num 1

      global num

      mhunt %actor%

   else

     growl %actor%

    end

  end

end

end



Dragon return

Commands:

if %num% == 1

 eval count 0

 while %count% < 11

 wait 45 s

 eval count %count%+1

 if %count% == 10

   eval num 0

   global num

   mhunt 0

   shout Next time, mortal! MUHAHA!

   emo wanders back to his cave.

   mgoto 6055

   rest

  end

 done

end


Kvetch:
22. FLOWER GROW



A cute little script that makes a seed grow into a flower if you drop

it in a certain room. Actually the seed could also be made to grow

in any room with the words dirt, earth, soil or garden in the room

desc, by using the command line:



eval c %actor.room%

if (%c.name%/=dirt||%c.name%/=earth||%c.name%/=soil||%c.name%/=garden)



But if the reward item is any good, it would be better to restrict it

to a few rooms.



Room trigger - drop

if  (%actor.room% == 23205)||(%actor.room% == 23206)

 wait 1

 %echo% The seed falls into a small hole and you push the dirt around it.

 wait 1s

 %echo% After a moment a little sprout grows out of the ground.

 wait 2s

 %echo% The sprout quickly grows into a flower.

 %load% obj 23210

 %purge% %self%

else

 wait 1

 %echo% The little seed struggles to grow here but can't.

 %purge% %self%

end

Kvetch:
23. TWO ITEMS WORN TOGETHER BECOME STRONGER

Now it becomes more complicated. If you wear two certain items

at the same time, they switch into something more powerful. For

this you need 6 scripts, 2 wear, 2 remove and 2 random triggers,

(THIS SCRIPT MIGHT STILL BE BUGGY!)



#23637

Set Items, Wear script 1~

1 j 100

~

if %self.vnum% == 23605

 if !%actor.varexists(itemoneworn)%

  set itemoneworn 1

  remote itemoneworn %actor.id%

  if %actor.varexists(itemtwo)%

   set itemone 1

   remote itemone %actor.id%

   %send% %actor% %self.name% shimmers as you wear it, becoming more powerful.

   otransform 23607

  else

   %send% %actor% %self.name% flickers as if seeking another of its type.

  end

 end

end

~

#23638

Set Item, wear script 2~

1 j 100

~

if %self.vnum% == 23606

 if !%actor.varexists(itemtwoworn)%

  set itemtwoworn 1

  remote itemtwoworn %actor.id%

  if %actor.varexists(itemone)%

   set itemtwo 1

   remote itemtwo %actor.id%

   %send% %actor% %self.name% shimmers as you wear it, becoming more powerful.

   otransform 23608

  else

   %send% %actor% %self.name% flickers as if seeking another of its type.

  end

 end

end

~

#23639

Set Item, remove script 1~

1 l 100

~

if %self.vnum% == 23607

 wait 1

 if %actor.varexists(itemoneworn)%

  rdelete itemoneworn %actor.id%

  if %actor.varexists(itemone)%

   rdelete itemone %actor.id%

   %send% %actor% %self.name% flickers and becomes dull once more.

   otransform 23604

  end

 end

end

~

#23640

Set Item, Remove script 2~

1 l 100

~

if %self.vnum% == 23608

 wait 1

 if %actor.varexists(itemtwoworn)%

  rdelete itemtwoworn %actor.id%

  if %actor.varexists(itemtwo)%

   rdelete itemtwo %actor.id%

   %send% %actor% %self.name% flickers and becomes dull once more.

   otransform 23606

  end

 end

end

~

#23641

Set Items, random 2~

1 b 100

~

if %self.vnum% == 23606

 if %actor.varexists(itemtwoworn)% && %actor.varexists(itemone)%

  %send% %actor% %self.name% shimmers, becoming more powerful.

  otransform 23608

 end

elseif %self.vnum% == 23608

 if %actor.varexists(itemtwoworn)% && !%actor.varexists(itemone)%

  %send% %actor% %self.name% flickers and becomes dull once more.

  otransform 23606

 end

endif

~

#23642

Set Item, Random 1~

1 b 100

~

if %self.vnum% == 23605

 if %actor.varexists(itemoneworn)% && %actor.varexists(itemtwo)%

  %send% %actor% %self.name% shimmers, becoming more powerful.

  otransform 23607

 end

elseif %self.vnum% == 23607

 if %actor.varexists(itemoneworn)% && !%actor.varexists(itemtwo)%

  %send% %actor% %self.name% flickers and becomes dull once more.

  otransform 23605

 end

end

~

Kvetch:
24. DOOR SCRIPTS

There is often some confusion about what the DOOR triggers doo,

so here is a brief:

(NOTE! Door scripts can sometimes get screwed up if the Mud crashes at a

critical stage of the script, leaving a door open that really should be

closed. So loading a timered portal is usually a better option.)



%door% room.vnum direction field [value]



This command is used for adding, deleting, and modifying doors in room.

Direction determines which door is being changed, and can be north, south,

east, west, up, or down. If the door does not exist first, a new door can

be created.

Field is what property of the door is being changed. Valid fields are:



purge

    Removes the door completely. Value is not used.



description

    Value will be the new exit description.



flags

    Value will be the new door flags. This is a list of letters representing

    all the door flags.

    'a' EX_ISDOOR Exit has a door that can be opened and closed.

    'b' EX_CLOSED The door is closed.

    'c' EX_LOCKED The door is locked.

    'd' EX_PICKPROOF Lock can't be picked.

    'e' EX_SECRET  The door is secret.



 For example,

    %door% 13703 north room 13704

     *creates a new exit from room 13703 to room 13704

    wdoor 13703 north flags abe

     *creates a closed, secret door to the north in room 13703.

    %door% 13703 north flags ab

     *sets the door north as closed

    %door% 13703 north flags abc

     *sets the door north as closed and locked



key

   Value is the object number of the new key.



name

   Value is the new name of the door.



room

   Value is the room this door will connect to.



    For example,

    %door% 13703 north room 13704

     *creates a new door from room 13703 to room 13704

    %door% 13703 north name gate north

     *sets the name of the new door

    %door% 13703 north key 13704

     *sets the vnum of the key to the new door



A very useful option is to identify the vnums of the room the script is

set in and the room the actor just came from. Here are the command lines

for that:



eval r %self.vnum%

eval p %actor.room%



NOTE:

To create, open and close, or in any way modify a door in a room, the

script doesn't need to be set on that room. Any script, on any room, mob

or object can be set to modify a door, if the formats above are followed.



EXAMPLE 1

TYPE IN A CODE IN ONE SEQUENCE

1) Name         : code PWZ7438 ROOM

2) Intended for : rooms

3) Trigger types: Command

4) Numberic Arg : 0

5) Arguments    : PWZ7438

6) Commands:

wait 1s

*CLICK!*

%echo% The door silently slides to one side.

%door% 7551 west flags a

wait 10 s

%echo% The door silently slides shut again.

%door% 7551 west flags b



EXAMPLE 2. PRESS BUTTON

1) Name         : press button

2) Intended for : room

3) Trigger types: Command

4) Numberic Arg : 1

5) Arguments    : press

6) Commands:

if (button/%arg%)

%echo% the panel silently slides to one side, revealing an opening in the

wall.

%door% 7552 west flags a

wait 10 s

%echo% the panel silently slides shut again.

%door% 7552 west flags b

else

%send% %actor% press what?

endif



EXAMPLE 3

TYPE IN A CODE, NUMBER BY NUMBER (not quite sure if this works!)

1) Name         : open door 3674

2) Intended for : rooms

3) Trigger types: speech

4) Numberic Arg : 100

5) Arguments    : *

6) Commands:

if (3/%arg%)

 %echo% *click*

 set HCounter 1

 global HCounter

elseif (6/%arg%)

 if %HCounter% == 1

  %echo% *click*

  set HCounter 2

  global HCounter

 endif

elseif (7/%arg%)

 if %HCounter% == 2

  %echo% *click*

  set HCounter 3

  global HCounter

 endif

elseif (4/%arg%)

 if %HCounter% == 3

  %echo% *click*

  set HCounter 4

  global HCounter

 endif

endif

if %HCounter% == 4

 wait 1 s

 %echo% the door silently slides to one side.

 %door% 7552 west flags a

 wait 10 s

 %echo% the door silently slides shut again.

 %door% 7552 west flags b

endif

endif



EXAMPLE 4

REMOVE THE EXIT THE ACTOR JUST WALKED THROUGH

(Entry or greet trigger)

eval r %self.vnum%

eval p %actor.room%

if %direction% == north

 %door% %r% north purge

 %door% %r% north description There is no exit to the north.

 %door% %p% south purge

 %door% %p% south description There is no exit to the south.

 wait 1 s

 %echo% The door silently slides shut behind you.

endif

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version