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
Jhorr
Newbie


Joined: 29 Aug 2005
Posts: 6

PostPosted: Mon Aug 29, 2005 9:26 am   

Database Question
 
Hi. I'm trying to make a trigger set that analyzes who is in a group and makes a list of the priests (Cleric, Shaman, Druid) and their levels and then sorts it from highest to lowest.

I wanted to use the database functionality but am having trouble with #DBLOADing the empty database and adding to it. Note: this particular database would not be saved each time and would be created anew with each new group.

Also, #DBCLOSE doesn't seem to be working when I try to close my database of equipment from the command line. It seems to clear all the info and keeps the template open.

Are these known issues with the database. Are there known solutions?

Thanks.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Aug 29, 2005 8:49 pm   
 
It sounds like you aren't really looking for a database for your tigger question, but a simple record variable. These use the same #ADDKEY and #DELKEY commands, but do not actually make use of the DB module.

As to keeping an empty database by way of never saving it, I am not sure that is possible. zMud makes background saves to the database to protect data. Databases are meant for long term usage.

What you mention about #DBCLOSE sounds like a bug, but you would have to provide more information before I could be sure. You are welcome to use the bug tracking system to report it though, I would suggest coming up with a procedure that is replicatible from a "default", just installed setup, including every step required. You can access a near default systm by pressing ESC at the Character Window.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Jhorr
Newbie


Joined: 29 Aug 2005
Posts: 6

PostPosted: Mon Aug 29, 2005 9:16 pm   
 
Thanks, ADDKEY/DELKEY might work. How though could I compare the values of one such variable with another. For example, if cleric1=Jhorr|34, and cleric2=Lhorr|36, how do you compare the number part?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Aug 30, 2005 12:16 am   
 
You can use %item with the %db function to access the results. There is also a shorthand 'dot' notation, but from what you have described so far I do not think it is the best way to go. Perhaps if you just explained what you want to do; those of us that have done it before can point you in the right direction or even just go 'here is the script I use, adjust it at your own risk.'
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Jhorr
Newbie


Joined: 29 Aug 2005
Posts: 6

PostPosted: Tue Aug 30, 2005 12:35 am   
 
Thanks for your help. In Sojourn, when you type 'group' you get (for example):


< 1030h/830H 115v/115V > group

Group information for Lilithelle and Company
Size: 15
Unsplit Coins: 0 platinum 0 gold 0 silver 0 copper
(Head) 992/992 hit, 173/173 move, 0/0 psp Lilithelle
345/450 hit, 48/112 move, 0/0 psp Cofen
815/625 hit, 129/129 move, 0/0 psp Anaram
805/721 hit, 116/116 move, 0/0 psp Yog
1026/830 hit, 115/115 move, 0/0 psp Tajan
684/684 hit, 131/131 move, 0/0 psp Goroz
678/691 hit, 134/134 move, 0/0 psp Ceda
1302/1302 hit, 130/130 move, 0/0 psp Turgy
788/788 hit, 126/126 move, 0/0 psp Pid
898/911 hit, 127/127 move, 0/0 psp Ifin
851/851 hit, 134/134 move, 0/0 psp Kurkis
421/492 hit, 125/125 move, 324/472 man Katra
996/1021 hit, 112/112 move, 0/0 psp Galzar
948/948 hit, 118/118 move, 0/0 psp Kramel
722/722 hit, 82/160 move, 0/0 psp Kiryan

< 1026h/830H 115v/115V >

I want my trigger set to scan through the group members, figure out who is a priest type (Shaman, Cleric, or Druid) and their level, then assign spell targets for a 'Vitality' spell. The trigger set can get level and class for each char from the 'who' command, for example 'who Tajan' =


< 293h/554H 16v/115V > who tajan
Listing of Specific Character
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
[46 Cleric ] Tajan (Dwarf)
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

< 293h/554H 17v/115V >
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Aug 30, 2005 8:04 am   
 
How would you like the targets for the Vitality spell assigned? I get that you want to target the preist types and it has something to do with thier levels.

Next when do you want to cast this spell, and what method are you going to use to determine this? I ask because if you are using the group list to decide when to cast then I have to design the data capture triggers to be noninterferring. If you are using some other method then different designs are possible, and perhaps you will want the group list capture to pick up more data.

Some of these design choices also affect how best to store the data. Right now I am thinking 2 record variables and 1 list variable.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Jhorr
Newbie


Joined: 29 Aug 2005
Posts: 6

PostPosted: Tue Aug 30, 2005 9:16 am   
 
