|
fattony Apprentice
Joined: 27 Dec 2001 Posts: 105 Location: USA
|
Posted: Tue Jun 11, 2002 6:38 am
Kill History and string lists |
I know this is probably a stupid question and will probably be a very simple and easy answer that I SHOULD have known, but for some reason, I don't. Here's the question. I have a kill history variable that stores each thing I've killed and the time I killed it at. This variable will store 100 kills before deleting the oldest one to replace it with the newest one. What I want to be able to do is search the list for specific names and see how many times that name is listed (and eventually break it down to %/total kills)
Ex-
Orc soldier - Jun 10 at 9:08 pm
Orc soldier - Jun 10 at 9:12 pm
Orc soldier - Jun 10 at 9:13 pm
Goblin shaman - Jun 10 at 9:18 pm
Troll - Jun 10 at 9:20 pm
Troll - Jun 10 at 9:36 pm
Owlbear - Jun 10 at 9:39 pm
Goblin shaman - Jun 10 at 9:48 pm
Orc soldier - Jun 10 at 9:54 pm
Goblin shaman - Jun 10 at 9:55 pm
I would like an alias that would display something like:
Orc soldier - 4 Total Kills {40%}
Goblin shaman - 3 Total Kills {30%}
Troll - 2 Total Kills {20%}
Owlbear - 1 Total Kills {10%}
Anything like this possible? I can script the rest I'm sure, but any help would be appreciated. Thank you in advance.
Fat Tony |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Tue Jun 11, 2002 7:03 am |
#FORALL @V_Percent_Mob_Type {#UNVAR V_Percent_Mob_%replacE(%copy( %i, 1, %pos( "-", %i)-2), " ", "_")}
#FORALL @v_Death_log {#VAR TempMob %copy( %i, 1, %pos( "-", %i)-2);#ADDITEM V_Percent_Mob_Type @TempMob;#ADD V_Percent_Mob_%replacE( @TempMob, " ", "_") 1}
#FORALL @V_Percent_Mob_Type {#SH %i - @{V_Percent_Mob_%replacE( %i, " ", "_")} Total Kills ~(@{V_Percent_Mob_%replacE( %i, " ", "_")}~%~)}
Something like that
Ton Diening
Providing untested answers that tend to be
more complicated than others. |
|
|
|
fattony Apprentice
Joined: 27 Dec 2001 Posts: 105 Location: USA
|
Posted: Wed Jun 12, 2002 3:52 am |
Okay, I'm not new to coding, but that made only a little sense to me. I applied it to my setup and didn't get much for results. The vars do identify the most common of the mobs in the list, but it doesn't make the stats or anything. My variable containing the history (khistory) has 100 mobs in it, including the date and time they were killed. If it would make the script any simpler, I can take out the date/time tag (its not necessary anyway). The alias (kill_history) just displays the list for now, but as I stated, I would like it to show the total kills and percent IF POSSIBLE, not a huge deal if it'll be a struggle. Any help you guys can shed is greatly appreciated. :)
Fat Tony |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Wed Jun 12, 2002 12:43 pm |
Try using this script:
#VAR khistorytemp ""
#FORALL @khistory {#VAR khistorytemp %additem(%copy(%i, 1, %pos(" -", %i) - 1), @khistorytemp)}
#WHILE (%numitems(@khistorytemp) > 0) {#VAR curmob %item(@khistorytemp, 1);#VAR initial %numitems(@khistorytemp);#DELITEM khistorytemp {@curmob};#VAR count %eval(@initial - %numitems(@khistorytemp));#SAY {@curmob - @count Total Kills ~{@count~%~}}}
Basically what this does is that it first converts the @khistory variable into a useful format (we strip all the times and dates and leave only the names of the mobs.) This is stored into another variable. Then we go through this temporary variable and get the first item in the list, find out how many items are currently in the list, delete all ocurrances of the first item in the list, and find out how many items are remaining in the list. The difference between these two numbers, is how many of that particular mob were in the list. We display it and do it all over again until there are no more items in the list.
Kjata |
|
|
|
fattony Apprentice
Joined: 27 Dec 2001 Posts: 105 Location: USA
|
Posted: Thu Jun 13, 2002 12:53 am |
Very impressive, Kjata. Works like a charm, thank you very very much. I'm always surprised at how versatile zMUD is, and even more so by how helpful you guys are. Thank you again. :)
Fat Tony |
|
|
|
fattony Apprentice
Joined: 27 Dec 2001 Posts: 105 Location: USA
|
Posted: Thu Jun 13, 2002 2:08 am |
One question though. To make it simpler, I just stated that the kill history contains 100 kills. This is actually a user-defineable variable (I usually have it around 30 or 40) I saw the ~{@count~%~} part, works perfectly if the history stores 100 kills, but obviously not if its down at 30 or 40 :)
I messed around with it a little and added a variable to count the percent, but I can't get it working. Any more ideas?
Fat Tony |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Thu Jun 13, 2002 2:25 am |
Multiply the number by 100 and divide it by the number of elements in the list. So:
~{@count~%~}
will be:
~{%eval((@count * 100) / %numitems(@khistory))~%~}
Kjata |
|
|
|
|
|
|
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
|
|