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
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Thu Jul 08, 2004 4:07 pm   

Database Script for Motrals of KOTL
 
Ok so I have started a database script for this mud. But I think I have gotten in over my head. I want to be able to capture everything if i can. Here is what i have so far

#ALIAS store_data {
#IF !%null( %find( @newRecord.Name, All, Name)) {#YESNO "A duplicate item already exists, add anyway?" {#NOOP} {#ABORT 1}}
#PROMPT newRecord.Source "Name, and Zone of mob?"
#DBLOAD eq
#NEW All @newRecord
#DBRESET
}
#VAR newRecord {Namea Guards TunicKindarmorLevel85Weight(15)SpAffects(burn_proof)AcPierce(***)AcBash(***)AcSlash(***)AcMagicWeap(***)Saves-3Ac3HitRoll5Hp33Con3} {}
#TRIGGER {Item '%1' is {a|an} %1, of level %1, with weight %1.} {
#VAR newRecord %null %null equip_id
#ADDKEY newRecord Name {%1}
#ADDKEY newRecord Kind {%2}
#ADDKEY newRecord Level {%3}
#Addkey newRecord Weight (%4)
#TEMP eqidtemptrig {^$} {
#T- eqidtemptrig
store_data
}
}
#TRIGGER {Its special affects are: %1.} {#ADDKEY newRecord SpAffects (%1)}
#TRIGGER {Weapon type is %1.} {#ADDKEY newrecord WeaponType %1}
#TRIGGER {The average of damage is %1} {#ADDKEY newrecord AvgDam (%1)}
#TRIGGER {Special weapon affects: (%1).} {#ADDKEY newRecord WeaponAffects (%1)}
#TRIGGER {Armorclass against pierce:%1} {#ADDKEY newRecord AcPierce %1}
#TRIGGER {Armorclass against bash:%1} {#ADDKEY newRecord AcBash %1}
#TRIGGER {Armorclass against slash:%1} {#ADDKEY newRecord AcSlash %1}
#TRIGGER {Armorclass vs. magical weapons:%1} {#ADDKEY newRecord AcMagicWeap %1}
#TRIGGER {*- Affects hit roll by %1, } {#ADDKEY newRecord HitRoll %1}
#TRIGGER {*- Affects damage roll by %1, } {#ADDKEY newRecord DamRoll %1}
#TRIGGER {*- Affects strength by %1, } {#ADDKEY newRecord Str %1}
#TRIGGER {*- Affects res%1 by %2, permanently.} {}
#TRIGGER {*- Affects intelligence by %1, } {#ADDKEY newRecord Int %1}
#TRIGGER {*- Affects wisdom by %1,$} {#ADDKEY newRecord Wis %1}
#TRIGGER {*- Affects dexterity by (%n).$} {#ADDKEY newRecord Dex %1}
#TRIGGER {*- Affects constitution by %1, permanently.} {#ADDKEY newRecord Con %1}
#TRIGGER {*- Affects agility by (%n).$} {#ADDKEY newRecord Agi %1}
#TRIGGER {*- Affects charisma by (%n).$} {#ADDKEY newRecord Cha %1}
#TRIGGER {*- Affects luck by (%n).$} {#ADDKEY newRecord Luk %1}
#TRIGGER {*- Affects leadership by (%n).$} {#ADDKEY newRecord Led %1}
#TRIGGER {*- Affects perception by (%n).$} {#ADDKEY newRecord Pec %1}
#TRIGGER {^Affects resistant by (*)$} {#ADDITEM newRecord.Resists {%1}}
#TRIGGER {^Affects susceptible by (*).$} {#ADDITEM newRecord.Suscepts {%1}}
#TRIGGER {*- Affects hp by %1, } {#ADDKEY newRecord Hp %1}
#TRIGGER { - Affects moves by (%n).$} {#ADDKEY newRecord Moves %1}
#TRIGGER {*- Affects constitution by %1,} {#ADDKEY newRecord Ac %1}
#TRIGGER {*- Affects saves by %1, } {#ADDKEY newRecord Saves %1}
#TRIGGER {^Affects immune by (*)$} {#ADDITEM newRecord.Immunes - Affects {%1}}
#TRIGGER {You have now obtained experience level (%d)!} {
#VAR myLevel %1
wimpy
}
#TRIGGER {Object '*' is {a|an} (%x), special properties: (*)$} {
#IF %null( %find( @aucitem, All, Name)) {
#VAR newRecord ""
#ADDKEY newRecord Name @aucitem
#ADDKEY newRecord Kind {%1}
#LOOP %numwords( %2) {#IF %ismember( %word( {%2}, %i), @allRestrictions) {#ADDITEM newRecord.Restrictions %word( {%2}, %i)} {#ADDITEM newRecord.Properties %word( {%2}, %i)}}
#TEMP eqidtemptrig {^$} {
#T- eqidtemptrig
#DBLOAD eq
#NEW All @newRecord
#DBRESET
}
}
}
#TRIGGER {Auction: A new item is being auctioned: (*) at %x gold.} {
#VAR aucitem {%1}
~auction
}
#TRIGGER {^Item's wear location: (%w)$} {#ADDKEY newRecord Wear %replace( "%1", " ", "|")}
#TRIGGER {Object '(*)' is {a|an} (%x), with wear location: (*)$} {
#VAR newRecord %null %null equip_id
#ADDKEY newRecord Name {%1}
#ADDKEY newRecord Kind %2
#ADDKEY newRecord Wear %replace( "%3", " ", "|")
#TEMP eqidtemptrig {^$} {
#T- eqidtemptrig
store_data
}
}
#TRIGGER {Object '(*)' is {a|an} (%x).$} {
#VAR newRecord %null %null equip_id
#ADDKEY newRecord Name {%1}
#ADDKEY newRecord Kind %2
#TEMP eqidtemptrig {^$} {
#T- eqidtemptrig
store_data
}
}
#TRIGGER {^Special properties: (*)$} {#LOOP %numwords( %1) {#IF %ismember( %word( {%1}, %i), @allRestrictions) {#ADDITEM newRecord.Restrictions %word( {%1}, %i)} {#ADDITEM newRecord.Properties %word( {%1}, %i)}}}
#TRIGGER {^Its weight is (%d), value is (%d), and level is (%d).$} {
#ADDKEY newRecord Weight %1
#ADDKEY newRecord Value %2
#ADDKEY newRecord Level %3
}
#TRIGGER {^Damage is (%d) to (%d) ~(average (%d)~).$} {
#ADDKEY newrecord mindam %1
#ADDKEY newrecord maxdam %2
#ADDKEY newrecord avgdam %3
}
#TRIGGER {^Has (%d)~(%d~) charges of level (%d) ~'(*)~'.$} {
#ADDKEY newrecord charges %1
#ADDKEY newrecord castlevel %2
#ADDKEY newrecord Spells {%3}
}
#TRIGGER {^Level (%d) spells of: ~'(*)~'.$} {
#ADDKEY newRecord castlevel %1
#ADDKEY newRecord Spells %replace( {%2}, "' '", "|")
}
#TRIGGER {^Armor class is (%d).$} {#ADDKEY newrecord AC %1}
#TRIGGER {^Affects hp by (%n).$} {#ADDKEY newRecord hp %1}
#TRIGGER {^Affects dexterity by (%n).$} {#ADDKEY newRecord dex %1}
#TRIGGER {^Affects strength by (%n).$} {#ADDKEY newRecord str %1}
#TRIGGER {^Affects constitution by (%n).$} {#ADDKEY newRecord con %1}
#TRIGGER {^Affects luck by (%n).$} {#ADDKEY newRecord luck %1}
#TRIGGER {^Affects intelligence by (%n).$} {#ADDKEY newRecord int %1}
#TRIGGER {^Affects wisdom by (%n).$} {#ADDKEY newRecord wis %1}
#TRIGGER {^Affects charisma by (%n).$} {#ADDKEY newRecord char %1}
#TRIGGER {^Affects save vs (%w) by (%n).$} {#ADDITEM newRecord.Saves %concat( %1, " ", %2)}
#TRIGGER {^Affects armor class by (%n).$} {#ADDKEY newRecord armor %1}
#TRIGGER {^Affects affected_by by (*).$} {#ADDITEM newRecord.Affects {%1}}
#TRIGGER {^Affects mana by (%n).$} {#ADDKEY newRecord mana %1}
#TRIGGER {^Affects moves by (%n).$} {#ADDKEY newRecord mv %1}
#TRIGGER {^Affects damage roll by (%n).$} {#ADDKEY newRecord dam %1}
#TRIGGER {^Affects hit roll by (%n).$} {#ADDKEY newRecord hit %1}
#TRIGGER {Class Name} {#gag}
#TRIGGER {Weapon type is %1} {#ADDKEY newRecord WeaponType %1}
#TRIGGER {Affects moves by (%n).$} {#ADDKEY newRecord Moves %1}
#TRIGGER {Adds %1 affect, permanently} {#ADDKEY newRecord Adds %1}
#TRIGGER {*- Affects armor class by %1, } {#ADDKEY newRecord Ac (%1)}
#CLASS 0

