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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
Togras
Newbie


Joined: 12 Jul 2003
Posts: 6
Location: USA

PostPosted: Mon Jul 14, 2003 1:15 pm   

Togras' SMAUG database script
 
Hi-ho.

Once upon a time, Togras played on a mud called Ad Infinium (talsvar.iflipout.com:5842). He thought it was good. He thought it was better than Realms of Despair, so he decided to stay. Besides, he had friends on it.

The above paragraph is absolutely irrelevant, except that Togras decided he wanted to show off his ability to waste time. Here are the results:

#CLASS 0

#ALIAS itemget {#VARIABLE itemsfound %find( "%1", %2);#DBGET %pick( p:Select item, o:1, @itemsfound);#VARIABLE itemname %rec.name _nodef idsay;#VARIABLE itemtype %rec.type _nodef idsay;#VARIABLE itemloc %rec.loc _nodef idsay;#VARIABLE itemprops %rec.properties _nodef idsay;#VARIABLE itemlvl %rec.level _nodef idsay;#VARIABLE itemhp %rec.hp _nodef idsay;#VARIABLE itemmana %rec.mana _nodef idsay;#VARIABLE itemhr %rec.hr _nodef idsay;#VARIABLE itemdr %rec.dr _nodef idsay;#VARIABLE itemstr %rec.str _nodef idsay;#VARIABLE itemdex %rec.dex _nodef idsay;#VARIABLE itemint %rec.int _nodef idsay;#VARIABLE itemwis %rec.wis _nodef idsay;#VARIABLE itemcon %rec.con _nodef idsay;#VARIABLE itemcha %rec.cha _nodef idsay;#VARIABLE itemlck %rec.lck _nodef idsay;#VARIABLE itemvsbrea %rec.vsbrea _nodef idsay;#VARIABLE itemvsspell %rec.vsspell _nodef idsay;#VARIABLE itemvsrod %rec.vsrod _nodef idsay;#VARIABLE itemvspara %rec.vspara _nodef idsay;#VARIABLE itemvsdeath %rec.vsdeath _nodef idsay;#VARIABLE itemvspoison %rec.vspoison _nodef idsay;#VARIABLE itemmindmg %rec.mindmg _nodef idsay;#VARIABLE itemmaxdmg %rec.maxdmg _nodef idsay;#VARIABLE itemavedmg %rec.avedmg _nodef idsay;#ECHO You have chosen ~"%rec.name~" as your item.}

#ALIAS isay {%1 %2 @itemname is a~(n) %if( @itemtype!=0 , @itemtype) is worn at: %if( @itemloc!=0 , @itemloc) and has minlvl of %if( @itemlvl!=0 , @itemlvl). Stats: %if( @itemplusac!=0 , @itemplusac"ac"" ")%if( @itemhp!=0 , @itemhp"hp"" ")%if( @itemmana!=0 , @itemmana"mana"" ")%if( @itemdr!=0 , @itemdr"dr"" ")%if( @itemnhr!=0 , @itemhr"hr"" ")%if( @itemstr!=0 , @itemstr"str"" ")%if( @itemdex!=0 , @itemdex"dex"" ")%if( @itemcon!=0 , @itemcon"con"" ")%if( @itemint!=0 , @itemint"int"" ")%if( @itemwis!=0 , @itemwis"wis"" ")%if( @itemcha!=0 , @itemcha"cha"" ")%if( @itemlck!=0 , @itemlck"lck"" ")%if( @itemvsbrea!=0 , @itemvsbrea"vsbreath"" ")%if( @itemvspoison!=0 , @itemvspoison"vspoison"" ")%if( @itemvsspell!=0 , @itemvsspell"vsspell"" ")%if( @itemvsdeath!=0 , @itemvsdeath"vsdeath"" ")%if( @itemvspara!=0 , @itemvspara"vspara"" ")%if( @itemvsrod!=0 , @itemvsrod"vsrod") Properties: %if( @itemprops!=0 , @itemprops.) %if( @itemtype="weapon", It does @itemmindmg to @itemmaxdmg damage with an ave. damage of @itemavedmg)}

#CLASS {identify}
#ALIAS idprep {#VARIABLE Item "";#ECHO ID Prepped}
#ALIAS idlog {c 'identify' %1;idprep;#WAIT 4000;idcap}
#ALIAS idcap {#NEW @ItemType @Item;#VARIABLE Item "";#ECHO ID Captured}
#TRIGGER {Its weight is &item.weight, value is &item.cost, and level is &item.level~.} {}
#TRIGGER {Affects strength by &item.str~.} {}
#TRIGGER {Affects dexterity by &item.dex~.} {}
#TRIGGER {Affects intelligence by &item.int~.} {}
#TRIGGER {Affects wisdom by &item.wis~.} {}
#TRIGGER {Affects constitution by &item.con~.} {}
#TRIGGER {Affects luck by &item.lck~.} {}
#TRIGGER {Affects charisma by &item.cha~.} {}
#TRIGGER {Affects armor class by &item.ac~.} {}
#TRIGGER {Affects hp by &item.hp~.} {}
#TRIGGER {Affects mana by &item.mana~.} {}
#TRIGGER {Affects damage roll by &item.dr~.} {}
#TRIGGER {Affects save vs paralysis by &item.vspara~.} {}
#TRIGGER {Affects save vs breath by &item.vsbrea~.} {}
#TRIGGER {Affects save vs rod by &item.vsrod~.} {}
#TRIGGER {Affects save vs spell by &item.vsspell~.} {}
#TRIGGER {Affects save vs death by &item.vsdeath~.} {}
#TRIGGER {Affects save vs poison by &item.vspoison~.} {}
#TRIGGER {Affects hit roll by &item.hr~.} {}
#TRIGGER {Armor class is &item.itemac~.} {}
#TRIGGER {Weapon Type: &item.wpntype} {}
#TRIGGER {Damage is &item.mindmg to &item.maxdmg ~(average &item.avedmg~)~.} {}
#TRIGGER {Object '&item.name' is (*) &item.type, with wear location: &item.loc} {}
#TRIGGER {Object '&item.name' is (*) &item.type~.} {}
#TRIGGER {Special properties: &item.properties} {}
#CLASS 0

