Building & Scripting > Scripting Board

Advanced Scripts

<< < (2/10) > >>

Kvetch:
5. RANDOM SCRIPTS

These can be set up in different forms.



EXAMPLE 1:

The first example is the simplest one, which makes the mob perform

one of the actions 50% of the times.



Commands:

if %random.10% <= 5

 poke %actor.name%

else

 bite %actor.name%

endif



EXAMPLE 2:

The example below will make the mob perform 5 different actions randomly,

with about the same chance for each of them triggering.



Commands:

if %actor.vnum% < 0

eval number %random.5%

  switch %number%

   case 1

    snicker

    break

   case 2

    nudge %actor.name%

    break

   case 3

    giggle

    break

   case 4

    puke

    break

   default

    growl

    break

  done

endif



EXAMPLE 3:

The script below executes a random number of the same command,

(for instance to load a random number between 2 and 6 of the same object).

 

eval r 2+%random.4%

while %r%>0

eval r %r%-1

*do stuff

done



------------------------------

TO SET AN ACTOR TO RANDOM SCRIPTS:



set actor %random.char%

or

set actor %room.people%

to get a %actor% variable.





TO LOAD A RANDOM OBJECT FROM A ZONE

just do:

eval ovnum 12300 + %random.99%

%load% obj %ovnum%

Kvetch:
6. DOUBLE KEYWORD SCRIPT

Sometimes you might want to use a double keyword to trigger a speech

script, for instance two lines of a poem. The first line sets a counter,

the second line triggers the action you want.



SCRIPT 1

--

Argument: Keyword 1

commands:

context %actor.id%

<insert whatever action you want to happen here>

set HCounter 1

global HCounter



SCRIPT 2

--

Argument: Keyword 2

commands:

if %HCounter% == 1

 <insert whatever action you want to happen here>

 set HCounter 0

 global HCounter

 unset HCounter

endif



EXAMPLE:

This script will allegedly summon a Keeper to the room with the first

keyword, and make him open a door with the second. If you say the

second key phrase without the first, nothing will happen.

(The Keeper is never really there, it is all done with room scripts).



Part 1. say Key phrase 1

Commands:

%echo% You feel a strange presence as the Keeper appears before you.

%echo% The Keeper booms, '{cWWhat do you want, puny mortal?{c0'

set HCounter 1

global HCounter



Part 2. say Key phrase 2

Commands:

if %HCounter% == 1

  wait 2 s

  %echo% The door silently slides to one side.

  %door% 8145 east flags a

  wait 10 s

  %echo% The door silently slides shut again.

  %door% 8145 east flags b

  set HCounter 0

  global HCounter

  unset HCounter

else

  %echo% %actor.name%'s voice echoes hollowly from the walls of the room.

endif



Here is another variation. You want the script to react to three

different keywords, but the order in which they are said is not

important. Below is an example of how to do it.



if (%speech.contains(word1)%&&%speech.contains(word2)%&&%speech.contains(word3)%)

 %echo% The room echoes your words, '%speech%'

 <insert any wanted action here>

endif

Kvetch:
7. LOAD HELPERS

You may want a mob to load a helper, if he is under attack. To avoid

him loading an unrestricted number of helpers, use the following

hitprc trigger, when he drops below a certain hitprc:



1: load one mob

Num arg: 30 (or whatever you want it to be)

Commands:

if (%load_helper% != 1)

 %echo% whatever

 %load% mob 1838

 %force% helper kill %actor.name%

 set load_helper 1

 global load_helper

endif



OR

2:Load multiple mobs (5 in this example), one per combat round.

Commands:

if (%load_helper% <= 5)

 %echo% whatever

 %load% mob 1838

 eval load_helper (%load_helper%+1)

 global load_helper

endif



Make the loaded mob either helper or aggro, or

set a load trigger on the helper 'assist mob-name'

or use this line in the first script:

%force% mobname kill %actor%



If the loaded mob is aggro, set the load script to make it go away and purge

itself after a suitable wait. (We don't want aggro mobs hanging around).

Commands:

wait 20 T

%purge% self

Kvetch:
8. LOAD SEVERAL HELPERS - ALL AT ONCE

Maybe you want the mob to load several helpers? Use the script

below to restrict the number.



Commands:

if !(%all_done%)

eval load_mob 1

while (%load_mob% < 3)

%load% mob <vnum>

eval load_mob (%load_mob%+1)

done

set all_done 1

global all_done

end



(*3 being the amount you want to load.)




Kvetch:
9. MOB TRANSFORM AND HEAL

The script below makes the mob transform into a bigger and tougher mob,

when it drops below 80% of its hitpoints. The - before the vnum ensures

that the new mob is at full hp. This means that you can make a mob

virtually unkillable, by just loading itself with a negative vnum, each

time it drops below a certain point. It should be used with restraint,

since it is extremely frustrating to the player, but can be practical

on Quest mobs that you don't want to put in a peaceful room.



Hitprc 80

Commands:

if !%activated%

eval activated 1

global activated

wait 3 s

%echo% The kitten begins to mutate!

wait 2 s

%echo%  DEVOLVING INTO...

wait 2 s

%echo% ... A LIONESS!!

%echo The lioness roars at you!

mtransform  -203

end



The following script will make a mob transform itself in five different

shapes - it starts out with the mob 1200, then changes to 1201, when

it reaches 70% hit, then changes to 1202 when it reaches 70% the second

time etc. Each new mob is at full hp, and the fight will continue as

if nothing happened. (You will have to make all 5 mobs in OLC of course).



if !(%stop_transform%)

switch %self.vnum%

  case 1200

    %echo% The wizard transform to a lion!

    mtransform 1201

    break

  case 1201

    %echo% The wizard transform to a Dragon!

    mtransform 1202

    break

  case 1202

    %echo% The wizard transform to a Fire Flame!

    mtransform 1203

    break

  case 1203

    %echo% The wizard transform to a Demon!

    mtransform 1204

    break

  case 1204

    %echo% The wizard returns to his original shape!

    mtransform 1200

    set stop_transform 1

    global stop_transform

    break

  default

    break

done



The following script will make the mob transform into itself with full

hitpoints. This script is extremely irritating for the players, so

don't misuse it. Basically it should only be used for Quest mobs, which

are supposed to be unkillable.



%echo% {cWIt is impossible to kill <Whoever>, you'd better give it up.{c0

mtransform -%self.vnum%



Another way to make a mob heal itself during a fight would be the line:

%damage% %self% -100000


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version