There have been some recent changes made to the game that make SO many different things to capture that i dont know how to make room for, and grab them all. Also I want to know if there is a way to have it report the item to my say screen with out haveing to go look it up.

the id spells display like this

Item 'a Guards Tunic' is an armor, of level 85, with weight 15.
Its special affects are: burn_proof.
This is meant for: take torso.
---------------------------------------------------------
Armorclass against pierce: (***)
Armorclass against bash: (***)
Armorclass against slash: (***)
Armorclass vs. magical weapons: (***)
-= Additional Affects =-
- Affects respoison by -3, permanently.
- Affects black by 9, permanently.
- Affects saves by -3, permanently.
- Affects armor class by 4, permanently.
- Affects hit roll by 5, permanently.
- Affects hp by 33, permanently.
- Affects armor class by 1, permanently.
- Affects constitution by 3, permanently.

Item 'a Ruby Crown' is an armor, of level 90, with weight 15.
Its special affects are: burn_proof.
This is meant for: take head.
---------------------------------------------------------
Armorclass against pierce: (****)
Armorclass against bash: (****)
Armorclass against slash: (****)
Armorclass vs. magical weapons: (****)
-= Additional Affects =-
- Affects reswind by -3, permanently.
- Affects white by 12, permanently.
- Affects agility by 2, permanently.
- Affects armor class by 1, permanently.
- Affects damage roll by 4, permanently.
- Affects hit roll by 3, permanently.
- Affects intelligence by 3, permanently.
- Affects resmental by -10, permanently.

