4Dimensions Forum
Building & Scripting => Scripting Board => Topic started by: Kvetch on October 29, 2013, 06:10:31 pm
-
This will be a breakdown of all of the Scripts in the Advanced Scripts Document that is sent out to new scriptors. I will break each part down by their parts. Perhaps using this we can come up with new examples to use in an updated version of this handout. These current examples are what's in the current handout - I have skipped section 0, though may add on some of the information there at the end. Here is the index of what will be here.
1. PERSONAL REMOTE FLAG
2. PERSONAL GLOBAL FLAG
3. TAKE/GIVE PREVENT/RESTRICT
4. RESTRICT CONSEQUENCES OF AN ACTION TO A CERTAIN ROOM/ROOMS
5. RANDOM SCRIPTS
6. DOUBLE KEYWORD SPEECH SCRIPT
7. LOAD HELPER
8. LOAD SEVERAL HELPERS
9. MOB TRANSFORM AND HEAL
10. OBJECT TRANSFORM
11. ROOM SWITCH
12. RESTRICT ENTRY
13. RANDOM LOAD MOBS
14. RANDOM LOAD OBJECTS
15. MULTIPLE RECEIVE
16. AVOID THE USE OF CHARMED MOBS IN RESTRICTED QUESTS
17. MULTIPLE ANSWERS
18. EXPERIENCE SCRIPT AND ONCE PER REBOOT SCRIPT
19. FOLLOWER IN RESCUE QUESTS
20. GOLD SCRIPT
21. HUNT SCRIPT
22. GROW FLOWER
23. TWO ITEMS WORN TOGETHER BECOME STRONGER
24. DOOR SCRIPTS
25. CONTAINER SCRIPTS
26. MAKE A MOB HUNT A CERTAIN PLAYER
27. TIME SCRIPTS
28. NUM ARG ON OBJECT SCRIPTS
29. DAMAGE ACTOR IN PROPORTION TO HITPOINTS
30. ZONE ECHO
31. PREVENT FROM USING TWO OF THE SAME ITEM
32. CHECK FOR PLAYERS IN THE ROOM
33. STOP SCRIPT LOOP
34. %ACTOR% and %ACTOR.NAME%, HIS AND HER
35. %PURGE% RULES
36. COMMAND TRIGGERS
37. SET PLAYER FLAGS WITH SCRIPTS
38. RANDOM SPELLS ON A POTION
39. SEX CHANGE AND ABORTION PILLS
40. ARRAY EXAMPLES
-
1. PERSONAL REMOTE FLAG
This flag stays on the player file until it is removed by an imp or
another script.
OBS!!!! This flag is essential for most quests, because the reward
should always be lower after the first time a quest is performed,
if the quest is repeatable (to avoid script abuse).
Make sure that you choose a unique name for the flag, preferably
something referring to your zone or the quest/mob/object the script
is set on!
For example: mob3321, feniziawoman, textilesubskill, vikingmother etc.
Commands:
if !%actor.varexists(whatever)%
set whatever 1
remote whatever %actor.id%
endif
To make a script remove a flag from a player, use the line:
rdelete whatever %actor.id%
EXAMPLES
ONE TIME QUEST:
if !%actor.varexists(quest5)%
%send% %actor% Well done for doing this Quest!
set quest5 1
remote quest5 %actor.id%
else
%send% %actor% You cannot get in here again, %actor.name%!
%teleport% %actor% 3001
endif
QUEST EQUIPMENT RESTRICTION:
trigger type: wear
if !%actor.varexists(quest5)%
return 0
wait 1
%echoaround% %actor% This creature isn't worthy of using this item!
%send% %actor% You didn't do this Quest yourself, %actor.name%.
%send% %actor% So what makes you think you are worthy of the Reward?
%purge% %self.name%
endif
REMOVE REMOTE FLAG:
if %actor.varexists(quest5)%
rdelete quest5 %actor.id%
endif
MULTIPLE STEP QUEST:
if !%actor.varexists(whatever)%
set whatever 1
remote whatever %actor.id%
halt
elseif %actor.varexists(whatever)%
if %actor.whatever% == 1
set whatever 2
remote whatever %actor.id%
halt
elseif %actor.whatever% == 2
set whatever 3
remote whatever %actor.id%
halt
*etc. - for as many steps as you like...
endif
endif
-
2. PERSONAL GLOBAL FLAG
This flag only stays on the player file until crash or reboot. It can
ensure that a player only gets the same reward once per reboot, while
at the same time leaving the reward available for other players. A very
useful loop for Quests that you want the player to be able to do more
than once, but not TOO often.
Note that this flag cannot be used on a mob that purges itself after
the Quest. Next time the zone resets the player will be able to do the
quest again. The same thing happems if the mob simply is killed.
Use it on room scripts or mobs that are hard or impossible to kill.
Commands:
context %actor.id%
if !%done%
<insert whatever commands you want here>
eval done 1
global done
else
<insert whatever you want here>
endif
context 0
EXAMPLE
context %actor.id%
if %done% == 0
%send% %actor% You just found a treasure!
%load% obj 3300
eval done 1
global done
else
%send% %actor% Aaaaw - You have taken this treasure already!
endif
context 0
** Note: the last I knew context was not working right. Beware of that if you choose to use this**
-
3. TAKE/GIVE PREVENT/RESTRICT
This can be used to stop players from giving away Quest items, or from
picking up certain objects. Unless they have the flag, they cannot receive
or get the object. It can be used with or without messages to the actor
and/or victim (but with messages is usually better).
Use a give or get trigger on the object.
OBS!!!! Note that there cannot be any delay before the return 0 line,
or the script won't work.
(give trigger)
Commands:
if %victim.varexists(whatever)%
<insert whatever you want here>
else
<insert whatever you want here>
return 0
endif
(get trigger)
if !%actor.varexists(whatever)%
<insert whatever you want here>
return 0
else
<insert whatever you want here>
endif
EXAMPLE
if !%actor.varexists(whatever)%
%send% %actor% You can't get that!
%echoaround% %actor% %actor.name% tries in vain to get %object.shortdesc%
return 0
else
return 1
endif
-
4. RESTRICT CONSEQUENCES OF AN ACTION TO A CERTAIN ROOM/ROOMS
This can be used for instance if you want the player to get a nasty chock
the first time he picks up an item, but otherwise want the item to be
'normal'. It can also be used so that the player only hears a message or
performs an act if he is in a certain room.
Or maybe for a dragon, who will devour an intruder in its lair, but is
too lazy to hunt him if he flees.
Commands:
if %actor.room% == <vnum of room>
<insert whatever you want here>
endif
You can also use the following lines for similar effects:
if %actor.room% == %self.room%
if %actor.canbeseen%
EXAMPLE 1:
Object script, Trigger type: get
Commands:
if %actor.room% == 8128
wait 1
%damage% %actor% 200
%force% %actor% sit
%echo% {cRYou have awoken the wrath of Pharaoh!{c0
%echo% {cRNow suffer the consequences!{c0
wait 2 s
%load% mob 8119
%force% guardian kill %actor.name%
else
return 0
%echo% Better be careful with what you are getting!
%echo% The mummy crumbles to dust before your eyes.
%purge% %self.name%
endif
EXAMPLE 2:
Mob script, Trigger type: Greet
Num arg: 100
Commands:
wait 1
emote roars, letting out a blast of fire.
%damage% %actor% 100
wait 5 s
if %actor.room% == %self.room%
emote opens its gap to devour you.
mkill %actor.name%
else
tell %actor.name% Next time, mortal!
say damn - the brat got away!
endif
EXAMPLE 3:
The script below executes the action in all rooms between a set range of vnums
(the numbers need to be in a sequence)
*choose one of the 'a's below
eval a %actor%
eval a %self%
eval a %self.carried_by%
eval a %self.worn_by%
if %a.vnum%<0
if %a.room%>=<firstroom> || %a.room%<=<secondroom>
*do stuff
end
end
-
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%
-
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
-
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
-
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.)
-
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
-
10. OBJECT TRANSFORM
This can be used to make it appear as if an object breaks when it is
dropped, or to magically change into something new when you wear it
or remove it.
EXAMPLES:
1. Wear trigger:
if %self.vnum% == 23603
%send% %actor% You put a spider on your nose!
%echoaround% %actor% puts a spider on their nose. YUK!
%echo% The Spider spins its web over its new home!
otransform 23604
end
-----
2. Rem trigger:
if %self.vnum% ==23604
return 0
%send% %actor% You struggle but just cannot get the sticky web off your
face.
%echoaround% %actor% struggles but just cannot get the sticky web off their
face.
otransform 23603
end
-----
Drop trigger, object 230:
if %self.vnum% == 230
wait 1
%echo% As the vial hits the floor, it shatters into tiny fragments.
%echo% A pool of red fluid spreads on the floor.
%transform% 231
end
----
(231 is a pool of liquid with glass shards, with no take flag)
When an object transforms to a new vnum, the scripts set on the
original object will follow over to the new vnum. To avoid this, and
to make sure that the right scripts are attached to the new object,
you use the commands dg_attach and dg_detach:
dg_attach <vnum of trigger> <id of object to attach it to>
dg_detach <vnum of trigger> <id of object to remove it from>
-
11. ROOM SWITCH
This is a neat trick, a player with a certain flag is taken to a different
room than everybody else when he enters a certain room. The new room can
have an identical desc, but contain a reward, or perhaps an entrance to a
part of the zone that you cannot get to without the flag. Since there are
no messages it's hard for the players to figure out what happens.
Make two different rooms and use an Enter trigger:
if %actor.varexists(whatever)%
eval r %actor.room%
%door% %r% %direction% door <vnum of second room>
wait 1
%door% %r% %direction% door <vnum of first room>
end
EXAMPLE
if %actor.varexits(NewRoom)%
eval r %actor.room%
%door% %r% east door 1220
wait 1
%door% %r% east door 1221
end
-
12. ENTER RESTRICTION
This simple loop on an Enter script can stop the actor from entering the
room, unless he's got a certain flag. You can put in a message, but it is
even more frustrating without. The exit east is there, but nothing happens
when you type east.
EXAMPLE:
if !%actor.varexists(whatever)%
return 0
%send% %actor% Alas, you cannot go that way...
end
-
13. RANDOM LOAD MOBS
Sometimes it can be useful to make a mob load in random rooms,
when the zone resets. If nothing else it makes for more variation
and makes the mob a bit harder to find. (The mob only appears in
a new room if it is killed before the zone resets).
For: mobiles
type:load
narg: 100
commands:
set num1 <first.room.in.zone.vnum>
eval room (%num1%+%random.<total.number.of.rooms.in.zone>%)
if (%room.name%!=0)||("%room.name%"!="")
*this makes sure the room exists
mgoto %room%
end
-
14. RANDOM LOAD OBJECTS
Making objects load in random rooms is a bit trickier. You have
to make a mob that teleports around and drops them. Make the mob
purge itself after it dropped the object, if you want a new object
to appear every time the zone resets. Otherwise the object only
appears if the mob is killed before the reset. Both principles
can be equally useful.
The script below will make the mob drop a given number of the
item randomly in any of the rooms of the zone each time he is
loaded after a reboot or getting killed.
for: mobiles
type: load
narg: 100
arg:
commands:
set num1 <first.room.of.zone.vnum>
set total <total.amount.of.items.to.be.randomly.distributed>
set what <vnum.of.item.to.be.distributed>
set count 0
while (%count%<%total%)
eval count (%count+1)
%load% obj %what%
eval room (%num1%+%random.<total.number.of.rooms.in.zone>%)
mat %room% drop <name.of.the.item>
done
-
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
--
-
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
-
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)%
-
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.
-
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
-
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
-
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
-
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
-
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
~
-
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
-
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).
-
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...
-
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
-
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.
-
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%
-
30. ZONE ECHO
There is now a way to send the same echo to an entire zone, or to a
range of rooms within a zone.
Use %zecho% for sending echos to the entire zone
and %zrecho% for sending echos to a range of rooms.
The syntax for them are:
%zecho% <zone#> <message>
%zrecho% <zone#> <first room> <last room> <message>
where first room is the first room that will get the message
and last room is the last room to get it.
-
31. PREVENT FROM USING TWO OF THE SAME ITEM
This is useful if the item is very powerful, and there are more than one
location where you can wear/wield it (neck, wield, ear, ankle and legs/feet
for centaurs).
It can also be used for an action that is only triggered if the actor is
wearing/wielding a certain item.
The wear_loc numbers are the same that you get in ZEDIT when equipping a
mob.
EXAMPLE
if !%actor.varexists(whatever)%
return 0
%send% %actor% You are not worthy of using this item, %actor.name%
%echoaround% %actor% {cR%actor.name% is a THIEF!{c0
else
wait 1
eval w1 %actor.eq(16)%
*/Primary
eval w2 %actor.eq(28)%
*/Secondary
if ((%w1.vnum%==5641)||(%w2.vnum%==5641))
return 0
%send% %actor% You are not a strong enough warrior to handle two of these items.
endif
endif
-
32. CHECK FOR PLAYERS IN THE ROOM
Here's how how to find out other than the actor and self are in a room:
You will need to make a LOOP that has a 'look' at all the people in the room
with it, using the '.next_in_room' variable.
for example:
eval this_room %self.room%
eval person %this_room.people%
while %person%
<do action>
eval person %person.next_in_room%
done
explained-->:
"eval this_room %self.room%"
this line creates a new local variable called 'this_room' that contains
the identity of the room that the mob (self) is in.
so whenever you refer to 'this_room' you mean the room the 'self' is in.
You can use any room fields with this variable as if it was the room itself.
IE. %this_room.<room field>%
"eval person %this_room.people%"
This line creates a new local variable called 'person' that contains the
identity of the first person in room 'this_room'.
'person' can be now used the same way you use character variables, like
%actor.name%, you can use %person.name% to return that value.
"while %person%"
This like starts a loop that runs IF %person% doesn't equal 0, or rather,
if %person% exists.
"<do action>"
these actions can be anything you like to happen to that particular individual.
I would suggest that if you want it to respond to ALL the players in
the room, you have a check like this next:
if %person.vnum%<0
say %person.name% is a player.
elseif %person.vnum%>0
say %person.name% is a mob.
else
say There is an invisible immortal in the room.
endif
"eval person %person.next_in_room%"
This line changes the data in the local variable called 'person', with the identity of the NEXT person in the room list.
so for example if you had in a room:
Bob the builder. //Bob being an pc.
Hector the heroic. //Hector being an pc.
Sally the annoying newbie. //Sally being an pc.
A young mouse nibbles at your toes. //A young mouse being a npc.
if these people were in the room, the first person in the loop would
be Bob (%person.name% == Bob), then when it did the
'eval person %person.next_in_room%' the person.next_in_room is Hector.
So (%person.name% == Hector) now.
when it gets to 'a young mouse' then %person.vnum% will be greater
than 0 (all mobs have positive vnums (as far as we are concerned) players
have a vnum equal to -1).
Once the loop gets to 'a young mouse' the next person in the room
doesn't exist. so %person%==0, or NULL, nothing.
And the loop will stop.
"Done"
Done shows the script where then end of the loop is. (not the end of
the script)
if you want the while loop to stop in the middle of looping you can
use the 'break' command.
--------------
OKAY so lets apply that to your script.
Your script is:
eval Xecks %xecks%
set xecks %xecks%
global xecks
while %xecks% !=3
mecho %self utters yada yada
wait 2
mload mob 12099
wait 10
mforce xecks say i will protect you master
wait 1
mforce xecks fol jupiter
group xecks
mforce xecks massist jupiter
eval xecks %xecks% +1
set xecks %xecks%
global xecks
done
Edited:
From the information there is, i am assuming it is a MOB
trigger set to go off in a fight.
(so i am going to offer an alternative script for you. Just
to make it 'easier'. heh.)
firstly, instead of your previous script (above), use this.
All it does is load the 'xecks' mobs.
for: mobs
type: hitperc (or fight)
narg: 99 // i put 99 because if its a hitperc trigger set at 100
arg: // it can be a lil bugged sometimes.
commands:
while (%xecks%<3)
%echo% %self.name% utters yada yada
wait 2
%load% mob 12099
eval xecks %xecks%+1
global xecks
wait 10
done
Then put THIS script on the xecks themselves:
for: Mobs
type: load
Narg: 100
arg:
commands:
wait 1
eval this_room %self.room%
eval person %this_room.people%
while %person%
wait 10
eval jupi_name %person.alias%
if %jupi_name.contains(jupiter)%
* This checks to see if the word jupiter is in 'person's' list of alias's
if %person.fighting%
* if this is true, 'jupiter' is currently fighting someone.
(and therefore is assistable)
say I will protect you master!
wait 1
assist jupiter
else
%purge% self
* The purge will remove the mob if Jupiter IS NOT fighting.
%echo% %self.name% dissappears.
end
else
%purge% self
* The purge will remove the mob if Jupiter isn't in the room.
%echo% %self.name% dissappears.
end
eval person %person.next_in_room%
done
Basically this script, goes through each person in the room that this
mob loads in, and if one of the people in the room is called jupiter
and they are fighting someone, then this mob will assist, otherwise it
will remove itself.
-
33. STOP SCRIPT LOOP
A loop basically consists of an if-check and an endif.
If you want the loop to stop running the rest of the script if the
if-check is true, you put a 'halt' line at the end of the loop.
If you want the script to keep running after checking the loop, you put
a 'done' line at the end of it.
-
34. %ACTOR% and %ACTOR.NAME%, HIS AND HERS
Some players, who have chosen names that are also used for mobs, sometimes
are having problems doing the Quests, because the script code confuses them
with the mobs. Below are some info to remedy this problem as far as possible.
The difference between %actor% and %actor.name%:
%actor% is a reference to the player exactly. It's like the players unique
soul, the id number.
The script can use it directly for sending messages to, damaging and whatever.
It is also possible for the script to locate that player by name.
Which is why %actor.name% usually works as well.
Basically use %actor% with 'imm' commmands, and %actor.name% with mortal
commands. I.e.
%actor.name% needs to be used in normal commands, like tell, whisper, kill,
look, give... etc.
But %actor% needs to be used with scripts commands like: mkill, mhunt, %send%,
%echoaround%, %damage% %teleport% etc etc...
THE SEX OF THE ACTOR:
The sex of the actor is determined with %actor.sex%.
Below is the easiest way to ensure that you also get the right sex on
expressions like his/her, so you don't have to use 'their' in a script.
if %actor.sex% == male
eval he his
else
eval he her
end
%echo% %actor.name% looks very cool wielding %he% dagger!
You can use a similar loop for 'he' and 'she'.
if %actor.sex% == male
eval se he
else
eval se she
end
%echo% %actor.name% doesn't seem to know what %se% is doing!
-
35. %PURGE% RULES
for objects:
when the item is worn use: %purge% %self%
otherwise use: %purge% %self.name%
for mobs:
%purge% without arg won't make the mob purge itself, but everything else in the room.
To make a mob get rid of itself use: %purge% self
containers:
If you want a script to purge a container with content, you need to purge twice,
otherwise the content will ne on the floor.
OBS!!!!
mjunk is a safer way of purging mob inventory. (leaves no room message).
The %purge% scripts have a tendency to screw things up after the code update,
since they now can do a purge even outside the room where the mob is.
So the command line
%purge% sword
would purge the first sword it finds in the WHERE list, which might be disastrous.
This happens especially if there is no ball in the room with the script, because
someone took it away, or whatever. This is one reason for the weird equip bug where
certain items would inexplicably disappear from a player's inventory.
Go easy on the %purge% script, and consult a head builder about how to use them!
-
36. COMMAND TRIGGERS
1. Command triggers don't work for immortals, so you need a mort to test
those scripts, or use
atlev 50 >command>
2. If the command line is one of the usual mudcommands, you need to bypass
it by setting the trigger up like this:
Trigger Intended Assignment: Rooms
Trigger Type: Command , Numeric Arg: 100, Arg list: *
Commands:
if %cmd.mudcommand% == sit
%send% %actor% Go hang out somewhere else.
%teleport% %actor% 3000
else
return 0
endif
3. You can also set the command arg in 2 steps, like this:
Trigger Type: Command , Numeric Arg: 100, Arg list: push
Commands:
if boulder/=%arg||stone/=%arg%
wait 1 s
%echo% The boulder reluctantly rolls to one side.
else
wait 1 s
%send% %actor% push what?
endif
-
37. SET PLAYER FLAGS WITH SCRIPTS
example:
nop %actor.is_killer(on)%
------------
SOME UNSORTED EXAMPLES:
THIEF_ASSASSIN SCRIPT
Name: 'Near Death Trap Mahatma - 6318', VNum: [ 6300], RNum: [ 618]
Trigger Intended Assignment: Mobiles
Trigger Type: Greet , Numeric Arg: 100, Arg list: None
Commands:
* Near Death Trap stuns actor and takes all of their equipment.
wait 3 sec
say Here, have a quick trip to Hell.
wait 2 sec
%send% %actor% Mahatma plunges a black dagger into your back and takes all
your equipment.
%echoaround% %actor% Mahatma plunges a black dagger into %actor.name%'s back
and takes all of %actor.hisher% equipment.
eval stunned %actor.hitp%
%damage% %actor% %stunned%
while %actor.inventory%
eval item %actor.inventory%
eval item_to_purge %%actor.inventory(%item.vnum%)%%
eval stolen %item.vnum%
%purge% %item_to_purge%
%load% obj %stolen%
done
eval i 0
while %i% < 18
eval item %%actor.eq(%i%)%%
if %item%
eval stolen %item.vnum%
eval item_to_purge %%actor.eq(%i%)%%
%purge% %item_to_purge%
%load% obj %stolen%
end
eval i %i%+1
done
----------
This script makes a mob load and hand out random objects.
Name: 'trick or treat', VNum: [37522], RNum: [ 4109]
Trigger Intended Assignment: Mobiles
Trigger Type: Speech , Numeric Arg: 1, Arg list: trick treat
Commands:
wait 1s
if !%actor.inventory(34016)%
shout Get lost you beggar!
halt
end
say Oh my! Don't you look .. uhh.. how do you look? Well, anyway, nice get up.
em goes to get the treat bowl.
wait 4s
em comes back holding a huge bowl filled to the brim with all sorts of things.
wait 2s
em digs in the bowl and pulls something out.
set obj1 11060
set obj2 37571
set obj3 13315
set obj4 37572
set obj5 17430
set obj6 32089
set obj7 37573
set obj8 14771
set obj9 37574
set obj10 22360
set obj11 12300
set obj12 37575
set obj13 37547
set obj14 37576
set obj15 37577
eval obj %%obj%random.15%%%
%load% obj %obj%
wait 1s
eval object %self.inventory%
eval objname %object.name%
give %objname.car% %actor.name%
say There you go! Enjoy!
end
-
38. RANDOM SPELLS ON A POTION
Name: 'A Potion of Many Things', VNum: [10116], RNum: [ 2467]
Trigger Intended Assignment: Objects
Trigger Type: Load , Numeric Arg: 100, Arg list: None
Commands:
set spell_list 1 3 4 12 14 15 16 17 18 19 20 21 28 29 33 34 36 38 39 41 43 44
46 50 51 56 57 58 59 60
extract oval %random.30% %spell_list%
osetval 1 %oval%
extract oval %random.30% %spell_list%
osetval 2 %oval%
extract oval %random.30% %spell_list%
osetval 3 %oval%
global oval
%echo% The drink bubbles and foams.
-
39. SEX CHANGE AND ABORTION PILLS
OBS! You can have no waits in consume triggers!
#44603
fertility pill~
1 s 100
~
%send% %actor% You swallow a fertility pill.
%echoaround% %actor% %actor.name% hopefully swallows a fertility pill.
if %actor.sex% == female
nop %actor.is_pregnant(on)%
%send% %actor% It seems the Goddess Illythia made your wish come true!
%echoaround% %actor% It seems the Goddess Illythia made %actor.name%'s wish come true!
else
%send% %actor% Only females can get pregnant, you dork!
%echoaround% %actor% What a dork! Next he'll ask for an abortion, no doubt.
endif
~
#44609
abortion pill~
1 s 100
~
%send% %actor% You swallow a fertility pill.
%echoaround% %actor% %actor.name% hopefully swallows an abortion pill.
if %actor.sex% == female
nop %actor.is_pregnant(off)%
eval amount (%actor.hitp%/2)
%damage% %actor% %amount%
%send% %actor% You feel a wave of nausea and a searing pain.
%send% %actor% It's taken care of. But next time use a contraceptive instead!
%echoaround% %actor% Really - you'd think people could use contraceptives instead!
else
%send% %actor% Just use a condom, you dork!
%echoaround% %actor% What a dork! Next he'll ask for a pregnancy pill, no doubt.
endif
~
num arg 2
if %cmd.mudcommand%==eat
if ((%arg% == meat)||(%arg% == meatball))
if %actor.sex(female)%
nop %actor.sex(male)%
%echo% %actor.name% eats the meatballs.
%echo% %actor.name% has become a GIRL!
%purge% %self%
elseif %actor.sex(male)%
nop %actor.sex(female)%
%echo% %actor.name% eats the meatballs.
%echo% %actor.name% has become a BOY!
%purge% %self%
endif
else
return 0
endif
else
return 0
endif
-
40. ARRAY EXAMPLES
Name: 'Random Healing Spell', VNum: [57715], RNum: [ 3668]
Trigger Intended Assignment: Rooms
Trigger Type: Speech , Numeric Arg: 100, Arg list: heal
Commands:
eval heal %random.15% -1
eval text[0] %random.5% * -10
eval text[1] %random.8% * -7
eval text[2] %random.3% * -5
eval text[3] %random.6% * -7
eval text[4] %random.2% * -3
eval text[5] %random.5% * -3
eval text[6] %random.6% * -2
eval text[7] %random.6% * -3
eval text[8] %random.1% * -1
eval text[9] %random.1% * -10
eval text[10] %random.3% * -10
eval text[11] %random.7% * -2
eval text[12] %random.4% * -8
eval text[13] %random.2% * -3
eval text[14] %random.4% * -2
set heal2 %%text[%heal%]%%
eval heal2 %heal2%
%damage% %actor% %heal2%
set heal3 -%heal2%
eval heal3 %heal3%
%send% %actor% You have been healed by %heal3% hitpoints.
This one was written by me, there a few other examples by other people such as:
Name: 'Dog Emote - 192', VNum: [ 150], RNum: [ 150]
Trigger Intended Assignment: Mobiles
Trigger Type: Random , Numeric Arg: 10, Arg list: None
Commands:
eval max %random.4%
set txt[1] sniffs at you friendlily.
set txt[2] whimpers for some attention.
set txt[3] growls menacingly at your feet.
set txt[4] watches your every movement suspiciously.
set speech %%txt[%max%]%%
eval speech %speech%
emote %speech%
Name: 'Falling Fruit', VNum: [41005], RNum: [ 3014]
Trigger Intended Assignment: Rooms
Trigger Type: Random , Numeric Arg: 25, Arg list: None
Commands:
* Random
* Falling fruity affects
* Fruit of various descriptions falls from the tree and as it strikes
* players it cast's various affects on them
eval numOne %random.8%
eval numTwo %random.6%
eval numThr %random.16%
*
set fruit[1] apple
set fruit[2] banana
set fruit[3] pear
set fruit[4] orange
set fruit[5] kiwi
set fruit[6] starfruit
set fruit[7] peach
set fruit[8] strawberry
set color[1] red
set color[2] orange
set color[3] yellow
set color[4] green
set color[5] blue
set color[6] purple
set spell[1] cure light
set spell[2] heal
set spell[3] poison
set spell[4] blind
set spell[5] curse
set spell[6] cure blind
set spell[7] armor
set spell[8] bless
set spell[9] cure light
set spell[10] invisibility
set spell[11] strength
set spell[12] sense life
set spell[13] bless
set spell[14] sleep
set spell[15] sanc
set spell[16] chill touch
*
set type %%fruit[%numOne%]%%
set desc %%color[%numTwo%]%%
set affect %%spell[%numThr%]%%
*
eval type %type%
eval desc %desc%
eval affect %affect%
eval target %random.char%
*
%send% %target% A %desc% %type% falls from the tree and hits you.
%echoaround% %target% A %desc% %type% falls from the tree and hits %target.name%
.
dg_cast '%affect%' %target%
wait 1 sec
%echo% The %type% falls to the ground and vanishes.
http://www.dgscripts.n3.net/
Name: 'bbv find pkers', VNum: [*****], RNum: [ 3931]
Trigger Intended Assignment: Objects
Trigger Type: Command, Numeric Arg: 1, Arg list: locate
Commands:
if %arg%
if %arg.omr%==mobile
if %arg.is_pc%
if %arg.canbeseen%
if %arg.is_pk%
eval rname %arg.room%
%send% %actor% As you gaze into the present. You see an image of %arg.name% in %rname.name%
else
%send% %actor% They are not PK.
end
else
%send% %actor% %arg% doesn't appear to be around.
end
else
%send% %actor% %arg% doesn't appear to be around.
end
else
%send% %actor% That is not a player.
end
%echoaround% %actor% %actor.name% peers into the present.
else
return 0
end
Name: 'Room peeker', VNum: [25617], RNum: [ 5080]
Trigger Intended Assignment: Objects
Trigger Type: Command, Numeric Arg: 3, Arg list: peek
Commands:
switch %arg.mudcommand%
case north
set arg north
break
case south
set arg south
break
case east
set arg east
break
case west
set arg west
break
case up
set arg up
break
case down
set arg down
break
default
return 0
halt
break
done
eval thatRoom %%actor.room.%arg%(vnum)%%
if %thatRoom% > 0
%send% %actor% You peek %arg%.
dg_peek %actor% %thatRoom%
else
%send% %actor% Where do you want to peek?
end
-
if %arg%|=carvings
will return true if the arg is car, carv, carvi, carvin, carving or carvings
nop %actor.is_pregnant(on)%
will make a character pregnant
mlag <player> <1 to 300 miliseconds>
lags said player by the amount of time stated
if %self.contained_by%== vnum
checks to see if the item with this script is in the container that equals the vnum
if %findmob.21311(21332)%
checks to see if a certain mob is in a certain room.
(the first vnum is the room, the second is the mob)
so this script is looking for mob 21332 in room 21311
%actor.room.vnum%
gives you the vnum of the room the actor is in.
%actor.room.name%
gives you the name of the room the actor is in.
%actor.room.north(room).name%
gives the name of the room to the north of the actor.
%load% obj <vnum> %actor%
loads an object directly onto the player instead of having the mob have to drop the object and the player to pick it up.
%load% obj 1234 %actor% 16
allows you to load an object (12234) directly to the wear location (16-wielded) on the actor.
Note: if the actor is already wielding something, it will go to inventory.
%load% obj 1234 %actor.eq(wield)% does the same thing.
-
if %actor.eq(wield1)%
if %actor.eq(wield2)%
set wield %actor.eq(wield2)%
if %wield%
if %wield.vnum% == 1300
%echo% yes, that actor is wielding the correct weapon!
end
end
if %actor.eq(neck1)%
if %actor.eq(neck1).vnum% == 1300
etc
For positions on a player for use in scripts with the %actor.eq(<position>)% thing.
"hold", WEAR_HOLD
"held", WEAR_HOLD
"light", WEAR_LIGHT
"wield", WEAR_WIELD
"wield2", WEAR_WIELD_2
"rfinger", WEAR_FINGER_R
"lfinger", WEAR_FINGER_L
"neck1", WEAR_NECK_1
"neck2", WEAR_NECK_2
"body", WEAR_BODY
"head", WEAR_HEAD
"legs", WEAR_LEGS
"feet", WEAR_FEET
"hands", WEAR_HANDS
"arms", WEAR_ARMS
"shield", WEAR_SHIELD
"about", WEAR_ABOUT
"waist", WEAR_WAIST
"rwrist", WEAR_WRIST_R
"lwrist", WEAR_WRIST_L
"face", WEAR_FACE
"eyes", WEAR_EYES
"hips", WEAR_HIPS
"legs2", WEAR_LEGS_2
"feet2", WEAR_FEET_2
"antenna", WEAR_ANTENNA
"tail", WEAR_TAIL
"horns", WEAR_HORNS
"focus", WEAR_FOCUS
The ones in the quote marks are what you can use, minus the quote marks as in:
if %actor.eq(hands)%
say You have something on your hands!
end
-
as first line in the script.put an * as arg under 5, and then the line
if %cmd.mudcommand%==<mud command used>
example:
if %cmd.mudcommand%==put
as first line in the script.
-
To load an object into a container use
%load% obj <vnum> %container%
*load container
%load% obj <obj vnum>
*save the reference to the container (so it doesnt get wiped when you load the next item)
set cont %loaded%
*then load each item you want to put in the container.
%load% obj <vnum> %cont.name%
etc etc...
Or use
%load% obj <obj vnum> <room vnum>
to load the object in a different room than the script is set on.
To load new objects at each zone reset
when you load the container the first time...
just save the %loaded% value in a global
so the next time you wanna put something in it...
you just keep using the %cont%
if !%cont%
%load% obj <cont vnum>
set cont %loaded%
global cont
%load% obj 12346 %cont%
else
%load% obj 12346 %cont%
end
-
Name: 'Load_Breakfast', VNum: [ 4409], RNum: [ 441]
Trigger Intended Assignment: Rooms
Trigger Type: Time, Numeric Arg: 5, Arg list: None
Commands:
%echo% A gong sounds throughout the fort, notifying everyone that breakfast is about to begin.
wait 3s
%load% mob 4445
%echo% Parading into the room, a gathering of serving wenches brings out the breakfast.
%echo% They set the tables at neatly as possible, cheeses on plates and loaves of bread in cloth-covered baskets.
%load% obj 4407
set cont %loaded%
%load% obj 4400 %cont.name%
%load% obj 4400 %cont.name%
%load% obj 4400 %cont.name%
%load% obj 4400 %cont.name%
%load% obj 4409
set cont %loaded%
%load% obj 4401 %cont.name%
%load% obj 4401 %cont.name%
%load% obj 4401 %cont.name%
%load% obj 4401 %cont.name%
%load% obj 4411
%load% obj 4402
%load% obj 4402
%load% obj 4402
%load% obj 4402
wait until 7:00
%echo% As breakfast finishes, the serving wenches get to work again and begin to pick the tables clean.
%echo% They skillfully stack plates and silverware and carry it off to be washed.
set o %self.contents%
while %o%
set next %o.next_in_list%
if %o.vnum% == 4407 || %o.vnum%== 4409 || %o.vnum% == 4402 || %o.vnum% == 4400 || %o.vnum%== 4401 || %o.vnum% == 4411
%purge% %o%
end
set o %next%
done
set m %self.people%
while %m%
set next %m.next_in_room%
if %m.vnum% == 4445
%purge% %m%
end
set m %next%
done
-
To get the current season, do %time.season%.
The seasons are:
winter (month 0-3), spring (month 4-7), summer (month 8-12) and autumn (month 13-16).
Note that the total amount of months is 17, and that summer has 5 months.
All other seasons have 4 months.
To get the current moon phase, do %time.moon%.
The moon phases are:
"full", "waning gibbous", "last quarter", "waning crescent", "new", "waxing crescent", "first quarter" and "waxing gibbous".
For example, if something in a script should only happen if the moon is waning gibbous, do
if %time.moon% == waning gibbous
%echo% leprechauns take over the world
end
Keep in mind that %time.moon% will return the current moon phase even if it's daytime.