PDA

View Full Version : Script Help



Danical
08-25-2006, 08:51 PM
I'm having a bit of trouble making this work. I can't seem to make it all work. I've tried looking at the tutorials and bugged shaelun numerous times but I still can't seem to make sense of it.

Specifically, it targets constructs when I'm trying to make it skip those. I'd also like to add in a few lines for when I run into scouts/jans so I can 1013 them for mana then proceeded to "kill."

And possibly, I'd like to add in a line for if there are two or more ithzir/griffins in the room then I would open 1030 but that can wait.

Any help would be very much appreciated.



setpriority(-1)
otfroom = Array.new
otfroom[0] = "w"
otfroom[1] = "n"
otfroom[2] = "n"
otfroom[3] = "e"
otfroom[4] = "w"
otfroom[5] = "s"
otfroom[6] = "e"
otfroom[7] = "w"
otfroom[8] = "s"
otfroom[9] = "e"
otfroom[10] = "e"
otfroom[11] = "e"
otfroom[12] = "ne"
otfroom[13] = "e"
otfroom[14] = "ne"
otfroom[15] = "go shore"
otfroom[16] = "e"
otfroom[17] = "e"
otfroom[18] = "go shore"
otfroom[19] = "n"
otfroom[20] = "ne"
otfroom[21] = "e"
otfroom[22] = "sw"
otfroom[23] = "s"
otfroom[24] = "e"
otfroom[25] = "e"
otfroom[26] = "e"
otfroom[27] = "e"
otfroom[28] = "e"
otfroom[29] = "w"
otfroom[30] = "n"
otfroom[31] = "e"
otfroom[32] = "w"
otfroom[33] = "w"
otfroom[34] = "w"
otfroom[35] = "w"
otfroom[36] = "nw"
otfroom[37] = "nw"
otfroom[38] = "w"
otfroom[39] = "w"
otfroom[40] = "w"
otfroom[41] = "s"
otfroom[42] = "nw"
otfroom[43] = "s"
otfroom[44] = "nw"
otfroom[45] = "s"
otfroom[46] = "nw"
otfroom[47] = "s"
otfroom[48] = "s"
otfroom[49] = "w"

move:
loop{
for dir in otfroom
move dir
mobs = Array.new
mobs = checknpcs
mobs.delete('a greater construct')
if mana?(60) and !checkpcs and mobs
echo mobs
goto "kill"
else
next
end
end
}

kill:
loop{
;mobs = Array.new
;mobs = checknpcs
;mobs.delete('a greater construct')
fput "prep 1030"
fput "cast at #{mobs.first}"
waitrt?
until waitfor("leaving you gesturing at nothingness", "What were you referring to", "motionless", "life fading from", "in a crumpled heap", "goes still", "as it dies", "then collapses") =~ /leaving you gesturing at nothingness|What were you referring to|motionless|life fading from|in a crumpled heap|goes still|as it dies|then collapses|Sing Roundtime/
fput "prep 1030"
fput "cast at #{mobs.first}"
waitrt?
end
fput "loot"
mobs.clear
fetchloot
mobs = Array.new
mobs = checknpcs
mobs.delete("a greater construct")
if mana?(60) and mobs
goto "kill"
else
goto "move"
end
}

Shaelun
08-26-2006, 02:36 AM
It looks like the construct issue is because you're trying to delete "a greater construct" from the `mobs' array, but the `checknpcs' command strips off everything except the last word of the critter: so basically, if there's a construct in the room, your array is going to have an element named `construct', which doesn't match "a greater construct." In other words, you're not deleting constructs, so it isn't skipping them. Change it to

mobs.delete("construct")

As for the 1013 thing, just stick this in:


if which = checknpcs("scout", "jantalarian")
cast(1013, which)
end

The if which = checknpcs("scout", "jantalarian") line is storing the return value of the checknpcs("scout", "jantalarian") command into the which variable, which then gets checked by the if -- if you read the ;man checknpcs info, you'll see that checknpcs returns "false" (or is it "nil" ? Well, they both work the same in this case) if you give it names to check for and there isn't anything like that in the room. If it does find a match for the critter names you give it, it returns the first matching name: so if there aren't any "scouts" or "jantalarian" critters, the if will fail. If there are, the if will execute the cast blah-blah stuff.

Hope that made sense.

Danical
08-27-2006, 03:03 AM
Alright, I worked on it a bit, and now I've ran into another obstacle for some reason. What happens is it gets the first cast off, regardless of it killed the creature or not, then hangs until I cast again. I'm assuming something is wrong with my waitfor/=~ line. But i'm not exactly sure what's the problem.



if which = checknpcs('seer', 'adept', 'griffin') and mana?(70) and !checkpcs
cast(1030, which)
until waitfor('Letta, Leth, Latoth', 'leaving you gesturing at nothingness', 'he collapses', 'motionless', 'life fading from', 'in a crumpled heap', 'goes still', 'as it dies', 'then collapses', 'cast at what', 'what were you referring', 'Sing Roundtime') =~ /Letta, Leth, Latoth|leaving you gesturing at nothingness|collapses|motionless|life fading|crumpled heap|still|dies|Roundtime/
cast(1030, which)
end
fput "loot"
pause 2
end

Shaelun
08-30-2006, 01:04 AM
The cast command consumes any data waiting to be checked in the script's "input buffer" -- it waits for a "successfully cast" line, and when it sees one, it moves on. If it sees a recognized "cast failed" line, it checks your mana and if you have enough attempts to recast. The problem is that when it sees a matching line it "consumes" it so that the waitfor command isn't getting a chance to see it (until you cast something else for it to see).

Remembering how Lich works may help you to understand its behavior: every script has its own personal "input buffer," where it gets fed game lines. Any command that requires checking game lines (cast, waitfor, fput, move, take, fetchloot, so on and so on) consume the data in this "input buffer."

To make a long story short, change the cast(1030, which) line to:


fput "prep 1030"
fput "cast at #{which}"


That should fix the problem you're having. Also check out the manual info for the reget and regetall commands if you want an alternative (;man {command} to look at it in-game, or http://lich.gs4groups.com/api.xml to see it online).

Danical
08-30-2006, 06:10 PM
awesome socks, thanks!