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


Joined: 14 Nov 2004
Posts: 3

PostPosted: Sun Nov 14, 2004 6:23 pm   

Logging equipment.
 
Hi,

I'm trying to figure out the best/easiest way to log equipment. When I arrive in a room I see something like this:

Stockade, Chief's Tent (s)
The orc chieftain.
A female kobold.

Then when I examine the chieftain I see:

A gigantic green-skinned humanoid who has hastily thrown on a cloak. It
regards you with a look of murder in his piggy eyes!
He is in good shape.
Orc is carrying:
A fur cloak (worn).
An orcish handaxe (wielded in right hand).

I created a database in zmud with the fields NPC and Equipment. I wanna log "The orc chieftain" and when I enter the room and then log it's equipment when I examine the npc. Is it possible to do this? I asume using some sort of trigger?

Thanx in advance.
Reply with quote
mortie
Wanderer


Joined: 26 Sep 2002
Posts: 73
Location: United Kingdom

PostPosted: Sun Nov 14, 2004 9:23 pm   
 
Theres a good example in the finished script section.

http://forums.zuggsoft.com/phpbb/viewtopic.php?t=2164


I would do something like this:-

Create my trigger(s) to pick up the items and keep them in one class folder

#CLASS {NPCEquipment|EQTriggers}
#TRIGGER {^(*)%s~((*)~)~.$} {#ADDKEY newRecord "%2" %trim(%1)}
#TRIGGER (^(*) is carrying~:} {#ADDKEY newRecord NPCNAME %trim(%1)}
#CLASS 0

I would then create my database with all possible fields which appear in the brackets.

NPCName
worn
wielded in right hand
etc


Set up an alias to examine the NPC and an alias to store the data to your DB:-

#ALIAS addmob {#t+ EQTriggers;#VAR newRecord %null;exa %1;#TEMP eqtemptrig {^$} {#t- EQTriggers;storeData}}
#ALIAS storeData {
existingRecord="";
#IF !%null( %query(&NPCName=@newRecord.NPCName)) {
existing_record=%query((&NPCName=@newRecord.NPCName), All|<optional db name here>)
#dbput @existingRecord @newRecord
} {
#new all||<optional db name here> @newRecord
}

I haven't tested it so you'll have to play around with it. Hopefully this will give you some idea.
If you don't want it to update existing records then edit that part.
You can use %find rather than %query. If you have a v.large db (5000+ items) then %query will be noticeably slower
than %find. You'll have to decide which one is more suited for your needs.
Reply with quote
Funkyflea
Newbie


Joined: 14 Nov 2004
Posts: 3

PostPosted: Mon Nov 15, 2004 7:34 pm   
 
Hi,

I tried this but didnt get it to work. I even cut out the IF statement part but no luck. I checked the @newRecord and all the items where stored in it but it wouldnt add to the database. I used the line " #new all||<optional db name here> @newRecord" like " #new all my_database @newRecord" with the fields you mentioned but no luck. I was thinking an easier way might be to do this:

When I kill a mob I see this:
You killed Messenger.

Then I hit my alias to take all:
You take 45 gold coins; a hard leather armour; a large knife from the corpse of
Messenger, claimed by Funkyflea.

I want a trigger something like this:

#trigger {^killed (*)~ } {write to a text file called BigList}
#trigger {^You take (*) from the corpse~} {write whatever in the BigList file right under the previous trigger}

Possible?
Reply with quote
mortie
Wanderer


Joined: 26 Sep 2002
Posts: 73
Location: United Kingdom

PostPosted: Mon Nov 15, 2004 10:49 pm   
 
The <optioanl db name> is the two letter name for the db. You can see this with the record numbers


e.g 1eq, 200eq etc so "eq" is the db name.

Using the above example the syntax would be

#new all|eq @newRecord

Its important you use the | in the above statement. If its going to be the only db you use you can
do with out that.

#new all @newRecord

Its also important that the Fields you created in the database are the same as the ones in the #ADDKEY statements otherwise it wont update those fields.

I'd advice against a text file list.Its inwieldy and a pain to maintain.
It does takes a little time setting up your database(s) with views and fields etc. However, once you get the hang of it you will wonder how you coped all this time without them.


Last edited by mortie on Mon Nov 15, 2004 11:12 pm; edited 1 time in total
Reply with quote
Funkyflea
Newbie


Joined: 14 Nov 2004
Posts: 3

PostPosted: Mon Nov 15, 2004 11:06 pm   
 
the above example fails though, because if the npc is wearing multiple things only the 1st item that's "worn" is captured.

I'm getting by with this for the moment:

#trigger {^You killed (%w).} {#FILE 1 equipment.txt
#WRITE 1 {%1}}

#trigger {^You take (*) from the corpse} {#WRITE 1 {%1}
#CLOSE 1}

This seems to work ok. Prolly a better way to do it though, only learning this zmud scripting.
Reply with quote
mortie
Wanderer


Joined: 26 Sep 2002
Posts: 73
Location: United Kingdom

PostPosted: Tue Nov 16, 2004 4:16 pm   
 
This reason its 'failing' is im assuming your NPCs dont have particular slots for items worn i.e back, leg, arm, etc

So when a mob is wearing more than one item it looks like this:-

A fur cloak (worn).
A pair of bracers (worn).
An orcish handaxe (wielded in right hand).

The example i gave was just to give you some idea how to interact with the db and not an exact solution.

You could either have used some form of counter so when more than one worn item is encountered it increments so you have fields called worn1 worn2 etc.

Or you could have used #additem to update the worn field.
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