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
DaraisDarkwave
Beginner


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Tue Nov 27, 2007 10:53 pm   

Kill Counting
 
I've been reading all kinds of diffrent scripts and set up's on how to do this and i found at using the database would be a easier way

I got it set up to where it counts how many kills i do, but i want to set it up to where it tells me how many of a certain mob i kill...

Is there a way to set this up?
Reply with quote
DaraisDarkwave
Beginner


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Tue Nov 27, 2007 11:04 pm   Re: Kill Counting
 
DaraisDarkwave wrote:
I've been reading all kinds of diffrent scripts and set up's on how to do this and i found at using the database would be a easier way

I got it set up to where it counts how many kills i do, but i want to set it up to where it tells me how many of a certain mob i kill...

Is there a way to set this up?


Ok i just created a way to do something like this but it still isn't the way i want it...

#TR {(*) is dead! R.I.P.} {#ADDKEY mobkills "%1" %eval(%db(@mobkills,"%1")+1)}
#LOOPDB @mobkills {#SHOW %key%val}
#MENU {Mob Count} {#ECHO You have killed %db(@mobkills,%selected) %selected~.}

I set it up like that, but is there a way to show like a little mini window that will keep track?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Nov 27, 2007 11:05 pm   
 
You'll need some kind of line that says the name of whatever you've killed. In mine, the line looks like this:

You have slain an enraged stoat!
You have slain your mother!
You have slain a hulking bug list!

So my pattern looks like this:

You have slain (*)!

You'll need to set up your own or provide some sample text for us to use.

Now, you need a variable to keep your killcount in. That's the easy part - I'll call mine @KillCount. It's going to be a data record variable. First, you check if you've already killed a mob of this type. You do this with the %db function:

#if (%db(@KillCount,"%1")) {} {}

This checks to see if there's already a key of the KillCount variable with any value. If there is, you just add 1 to that key:

#if (%db(@KillCount,"%1")) {#addkey KillCount {%1} {%db(@KillCount,"%1")+1}} {}

The #addkey command here is replacing the key with the name of the mob you killed, replacing its value with the old value (as returned by the %db function) plus one.

If the mob hasn't been killed before, you add a new key to the variable, with the starting value 1:

#if (%db(@KillCount,"%1")) {#addkey KillCount {%1} {%db(@KillCount,"%1")+1}} {#addkey KillCount {%1} 1}

Giving me a final trigger that looks like this:

#trig {You have slain (*)!} {#if (%db(@KillCount,"%1")) {#addkey KillCount {%1} {%db(@KillCount,"%1")+1}} {#addkey KillCount {%1} 1}}

Now, to get the value for a particular mob, I use %db(@KillCount,"mobname). I can use that anywhere in a script. To loop through all the mobs I've killed, I use #loopdb like this:

#loopdb {#say I have killed %key %val times.}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)

Last edited by Fang Xianfu on Tue Nov 27, 2007 11:09 pm; edited 1 time in total
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Nov 27, 2007 11:07 pm   
 
Okay, so you have the script all set up and working. Excellent.

Adding a tracking window is easy. To track only a certain mob (or a certain subset of mobs) you just put %db(@mobkills,name) in the status window or button caption or wherever. To get the whole list, you'll need to use %expanddb.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
DaraisDarkwave
Beginner


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Tue Nov 27, 2007 11:20 pm   
 
Fang Xianfu wrote:
Okay, so you have the script all set up and working. Excellent.

Adding a tracking window is easy. To track only a certain mob (or a certain subset of mobs) you just put %db(@mobkills,name) in the status window or button caption or wherever. To get the whole list, you'll need to use %expanddb.




rok-man|hero|black-pudding|purple-worm|cave-thing|caecilia|salamander|efreet|hera|zeus|apollo|ares|athena-goddess|gypsy-wizard|gypsy-paladin|
gypsy-warlord|gypsy-assassin|gypsy-abdul|gypsy-bartender|lord-python|ajax|poseidon|patroclus|alecto|hippolyta|agamemnon|odysseus|dionysus|black-slayer
|mulichort|guillotine|master-xorn|proserpina|donjonkeeper|queeklor|master-torturer|athena|skekie-mantern|skexie-bard|skexie-ancient|skexie-lair-guard|skexie-magister
|raistlin|centaur-master|mrs-day|ixitxachitl|black-enfan|gelfling-weaponsmaster|cloud-butcher|iktham-cloud-giant|aeolus|cleric-guildguard|anubis|nobleman|cerebus
harpy-xanth|mundane|lord-menelaus|hector|Arishh|Arachnos|Illyari|Iktham|Princess-Po|tree-ancient|caramon|curley|abdul|swamp-crawler|shark|viking-slave
|viking-merchant|viking-fisherman|viking-guard|druid-lib|druid-guard|guildguard|elf-arm|elf-shop|elf-bard|elf-wine|elf-arch|sal|cimmura-knight|skele-knight|tin-goose
|tin-parot|tin-monkey|noble}


