[?] No-Hands Killing Script

Posted by Amoeba on Sun 20 Feb 2005 10:43 AM — 32 posts, 107,371 views.

#0
Note: Wizards of the MUD have said this is okay

I'm new to the mudding world and especially MUSHclient. With the help of a forum post on coding a delay functionality into my scripts I have written a script that will summon an enemy, kill it, get loot, cleanup, rest and repeat.

-- table of outstanding threads that are waiting
wait_table = {}

-- called by a timer to resume a thread
function wait_timer_resume (name)
  thread = wait_table [name]
  if thread then
    assert (coroutine.resume (thread))
  end -- if
end -- function wait_timer_resume 

-- we call this to wait in a script
function wait (thread, seconds)

  id = "wait_timer_" .. GetUniqueNumber ()

  hours = math.floor (seconds / 3600)
  seconds = seconds - (hours * 3600)
  minutes = math.floor (seconds / 60)
  seconds = seconds - (minutes * 60)

  status = AddTimer (id, hours, minutes, seconds, "",
            timer_flag.Enabled + timer_flag.OneShot + 
            timer_flag.Temporary + timer_flag.Replace, 
            "wait_timer_resume")
  assert (status == error_code.eOK, error_desc [status])

  wait_table [id] = thread
  coroutine.yield ()
end -- function wait

function my_alias_thread (thread, name, line, wildcards)

  Send ("stand")
  wait (thread, 10)
  
  Send ("challenge")
  wait (thread, 10)

  Send ("kill student")
  wait (thread, 60)

  Send ("get all from corpse")
  wait (thread, 10)
  
  Send ("get coins")
  wait (thread, 10)

  Send ("cleanup")
  wait (thread, 10)
  
  Send ("hp")
  wait (thread, 1)
  
  Send ("rest")
  wait (thread, 90)
  
end -- function my_alias_thread 

function my_alias (name, line, wildcards)

  thread = coroutine.create (my_alias_thread)
  assert (coroutine.resume (thread, thread, name, line, wildcards))

end -- function my_alias


This works but it isn't all that great..
-It requires I find out what appropriate times are
-It only works for one situation (see above complaint)
-It could kill a lot faster if I coded it better
-More complaints, but anyways

Here's What I Want

I will manually start the script once I'm in an appropriate room.

-Summon enemy (Send "challenge")
-Text "The Intermediate calmly steps onto the mat." will be displayed
-Once enemy is summoned, kill enemy (Send "kill student")

-When I'm finished killing the enemy (String: "You killed Intermediate!")
--Loot corpse (Command: "get all from corpse")
--Cleanup the room (Command: "cleanup")