On sojourn, the vitality spell is usually casted prior to a big fight. Everyone in the group usually gets one so this task is divided up among those who have the spell. Clerics do the brunt of the work and are usually assigned to the warrior types (Warrior, Ranger, Paladin, Anti-Paladin) since their vitality spells are the best and it's the warriors that take damage for the group. Shaman and Druids usually help out with one or two. All priests cast this spell on themselves. I want the output from the trigger set to look something like:

Kiryan - Turgy Galzar Kramel Ceda Ifin self
Tajan - Cofen Anaram Goroz Ceda Kurkis self
Yog - Katra self
Lilithelle - self

In this example, Kiryan is the highest level cleric so he casts the spell on the warrior types (Turgy, Galzar, and Kramel) as well as Ceda and Ifin (mage-types who usually have lowest hitpoints). Tajan is the next best cleric, Yog is a shaman, and Lilithelle is a druid. I guess ideally the mage-types should have a Cleric spell if one is available.

Usually when the group is formed up, a cleric is asked to assign 'vits' (the vitality spell). This is a dreaded chore so a trigger set would make life a lot easier. The group composition can and does change each time though. Sometimes there is just 1 cleric, sometimes 2 druids, sometimes zero shaman. Group sizes can range from 2 - 15.

Also, sometimes there are more group members than there are available vitality spells. In such a mismatch, I guess the Cleric would have to repray the spells to cover the slack since some group members would be unassigned. The number of vitality spells a priest has is level dependent so I was thinking of making a reference chart like that you find in the AD&D Players Handbook that the trigger set would use to fetch the number of available vitality spells for each priest.

Regarding when to cast: (1) the group leader calls for the spell before a major fight, or (2) up to the discretion of the priest.

Ideally, it would be nice to be able to manually edit the assignments once they are calculated.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Aug 30, 2005 9:08 pm   
 
Ok. Give me a little time to work on this. You are really asking for a custom script with a lot of logic in it, and I have to deisgn it so the logic involved is readily edittable by you.

In some ways you are the boss, as far the script will be concerned. So I will create an opening for the leader to call for the spell to be cast. I will also design it such that it can be used by other players; and once they detect another cleric involved, of higher level, they will defer to that cleric. In essence the script requires 2 parts, first reponding to a request for assignments to be made, and second preforming the assigned jobs. I will try to make it as easy as possible for you to distribute this script among friends, so that the highest level cleric can make the assignments and all other clerics can perform the assigned task.

Currently the only information I see as missing is whether there is a messgae when someone is joined to the group.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Jhorr
Newbie


Joined: 29 Aug 2005
Posts: 6

PostPosted: Tue Aug 30, 2005 9:39 pm   
 
Thanks for your help!

I already have a trigger set that casts the spell. All I need is one to make the list of assignments. Only 1 priest per group is asked to make the list and that priest assigns spell targets to all the other priests.

So far, the number of vits per level I have figured out is:


Class Circle Level # vits max
Cleric 5 21 1
. 22 2
. 30 4
. 46 6

Druid 6 26 1
. 50 7

Shaman 7 31 1
. 39 5

I'll fill in the table more as I get more...
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Aug 31, 2005 9:57 pm   
 
Ok this is what I came up with. It uses the small amount of a table you provided, but will need more. Also It doesn't have the logic for a second pass. I hope you figure out how it works, I took a few odd script shortcuts, but otherwise wrote the script to be extremely verbose in how it handles and accesses the data.

