Guide to Random Phrases!
First off, thank you so much for posting this.
I've used a rotating series of binds before but allways wanted to be able to do this.
[ QUOTE ]
Target.bat contents (the "for" line is all one line):
@echo off
:TOP
for /f "delims=zzz" %%i in (phrases.txt) do (echo space "local %%i$$unselect$$toggle_enemy$$bind_load_file C:\kb\target.txt">target.txt)&&sleep 1&&echo %%i
GOTO TOP
[/ QUOTE ]
Ok...
What does for /f "delims=zzz" mean?
If I want to use a different key than space could I, for instance:
echo F10 "local %%i$$unselect$$toggle_enemy$$bind_load_file C:\kb\target.txt"
Could the lines in phrases.txt make use of CoH's $target macro (don't see why not, it's just a text macro, right?) Are there characters that aren't allowed in that file?
What does sleep actually do?
[url="http://tinyurl.com/4ylgy"]The Wanderers[/url] of Virtue
We farm fun!
You've got questions, I've got answers:
[ QUOTE ]
What does for /f "delims=zzz" mean?
[/ QUOTE ]
Command Line command reference
Basically the /f "delims=zzz" makes the for command process a line at a time rather than breaking the line into pieces. I would have used something else, like ",,,", since someone might want to have zzz in a quote "You'll get a charge out of this! Zzzzt!"
[ QUOTE ]
If I want to use a different key than space could I, for instance:
echo F10 "local %%i$$unselect$$toggle_enemy$$bind_load_file C:\kb\target.txt"
[/ QUOTE ]
yes
[ QUOTE ]
Could the lines in phrases.txt make use of CoH's $target macro (don't see why not, it's just a text macro, right?) Are there characters that aren't allowed in that file?
[/ QUOTE ]
See comment on delim above. Basically as long as you don't use the delimiter string, you'll be fine.
[ QUOTE ]
What does sleep actually do?
[/ QUOTE ]
It does nothing. What makes it useful is that it does that nothing for a specific length of time (the number after sleep is the number of seconds to do that nothing). This way you aren't constantly rewriting your target.txt file, just once every second.
That's pretty cool... I'm working with batch files in school right now, and that's one of the more interesting, if somewhat pointless, uses that I've seen... then again... most things that can be done with batch files are pretty interesting... and usually pointless.
Anyways... quick question. What would the file look like if it were just the random name rotator put on one key? Would that be
[ QUOTE ]
@echo off
:TOP
for /f "delims=zzz" %%i in (phrases.txt) do (echo <KEY> "local %%i$$bind_load_file C:\kb\target.txt">target.txt)&&sleep 1&&echo %%i
GOTO TOP
[/ QUOTE ]
or am I screwing something up? (I have a tendancy to do that, which is why I'm asking)
[ QUOTE ]
It does nothing. What makes it useful is that it does that nothing for a specific length of time (the number after sleep is the number of seconds to do that nothing). This way you aren't constantly rewriting your target.txt file, just once every second.
[/ QUOTE ]
Ding! light bulb just went on.
The batch file rewrites the keybind file every second with the next line from the phrases file.
So there isn't a randomizer at all, but takes advantage of the fact that you will make calls to it in a random fashion, yes? I thought sleep was some sort of randomization function. Now I think I get it. Sorry, I just like to understand how stuff works.
This would have been fantastic for my rad defender. I'll have to think about how to use it on my newer heroes.
Thanks for the explanation!
I'm assuming the resource overhead for this is negligible?
[url="http://tinyurl.com/4ylgy"]The Wanderers[/url] of Virtue
We farm fun!
Yeah, next to no resource overhead. It's just one extremely small line of code running over and over and over and over until you shut it off.
Thanks for the explanation Grotus. You're exactly right on the zzz vs. ,,, thing, that would've made more sense.
Yep, not really random at all but it sounded better than incremental phrases script or something similiar
There are a lot things a script like this could be used for and I'm sure I just scratched the surface. I'd like to see somebody that is handy with visual basic or C do a small util that would do the same thing and could be configured via a GUI interface.
This is a very cool idea, and I'm definately going to have to try it out. I've worked with batch files before, but stayed away from most of the arcane stuff. Thanks for working this all out.
Has anyone other than the OP gotten this to work? I can't seem to... it keeps saying that it can't find the text file that's sitting right next to it on the drive. I've got a friend of mine who is much more familiar with batch files looking at it and trying to figure out what's wrong... on that note, which version of windows are you using (there are some commands that are different, or non-existant, in different versions of windows, mainly between 2000 and xp)
Oh, to see why it wasn't working, I removed the @echo off line.
Edit: Ok, I fixed the phrases.txt, it should work now.
Got it to work... this is how the batch file is written
[ QUOTE ]
@ECHO OFF
:TOP
FOR /F "DELIMS=~~~" %%i IN (phrases.txt) DO (echo %%i>target.txt)&&SLEEP 1&&ECHO %%i
GOTO TOP
[/ QUOTE ]
I used ~~~ for the delimiters so that there's pretty much no way that anyone would accidentally use them in a saying.
The target.txt starts empty, but it has to be there.
The phrases.txt is where all the magic is done. The cool thing about this setup is that you can have different emotes attached to each saying... the drawback is that you have to have a longer file... Example:
[ QUOTE ]
F10 "em dance$$Local Hi!$$bind_load_file C:/cohbind/target.txt"
F10 "em wave$$Local My name is $name, who are you today?$$bind_load_file C:/cohbind/target.txt"
F10 "em shrug$$Local How are you today?$$bind_load_file C:/cohbind/target.txt"
F10 "Local S'up?$$bind_load_file C:/cohbind/target.txt"
F10 "em frustrated$$Local
GRAAAAAAAAAAAAAAAAAHHHHHHHH!!!!!!!!!!!!!!!!!$$bind _load_file C:/cohbind/target.txt"
[/ QUOTE ]
You can replace 'Local' with 'beginchat' and it will be said in the current channel, you can use any button in the place of F10... I'm just used to F10.
Make SURE that the program is running and you type "/bind_load_file C:/location/target.txt" (not phrases.txt, that would just mess it all up) in the game before trying this. It's best to keep the binds in their own folder in the root directory (C:/cohbinds is where I keep mine)
Has anyone gotten this to work as a macro? This is making me feel like an idiot.
I don't know how well it'd work for a Macro. Is there a /macro_load_file?
[ QUOTE ]
I don't know how well it'd work for a Macro. Is there a /macro_load_file?
[/ QUOTE ]
Nope, nor can you create a macro from a bind.
Curses! Damn my reliance on the tray!
Starmor, thanks for posting this. I added a crap load of moma jokes to go with my taunt.
[ QUOTE ]
Curses! Damn my reliance on the tray!
[/ QUOTE ]
Bill, what is it you are trying to do?
I don't see why you couldn't use a power tray activate command with this then put the macro you want in a tray slot.
[url="http://tinyurl.com/4ylgy"]The Wanderers[/url] of Virtue
We farm fun!
Eh, I'm used to taunting with "T" now. I was too lazy to make macro for it, but it works better than I thought it would.
Though I can't hide the target window anymore. Oh damn. Guess I'll set it to some key I never plan on hitting.
[ QUOTE ]
Eh, I'm used to taunting with "T" now. I was too lazy to make macro for it, but it works better than I thought it would.
Though I can't hide the target window anymore. Oh damn. Guess I'll set it to some key I never plan on hitting.
[/ QUOTE ]
Just make it shift+T, that way you'll have a harder time forgetting where you put it.
[ QUOTE ]
[ QUOTE ]
Eh, I'm used to taunting with "T" now. I was too lazy to make macro for it, but it works better than I thought it would.
Though I can't hide the target window anymore. Oh damn. Guess I'll set it to some key I never plan on hitting.
[/ QUOTE ]
Just make it shift+T, that way you'll have a harder time forgetting where you put it.
[/ QUOTE ]
Yeah, just make a new character, save the binds, take a look at the default command bound to 'T', and put that where you like in your main's bind file.
Very nice guide. I stumbled upon this thread while searching for something else, but I'm very glad I took the time to read this post. I've always wanted to have my tanker say random "taunting" phrases when he uses taunt, but I didn't want to use the method I read about in the "Wholly Unofficial and Fairly Incomplete guide to /BIND". It seemed like to much work for me to bother with. But this method made it so easy to do. (although I did mostly use the post by MrNoj more than the original. It looked easier for me to modify for my own purpose then the one the Mod posted.) But any way, thanks for this, I really like it.
I am definitely trying this at home tonight. I just created a new alt, the Librarian, and I have a ton of taunts for her to use ("hey $target, I'm here to collect your overdue fines!" etc). I was dreading the idea of setting up so many binds, this will make it a lot easier. Thanks!!!
Awesome post!
Quick Question though:
How would I go about just putting this to a key so I could just hit the key to say a witty (read: cheesey) line? Perhaps like this?:
<font class="small">Code:[/color]<hr /><pre>
@echo off
:TOP
for /f "delims=zzz" %%i in (phrases.txt) do (echo v "local %%i$$bind_load_file C:\kb\target.txt">target.txt)&&sleep 1&&echo %%i
GOTO TOP
</pre><hr />
So this would technically make it so when you pushed v, you'd say a line, yes?
[ QUOTE ]
[ QUOTE ]
for /f "delims=zzz" %%i in (phrases.txt) do (echo v "local %%i$$bind_load_file C:\kb\target.txt">target.txt)&&sleep 1&&echo %%i
[/ QUOTE ]
So this would technically make it so when you pushed v, you'd say a line, yes?
[/ QUOTE ]
Correct. But, you first have to make sure that you have bound "v" in the game to "bind_load_file C:\kb\target.txt".
See my next post for a better explanation of it all...
Dwimble
Just to clarify this for everyone (because I was confused by it a little at first, so I'm sure others are too)...this method doesn't affect City or Heroes or your keyboard in any way at all.
_______________
A "Plain English" Explanation of How This Works
Summary:
This method creates a text file over and over again every second, containing a different phrase each time. You are telling City of Heroes to cause your character to say whatever that file contains whenever you press a certain key. Because the contents of that file are different every second, your character will say something different each time you press the key.
The Long Version:
1. You are using a common command in City or Heroes to bind a key that tells the game to load a bind file whenever you press that key. So, you could make a plain ol' run of the mill bind like this: /bind F1 "bind_load_file C:\target.txt.
Your "target.txt" file would contain something like this: F1 "local Hey, big nose!$$bind_load_file c:\target.txt" So, each time you pressed F1, your character would say "Hey, big nose!" and then City of Heroes would load "targets.txt" and replace the F1 bind with the new F1 bind contained in that file. But, because the contents of that file never change, it is basically just creating the same F1 bind over and over again each time you press F1.
2. All this batch file method does is rewrite that text file on your computer over and over every second. It doesn't do anything to City of Heroes or your keyboard. So, you are going about playing the game normally, but in the background this batch file is basically creating one text file over and over again with slightly different contents each time. It isn't interacting with the game or doing anything else--all it does is create a text file.
It's contents are slightly different each time because that crazy computer lingo is essentially telling the computer to do this: "Hey, once every second, create a text file for me called 'target.txt' and in that text file put this line 'F1 local %%i$$bind_load_file c:\target.txt'. But, don't make it exactly the same every time. Instead of actually putting '%%i' in there when you create the file, please grab the next line of text from this other file called 'phrases.txt' and substitute it for the '%%i' part.
3. Nothing in City of Heroes has changed. It still loads "target.txt" whenever you press F1. But, the contents of that file are different every second because the batch file keeps recreating it. Consequently, your character says something different every time.
Dwimble
This guide is AWESOME! I use it on all my characters now!
Have you ever gotten sick of using the same phrases for your character? Well here's a way for you to have as many as you want! By running a batch job that rewrites a key bind file you can have as many battle cry phrases (or for any other phrase) as you want.
This guide assumes you have a basic understanding of the /bind command. You can find excellent guides in this
forum for it.
Here are the steps:
1. You'll need the sleep.exe utility for this to run properly. You can get it here (or get all files at the link provided at the bottom of the post)
2. Create a folder for your files (for example c:\KB) and put sleep.exe in it.
3. Right click in the folder and create a new text file and rename the file
to target.bat. I used this name since I wanted my battle cry to happen each time I targeted the next enemy. You
can call it what you want.
The key to this is the "for" line. If you want to change the the key that is bound or the function the key does you'll
need to edit this line. Again, check the /bind FAQ for more information on the /bind command.
Note: I used target.txt as the output. You can edit the "for" line and change target.txt to any file name you want. If you
do, make sure you use that file name for step 6.
Target.bat contents (the "for" line is all one line):
@echo off
:TOP
for /f "delims=zzz" %%i in (phrases.txt) do (echo space "local %%i$$unselect$$toggle_enemy$$bind_load_file C:\kb\target.txt">target.txt)&&sleep 1&&echo %%i
GOTO TOP
4. Create a phrases.txt file in the same folder you created in step 2. This is where all of your phrases are pulled from. I
suggest at least thirty so you don't drive your team mates crazy with the same thing over and over again.
Example phrases.txt file:
Now you made me mad!
Who wants some?
It's time to do some clobberin'!
and so on....
5. Run the batch job by double clicking on it and then get in the City of Heroes game.
6. Last, bind the keybind text file in COH. For instance you would use: bind_load_file c:\kb\target.txt
That's it! For this example every time you hit the space bar you'll get a random saying from your phrases.txt file. Just run the
.bat file each time you get into COH and you'll have random phrases.
If this is as clear as mud, you can always create a "C:\KB" folder and unzip the files from here .