Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Thu Oct 30, 2003 9:34 pm   

Arrays
 
I have a few basic triggers on the mud I play. What I'd like to set up is some sort of priority list to fire triggers based on what needs to be done most urgently. zMud went horribly pear-shaped recently (that's another story though) so I'm working from a clean slate now.

Triggers fire immediately under normal circumstances - the problem is when the character is unable to execute the command (off balance, asleep etc). Assume that eating & drinking has a medium priority, preparing to parry or healing has a high priority, meditating has a low priority.

If (unlikely as it sounds) whilst off balance then I suddenly need to eat, drink, parry, heal and meditate. When I regain then I'd like to be able to search a list of things to do, and execute the command that is highest priority (if two are same priority, then doesn't matter which of them fires first). When a command executes correctly it should be removed from the list, and the next will then fire when possible.

So... things could go something like the following:


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

::game:: You are knocked off balance.
::game:: You are hungry, thirsty, need to parry, heal and meditate.
::game:: You regain your composure.


parry

::game:: You prepare to parry
::game:: You regain your composure.


heal

::game:: You heal yourself.
::game:: You regain your composure.


eat food

::game:: You eat some food.
::game:: You regain your composure.


drink water

::game:: You drink some water.
::game:: You regain your composure.


meditate

::game:: You begin meditating.
::game:: You regain your composure.


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



Anyways, hope that makes sense. Thanks in advance to anyone that has any advice how I might set this up.

Guinn
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Oct 31, 2003 1:03 am   
 
You may want to search the forums. I have written a number of different prioritzing queues for people. Currently I am working on one for myself, but until I am happy with it I won't post it. I may never be happy since I haven't made much progress lately.

Actually looking more at your post I recall one written for spelling up that had the ability to put success/fail trigger directly into its variable matrix. That might be readily modifiable, again see what you find. If I happened to write the one you find looks to do most of what you want I will certainely help you modify to perfection.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Oct 31, 2003 1:09 am   
 
One possibility is a binary status variable.
1 = parry
2 = heal
4 = hungry
8 = thirsty
16 = meditate

#VAR status 0
#TR {^You *need to* parry} {#VAR status %bitor( @status, 1);parry}
#TR {^You *need to* heal} {#VAR status %bitor( @status, 2);heal}
#TR {^You *are* hungry} {#VAR status %bitor( @status, 4);eat food}
#TR {^You *are* thirsty} {#VAR status %bitor( @status, 8);drink water}
#TR {^You *need to* meditate} {#VAR status %bitor( @status, 16);meditate}
#TR {You prepare to parry} {#VAR status %bitand( @status, 30)}
#TR {You heal yourself} {#VAR status %bitand( @status, 29)}
#TR {You eat some food} {#VAR status %bitand( @status, 27)}
#TR {You drink some water} {#VAR status %bitand( @status, 23)}
#TR {You begin meditating} {#VAR status %bitand( @status, 15)}
#TR {You regain your composure} {
#IF (@status2) {parry} {
#IF (@status4) {heal} {
#IF (@status8) {eat food} {
#IF (@status16) {drink water} {
#IF (@status32) {meditate}
}}}}}

This is not the only way to handle the problem, and it may not be the best or easiest either. I strongly recommend picking a method which YOU understand. Some other possibilities include:
String variable "00110" with %pos() and %copy()
Numeric List variable {0|0|1|1|0} with %ismember() and %item()
String List variable {eat|parry|meditate} with #ADDITEM, #DELITEM, and %ismember
Multiple variables
Record variable using #ADDKEY and %db()
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sat Nov 01, 2003 3:06 pm   
 
Thanks to both for the replies. I did a bit of trawling and managed to work out something close to what I might be after :)

I decided that it'll be unlikely that I have too many different priorities, and that a high, medium, low would probably do me fine. So I set up three lists, with an alias that cycles through the lists and executes a command that's on the appropriate list (so if priorityhigh is empty then it'll look at prioritymedium, then prioritylow) - when it's found the command it's looking for it then goes through the list and deletes that command out of the list.

Let me know if you think the following looks useful, or if you have any suggestions to improve.

Thanks again in advance.




#CLASS {Priority} {enable}

#VAR PriorityHigh {} {}
#VAR PriorityMedium {} {}
#VAR PriorityLow {} {}
#VAR ToDo {} {}

#ALIAS ToDo {#IF (%item( @PriorityLow, 1) != "") {#VARIABLE ToDo %item( @PriorityLow, 1)};#IF (%item( @PriorityMedium, 1) != "") {#VARIABLE ToDo %item( @PriorityMedium, 1)};#IF (%item( @PriorityHigh, 1) != "") {#VARIABLE ToDo %item( @PriorityHigh, 1)};#FORALL @PriorityLow {#VARIABLE PriorityLow %delitem( @ToDo, @PriorityLow)};#FORALL @PriorityMedium {#VARIABLE PriorityMedium %delitem( @ToDo, @PriorityMedium)};#FORALL @PriorityHigh {#VARIABLE PriorityHigh %delitem( @ToDo, @PriorityHigh)};#SAY @ToDo;#SEND @ToDo}

#CLASS 0




I add items to each list using
#ADDITEM PriorityHigh {WhatToAdd}

so assume
PriorityHigh is {eat|drink|be merry}
PriorityMedium is {sleep|dream}
PriorityLow is {wake up}

Running the alias ToDo 6 times would produce: eat, drink, be merry, sleep, dream, wake up


Anyways, I'm relatively new to this, so I'm sure there's better ways :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net