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


Joined: 04 Mar 2004
Posts: 24
Location: Australia

PostPosted: Tue Nov 16, 2004 12:47 pm   

trigger/variable help
 
I use variations of the following trigger to report on damage from a blast.

#TRIGGER {^([a-z~-~'~, ]) screams in pain.} {#if (@blasttype != "") {party report %1 SCREAMS to @blasttype} {party report %1 screams};#var resist screams;#var target {%1}}

The @target, @blasttype and @resist are then shown in my status window.

The triggers, and variables work fine in their current form.

I have 2 questions.

Is there some easy way to store the last 10-20 different combos .. ie

orc
grunts
acid

orc
screams
mana

orc
winces
mana

Witch-king
grunts
cold

withered hobbit
shrugs
fire

so that i can recall/view them at will. viewing on another window or with #show is fine. I realise i can do #var resist4 @resist3; #var resist3 @resist2; #var resist2 @resist .. but i was hoping for a neater way to do this.



The other question i have ( i guess it will prolly be easier if i figure out the first part) is to only do the party report if the combo of @target, @resist, @damtype is different from the previous report. I guess 1 #if statement to check all 3 would be much faster than 3, being that this will be triggering every 5-10 seconds when in combat.


thanks
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Nov 17, 2004 1:18 am   
 
I would say you are going to want to use record variables. These provide a linked pair of key and value. Since you have 3 things to correlate I would suggest using mob and blast types for key names and then have resist as value. If you select a character that is not in any mob name and not reserved in zMud to seperate the mob name and the blast type then you should have no problems with various sorts or other data manipulations. The plus sign comes to mind '+'.

Next solution would be to go with a full database. Searching would be faster, storage might be slightly slower, and memory usage would be higher. However that would allow for better data access.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
a5hi5m
Beginner


Joined: 04 Mar 2004
Posts: 24
Location: Australia

PostPosted: Sun Nov 28, 2004 11:23 pm   
 
I got this working really well, Thanks. I use variations of the following trigger, and alias to store and recall it all.

Seems the spacing isnt shown prettily here, but this works how i want it to ..

#TRIGGER {^([a-z~-~'~, ]) screams in pain.}
{#var res 0%;
#var target {%1};
#var blastcheck {@target~|@resist~|@blasttype};
#if (@blastcheck=@blastcheckold)
{#noop}
{#var mobcheck {@target + @blasttype};
#addkey blastdb @mobcheck @res;
#add dbcount 1;
#if (@blasttype != "")
{party report %1 SCREAMS to @blasttype}
{party report %1 screams}};
#var blastcheckold @blastcheck;
#if (@dbcount > 25)
{#YESNO "DB Count is high. Clear?" {#var blastdb {};#var dbcount 0}}
{#noop}}

#ALIAS bhist {#if (%-1="") {#LOOPDB @blastdb {#say %key resists-> %val}} {#LOOPDB @blastdb {%-1 %key resists-> %val}}}


What im am now wondering, and i cant seem to find it easily, is a way to loop through @blastdb, searching for a particular keyword, and recalling just those, instead of the last 25 blasts or so. Something along the lines of the next alias, i realize there is something missing where the XXX is, but im not sure of the function to call

#alias bfind {#LOOPDB %XXX(@blastdb {%-2 %key resists-> %val})}

"bfind troll p'" then returns
p' Troll + Acid resists-> 60%
p' Troll + Mana resists-> 100%
p' Troll + Cold resists-> 0%


Another question i do have, is how laggy, or how much memory usage is looping through @blastdb likely to involove if, instead of clearing them after 15 or 25 blasts, letting it run to 100, or higher?



Thanks again!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Nov 29, 2004 1:02 am   
 
Looping through the record doesn't require much memory and won't be laggy unless used within or called from a trigger. So as long as you do it from the command line there is no lag.

The only way to do the find that I can see is to test every %key with an #IF. Since your mob names could be multiple words I would use %pos to allow partial matches. This also will leave the possibility of searching on blast types with the same find alias.
#alias bfind {#LOOPDB @blastdb {#IF (%pos("%1",%key)) {%-2 %key resists-> %val}}}

Again searching would be faster with an actual database, but this should go fast enough for a while.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
a5hi5m
Beginner


Joined: 04 Mar 2004
Posts: 24
Location: Australia

PostPosted: Mon Nov 29, 2004 1:08 am   
 
Awesome, thanks once again!
_________________
Smoking@BatMUD
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