Using if to decide whether to cure now or later

Posted by Faedara on Thu 25 Nov 2010 12:58 PM — 5 posts, 21,810 views.

#0
I'm working on my AutoHealerAlpha since AutoSipperAlpha is stable and running, only I've already encountered a problem based on Achaea's "locking" system:

I might want to cure something, but if I'm afflicted by something else that has to be cured first. Therefor I have to prioritize things and queue cures, and I'm not at all sure how queue works in situations like this where certain things need priority over other things.

Right now I have this:

<triggers>
  <trigger
   enabled="y"
   match="^You are paralysed and cannot do that\.$"
   regexp="y"
   sequence="100"
  >
  <send>paralysis = "y"
if herb_bal == "y" and arms == "y" then
   Execute ("outr bloodroot;eat bloodroot")
end</send>
  </trigger>
</triggers>


However, if I need to eat more than one herb because I was afflicted by two different things, then I need it to queue the next herb without interrupting what I'm doing (fighting), while still waiting for herb_bal (herb balance).

Notes you probably don't need but could be helpful anyways:
If your arms are broken then you can't get herbs out of the 'rift' (sorta like a magical bag) and you can't eat them, so I need to put curing the broken arms before trying to eat any herbs. I was thinking that it would set a trigger for the variable herb_bal to 0.5 (balance on but not ready), however I see this conflicting with the herb queue. Also, is it possible to have multiple queue at once?
Amended on Thu 25 Nov 2010 10:19 PM by Faedara
Australia Forum Administrator #1
I seem to recall healing and curing systems for Achaea have been done before. Try a search.

The overall approach would be to have a table of the order in which things are to be cured. In your example, curing broken arms would be high up the list.

Then you would go through the table of the correct order (eg. using ipairs) and then for each item, consult another table of things you actually are afflicted with, to see if you need to apply that cure.

Then you might cross-reference the affliction to the cure, to whether or not you have the cure on you, and whether enough time has elapsed, etc. to work out whether to do it now or soon.
#2
I came up with a few different possible ways of doing this, though I still haven't figured out the coding needed.

Timer: Have a timer that checks all the affliction variables and then cures them in a specific order

Example:


<timers>
  <timer enabled="y" second="0.30" offset_second="0.00" >
  <send>if herb_bal == "y" and bound == "n" and arms == "y" and anorexia == "n" and stupidity == "n" then
  if paralysis == "y" then 
    Execute ("outr bloodroot; eat bloodroot")
    herb_bal = "no"
  elseif nausea == "y" then
    Execute ("outr ginseng; eat ginseng")
    herb_bal = "no"</send>
  -- more elseif statements covering the various herb-cured afflictions
  </timer>
</timers>


However this can easily be broken, and with the numerous afflictions and different balances (elixir, herb, and salve), the fact that this will constantly be running feels like it could slow MUSHclient, or at the very least my computer.

Thoughts, opinions, improvements, etc?

While I wait for a response I'll build and test it like this, just to see how effective it'll be.
Amended on Thu 25 Nov 2010 11:08 PM by Faedara
Australia Forum Administrator #3
Template:post=9220
Please see the forum thread: http://gammon.com.au/forum/?id=9220.
#4
Thanks Nick, I'm looking into it. I still don't understand tables or ipairs yet, so I'll do some research