|
daemi0n Newbie
Joined: 27 Sep 2002 Posts: 3
|
Posted: Fri Sep 27, 2002 8:18 am
This one's complicated. |
I'm currently working on a priority-based affliction curing system for one of the MUDs that I play. Current ingredients:
eatwait ('bool') - set to 0 if an herb can be consumed immediately, and to 1 if one must wait.
hq (array) - 30 elements, each index represents a different affliction, 0 if free of it, 1 if you have it
Here's how I see it working. Each time an affliction hit message comes through, the trigger checks to see if another herb can be effectively eaten. If so, herb goes down the hatch, eatwait is set to 1, and we verify that the affliction in question is not set as active on the list. If an herb cannot be eaten, hq.# is set to 1 for curing at the earliest possible time, where lower integers reflect higher priority.
Here's where I run into problems. I want the message "You can eat another herb" to do the following things:
1) Set eatwait to 0.
2) Start checking the array for 1's. Simple n+=1 until it finds one, at which point it'll activate a healing trigger and break out of the loop, or the end, which will break out of the loop.
Unfortunately I'm used to more conventional programming methods and have no idea how to do that here.
Other questions I have:
Certain classes can make you waste cures by casting an illusion of the messages you would get when afflicted with, say
paralysis. Illusions are tagged as such beforehand, and I'd like to find a way to make the text in between the illusion disclaimer and the next prompt (a couple lines away) ignored by the curing triggers.
I'd appreciate any advice you could offer on this. Thanks. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Sep 27, 2002 5:31 pm |
I think I'd recommend either a stringlist or a record (db) variable instead of an array. They just seem easier to work with. Another possibility would be a 30-place binary array. However, the choice is yours.
#VAR eatwait 0 0
#VAR hq {0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0}
#AL whichherb {#VAR whichherb 0;#LOOP 1,30 {#IF (%item(@hq,(31 - %i)) {#MATH whichherb {31 - %i}}};#IF (@whichherb) {eatherb}}
#AL eatherb {#IF (@eatwait = 0) {#VAR eatwait 1;#CASE @whichherb {outb ginseng;eat ginseng} {outb skullcap;eat skullcap} {outb lobelia;eat lobelia}}} //(you'll need 30 of these, with the correct herb for each affliction)
#TR {You need to eat a piece of ginseng} {%replaceitem(1,1,@hq);whichherb}
#TR {You need to eat some skullcap} {%replaceitem(1,2,@hq);whichherb}
#TR {You need to eat some lobelia} {%replaceitem(1,3,@hq);whichherb}
;(You'll need 30 of these with the correct messages to match each affliction)
#TR {You eat a piece of ginseng} {%replaceitem(0,1,@hq)}
#TR {You eat some lobelia} {%replaceitem(0,3,@hq)}
;(You'll need one of these for each herb, which will reset the correct items in the list)
#TR {You can eat another herb} {#VAR eatwait 0;whichherb}
Basically, this just implements the scheme you suggested except it uses a stringlist instead of an array.
LightBulb
Senior Member |
|
|
|
daemi0n Newbie
Joined: 27 Sep 2002 Posts: 3
|
Posted: Sat Sep 28, 2002 7:39 pm |
Huh, didn't think of using an alias to handle that. Silly me. Question about the line containing the loop; I'm not following the logic very well, what will that line return on completion?
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Sep 29, 2002 3:34 am |
The line in question:
#AL whichherb {#VAR whichherb 0;#LOOP 1,30 {#IF (%item(@hq,(31 - %i)) {#MATH whichherb {31 - %i}}};#IF (@whichherb) {eatherb}}
It should set @whichherb to the lowest item-number which equals 1 (or higher). That is, the highest-priority herb on your to-eat list.
Analysis:
#VAR whichherb 0 Clears the variable
#LOOP 1,30 Do the following 30 times (since there are 30 entries in the itemlist)
#IF (%item(@hq,(31 - %i)) Counts backward from 30 (31 - 1) to 1 (31 - 30). True if that item is non-zero
#MATH whichherb {31 - %i} Counts backward to match the #IF, sets the variable to the item number if that item is nonzero. Since this overwrites the variable, @whichherb will always contain the herb with the lowest number
END OF IF, END OF LOOP
#IF (@whichherb) {eatherb} Checks whether you want to eat a herb and calls the next alias if you do. If @whichherb is still zero, does nothing
It's pretty straightforward, I think.
LightBulb
Senior Member |
|
|
|
daemi0n Newbie
Joined: 27 Sep 2002 Posts: 3
|
Posted: Sun Sep 29, 2002 6:25 am |
That's what I thought. Thank you very much for your help. You know of a way to ignore everything after a certain word before the next prompt?
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Sep 29, 2002 5:54 pm |
Make a new class (Triggers, for example) and move all your triggers to it. If they are in existing classes, move the entire class. Move the prompt trigger back to the None class and add #T+ Triggers to the end of it.
#TR {a certain word} {#T- Triggers} {Triggers} {notrig}
LightBulb
Senior Member |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|