Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; <MHFIVER'S AWESOME INCREDIBLE AI FOR GAMEZ>
- ; Seeing this is getting more views than I expected on PasteBin, I suppose i should write a proper "Read Me" with a few pointers. First of all, if you're reading this, thanks for taking a look. I am sorta proud I could do something like this given my lack of coding skills and pea sized brain. If you're already good at AHKing, I'm sure you can hustle your way around this little mess, but I've thrown some comments to help whoever needs helping. (I hope they're good enough.)
- ; This is a script for AutoHotKey that uses both the vJoy software (That creates virtual joysticks on Windows) and a library that integrates it with AHK. Just google them up, I'm sure you'll find them. Thanks to the creators of both!
- ; Basically, it toggles a random button with a random delay between them, and also I did a "turbo" function of sorts that triggers a specific button every loop, no matter what button was chosen to be pressed, a held button which is always activated, and an unheld one which is vice versa. (If 0 was chosen then it disables the function.) If you hold the right Ctrl key a message box appears. (The same one that appears at the start.) Click OK to start the inputnado. right Ctrl works as a sort of pause button, and a reset button. (It clears all the inputs, making all buttons unpressed.)
- ; How is this script useful? Well...the most useful I can find is by being a dumb opponent on 2 player games without a CPU option. Atari 2600 had a lot of these. Alternatively, you could make both be controlled by the script so you can watch...that's what I do. I even put bets on who's going to win. It's kinda fun...don't laugh! >:(
- ; Optimally, you should set the variables below to suit your needs, but i've set some defaults that should work on simple Atari 2600 games. The delay is calculated based on the number of buttons and joysticks, so that having more won't make it necessary to reduce the delay. It also has a minimum amount of delay you can set so that no button toggle is faster than it.
- ; I don't know what else to explain, but feel free to fool around and mess with the code. It has the "Do whatever with it, but don't blame me if something happens." license, which should be self-explanatory. I don't even need credit, just knowing my code is making the world better makes me all fuzzy wuzzy inside :3
- ; So...what you waiting for? Go have some fun!
- #singleinstance, force
- #include <cvjoyinterface> ;vjoy interface
- vjoy:=new cvjoyinterface() ;create parent obj
- vjoy.singlestickmode:=0 ;control multiple joys
- joynum:=2 ;how many joysticks
- btnnum:=5 ;how many buttons on each
- delay:=2000 ;delay between inputs
- mindelay:=500 ;minimum delay
- btntur:= ;optional turbo button
- btnhld:= ;optional held button
- btnunhld:= ;optional unheld button
- while(1) ;loop entire script
- {
- lap:=1 ;init lap for next loop
- while(lap<=joynum) ;init all joys
- {
- joy_%lap%:=vjoy.devices[lap]
- lap_b:=1 ;init lap for next loop
- while(lap_b<=btnnum) ;init buttons for each joy
- {
- joy_%lap%_btn_%lap_b%:=0
- joy_%lap%.setbtn(0,lap_b)
- lap_b++
- }
- lap++
- }
- reset:=0 ;init reset var
- MsgBox, 0, , ;pause until closed
- while(!reset) ;input generation
- {
- if getkeystate("rctrl") ;detect input before
- {
- reset:=1
- }
- random,joysel,1,joynum ;randomize picks
- random,btnsel,1,btnnum ;
- random,delay_b,1,delay ;
- random,delay_c,1,delay_b ;weigh towards low delay
- joy_%joysel%.setbtn(joy_%joysel%_btn_%btnsel%,btnsel) ;actual input
- joy_%joysel%_btn_%btnsel%:=!(joy_%joysel%_btn_%btnsel%) ;invert button state
- joy_%joysel%.setbtn(joy_%joysel%_btn_%btntur%,btntur) ;turbo input
- joy_%joysel%_btn_%btntur%:=!(joy_%joysel%_btn_%btntur%)
- joy_%joysel%.setbtn(1,btnhld) ;held input
- joy_%joysel%_btn_%btnhld%:=1
- joy_%joysel%.setbtn(0,btnunhld) ;unheld input
- joy_%joysel%_btn_%btnunhld%:=0
- sleep,(delay_c+mindelay)/(joynum*btnnum) ;wait depends on number of buttons/joys
- if getkeystate("rctrl") ;detect input after
- {
- reset=1
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement