PDA

View Full Version : Extremely basic Hunting Script



DansMtnVue
07-08-2008, 06:08 PM
So... I'm not COMPLETELY lame... but I was wondering if I could get someone with some ruby / lich knowledge to help me with this... I wrote a script in SF to do what I need (pending testing... on paper it should work). I'm wondering if someone can tell me how to write a routine in lich that'll sit back and watch, and if another critter walks in, it'll kill the script (hit ESC for me) and go defensive. That's all, to keep me from dying with another swing at a time when I can't really afford it.

Oh... and any comments / critiques of this would be appreciated... Basically it hides, waits for the RT to clear, then as soon as the giant makes a move, hits for the leg. If it doesn't sever it, it hides, waits, and does it again. If it is severed, then it moves on to chopping off the arm (still waiting and being careful). Once that's done, it's just kill time, ambushin the head (which will change to the chest when the head is done), then lootin when it's dead. Nothing elegant about it. :)


put loot
put stance def
goto Prep

Prep:
put Sign of smiting
put sign of striking
put sign of warding
put sign of defending
put sign of swords
pause
goto Hunt

Hunt:
put hide
pause
goto Wait

Wait:
match Ambush giant
matchwait

Ambush:
put stance off
put ambush giant right leg
pause
goto Examine

Examine:
put look at giant
match LootDone dead
match Hunt2 severed right leg
match Hunt2 severed left leg
match Hunt he has
matchwait

Hunt2:
put stance def
put hide
pause
goto Ambush2

Ambush2:
put stance off
put ambush giant right arm
pause
goto Examine2

Examine2:
put stance def
put look at giant
match LootDone dead
match Hunt3 severed right arm
match Hunt2 he has
matchwait

Hunt3:
put stance def
put hide
wait
goto Ambush3

Ambush3:
put stance off
put ambush giant head
pause
goto Examine3

Examine3:
put look at giant
match LootDone dead
match Hunt3 he has
matchwait

LootDone:
put stance def
put loot
exit

Stanley Burrell
07-08-2008, 06:12 PM
Is that your boomstick?

DansMtnVue
07-08-2008, 06:22 PM
KLAATU... VERATA...

...necktie... nectar... nickel...

{mutters} it's an n-word, definitely an n-word...

It's definitely an n-word.

Jaimaltz
07-08-2008, 11:31 PM
So... I'm not COMPLETELY lame... but I was wondering if I could get someone with some ruby / lich knowledge to help me with this... I wrote a script in SF to do what I need (pending testing... on paper it should work). I'm wondering if someone can tell me how to write a routine in lich that'll sit back and watch, and if another critter walks in, it'll kill the script (hit ESC for me) and go defensive. That's all, to keep me from dying with another swing at a time when I can't really afford it.


From Command_Quicklist.txt:

86) kill_script
89) stop_script

I'm not sure what the difference is, perhaps stop_script just pauses the script. Anyway, further down the file it has some instructions:

stop_script("script1", "script2", "script3", "etc.")

So you'd do something like:

#stopscriptwhencreaturewalksin.lic

begin:
match "stopscript", "messaging when creature walks in"
match "stopscript", "messaging when creature2 walks in"
matchwait

stopscript:
stop_script("yourhuntingscriptname")
goto begin

Shaelun
07-09-2008, 01:34 AM
Lich will have to be running the hunting script, if you weren't aware of that -- it can't stop SF/Wizard scripts (only ones it's running). Actually simulating the ESC key being hit is a whole lot harder than you might think; telling SF the ESC key has been hit is actually possible, but not without more than Lich provides.

There're lots of ways of doing this, but what seems easiest offhand is...



entry:
i = 0
goto :monitor

escape:
stop_script "huntingScript"
wait_until { running?("huntingScript") }
i = 0
goto :monitor

decrement:
i -= 1
goto :check

increment:
i += 1
goto :check

check:
goto :escape if i > 1

monitor:
match 'increment', 'A very mean looking ant just skittered in!'
match 'decrement', 'You have slain the ferocious ant!'
match 'decrement', 'An ant hastily flees from you!'
matchwait

The i variable keeps track of how many active critters are in the room; the script will kill the hunting script if i > 1, and then wait until the hunting script is running again to continue. There are "better" ways of handling it, but this is easy to understand and should work pretty well. Oh, BTW, kill_script and stop_script are identical synonyms -- they both execute the same code.