Item 'some bloody sleeves' is an armor, of level 109, with weight 5.
Its special affects are: none.
This is meant for: take arms.
---------------------------------------------------------
Armorclass against pierce: (***)
Armorclass against bash: (***)
Armorclass against slash: (***)
Armorclass vs. magical weapons: (***)
-= Additional Affects =-
- Affects intelligence by 2, permanently.
- Affects armor class by 5, permanently.
- Affects hit roll by 5, permanently.
- Affects hp by 1, permanently.
- Affects hp by 4, permanently.
- Affects constitution by 4, permanently.

a few things that i am having problems with are grabing the res(what ever) some of the stats for some reason, and if there are more then one of a stat (for example the bloody sleeves give hp 1, and hp 4. but the script only adds one of them. If anyone can offer some tips that would be great. Thanks for the help.

Complex
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Jul 09, 2004 5:46 pm   
 
My first piece of advice would be to use the documented wildcards in your pattern instead of %1, %2, etc. I notice you've already done this in the later portion of the script.

You are having problems grabbing res(whatever) because you haven't assigned any commands to the trigger.
quote:
#TRIGGER {*- Affects res%1 by %2, permanently.} {}
The exact commands you need will depend on the Field names and types which you use for this, but something like this:
#TR {- Affects res(%w) by (%n), permanently.} {#ADDK newRecord {%1Res} {%2}}

Use #ADD when there is (or might be) more than one value for the same stat. This is easiest if you have one-word keys so that you can use the Varname.Key notation.
#TR {^Affects hp by (%n).$} {#ADD newRecord.hp %1}
#TR {- Affects res(%w) by (%n), permanently.} {#ADD newRecord.%1Res {%2}}

Your alias could be simplified by removing the !%null(). This is a double-negative which adds nothing except some slight extra processing time. You can also remove the #DBLOAD. You just got through checking the database with %find, so it should already be open.

To report the latest item to your Say screen, just add the appropriate commands immediately before or after the #NEW command.
#WINDOW Say {%expanddb( @newRecord)}
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Fri Jul 09, 2004 10:41 pm   
 
Thanks Lightbulb! I have 2 more questions for the
#TR {- Affects res(%w) by (%n), permanently.} {#ADD newRecord.%1Res {%2}}
Do I still have to add all the possible res types as fields in the database itself, or what do i make as the addkey?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jul 10, 2004 2:27 am   
 
The #ADD should suffice. Also from your examples:
- Affects intelligence by 2, permanently.
This would seem to indicate that you can eliminate a few triggers and just do:
#TR {^- Affects (*) by (%n), permanently.$} {#ADD {newRecord.%1} {%2}}
That might not like those with a space like "hit roll" so the alternate would be:
#TR {^- Affects (*) by (%n), permanently.$} {#ADDKEY newRecord {%1} {%eval(%db("%1",@newRecord)+(%2))}}

The added benefit of this route is that imm's don't always adjust a given value when adding an affect. Often they simply tack the affect on irregardless of what stat it changes.
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Sat Jul 10, 2004 3:24 am   
 
Ok I dont think i 100% understand your responce Vij. Let me make sure So I can create a New Database, and in the database screen I dont have to make anyfields, it will just add the fields as new fields are made with these 2 (more powerful) triggers?
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Sat Jul 10, 2004 3:31 am   
 
To tell you the truth after looking at it again i think i have confused myself even more. Now I want to redo all my triggers as you did then vij, but if i read that correctly I dont think i need more then one trigger. Just that last one you made. But how do i get the information into my var?
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Sat Jul 10, 2004 5:04 am   
 
OH WAIT. Are the * what my trigger should look for?
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Sat Jul 10, 2004 9:54 am   
 
Ok so here is the new script

#CLASS {equip_id}
#ALIAS store_data {
#IF !%null( %find( @newRecord.Name, All, Name)) {#YESNO "A duplicate item already exists, add anyway?" {#NOOP} {#ABORT 1}}
#PROMPT newRecord.Source "Name, and Zone of mob?"
#DBLOAD eq
#NEW All @newRecord
#DBRESET
}
#VAR newRecord {NameA Bloody FangLevel72Weight(1)SpAffects(glow hum magic nopurge burn_proof)KindearAcPierce(***)AcBash(***)AcSlash(***)AcMagicWeap(***)rescharm-5armor class5moves50hp19hit roll1agility1saves-3white6Source} {}
#TRIGGER {Item '%1' is {a|an} %1, of level %1, with weight %1.} {
#VAR newRecord %null %null equip_id
#ADDKEY newRecord Name {%1}
#ADDKEY newRecord Level {%3}
#Addkey newRecord Weight (%4)
#TEMP eqidtemptrig {^$} {
#T- eqidtemptrig
store_data
}
}
#TRIGGER {This is meant for: take %1.} {#ADDKEY newRecord Kind {%1}}
#TRIGGER {Its special affects are: %1.} {#ADDKEY newRecord SpAffects (%1)}
#TRIGGER {Weapon type is %1.} {#ADDKEY newrecord WeaponType %1}
#TRIGGER {The average of damage is %1} {#ADDKEY newrecord AvgDam (%1)}
#TRIGGER {Special weapon affects: (%1).} {#ADDKEY newRecord WeaponAffects (%1)}
#TRIGGER {Armorclass against pierce:%1} {#ADDKEY newRecord AcPierce %1}
#TRIGGER {Armorclass against bash:%1} {#ADDKEY newRecord AcBash %1}
#TRIGGER {Armorclass against slash:%1} {#ADDKEY newRecord AcSlash %1}
#TRIGGER {Armorclass vs. magical weapons:%1} {#ADDKEY newRecord AcMagicWeap %1}
#TRIGGER {*- Affects (*) by (%n), permanently.} {#ADD newRecord {%1} {%eval( %db( "%1", @newRecord)+(%2))}} "" {disable}
#TRIGGER {*- Affects (*) by (%n), permanently.$} {#ADDKEY newRecord {%1} {%eval( %db( "%1", @newRecord)+(%2))}}
#TRIGGER {Object '*' is {a|an} (%x), special properties: (*)$} {
#IF %null( %find( @aucitem, All, Name)) {
#VAR newRecord ""
#ADDKEY newRecord Name @aucitem
#ADDKEY newRecord Kind {%1}
#LOOP %numwords( %2) {#IF %ismember( %word( {%2}, %i), @allRestrictions) {#ADDITEM newRecord.Restrictions %word( {%2}, %i)} {#ADDITEM newRecord.Properties %word( {%2}, %i)}}
#TEMP eqidtemptrig {^$} {
#T- eqidtemptrig
#DBLOAD eq
#NEW All @newRecord
#DBRESET
}
}
}
#TRIGGER {Object '(*)' is {a|an} (%x), with wear location: (*)$} {
#VAR newRecord %null %null equip_id
#ADDKEY newRecord Name {%1}
#ADDKEY newRecord Kind %2
#ADDKEY newRecord Wear %replace( "%3", " ", "|")
#TEMP eqidtemptrig {^$} {
#T- eqidtemptrig
store_data
}
}
#TRIGGER {Object '(*)' is {a|an} (%x).$} {
#VAR newRecord %null %null equip_id
#ADDKEY newRecord Name {%1}
#ADDKEY newRecord Kind %2
#TEMP eqidtemptrig {^$} {
#T- eqidtemptrig
store_data
}
}
#TRIGGER {^Special properties: (*)$} {#LOOP %numwords( %1) {#IF %ismember( %word( {%1}, %i), @allRestrictions) {#ADDITEM newRecord.Restrictions %word( {%1}, %i)} {#ADDITEM newRecord.Properties %word( {%1}, %i)}}}
#TRIGGER {^Its weight is (%d), value is (%d), and level is (%d).$} {
#ADDKEY newRecord Weight %1
#ADDKEY newRecord Value %2
#ADDKEY newRecord Level %3
}
#TRIGGER {^Damage is (%d) to (%d) ~(average (%d)~).$} {
#ADDKEY newrecord mindam %1
#ADDKEY newrecord maxdam %2
#ADDKEY newrecord avgdam %3
}
#TRIGGER {^Has (%d)~(%d~) charges of level (%d) ~'(*)~'.$} {
#ADDKEY newrecord charges %1
#ADDKEY newrecord castlevel %2
#ADDKEY newrecord Spells {%3}
}
#TRIGGER {^Level (%d) spells of: ~'(*)~'.$} {
#ADDKEY newRecord castlevel %1
#ADDKEY newRecord Spells %replace( {%2}, "' '", "|")
}
#TRIGGER {Class Name} {#gag}
#TRIGGER {Weapon type is %1} {#ADDKEY newRecord WeaponType %1}
#CLASS 0

