View Full Version : Tiny Script
Wheelerm
10-12-2017, 09:27 AM
Can you ruby folks check out this script and let me know if it will work?
Goal:
Ensure that character is standing up.
If not standing up, then attempt to stand. Repeat as necessary until character is standing.
If character is standing, then aim for the head, go to offensive stance, then ambush (note, this script assumes that the character is hidden, but I would prefer to take the assumption out of the equation). In other words, what if the character wasn't hidden and I had to stand. I would like to hide before I go through the ambush routine.
Wait for the ambush RT to expire, then go to Defensive Stance.
Check to see if the character is hidden. If not, then attempt to hide a maximum of three times. If not hidden after three attempts, give up trying to hide.
End the script
waitrt?
if !standing?
waitrt?
fput "stand"
waitrt?
else
multifput "aim head", "stance off", "ambush"
waitrt?
fput "stance def"
3.times do
if !hidden?
waitrt?
fput "hide"
waitrt?
end
end
end
Do you think it would be better to break these individual "checks" (i.e., check standing, check hidden) into their own separate routines? If so, can you help me with breaking them out?
I plan to make a script for each body part that can be ambushed. This particular one will be called ambushHead.lic. The alias in StormFront will be /x;ambushHead/r. I'll assign this alias to a Macro, then map the macro to one of the key bindings on my Nostromo Keypad.
Thanks for your help.
Wheelerm
10-24-2017, 04:26 PM
The script posted above seems to be "mostly working," meaning that while hunting with a partner, the script sometimes missed that an action failed to be executed.
From what I understand, the reason why is because "fput" only reads the very NEXT line given from the game after it "fputs" the command to the game. So when the script gets to the line that reads, "fput "stance def" the script is only going to look at the very next line received from the game after entering "stance def" at the prompt. If that line happens to be "You are now in a defensive stance," then it's all good (the script will not see a "failed attempt" at going stance defensive - it saw a successful attempt). If, on the other hand, the next line the game spits out is "XXX swings his *thus-and-so weapon* at *thus-and-so creature*," then the script hangs because it's only looking at the very next line. So this explains (I think) why I would sometimes hang-up when hunting in a group and would stand there in offensive stance and not going defensive and hiding, and whatnot.
So, after some more reading, I believe the following corrections will fix this tiny script:
waitrt?
if !standing?
waitrt?
fput "stand", "you stand back up"
waitrt?
else
multifput "aim head", "stance off", "ambush"
waitrt?
fput "stance def", "you are now in a defensive stance"
3.times do
if !hidden?
waitrt?
fput "hide"
waitrt?
end
end
end
The first argument of "fput" is the command while all other arguments coming after are the "successful game strings" that the fput command looks for to continue on with the script. If it does not see those arguments, then it continues to execute the command until it sees the correct output.
Have I interpreted what I read correctly? Can you see any place where this script could be further refined?
Dagre
10-24-2017, 07:03 PM
I think your order is a bit wonky.
The way I'm reading it:
Stand if not standing
Then do the ambush bit
Then hide
You probably want to hide before the ambush part. Also consider using while statements instead of if statements.
(Sorry I'm not sure how to do the code block. If you let me in on that secret I'll post some)
Vanatar
10-25-2017, 11:50 AM
There's a lot of valid way to accomplish this. I would do something like this to start:
waitrt?
fput "stand" until standing? unless standing?
waitrt?
3.times do
break if hiding?
fput "hide"
waitrt?
end
multifput "aim head", "stance off", "ambush"
waitrt?
fput "stance def" until checkstance "defensive"
The biggest differences here are the order of operations (as noted in the previous reply) and some additional status checking. In the hiding loop there's no sense in performing all three iterations if you're already hiding so I'm checking to see if we can break out of the loop before doing any work. The second and last lines are basically spamming a command until the condition is met (standing or in stance defensive).
Note: I don't think this script will work as expected unless you have a valid target for the ambush command. Maybe take a look at splitting the ambush command out by itself and use dothistimeout to capture the game response and end the script if an invalid target error message is received.
Wheelerm
11-22-2017, 03:48 PM
Thanks for the replies - I meant to reply with additional information, but got extremely busy at work and simply didn't have time to run this ground at that time...
Anyhow...
There's a lot of valid way to accomplish this. I would do something like this to start:
waitrt?
fput "stand" until standing? unless standing?
waitrt?
3.times do
break if hiding?
fput "hide"
waitrt?
end
multifput "aim head", "stance off", "ambush"
waitrt?
fput "stance def" until checkstance "defensive"
The biggest differences here are the order of operations (as noted in the previous reply) and some additional status checking. In the hiding loop there's no sense in performing all three iterations if you're already hiding so I'm checking to see if we can break out of the loop before doing any work. The second and last lines are basically spamming a command until the condition is met (standing or in stance defensive).
Note: I don't think this script will work as expected unless you have a valid target for the ambush command. Maybe take a look at splitting the ambush command out by itself and use dothistimeout to capture the game response and end the script if an invalid target error message is received.
Thanks for the reply and the suggestion. A couple of notes of clarification:
I do want to hide last, as I typically stalk with the hunting party...the good news is that your script can be easily edited to move the order of operations where I want them, so many thanks for putting it together.
I think we're accomplishing the same thing with our respective hiding routines - the only difference I can see between our scripts is that you are breaking out of the hiding routine if I am hiding (break if hiding?), while my script only executes the hiding routine if I'm not hidden (if !hidden?). In both scripts, the script will attempt to hide a maximum number of 3 times before giving up and moving on (useful when fighting a critter with good perception). In any case, your routine is more efficient as it has fewer lines to do the same work, so I'm going to use yours. Also, your checkstance defensive line in your code is the ticket I was looking for. Thanks a lot! :smile:.
Finally, I was hoping you could look at the block of code below. What I want it to do is:
Check to see if I have enough mana to cast 903. If yes, go to offensive stance, incant minor water, wait for the cast RT to expire, then go defensive stance,
If the script sees the line, "The water completely drenches", then I want it to execute the alias I wrote that channels Minor Shock (Note: Minor Shock script is identical to this one, except 903 is changed to 901, and there is no "Watchfor" line,
If I don't have enough mana to cast 903, then I want the script to let me know that I'm out of mana and then cast Arcane Blast instead.
The part I'm wanting to know is whether or not I did the "Watchfor" bit correctly (line 6), and whether or not this script will behave as I enumerated above.
Thanks.
waitrt?
if Spell[903].affordable?
multifput "stance off", "incant 903", "stance def"
waitcastrt?
fput "stance def"
Watchfor.new "The water completely drenches" {fput \x;minorShockChannel\r}
else
echo ""
echo ""
echo "**********YOU ARE OUT OF MANA - CASTING ARCANE BLAST INSTEAD**********"
echo ""
echo ""
fput "incant 1700"
waitrt?
fput "stance def"
end
Vanatar
12-20-2017, 04:46 PM
I cancelled my GS sub so haven't kept up with the forums recently...
The biggest difference in the hiding code is the original block will always loop thrice and check the conditional. The updated code will break out of the loop entirely if you're hidden and move on.
I can took a look at the 903 script too if you still have questions about it.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.