Code:
#CLASS {VitAssign}
#ALIAS MakeAssignments {GroupAssignments="";#ADDKEY GroupAssignments {UnAssigned} {@GroupMembers.List};#FORALL @GroupMembers.Cleric {#IF (%word("%i",1)>=%word(%item(@KnownVit.Cleric,1),1)) {EstimateVits Cleric %word("%i",1);#ADDKEY GroupAssignments {%word("%i",2)} {%word("%i",2)};#ADDKEY GroupAssignments {%concat(%word("%i",2),"Vits")} {%concat(@TempVits,"=1")};#ADDKEY GroupAssignments {Casters} {%additem(%concat(%word("%i",2)," ",@TempVits),@GroupAssignments.Casters)};#ADDKEY GroupAssignments {UnAssigned} {%delitem("%i",@GroupAssignments.UnAssigned)}}};#FORALL @GroupMembers.Druid {#IF (%word("%i",1)>=%word(%item(@KnownVit.Druid,1),1)) {EstimateVits Druid %word("%i",1);#ADDKEY GroupAssignments {%word("%i",2)} {%word("%i",2)};#ADDKEY GroupAssignments {%concat(%word("%i",2),"Vits")} {%concat(@TempVits,"=1")};#ADDKEY GroupAssignments {Casters} {%additem(%concat(%word("%i",2)," ",@TempVits),@GroupAssignments.Casters)};#ADDKEY GroupAssignments {UnAssigned} {%delitem("%i",@GroupAssignments.UnAssigned)}}};#FORALL @GroupMembers.Shaman {#IF (%word("%i",1)>=%word(%item(@KnownVit.Shaman,1),1)) {EstimateVits Shaman %word("%i",1);#ADDKEY GroupAssignments {%word("%i",2)} {%word("%i",2)};#ADDKEY GroupAssignments {%concat(%word("%i",2),"Vits")} {%concat(@TempVits,"=1")};#ADDKEY GroupAssignments {Casters} {%additem(%concat(%word("%i",2)," ",@TempVits),@GroupAssignments.Casters)};#ADDKEY GroupAssignments {UnAssigned} {%delitem("%i",@GroupAssignments.UnAssigned)}}};#SHOW Initial assignments done, doing logic.;#NOOP My thinking match highest level to highest level, clerics getting mosts.;#NOOP Casters list is sorted this way as are group member by class lists.;TempVits=1;#WHILE (%numitems(@GroupAssignments.UnAssigned)) {#ADDITEM TempVits {%word(%item(@GroupAssignments.Casters,@TempVits),1)};#SHOW OuterLoop @TempVits;#WHILE ((!%eval(%db(@GroupAssignments,%concat(%item(@TempVits,2),"Vits")))) & (%numitems(@GroupAssignments.UnAssigned))) {#ADDKEY GroupAssignments {%item(@TempVits,2)} {%additem(%word(%item(@GroupAssignments.UnAssigned,1),2),%db(@GroupAssignments,%item(@TempVits,2)))};#ADDKEY GroupAssignments {UnAssigned} {%delnitem(@GroupAssignments.UnAssigned,1)};#ADDITEM TempVits {%db(@GroupAssignments,%concat(%item(@TempVits,2),"Vits"))};#ADDKEY GroupAssignments {%concat(%item(@TempVits,2),"Vits")} {%concat(%word(%item(@TempVits,3),1,"="),"=",%eval(%word(%item(@TempVits,3),2,"=")+1))};#DELNITEM TempVits 3};#DELNITEM TempVits 2;#ADD TempVits 1;#IF (@TempVits>%numitems(@GroupAssignments.Casters)) {#IF (%numitems(@GroupAssignments.UnAssigned)) {TempVits=@GroupAssignments.UnAssigned;#ADDKEY GroupAssignments {UnAssigned} {};#SHOW Ran out of Vits. Unassigned are @TempVits} {TempVits=""}}};#IF (@TempVits="") {ReportAssignments}}
#ALIAS ReportAssignments {#FORALL @GroupAssignments.Casters {gt %word("%i",1) - %db(@GroupAssignments,%word("%i",1))}}
#ALIAS EstimateVits {TempVits=%db(@KnownVit,"%1");#IF (%pos("%2",@TempVits)) {TempVits=%copy(@TempVits,%eval(%pos("%2",@TempVits)+3),1)} {#IF (%2>%word(%item(@TempVits,%numitems(@TempVits)),1)) {TempVits=%word(%item(@TempVits,%numitems(@TempVits)),2)} {#WHILE (%word(%item(@TempVits,1),1)<%2) {#IF (%word(%item(@TempVits,2),1)<%2) {#DELNITEM TempVits 1} {TempVits=%concat("999 ",%word(%item(@TempVits,1),2))}};TempVits=%word(@TempVits,2)}}}
#VAR GroupMembers {} {}
#VAR KnownVit {Cleric21 1|22 2|30 4|46 6Druid26 1|50 7Shaman31 1|39 5}
#VAR GroupAssignments {} {}
#VAR TempVits {} {}
#ONINPUT "GroupCapture" {^group$} {GroupMembers="";#SEND {gt Assessing group for vitality assignments.}}
#COND {^Unsplit Coins: %d platinum %d gold %d silver %d copper} {}
#COND {} {#IF (%line="") {#STATE GroupCapture 4;#SET GroupCapture 4 1} {#IF (%word(%line,1)="(Head)") {#ADDKEY GroupMembers Leader {%word(%line,%numwords(%line))}};#ADDKEY GroupMembers List {%additem(%word(%line,%numwords(%line)),%db(@GroupMembers,"List"))};#ADDKEY GroupMembers {%word(%line,%numwords(%line))} {}}} {looplines|param=20}
#COND {*} {#SHOW Error!! Group capture did not detect end of group.;#STATE GroupCapture 0}
#COND {} {#T+ WhoCapture;who %item(@GroupMembers.List,1)} {manual}
#TRIGGER "WhoCapture" {^Listing of Specific Character$} {} "" {disable}
#COND {^~[(%d) (%x) ~] (%w) ~(%w~)} {#ADDKEY GroupMembers {%3} {%1 %2};#ADDKEY GroupMembers {List} {%insert("%1 ",@GroupMembers.List,%pos("%3",@GroupMembers.List))};#ADDKEY GroupMembers {%2} {%additem("%1 %3",%db(@GroupMembers,"%2"))};#IF (%numitems(@GroupMembers.List)>%ismember("%1 %3",@GroupMembers.List)) {who %item(@GroupMembers.List,%eval(%ismember("%1 %3",@GroupMembers.List)+1))} {#IF (%iskey(@GroupMembers,"Cleric")) {#ADDKEY GroupMembers {Cleric} {%sort(@GroupMembers.Cleric,1)}};#IF (%iskey(@GroupMembers,"Shaman")) {#ADDKEY GroupMembers {Shaman} {%sort(@GroupMembers.Shaman,1)}};#IF (%iskey(@GroupMembers,"Druid")) {#ADDKEY GroupMembers {Druid} {%sort(@GroupMembers.Druid,1)}};#IF (%iskey(@GroupMembers,"Warrior")) {#ADDKEY GroupMembers {Warrior} {%sort(@GroupMembers.Druid,1)}};#IF (%iskey(@GroupMembers,"Ranger")) {#ADDKEY GroupMembers {Ranger} {%sort(@GroupMembers.Druid,1)}};#IF (%iskey(@GroupMembers,"Paladin")) {#ADDKEY GroupMembers {Paladin} {%sort(@GroupMembers.Druid,1)}};#IF (%iskey(@GroupMembers,"Anti-Paladin")) {#ADDKEY GroupMembers {Anti-Paladin} {%sort(@GroupMembers.Druid,1)}};#ADDKEY GroupMembers {List} {%sort(@GroupMembers.List,1)};#T- WhoCapture;MakeAssignments}} {disable}
#CLASS 0


