How can I make something to recognize certain items?

Posted by Rjak on Fri 06 Aug 2004 01:46 AM — 4 posts, 19,800 views.

Romania #0
Like I said on other posts, I know nothing about codding and scripting, so I will need full help. OK, here is my problem

In the mud I play, are quests - lol, like in many others. But here you have someone who hires you to retrieve a certain item. Those items are not unique, are to be find all over the place. The items are allways the same, could be pieces of armor, misc items, even food or light.
What I want is to make something that recognise the items on the ground or in mobs inventory and tells me "x - job item", or even better "x - job item for Y".
Of course, I can capture the description of each item and set some triggers, but it looks like a huge task, and must be an easyest way.
I realise I have to capture the description of the items when are laying on the ground, but having about 1000-1500 triggers just for this, don't look right.
Let me give you an example:
Is a mob, Chaste, who can hire you to retrieve: a platoon medpack, a ranger tool, an extractor, mountain ranger boots.
The ranger tool, when is on the ground is "A small black tool lies on the ground." When is in a mob inventory is a ranger tool" or the mob may held it then is "<held in hand> a ranger tool". To set 3 triggers for just 1 item... and are literally hundreds... hmm

I *think* a database or someting can be made, to hold all the items, and when I look/glance/peek at a mob or look/observe a room to see if the items there are to be found in the db.
Can be? :)

Thank you,
Rjak

PS Guys, sometimes I'm tinking... if I would know all you know about scripting, triggers and stuff, my life on any mud would be a lot easyer. :)
Portugal #1
Im sure there the more recent versions of MC features DB options, but im not familiar with them yet, so I would use an array and world.AddTrigger function. I dont see how you can manage to do what you want without 2 triggers for each item though ( not 3 as you were thinking as the inventory, held or wear has the same desc if you use the right match ), you dont need to build those triggers by hand though.

i would build a solution like this ( example in JScript ):


var eEnabled = 1; // enable trigger
var eTriggerRegularExpression = 32; // trigger uses regular expression
var eReplace = 1024; // replace existing trigger of same name


var match  = new Array()

// match [i] = "ground desc|inventory desc|quest mob"

match [0]  = "A small black tool lies on the ground.|a ranger tool|Chaste"
match [1]  = "A big rock lies on the ground.|a big rock|mason"

 
for ( i = 0 ; i < match.length ; i++ ) {

    var list = match[i].split("|"); // splits each match line in the 3 parts that we want
 
    var send_  = list [1] + " - job item for " + list [2] // creates the note "x - job item for Y"
    var flags_ = eEnabled | eTriggerRegularExpression | eReplace;
    
// AddTrigger(TriggerName, MatchText, ResponseText, Flags, Colour, Wildcard, SoundFileName, ScriptName);

    world.addtrigger( "Quest_G" + i , list [0] , send_ , flags_ , -1 , 0 , "" , "" );
    world.addtrigger( "Quest_I" + i , list [1] , send_ , flags_ , -1 , 0 , "" , "" );
    
    world.settriggeroption ( "Quest_G" + i , "send_to", 2 ); // set the trigger to send as note
    world.settriggeroption ( "Quest_I" + i , "send_to", 2 ); // set the trigger to send as note
    
}


Amended on Tue 17 Aug 2004 09:33 AM by Avariel
USA #2
Mushclient has no real database functions inbuilt.

It relys completely on the script languages for that, which is very versatile. (depending on which language you know/want to know/are learning whatnot, the approach is different). But you can check the mud database plugin for examples on using databases.

You wont be able to get away with much of anything, except tons and tons of triggers.
However, you CAN use scripting and a database. In many ways, your best bet would probably be to add appropriate triggers as per quests (three per item, or even one per item) which you then delete once youve found the item. And keep another database of what you need, and who the quest is for.

You could get away with a single trigger (and variable) per item, but it would probably be easiest and most versatile to add a trigger for each way of finding the item, that way you know if its on a mob, or on the ground, or whatnot, and can take steps accordingly.

But theres no reason to have triggers active for items that you dont need all the time. You can add/delete them just as easily as turn them on or off, and it would clean up your world file.
Greece #3
I would have 3 triggers, one for ground, one for inventory and one for held, and then do the rest via scripting, much like Avariel suggested, but instead of adding triggers, just using the for loop to check through each item and print the appropriate job.