however i still cant get the #add to work
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Jul 10, 2004 3:34 pm   
 
The database does not make fields automatically. You have to make any fields that you want.

I don't know what you want for field names and types. I just picked something out so I could give you an example. You might want fields for every possible resistance, named resPoison, resWind, etc. You might just want two fields named resName and resAmount. You might even want to combine them into one field. That's why I said, "The exact commands you need will depend on the Field names and types which you use."
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Sat Jul 10, 2004 6:55 pm   
 
Ok so that is the messy part, after i made the fields for all the res's, mana types, stats, ect there are a total of 64 fields. All of the fields save a few can have more then one bonus added to them. So it can have plus 6 hp, and plus 10hp.
I tryed to use #TR {^- Affects (*) by (%n), permanently.$} {#ADD {newRecord.%1} {%2}}
how ever that jumbled things up worse. This had caused the first name of the next field to be added to the last field.

Also one last thing is there a way i make the database look cleaner. I have 60 plus fields to mess deal with. its sorta anoying haveing them all over the place. (no one item i have encountered yet has affected all of them.)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Jul 11, 2004 2:26 am   
 
Personally I just use a string list for affects. So an item in my database has a string field. An example of its contents would be "dexterity=2|intelligence=4|hit roll=-1|dam roll=-2|ac=-3". It is still searchable and a little easier to read.

You really have to construct the database and then manipulate the data before recording it. Lightbulb and I just gave you a few things toward recording the data. How you really want to store it is up to you. Decide that, build the data base, and then perhaps we can help you with the proper manipulation.
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