Total writing time including the random group generator, about 4 hours. I will keep it on my system for a while just incase you need some tweaks, or something doesn't import correctly.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Jhorr
Newbie


Joined: 29 Aug 2005
Posts: 6

PostPosted: Wed Aug 31, 2005 11:23 pm   
 
Nice!

I imported it.

when I type 'MakeAssignments' it says 'Initial assignments done, doing logic' but then nothing else happens.

Any hints?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Sep 01, 2005 12:22 am   
 
I forgot to mention some assumptions. I assumed "gt" would preform a group tell it is a rather standard thing. I also assummed you had no means to capture the group members names and levels, so I created all that in there. If you have some existing scripts that preform that function you should turn them off while testing this script.

Start with sending a 'group' command to capture your group. It will do a 'gt' to inform everyone. It will then 'who' each person to get the levels and classes. All this data goes into the GroupMembers variable so you can take a look and get an idea how everything works.

Once the data has been successfully captured it preforms the MakeAssignments. When that finishes it will report the assignments again over a 'gt' or give you an error message if everyone couldn't be assigned. I just found a small bug in this where it doesn't report the assignments when there are a large number of casters most of which are high level. What happens is it completes but doesn't ReportAssignments.

Locate these 3 lines near the end of MakeAssignments:
#ADD TempVits 1
#IF (@TempVits>%numitems(@GroupAssignments.Casters)) {
#IF (%numitems(@GroupAssignments.UnAssigned)) {
The change to make is:
#ADD TempVits 1
#IF ((@TempVits>%numitems(@GroupAssignments.Casters))|(%numitems(@GroupAssignments.UnAssigned))) {
#IF (%numitems(@GroupAssignments.UnAssigned)) {

Also I just saw this one in the trigger for capturing the 'who' information. Near the bottom of state 1, I am sure you will spot the problem.
#IF (%iskey(@GroupMembers,"Warrior")) {#ADDKEY GroupMembers {Warrior} {%sort(@GroupMembers.Druid,1)}}
#IF (%iskey(@GroupMembers,"Ranger")) {#ADDKEY GroupMembers {Ranger} {%sort(@GroupMembers.Druid,1)}}
#IF (%iskey(@GroupMembers,"Paladin")) {#ADDKEY GroupMembers {Paladin} {%sort(@GroupMembers.Druid,1)}}
#IF (%iskey(@GroupMembers,"Anti-Paladin")) {#ADDKEY GroupMembers {Anti-Paladin} {%sort(@GroupMembers.Druid,1)}}


You really should take some time to work through the script and get a good understanding of how it does what it does. That way you will be able to add logic to handle either a second set of assignments when there are few priests or just decide that the unprotected people are not important. Also since I didn't test this online I had to simulate all mud responses, so if there are minor errors there you will need to be able to correct them.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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