DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 964,423 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for LET ME PLAY GTA:SA! Chaos using circuit python
int_13h
int_13h

Posted on

LET ME PLAY GTA:SA! Chaos using circuit python

For those who don't know what chaos mod is, here goes a little definition -

Every 30 seconds the game will trigger a random effect. This effect can be anything from giving you an RPG to exploding all nearby vehicles or making every nearby ped dance.

Source : https://www.gta5-mods.com/scripts/chaos-mod-v-beta

We are going to inject keyboard strokes using Adafruit's Circuit Python Express board (yea those cute circular boards with LEDs all over it :P). I've published a project in past that makes use of this same technique, so for a basic understanding you can check that out!

Ofcourse we can only inject cheat codes because of hardware limitations Β―\_(ツ)_/Β―. So a basic roadmap for this code will be to make a list out of all cheat codes of GTA-SA and then randomly choose a cheat code from the list and then inject that. Now because that is a list so it's kind of a universal chaos mod.

A quick google search for cheat codes landed me to this page, so I'll just use some IDE magic to transform it to a list. Here is the list :

[
"HESOYAM", "BAGUVIX", "CVWKXAM", "LXGIWYL", "PROFESSIONALSKIT",
"UZUMYMW", "STICKLIKEGLUE", "ANOSEONGLASS", "FULLCLIP",
"TURNUPTHEHEAT", "TURNDOWNTHEHEAT", "BTCDBCB", "BUFFMEUP",
"KVGYZQK", "AEZAKMI", "BRINGITON", "WORSHIPME", "HELLOLADIES",
"VKYPQCF", "PROFESSIONALKILLER", "NATURALTALENT", "SPEEDITUP",
"SLOWITDOWN", "AJLOJYQY", "BAGOWPG", "FOOOXFT",
"GOODBYECRUELWORLD", "BLUESUEDESHOES", "BGLUAWML", "LIFESABEACH",
"ONLYHOMIESALLOWED", "BIFBUZZ", "NINJATOWN", "BEKKNQV",
"CJPHONEHOME", "KANGAROO", "STATEOFEMERGENCY", "CRAZYTOWN",
"SJMAHPE", "ROCKETMAYHEM", "CPKTNWT", "WHEELSONLYPLEASE",
"ZEIIVG", "YLTEICZ", "LLQPFBN", "IOWDLAC", "EVERYONEISPOOR",
"EVERYONEISRICH", "CHITTYCHITTYBANGBANG", "FLYINGFISH", "JCNRUAD",
"SPEEDFREAK", "BUBBLECARS", "OUIQDMW", "GHOSTTOWN", "FVTMNBZ",
"BMTPWHR", "ROCKETMAN", "IWPRTON", "AIYPWZQP", "OLDSPEEDDEMON",
"JQNTDMH", "VROCKPOKEY", "VPJTQWV", "WHERESTHEFUNERAL",
"CELEBRITYSTATUS", "TRUEGRIME", "RZHSUEW", "JUMPJET", "KGGGDKP",
"OHDUDE", "FOURWHEELFUN", "AMOMHRER", "ITSALLBULL",
"FLYINGTOSTUNT", "MONSTERMASH", "PLEASANTLYWARM", "TOODAMNHOT",
"ALNSFMZO", "AUIFRVQS", "CFVFGMJ", "YSOHNUL", "NIGHTPROWLER",
"OFVIAC", "SCOTTISHSUMMER", "CWJXUOC"
]
Enter fullscreen mode Exit fullscreen mode

And here is the full code :

from adafruit_circuitplayground.express import cpx
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
import usb_hid
from time import sleep
from random import choice

kbd = Keyboard(usb_hid.devices)
layout = KeyboardLayoutUS(kbd)

CHEATS = [
"HESOYAM", "BAGUVIX", "CVWKXAM", "LXGIWYL", "PROFESSIONALSKIT",
"UZUMYMW", "STICKLIKEGLUE", "ANOSEONGLASS", "FULLCLIP",
"TURNUPTHEHEAT", "TURNDOWNTHEHEAT", "BTCDBCB", "BUFFMEUP",
"KVGYZQK", "AEZAKMI", "BRINGITON", "WORSHIPME", "HELLOLADIES",
"VKYPQCF", "PROFESSIONALKILLER", "NATURALTALENT", "SPEEDITUP",
"SLOWITDOWN", "AJLOJYQY", "BAGOWPG", "FOOOXFT",
"GOODBYECRUELWORLD", "BLUESUEDESHOES", "BGLUAWML", "LIFESABEACH",
"ONLYHOMIESALLOWED", "BIFBUZZ", "NINJATOWN", "BEKKNQV",
"CJPHONEHOME", "KANGAROO", "STATEOFEMERGENCY", "CRAZYTOWN",
"SJMAHPE", "ROCKETMAYHEM", "CPKTNWT", "WHEELSONLYPLEASE",
"ZEIIVG", "YLTEICZ", "LLQPFBN", "IOWDLAC", "EVERYONEISPOOR",
"EVERYONEISRICH", "CHITTYCHITTYBANGBANG", "FLYINGFISH", "JCNRUAD",
"SPEEDFREAK", "BUBBLECARS", "OUIQDMW", "GHOSTTOWN", "FVTMNBZ",
"BMTPWHR", "ROCKETMAN", "IWPRTON", "AIYPWZQP", "OLDSPEEDDEMON",
"JQNTDMH", "VROCKPOKEY", "VPJTQWV", "WHERESTHEFUNERAL",
"CELEBRITYSTATUS", "TRUEGRIME", "RZHSUEW", "JUMPJET", "KGGGDKP",
"OHDUDE", "FOURWHEELFUN", "AMOMHRER", "ITSALLBULL",
"FLYINGTOSTUNT", "MONSTERMASH", "PLEASANTLYWARM", "TOODAMNHOT",
"ALNSFMZO", "AUIFRVQS", "CFVFGMJ", "YSOHNUL", "NIGHTPROWLER",
"OFVIAC", "SCOTTISHSUMMER", "CWJXUOC"
]

