home » builders » builder's lessons » rand prog
Rand programs
Rand progs continually activate over and over and over when someone is in the area. They are a resource intensive prog so they should only be used if no other prog type will be able to do the job.
>rand_prog 1~ mpecho The moonclaw trips over his own feet. mpecho It makes you wonder what sort of thief he makes! ~ |
This program is on the Moonclaw Guild Member in Faerdale. This one is a fairly simple program that will have a 1% chance of happening every tick. For things like that that happen over and over while a player is in the room, keep the percentage very low so as to not be spammy.
>rand_prog 10~ if wear_loc($o) != -1 if manaprcnt($r) < 95 if questr(28500, 7, 6, $r) < 60 mpechoat $r You feel a surge of power. mpmadd $r currmana 10 mpmadd $r questr 28500 7 6 1 else mpechoat $n You crystal chain of power shatters into a million pieces. mpjunk i28418 endif endif endif ~ |
This program is on a magical object in an area. It has a 10% chance of triggering each tick. It checks to see if the item is worn, and that the PC's mana percentage is less than 95%. It also checks the quest bits in a given area. If all these conditions are satisfied it gives back 10 mana to the wearer and adds 1 to their quest bits. After 60 uses the object is junked. Often items like this stop working or are junked after so many uses. This allows for a super powerful item to be in the game, without disturbing game balance.
Another option instead of using quest bits in the area, would have been to use checks on value5. This would have saved quest bits.
>rand_prog 100~ if rand(40) if quest(0, 5, $r) == 6 mpechoat $n Blackstaff looks up at you. mpechoaround $n Blackstaff looks up at $n. sayto $r You must be hungry. emote utters some strange words and moves his hands. mpquiet on mpoload 8154 drop i8154 mpoload 8111 drop i8111 mpquiet off mpechoat $n Blackstaff places a fine feast of food before you. mpechoaround $n Blackstaff places a fine feast of food before $n. mpechoat Blackstaff returns to his studies. mpmset $r quest 0 5 7 else if quest(0, 5, $r) == 7 sayto $r Ahhh here we go. sayto $r I can cure her, but I will need some ingredients. mpecho Blackstaff turns the pages of the tome he had been reading through. mpmset $r quest 0 5 8 else if quest(0, 5, $r) == 8 sayto $r Now they wont be easy to find. sayto $r I need Brackish Herbs, Dragons Blood, and Golden Thorn. say Now let me think, where can these be found mpmset $r quest 0 5 9 else if quest(0, 5, $r) == 9 sayto $r Talk to Robyn Kendrick in Corwell about Brackish Herbs. sayto $r I understand dragons are rampaging in near Zhentil Keep. sayto $r Talk to Foxfire in Tethir Forest about the Golden Thorn. say Be quick. I will prepare the rest of the spell while you are gone. mpmset $r quest 0 5 10 endif endif endif endif endif if quest(0, 5, $r) == 10 if quest(5, 1, $r) == 1 if quest(6, 1, $r) == 1 if quest(7, 1, $r) == 1 mpecho Blackstaff adds the final ingredients to his potion. mpecho Blackstaff utters some strange words. mpecho Blackstaff swirls the potion and it shines an iridescent purple. mpoload 8048 mpechoat $r Blackstaff hands you the potion. mpechoaround $r Blackstaff hands $r the potion. mpgive dragolish $r mpjunk all sayto $r Take this and give it to the Merchants wife. sayto $r It should cure her. mpechoat $n Blackstaff gives you the potion. mpechoaround $n Blackstaff gives $n the potion. mpmset $r quest 0 5 11 mpmset $r quest 5 1 0 mpmset $r quest 6 1 0 mpmset $r quest 7 1 0 endif endif endif endif if position($r) == 4 wake $r sayto $r Hey! What do you think you doing sleeping here! sayto $r Go pay for a room in an Inn. endif ~ |
Rand progs can be used to slow down events happening. For instance this program stops Blackstaff s peaking too quickly when he had a lot of information to give to the player. It gives the player a chance to read the information before it scrolls off the screen. It is a very long and complicated program. It actually does more than one part of the quest. The first part is Blackstaff talking to the player when the first visit, the second is where they have handed him the ingredients and the final checks to make sure they have not slept in his study.
This who rand prog has a 100% chance of triggering - though I say it is 100% chance in actuality it does not activate that quickly I have found. After that in order to slow down the first part of the prog I have used an if rand(40) within the prog. This means that this part of the prog will activate 40% of the time while the rest will activate 100% of the time. You will notice that Blackstaff sets quest bits on the player as he talks. This is so he does not say the same thing each time the rand prog is activated. You must remember to set the bits up one to stop it repeating over and over again.
Another point to note is the use of $r in the rand prog. If you use $n the program will not work. You MUST use $r in rand progs.