 |
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Mon Sep 29, 2003 5:50 am
Difficult Problem |
I am trying to setup a way to stop overeating/overapplying.
Remember the thread about optomizing my piece of code? I used LightBulbs example, and now have a variable called SALVES which has twenty two 0's when there are no salves to apply. So let's say I get hit with a double-slash (two venoms, let's say it is two salves), and two positions on the @salves list get set to 1. I want to wait a fraction of a second to receive the trigger strings, then apply the highest priority salve. This way, I can use ALARM on stand-alone triggers so they work together.
After the doubleslash let's say @salves now looks like this:
0100000000000000100000
However, what if the double-venom attack contains one herb, one salve (or even breaks a limb in addition to those two venoms)? Using this type of automated healing seems inferior to using a Queue, considering right now I am using a similar variable shown above for herbs (which makes keeping track of what to heal, when, and in what order a huge mess).
Here is a sample to work with (including how my system responded):
Lightning-quick, Khoraji jabs your left leg with Lightsbane.
Your left leg is greatly damaged from the beating.
apply restoration to legs
You feel a tightening sensation in your lungs.
outr kelp
eat kelp
Khoraji viciously jabs the Manifestation of Hatred into your left leg.
You stumble as your left arm shrivels into a useless appendage.
apply mending to arms
This is probably the most complicated example of what can happen. In addition to two venoms (eating kelp, apply mending), a limb can be mangled (greatly damaged from the beating). So far it seems correct to add #ALARM +0.5 to each one of those triggers, to wait until all the afflictions are received before doing anything. But once I have all those afflictions I am a little lost on how to sort them out, with priority. In this example applying restoration and eating kelp would be the appropriate response.
Any help at all would be appreciated.
EDIT- Here are the triggers of what I have so far, using the above example.
#TRIGGER {^You feel a tightening sensation grow in your lungs.$} {#if (@balherb=0) {eke};Casthma6}
#TRIGGER {^Your left leg is greatly damaged from the beating.$} {#if (@balsalve=0){arl};Rrestoreleftlegtwo5;Crestoreleftlegone4;Cmendleftleg6}
#TRIGGER {^You stumble as your left arm shrivels into a useless appendage.$} {#if (@balsalve=0) {aml};cmendleftleg6}
The Casthma6 and cmendleftleg6 are aliases for changing the specific positions on my herb/salve variables. |
|
|
|
 |
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Mon Sep 29, 2003 6:34 am |
Is there a faster way other than this?
#TRIGGER {^Your left leg is greatly damaged from the beating.$} {#ALARM +0.4 {#IF (%pos( 1, @SALVES)) {#CASE %pos( 1, @SALVES) {ae} {arh} {arh} {arl} {arl} {aml} {arl} {arl} {aml} {ara} {ara} {amas} {ara} {ara} {amas} {art} {art} {am} {ac} {ama} {amh} {amt}}}}
Imagine adding all that to each trigger.. |
|
|
|
 |
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Wed Dec 31, 2003 8:56 am |
Bumping this, I still haven't found a good solution. Using an alarm really slows everything down, especially when losing even half a second every time they attack could mean life or death.
|
|
|
|
 |
TonDiening GURU

Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Wed Dec 31, 2003 9:08 am |
Maybe arrange your SALVES variable from most important to least important.
Gleaned from above:
#VAR SalveSolutions {ae|arh|arh|arl|arl|aml|arl|arl|aml|ara|ara|amas|ara|ara|amas|art|art|am|ac|ama|amh|amt}
#TRIGGER {^Your left leg is greatly damaged from the beating.$} {#ALARM +0.4 {%item(@SalveSolutions,%pos(1,@Salves))}}
//
I'd suggest a queue system as with its round times(?), you want to be able to prioritize the queue as you restabilize then act. |
|
|
|
 |
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Wed Dec 31, 2003 9:21 am |
So an alarm is the only way to do it? The solution you gave is also faster as well?
|
|
|
|
 |
TonDiening GURU

Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Wed Dec 31, 2003 3:08 pm |
Try benchmarking (timing) different solutions?
Your overall speed is probably controlled by scripts that are called more often than your fight scripts ie prompt triggers etc.
I'd parse a session log with the debugger on to see what was happening and then figure out the scripts that are called most often and see if I can improve speed there. |
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed Dec 31, 2003 7:12 pm |
A multi-state trigger using the Wait option might be faster than the alarm.
#TRIGGER {^Your left leg is greatly damaged from the beating.$}
#COND {} {#IF (%pos( 1, @SALVES)) {#CASE %pos( 1, @SALVES) {ae} {arh} {arh} {arl} {arl} {aml} {arl} {arl} {aml} {ara} {ara} {amas} {ara} {ara} {amas} {art} {art} {am} {ac} {ama} {amh} {amt}}} {Wait|Param=400}
As for "adding all that" to every trigger: put "that" on the clipboard and paste it wherever needed using CTRL-V. Or, put it in another alias and call the alias from the trigger. The one below took about 2 seconds to type, including the forum codes, since I just copied the bulk of it from the trigger above.
#AL salves {#IF (%pos( 1, @SALVES)) {#CASE %pos( 1, @SALVES) {ae} {arh} {arh} {arl} {arl} {aml} {arl} {arl} {aml} {ara} {ara} {amas} {ara} {ara} {amas} {art} {art} {am} {ac} {ama} {amh} {amt}}} |
|
|
|
 |
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Wed Dec 31, 2003 9:29 pm |
quote: As for "adding all that" to every trigger: put "that" on the clipboard and paste it wherever needed using CTRL-V. Or, put it in another alias and call the alias from the trigger. The one below took about 2 seconds to type, including the forum codes, since I just copied the bulk of it from the trigger above.
I wasn't referring to the time it takes to add the code to each necessary trigger - I was making a reference to the actual time it takes for zMUD to execute the code. The previous code was probably 1/4 the size, and I was hoping there was a solution that was about the same speed (there are quite a few triggers, so adding substantial amounts of code to every single one would slow down performance time dramatically).
I will run a few benchmark tests to get some definitive results, thank you for the responses. |
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed Dec 31, 2003 10:42 pm |
Without seeing the "previous code", there's no way to judge. However, it seems unlikely you'll find a method much faster than the #CASE I suggested or the %item() that Ton suggested. Either one is a single operation, no matter how many possibilities it includes. Can't get much faster than ONE operation.
Time of execution is far more dependent on number of operations than on number of characters. |
|
|
|
 |
|
|
|