-Rest ("Command: "rest")
-When HP/Fatigue are at 100% again (String: "HP: xxxx/xxxx Mana: xxxx/xxxx Fatigue: xxxx/xxxx Exp: xxxxxxxxx")
--Stand up (Command: "stand")

-- Loop script from here


I have been looking through all that MUSHclient can do and thought I'd post here before I spend major amounts of time. Does anyone have parts of this (or the whole thing) already written out?

Thank,
Amoeba
#1
This is an easy one. But, what scripting language do you want to use? (As a beginner, I would reccomend VBscript, mostly because thats what I learned on, and I'm still learning Lua)

I could have it written for you in... Lemme see here, 5 minutes, once you know what language you want to use.

It's very similar to the huntscript I wrote.
Amended on Mon 21 Feb 2005 08:38 AM by David Berthiaume
#2
LUA is what I'm best with.

Thanks very much for the reply!
#3
Ok, well... That's going to be a little more tricky, let me get back to you in a few minutes... I should have most of it hashed out.
#4
You're doing *me* a favor. Choose what you like. Heck, write it in psuedo-code :P

Thanks so much.
#5
Whats the output when you rest, and when you stand up?

Amended on Mon 21 Feb 2005 08:49 AM by David Berthiaume
#6
Doh! Sorry

You clamber to your feet.
#7
Timing isn't nearly as difficult as you think it is. So don't worry about that.
#8
I need to know EXACTLY what your prompt looks like.
#9
I'll paste in a sequence. Give me 5.

Thanks so much.
#10
The only thing I need now, is the Prompt, the exact prompt.

Also, I'm not to sure on how to do one thing...


if <wildcard 1> = <wildcard 2, AND Wild Card 3 = wildcard 4 Then
Blah, blah, blah
Else
Blah, Blah, Blah...
end
#11
Oh, it's just ">"

Is that what you're asking?
#12
That's the only part I don't know. Is the last part, making sure both Fat, and Health are at 100%, I can do either or... I don't know how to do both at the same time.

Somewhere in there, there has to be a way to join the two together...
#13
Never mind, I figured it out. I need to know your EXACT prompt.
#14
Well,

Can you say local health, fatigue = {regex string here}
then
if ( ( health = xxx ) and ( fatigue = xxx ) ) then
--stuff
else
--other
end
#15
I'm not sure what you mean. It's just a carrot.
#16
Also, When you type text into the mud, does it newline?

Or does it add into your prompt?

I.E.

<prompt> You say "Hello World"


Or:

<prompt>
You say "Hello World"
#17
What I need... Is your exact prompt... What does it look like?

My prompt looks like this:

<100%HP|100%Mana|100%Move> <H>
(STL: Defensive)(Night)
<82%XTL>
You say "This is what my says look like with a new line"
Amended on Mon 21 Feb 2005 09:13 AM by David Berthiaume
#18
Me

hp
HP: 56/64   Mana: 38/38   Fatigue: 28/45   Exp:  3349    
> say this is what mine look like
You say: this is what mine look like
>
#19
Ok, you're going to have to adjust the triggers to match what it is you want to match on, the code inside the trigger will be accurate. So keep that in mind...

Gimme the mud address and port, so I can see exactly what it is you are talking about.
#20
eotl.org:2012
#21
Well, it appears the mud is down... Ok, no biggie, like I said you will just have to adjust the Triggers.
Amended on Mon 21 Feb 2005 09:27 AM by David Berthiaume
#22
Doh

eotl.org:2010

Man, I typed that again as 2012 (in this post) and just had to edit it. I'm having a bad day today. Grr.
Amended on Mon 21 Feb 2005 09:28 AM by Amoeba
#23
This is the alias to turn the script on and off.
<aliases>
  <alias
   match="kill script *"
   enabled="y"
   send_to="12"
   sequence="900"
  >
  <send>if "%1" = "on" then
EnableGroup ("KillScript", True)
Note ("Kill Script ON!!")
Send ("challenge")
else
EnableGroup ("Kill Script", False)
Note ("KillScript OFF!!")
end</send>
  </alias>
</aliases>


--------------------------------------------------------------

These are the Triggers that make it work... Like I said before
you will need to adjust what they match on. The Trigger with
your health, and Mana, and Fatigue, needs the 6 wildcards.
I didn't make it a regexp trigger, I'm tired and this wasn't
that difficult to create. I use something similar for hunting
mobs.

<triggers>
  <trigger
   enabled="y"
   group="KillScript"
   match="The Intermediate calmly steps onto the mat."
   send_to="13"
   sequence="100"
  >
  <send>kill student</send>
  </trigger>
</triggers>


<triggers>
  <trigger
   enabled="y"
   group="KillScript"
   match="You killed Intermediate!"
   send_to="12"
   sequence="100"
  >
  <send>Send ("get all from corpse")
Send ("cleanup")
Send ("rest")
DoAfter (30, "Stand")</send>
  </trigger>
</triggers>

<triggers>
  <trigger
   enabled="y"
   group="KillScript"
   match="HP: */*   Mana: */*   Fatigue: */*   Exp:  *"
   name="KillScriptPrompt"
   sequence="100"
  >
  <send>If (("%1" = "%2") and ("%3" = "%4") and ("%5" = "%6") then
Send ("challenge")
else
Send ("rest")
DoAfter (30, "stand")
end</send>
  </trigger>
</triggers>

<triggers>
  <trigger
   enabled="y"
   group="KillScript"
   match="You clamber to your feet."
   sequence="100"
  >
  <send>EnableTrigger ("KillScriptPrompt, True)</send>
  </trigger>
</triggers>
#24
Thank you so kindly!! This makes me a very happy person.

I appreciate it.
#25
Ok, this is even easier than I thought.


LOL...


Need to make a few changes then it will work.
Amended on Mon 21 Feb 2005 09:49 AM by David Berthiaume
#26
Number of errors. Lots of assignment operators where I think you meant to put ==. I fixed those and I get

[string "Alias: "]:2: bad argument #2 to `EnableGroup' (number expected, got nil)
stack traceback:
[C]: in function `EnableGroup'
[string "Alias: "]:2: in main chunk
#27
yeah, hold on... I'm logged in there as Ryven, let me finish this up, I know there are errors. It would help if I was in the room where this script needs to run.
#28
I fixed that issue (some misspellings).

I think I have enough code here to let me write it all up.

I'm chugging away :)
#29
<triggers>
<trigger
enabled="y"
group="KillScript"
match="HP: */* Mana: */* Fatigue: */* Exp: *"
sequence="100"
>
<send>If (("%1" = "%2") and ("%3" = "%4") and ("%5" = "%6") then
Send ("Stand")
Send ("challenge")
else
Send ("rest")
DoAfter (10, "hp")
end</send>
</trigger>
</triggers>


<triggers>
<trigger
enabled="y"
group="KillScript"
match="You killed Intermediate!"
send_to="12"
sequence="100"
>
<send>Send ("get all from corpse")
Send ("cleanup")
Send ("rest")
DoAfter (10, "hp")</send>
</trigger>
</triggers>

You don't need the stand trigger at all. It's not needed... I misunderstood how the mud worked.


#30
You left before I could say thanks.

Thanks for your help.
#31
--edited for dumbness