Is there a fast way for me to put them into the Database?
Reply with quote
DaraisDarkwave
Beginner


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Tue Nov 27, 2007 11:36 pm   
 
Fang Xianfu wrote:
Okay, so you have the script all set up and working. Excellent.

Adding a tracking window is easy. To track only a certain mob (or a certain subset of mobs) you just put %db(@mobkills,name) in the status window or button caption or wherever. To get the whole list, you'll need to use %expanddb.


I just reread what you said and notice i don't got a status window, so how would i create one for this?
Reply with quote
DaraisDarkwave
Beginner


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Tue Nov 27, 2007 11:46 pm   
 
I got it recording as a variable but its not showing up in the Status window...Help please...
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Nov 28, 2007 2:03 am   
 
Patience is a virtue :)

You could use something like this:

%expanddb(@mobkills,%concat(" times.",%crlf)," killed ")
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
DaraisDarkwave
Beginner


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Wed Nov 28, 2007 2:31 am   
 
Fang Xianfu wrote:
Patience is a virtue :)

You could use something like this:

%expanddb(@mobkills,%concat(" times.",%crlf)," killed ")



where do i insert this?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Nov 28, 2007 4:42 am   
 
Anywhere you like. A (sufficiently big) button caption, a status window, a #say command in an alias...
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
DaraisDarkwave
Beginner


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Wed Nov 28, 2007 4:51 am   
 
Fang Xianfu wrote:
Anywhere you like. A (sufficiently big) button caption, a status window, a #say command in an alias...


would:

#STW %expanddb(@mobkills,%concat(" times.",%crlf)," killed ")

Would that work?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Nov 28, 2007 12:27 pm   
 
Yes, except annoyingly, it doesn't print the "times" at the end of the string, so you might want to do:

#STW {%expanddb(@mobkills,%concat(" times.",%crlf)," killed ") times.}

Also, you'll probably want to use %cr rather than %crlf, since it seems that the status window parses them separately.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
DaraisDarkwave
Beginner


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Wed Nov 28, 2007 7:03 pm   
 
Fang Xianfu wrote:
Yes, except annoyingly, it doesn't print the "times" at the end of the string, so you might want to do:

#STW {%expanddb(@mobkills,%concat(" times.",%crlf)," killed ") times.}

Also, you'll probably want to use %cr rather than %crlf, since it seems that the status window parses them separately.


Is there any ways to clear out the status window?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Nov 28, 2007 7:12 pm   
 
Open the settings editor and delete the status window item, or run #stw "" from the command line.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
DaraisDarkwave
Beginner


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Wed Nov 28, 2007 7:30 pm   
 
Fang Xianfu wrote:
Open the settings editor and delete the status window item, or run #stw "" from the command line.


Thank you Fang you have been a great help to me :-)..got everything up and running perfectly now
Reply with quote
Mixsel
Wanderer


Joined: 02 Feb 2003
Posts: 99
Location: Seattle, Wa

PostPosted: Thu Nov 29, 2007 2:28 am   
 
Quote:

You'll need some kind of line that says the name of whatever you've killed. In mine, the line looks like this:

You have slain an enraged stoat!
You have slain your mother!
You have slain a hulking bug list!

So my pattern looks like this:

You have slain (*)!

You'll need to set up your own or provide some sample text for us to use.

Now, you need a variable to keep your killcount in. That's the easy part - I'll call mine @KillCount. It's going to be a data record variable. First, you check if you've already killed a mob of this type. You do this with the %db function:

#if (%db(@KillCount,"%1")) {} {}

This checks to see if there's already a key of the KillCount variable with any value. If there is, you just add 1 to that key:

#if (%db(@KillCount,"%1")) {#addkey KillCount {%1} {%db(@KillCount,"%1")+1}} {}

The #addkey command here is replacing the key with the name of the mob you killed, replacing its value with the old value (as returned by the %db function) plus one.

If the mob hasn't been killed before, you add a new key to the variable, with the starting value 1:

#if (%db(@KillCount,"%1")) {#addkey KillCount {%1} {%db(@KillCount,"%1")+1}} {#addkey KillCount {%1} 1}

Giving me a final trigger that looks like this:

#trig {You have slain (*)!} {#if (%db(@KillCount,"%1")) {#addkey KillCount {%1} {%db(@KillCount,"%1")+1}} {#addkey KillCount {%1} 1}}

Now, to get the value for a particular mob, I use %db(@KillCount,"mobname). I can use that anywhere in a script. To loop through all the mobs I've killed, I use #loopdb like this:

#loopdb {#say I have killed %key %val times.}


I just have to say the way you explained it. I can totally wrap my brain around and understand stuff Thanks!
_________________
Spin
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