"Holy hell, Togras, what was THAT?"

Well, I didn't say it was pretty... This, my friends, is a product of 5 hours of wasting time trying to do an exercise in zMUD scripting. It might look basic to some of you, but I'm bloody proud of it! =P It's still a beta script, though, and definitely could use fixing here and there, but it does work as intended. I've used it quite often for sharing off my toys.

So, anyway, let me break this beast down:

The first alias, itemget, has the sole purpose in life of finding items in the database. Unfortunately, this script requires a specific setup in the database. Fortunately, I'll provide it =P Anyway, so, the alias works as follows:

"itemget nameofitemyou'relookingfor itemtype"

The itemtype field is optional, but may help if you have many different types of items with the same name. Once you type the alias, the %find function gets to work looking through the database and looking for what you searched for. Whether it found anything or not, a little prompt will come up. If it found something, there will be a list of items, listed by database call number like so:



No one is obviously going to remember all of the call numbers, except if you constantly spam the same item, in which case... well, anyway. Once you select the number, you will be prompted with the name of the item you've chosen:

You have chosen "Jher's curved dagger" as your item.

Now, depending on how big your database is, you can be going through 100 of these until you find the right one. If you do happen to develop a case of Big-DB-itis, then simply remove the %2 in the itemget alias. Now you can search by multiple keywords, although you will lose the ability to search by itemtype. It's up to you. I'll eventually find some sort of workaround for this, but until then, hey, it's just a beta script anyway =P

Upon selecting the item, it takes all of the relevant information in the database and sticks it in variables, thus the long ass string of #var's. I know it's not very interpreter friendly, and I'll eventually use %var to stick it all on a single line one day, but for now, I lazed out =P

If, by chance, the database doesn't find what you're looking for, the prompt will be blank. Pressing OK or Cancel will keep the previously selected item in the variable cache.

Then there's isay. Isay simply takes all of the information in the variables you just made and prints it out neatly as so:

You chat 'Jher's curved dagger is a(n) weapon is worn at: wield and has minlvl of 48. Stats: +90hp +9dr +9hr Properties: glow hum anti-good. It does 14 to 42 damage with an ave. damage of 28'

If the variable is '0' or '+0', it will simply not print that field at all, and thus you get things like the above. If the item is not a weapon, it will not print the weaponvars and will look something more like:

You chat 'a Cloak of Demons is a(n) armor is worn at: about and has minlvl of 48. Stats: +40hp +8dr +5hr +1str Properties: hum dark evil anti-good anti-mage anti-cleric. '

Nifty, huh?

The proper syntax for isay is simply 'isay (channel)' You can also use isay tell (playername)!

It doesn't just stop there, though. I even included the proper triggers for identify. The triggers allow you to capture identify information and insert it into the database. Once again, this requires the database to be of a strict format, but once again, I will supply my sample =P

the idcap and idprep aliases capture, and prepare the variables respectively. It basically works as such: IDPrep clears your variables (in case something went wrong with IDCap), and IDCap writes all of the information in your variables to the DB, then clears the variables itself. IDLog allows you to do this all automatically if you are a class that can cast identify. If you're not, and need to use scrolls, you'll have to use do this manually.

I personally use a button:

#BUTTON 20 {Log IDs: Off} {#T+ identify;#ECHO Now logging IDs for DB.} {Log IDs: On} {#T- identify;#ECHO No longer logging IDs for DB.} {} {identifytogglebutt} {NEW} {Size} {85} {23} {} {} {} {12} {10} {} {} "" {} {} {identifytoggle}

Though some of you might prefer aliases:

#ALIAS idlogon {#T+ identify;#ECHO Now logging IDs for DB.}
#ALIAS idlogoff {#T- identify;#ECHO No longer logging IDs for DB.}

These allow you to toggle the identify class off and on.

Here's the sample DB.
And here's a copy of the script in txt format for importing. Note that the button and aliases are also in there, so you may want to edit them out if you don't want either of them.

Note, that for ANYTHING to work, the DB MUST BE OPEN and it must be on the ALL tab.

This is a beta script, remember, and may not work on some modified SMAUGS or even Realms of Despair.

If anyone has any suggestions on bettering this script, please let me now. If anyone finds use in it, well, woot =P I did something useful for a change =P

I hope you all enjoy it.
Reply with quote
Evangelist
Adept


Joined: 10 Oct 2000
Posts: 224
Location: USA

PostPosted: Tue Sep 09, 2003 3:15 am   
 
The sample db link is not working. Is there an alternate link?
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts 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