PDA

View Full Version : Very basic question about scripting for Lich



lorddemandred
07-30-2020, 01:40 AM
Exactly how do I use, say, GameObj or something like matchfind to look at a line of information coming from Simu's side, catch it, see what i want, and rip it to a variable to use? Put very, very simply, I want to look at this exact line:


Your ora-studded gauntlets returns to normal.

...and strip either the usable GameObj code for the gauntlets, or use some variation on waitfor or matchwait/find to do the same. This is a small, and should be simple, thing I'm trying to do. Standby script that merely re-applies consecrate immediately, then returns to waiting. Also needs to watch for boots, and possibly cestus/etc... So while I could maybe write this for my very, very specific current loadout, I would love to watch for the consecrate dropping on any gear. And if two go at once, be able to parse both without losing one.

I wrote a three dimensional teleportation array storage/fetch utility for counter-strike servers in the early 00s, and for some reason this is giving me a bugger of a time.

Dantx
07-30-2020, 02:31 AM
Getting the ID is much harder, so if you just can deal with the nouns, it's much easier.



myNoun = matchfindword "? returns to normal."

pause_script "bigshot" if running? "bigshot"
waitrt?
waitcastrt?

fput "prep 1604", "cast #{myNoun}"

unpause_script "bigshot" if running? "bigshot"


Something like this should get your started.

lorddemandred
07-30-2020, 03:01 AM
Ok, that's a lot cleaner. I was working off the grab in bigshot. So that's easy enough... problem is it's going to try to cast consecrate at someone else's boots or whatnot (I'm trying to run with this head/tail a paladin/?? combo - could be two paladin, a monk and paladin, etc). So I need to watch for "Your"... which means I can't watch for "Your boots returns to normal." I have to watch for "Your x x x " + " ? ? ? " " returns to normal. And strip the noun from the end of it. Can I do that easier than:


matchfind /Your <a exist="(.*?)" noun=".*?">.*?<\/a> returns to normal\./i
?
I have no idea what's going on there. What is that returning? There's three "?"s there... am I getting three answers? I stripped that from bigshot and have been trying to work it to work in my script, but nothing I've tried casts the consecrate. It just sits there. Menacingly.

Edit: I honestly want this for three main reasons -
1) so I can have hassle free re-consecrates while just hunting.
2) so if I am running bigshot I can just run bigshot and not my heavily edited pbigshot, which brings us to:
3) so that I can run sbounty at all on my paladins - sbounty calls bigshot, instead of my pbigshot. and so
while just running bigshot works for me using my pbigshot modified version, the bigshot code handles
paladin consecrate poorly. If you mark, "Bless my weapon," in the setup gui, it will use consecrate, and
then, it will, if you're in Voln with the symbol, attempt to sym bless your weapon... regardless if it's
sanctified or not. Yay, wasted favor! ...

So #1 makes me want it regardless... but I would only have to run it while not using bigshot or sbounty if the bigshot code handled the sanctified consecrates properly.

Dantx
07-30-2020, 03:04 AM
That uses XML tags so you need to turn that on in your script for it to work:

https://gswiki.play.net/Lich_scripting_reference#status_tags

put

status_tags on

on the top of your script

lorddemandred
07-30-2020, 03:24 AM
Ok so.

I have a very basic script written.


status_tags on

loop{
matchfind /Your <a exist="(.*?)" noun=".*?">.*?<\/a> returns to normal\./i
weapon($1)
if Spell[1604].known? && Spell[1604].affordable?
waitrt?
waitcastrt?
Spell[1604].cast(weapon)
end
}

I did that and just running it gave this:


>;1604
--- Lich: 1604 active.
--- Lich: error: undefined local variable or method `on' for main:Object
Did you mean? o
1604:11:in `_script'
C:/Users/xxxxx/OneDrive/Documents/lich/lich.rbw:2526:in `eval'
--- Lich: 1604 has exited.
The xxxxx is obviously not originally xxxxx.

Removing the on let it run, but I haven't gone to see if it works. The only place in bigshot status_tags appears is:

wait_for_swing_exec = <<-eos
status_tags
while line = get
$stop_wait = true if line =~ /#{$global_target}.*#{$pcs}/ and line !~ /style id="".*style id="roomDesc"|(?:component|compDef) id='room objs'/
break if $stop_wait
break if !running?($current_script_name)
end
status_tags
eos

Is that the line that is being called that passes everything to everywhere? Is there an easier way for me to parse out the "gauntlets" from that line, without using this mishmash of required code that the behemoth of bigshot needs to cover all its bases?

Dantx
07-30-2020, 10:58 AM
Sorry it needs to be


status_tags "on"

Yeah it's a toggle so you can just call it 2x like bigshot does. If you don't need the ID of the object, you don't really need the code bigshot uses

Tgo01
07-30-2020, 11:55 AM
This line:

weapon($1)

Would need to be:

weapon = $1

Also if you use Spell[1604].affordable? and you don't have 4 mana when your consecrate wears off then the script won't recast it, so you could remove that requirement and just use wait_until { checkmana(4) }, only problem with this is if you are checking for consecrate to wear off of multiple things then while it's waiting for mana the script might miss wearing off messages for other items, so however you want to go. You could just run a script for each item you want to check but the chances of the script getting stuck waiting for 4 mana and other items losing consecrate during this time seems rather low.

Technically I don't think you need wait_until { checkmana(4) } because I'm pretty sure Spell.cast waits until you have enough mana before casting the spell.

Also this line:

Spell[1604].cast(weapon)

Wouldn't work because you're trying to cast at an item ID number so it would need to be:

Spell[1604].cast("##{weapon}")

To cast at the item ID number.

This should work:



status_tags
while line = get
if line =~ /^Your <a exist="(.*?)" noun=".*?">.*?<\/a> returns to normal\./i
if Spell[1604].known?
weapon = $1
wait_until { checkmana(4) }
Spell[1604].cast("##{weapon}")
end
end
end