while True:
    sleep(30)
    layout.write(choice(CHEATS))
Enter fullscreen mode Exit fullscreen mode

So this will just run a random cheat after every 30 seconds. Now I'll just make this look good by using the onboard LEDs. There are 10 of them so I can light one after every 3 seconds to make it look good. Here's the code for that:

from adafruit_circuitplayground.express import cpx
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
import usb_hid
from time import sleep
from random import choice
from adafruit_circuitplayground.express import cpx

cpx.pixels.brightness = 0.1

kbd = Keyboard(usb_hid.devices)
layout = KeyboardLayoutUS(kbd)

CHEATS = [
"HESOYAM", "BAGUVIX", "CVWKXAM", "LXGIWYL", "PROFESSIONALSKIT",
"UZUMYMW", "STICKLIKEGLUE", "ANOSEONGLASS", "FULLCLIP",
"TURNUPTHEHEAT", "TURNDOWNTHEHEAT", "BTCDBCB", "BUFFMEUP",
"KVGYZQK", "AEZAKMI", "BRINGITON", "WORSHIPME", "HELLOLADIES",
"VKYPQCF", "PROFESSIONALKILLER", "NATURALTALENT", "SPEEDITUP",
"SLOWITDOWN", "AJLOJYQY", "BAGOWPG", "FOOOXFT",
"GOODBYECRUELWORLD", "BLUESUEDESHOES", "BGLUAWML", "LIFESABEACH",
"ONLYHOMIESALLOWED", "BIFBUZZ", "NINJATOWN", "BEKKNQV",
"CJPHONEHOME", "KANGAROO", "STATEOFEMERGENCY", "CRAZYTOWN",
"SJMAHPE", "ROCKETMAYHEM", "CPKTNWT", "WHEELSONLYPLEASE",
"ZEIIVG", "YLTEICZ", "LLQPFBN", "IOWDLAC", "EVERYONEISPOOR",
"EVERYONEISRICH", "CHITTYCHITTYBANGBANG", "FLYINGFISH", "JCNRUAD",
"SPEEDFREAK", "BUBBLECARS", "OUIQDMW", "GHOSTTOWN", "FVTMNBZ",
"BMTPWHR", "ROCKETMAN", "IWPRTON", "AIYPWZQP", "OLDSPEEDDEMON",
"JQNTDMH", "VROCKPOKEY", "VPJTQWV", "WHERESTHEFUNERAL",
"CELEBRITYSTATUS", "TRUEGRIME", "RZHSUEW", "JUMPJET", "KGGGDKP",
"OHDUDE", "FOURWHEELFUN", "AMOMHRER", "ITSALLBULL",
"FLYINGTOSTUNT", "MONSTERMASH", "PLEASANTLYWARM", "TOODAMNHOT",
"ALNSFMZO", "AUIFRVQS", "CFVFGMJ", "YSOHNUL", "NIGHTPROWLER",
"OFVIAC", "SCOTTISHSUMMER", "CWJXUOC"
]

while True:
    for x in range(0,10):
        cpx.pixels[x] = (255,0,144)
        sleep(3)

    layout.write(choice(CHEATS))
    cpx.pixels.fill((0,0,0))
Enter fullscreen mode Exit fullscreen mode

Hope you enjoyed this small project. Check out my other projects on Hackster too :)

Shalom.

Top comments (7)

Collapse
 
gtamobile83 profile image
GTA Mobile • Edited on

Thanks for sharing this useful information. I loved it. Keep sharing and Thanks again.

Collapse
 
alok760 profile image
Alok Kumar • Edited on

This is really exciting!

Collapse
 
grlwholifts profile image
Ruchika

Loved this fun project!

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

πŸ‘‹ Have You Posted on DEV Yet?

Head over to our Welcome Thread and tell us a bit about yourself!