Building & Scripting > Scripting Board
Advanced Scripts
Kvetch:
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
Kvetch:
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
Kvetch:
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**
Kvetch:
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
Kvetch:
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
Navigation
[0] Message Index
[#] Next page
Go to full version