DEEPBOT RPG
So, I've been working on this thing for a bit, and it's just not working the way it needs to be.
Honestly, I'm not a great programmer, and my code solutions are totally unoptimized, but works, however unstable in its current form.
I'll post everything I've got so far, and explain it all, and hopefully we can make this a community effort, or something.
What I've got is pretty messy, but I can explain it all. Here's a .zip of the folder and file structure:
https://www.dropbox.com/s/w7ysqki8jx1frw4/RPG.zip?dl=0And, here's a .zip all the individual command code in .txt, for ease of use:
https://www.dropbox.com/s/ff6jehmryfgrclq/RPG%20Code.zip?dl=0Also, if you just want to see this in action, I've got it running on my
Twitch channel.
This all starts by creating the folders in the Custom Logs:
RPG -
Adjectives (These are used to randomly generate a unique monster name, by combining an adjective in front of the normal monster name.)
-
Classes (Users can choose 1 of 5 classes. Only difference is starting stats right now.)
-
Enemies (Enemy names are stored in here. I just took most of them from the MMORPG Ragnarok Online.)
- -
log (User combat logs are stored here, with the current enemy name, enemy stats, and rewards for killing the enemy.)
-
Levels (Does nothing. Not required. Not sure what I was planning with this. Maybe like, Town or Quest locations, or something.)
-
Users (User logs are stored here. Tracks whether they've initiated an RPG character, and tracks all their stats.)
-
Weapons (Does nothing. Not required. I was planning a whole equipment thing, but I couldn't figure out a good way to do it.)
Then, comes the actual code, and this'll get a bit thick and heavy.
Initialization:Every user will initialize an RPG character by using the !rpg command:
@if@[@readfile@[RPG\Users\@user@.txt]||1||!rpg2||@if@[@target@||Assassin||!rpginitass||@if@[@target@||Barbarian||!rpginitbar||@if@[@target@||Cleric||!rpginitcle||@if@[@target@||Templar||!rpginittem||@if@[@target@||Wizard||!rpginitwiz||@user@, you must choose a class. (Assassin, Barbarian, Cleric, Templar, or Wizard)]]]]]]
The code will check if the user already has an RPG character, (if "RPG\Users\@user@.txt" exists, and contains a "1"), and if so, will run !rpg2, which will show basic stats.
If the user does not have a character, one will be created based on the class provided with @target@. The classes are all Case-Sensitive. Users will be told to choose a class if they screw it up.
It's at this point where all of the .txt files are created for the user, as well. Their stats will be tracked in the "Users" folder, with their Username prefixing each stat.
Concerning stats, most of them are not taken into account yet, but were planned to be used later. I'll explain more in the Combat section.
!rpg2
@user@, you are a Level @readfile@[RPG\Users\@user@Level.txt] @readfile@[RPG\Classes\@readfile@[RPG\Users\@user@Class.txt].txt]. Use !stats to check your Stats.
Settings: Hide From Command List!rpginitass
@savefile@[RPG\Users\@user@.txt,1]@savefile@[RPG\Users\@user@Level.txt,1]@savefile@[RPG\Users\@user@Class.txt,1]@savefile@[RPG\Users\@user@Vit.txt,10]@savefile@[RPG\Users\@user@End.txt,12]@savefile@[RPG\Users\@user@Str.txt,10]@savefile@[RPG\Users\@user@Dex.txt,18]@savefile@[RPG\Users\@user@Int.txt,10]@savefile@[RPG\Users\@user@Wis.txt,15]@savefile@[RPG\Users\@user@Luc.txt,16]@savefile@[RPG\Users\@user@MaxHealth.txt,250]@savefile@[RPG\Users\@user@CurrentHealth.txt,250]@savefile@[RPG\Users\@user@Exp.txt,0]@savefile@[RPG\Users\@user@ExpToLevel.txt,25]
Settings: Hide From Command List and Command Chain !rpginit3!rpginitbar
@savefile@[RPG\Users\@user@.txt,1]@savefile@[RPG\Users\@user@Level.txt,1]@savefile@[RPG\Users\@user@Class.txt,2]@savefile@[RPG\Users\@user@Vit.txt,18]@savefile@[RPG\Users\@user@End.txt,16]@savefile@[RPG\Users\@user@Str.txt,18]@savefile@[RPG\Users\@user@Dex.txt,10]@savefile@[RPG\Users\@user@Int.txt,10]@savefile@[RPG\Users\@user@Wis.txt,11]@savefile@[RPG\Users\@user@Luc.txt,11]@savefile@[RPG\Users\@user@MaxHealth.txt,450]@savefile@[RPG\Users\@user@CurrentHealth.txt,450]@savefile@[RPG\Users\@user@Exp.txt,0]@savefile@[RPG\Users\@user@ExpToLevel.txt,25]
Settings: Hide From Command List and Command Chain !rpginit3!rpginitcle
@savefile@[RPG\Users\@user@.txt,1]@savefile@[RPG\Users\@user@Level.txt,1]@savefile@[RPG\Users\@user@Class.txt,3]@savefile@[RPG\Users\@user@Vit.txt,12]@savefile@[RPG\Users\@user@End.txt,16]@savefile@[RPG\Users\@user@Str.txt,16]@savefile@[RPG\Users\@user@Dex.txt,10]@savefile@[RPG\Users\@user@Int.txt,10]@savefile@[RPG\Users\@user@Wis.txt,18]@savefile@[RPG\Users\@user@Luc.txt,12]@savefile@[RPG\Users\@user@MaxHealth.txt,300]@savefile@[RPG\Users\@user@CurrentHealth.txt,300]@savefile@[RPG\Users\@user@Exp.txt,0]@savefile@[RPG\Users\@user@ExpToLevel.txt,25]
Settings: Hide From Command List and Command Chain !rpginit3!rpginittem
@savefile@[RPG\Users\@user@.txt,1]@savefile@[RPG\Users\@user@Level.txt,1]@savefile@[RPG\Users\@user@Class.txt,4]@savefile@[RPG\Users\@user@Vit.txt,20]@savefile@[RPG\Users\@user@End.txt,16]@savefile@[RPG\Users\@user@Str.txt,15]@savefile@[RPG\Users\@user@Dex.txt,10]@savefile@[RPG\Users\@user@Int.txt,10]@savefile@[RPG\Users\@user@Wis.txt,11]@savefile@[RPG\Users\@user@Luc.txt,8]@savefile@[RPG\Users\@user@MaxHealth.txt,500]@savefile@[RPG\Users\@user@CurrentHealth.txt,500]@savefile@[RPG\Users\@user@Exp.txt,0]@savefile@[RPG\Users\@user@ExpToLevel.txt,25]
Settings: Hide From Command List and Command Chain !rpginit3!rpginitwiz
@savefile@[RPG\Users\@user@.txt,1]@savefile@[RPG\Users\@user@Level.txt,1]@savefile@[RPG\Users\@user@Class.txt,5]@savefile@[RPG\Users\@user@Vit.txt,8]@savefile@[RPG\Users\@user@End.txt,10]@savefile@[RPG\Users\@user@Str.txt,7]@savefile@[RPG\Users\@user@Dex.txt,13]@savefile@[RPG\Users\@user@Int.txt,20]@savefile@[RPG\Users\@user@Wis.txt,15]@savefile@[RPG\Users\@user@Luc.txt,12]@savefile@[RPG\Users\@user@MaxHealth.txt,200]@savefile@[RPG\Users\@user@CurrentHealth.txt,200]@savefile@[RPG\Users\@user@Exp.txt,0]@savefile@[RPG\Users\@user@ExpToLevel.txt,25]
Settings: Hide From Command List and Command Chain !rpginit3!rpginit3
@user@ is now a Level @readfile@[RPG\Users\@user@Level.txt] @readfile@[RPG\Classes\@readfile@[RPG\Users\@user@Class.txt].txt]!
This just announces in chat that someone has created a new character.
Settings: Hide From Command List!stats
@if@[@readfile@[RPG\Users\@user@.txt]||1||@user@, Level @readfile@[RPG\Users\@user@Level.txt] @readfile@[RPG\Classes\@readfile@[RPG\Users\@user@Class.txt].txt], Vitality: @readfile@[RPG\Users\@user@Vit.txt], Endurance: @readfile@[RPG\Users\@user@End.txt], Strength: @readfile@[RPG\Users\@user@Str.txt], Dexterity: @readfile@[RPG\Users\@user@Dex.txt], Intelligence: @readfile@[RPG\Users\@user@Int.txt], Wisdom: @readfile@[RPG\Users\@user@Wis.txt], Luck: @readfile@[RPG\Users\@user@Luc.txt], Experience: @readfile@[RPG\Users\@user@Exp.txt]/@readfile@[RPG\Users\@user@ExpToLevel.txt], Health: @readfile@[RPG\Users\@user@CurrentHealth.txt]/@readfile@[RPG\Users\@user@MaxHealth.txt]||@user@, you must create a character first. Use the !rpg command.]
Note: This command, as well as any other main commands, will (should) always check if the user has created an RPG character first. Bad things happen otherwise.
Combat:Now, this is where things either start falling apart, or flaws in the previous code are broken even further.
In my testing, I found it's not a good idea to use @savefile@ and @readfile@ to manipulate and display the same value in the same command.
So, for 1 fight to happen, I had to split the code across several commands. Usually one that manipulates the value, and another that either displays it, or manipulates it further.
However, this still isn't very clean, and I'll explain what's broken as we go. There is a fatal flaw that I will also point out where I think this may be occurring.
!fight
@if@[@readfile@[RPG\Users\@user@.txt]||1||!fightencounter||@user@, you must create a character first. Use the !rpg command.]
There's the user character check.
!fightencounter
@savefile@[RPG\Enemies\log\@user@CurrentMonster.txt,@readfile@[RPG\Adjectives\@rand@[1|70].txt] @readfile@[RPG\Enemies\@rand@[1|50].txt]] @savefile@[RPG\Enemies\log\@user@CurrentMonsterLevel.txt,@calc@[+|@rand@[0|5]|@readfile@[RPG\Users\@user@Level.txt]]] @savefile@[RPG\Enemies\log\@user@CurrentMonsterHP.txt,@calc@[-|@readfile@[RPG\Users\@user@MaxHealth.txt]|@rand@[0|50]]] @savefile@[RPG\Enemies\log\@user@PointPot.txt,@calc@[+|@rand@[0|@readfile@[RPG\Enemies\log\@user@CurrentMonsterLevel.txt]]|@rand@[0|@readfile@[RPG\Users\@user@Level.txt]]]] @savefile@[RPG\Enemies\log\@user@ExpPot.txt,@calc@[+|@readfile@[RPG\Enemies\log\@user@CurrentMonsterLevel.txt]|@readfile@[RPG\Users\@user@Level.txt]]]
This will create an enemy for the user to fight, with a funny name that is randomly generated. Each user has their own enemy, with their username prefixed to the monster logs.
User stats are taken into account here. Enemy level, Point reward, and EXP reward are based on User's level. Enemy health is based on User's max health.
Settings: Hide From Command List and Command Chain !fightencounter2!fightencounter2
@user@ encounters a Level @readfile@[RPG\Enemies\log\@user@CurrentMonsterLevel.txt] @readfile@[RPG\Enemies\log\@user@CurrentMonster.txt], with @readfile@[RPG\Enemies\log\@user@CurrentMonsterHP.txt]HP.
This just announces in chat that a fight has began.
Settings: Hide From Command List and Command Chain !fight2!fight2
@savefile@[RPG\Enemies\log\@user@Roll.txt,@rand@[0|@readfile@[RPG\Users\@user@Dex.txt]]] @if@[>=||@readfile@[RPG\Enemies\log\@user@Roll.txt]||@calc@[/|@readfile@[RPG\Users\@user@Dex.txt]|2]||@savefile@[RPG\Enemies\log\@user@Turn.txt,1]||@savefile@[RPG\Enemies\log\@user@Turn.txt,2]]
Note: This command may contain an endless loop, forcing DeepBot (And possibly, your entire system) into extreme lag. Force-close the application if this happens.User stats are taken into account here. A roll takes place, based on User Dexterity. User must roll equal or greater than half of their Dexterity to attack, else the monster gets the attack.
Settings: Hide From Command List and Command Chain !fight3!fight3
@if@[@readfile@[RPG\Enemies\log\@user@Turn.txt]||1||!fightdealtdamage||!fighttookdamage]
A value of "1" in the file "RPG\Enemies\log\@user@Turn.txt" indicates Player's attack. Else, a value of "2" indicates monster's attack
Settings: Hide From Command List!fightdealtdamage
@savefile@[RPG\Enemies\log\@user@CurrentMonsterHP.txt,@calc@[-|@readfile@[RPG\Enemies\log\@user@CurrentMonsterHP.txt]|@readfile@[RPG\Enemies\log\@user@DamageDealt.txt]]]
The player deals damage to the monster.
Settings: Hide From Command List and Command Chain !checkmonsterhealth!fighttookdamage
@savefile@[RPG\Users\@user@CurrentHealth.txt,@calc@[-|@readfile@[RPG\Users\@user@CurrentHealth.txt]|@readfile@[RPG\Enemies\log\@user@DamageTaken.txt]]]
The monster deals damage to the player.
Settings: Hide From Command List and Command Chain !checkplayerhealth!checkmonsterhealth
@if@[<=||@readfile@[RPG\Enemies\log\@user@CurrentMonsterHP.txt]||0||!monsterdied||!fight2]
Checks if the monster is dead. (If they have equal or less than 0 HP)
If the monster is still alive, we loop back into !fight2, where we roll again to see who gets the next attack.
Settings: Hide From Command List!checkplayerhealth
@if@[<=||@readfile@[RPG\Users\@user@CurrentHealth.txt]||0||!playerdied||!fight2]
Checks if the player is dead. (If they have equal or less than 0 HP)
If the player is still alive, we loop back into !fight2, where we roll again to see who gets the next attack.
Settings: Hide From Command List!monsterdied
@user@ has slain the @readfile@[RPG\Enemies\log\@user@CurrentMonster.txt], and gained @readfile@[RPG\Enemies\log\@user@PointPot.txt]GP and @readfile@[RPG\Enemies\log\@user@ExpPot.txt]Exp! @editpoints@[@user@|@readfile@[RPG\Enemies\log\@user@PointPot.txt]] @savefile@[RPG\Users\@user@Exp.txt,@calc@[+|@readfile@[RPG\Users\@user@Exp.txt]|@readfile@[RPG\Enemies\log\@user@ExpPot.txt]]]
If the monster dies, then the player is awarded the Point pot, and the EXP pot. They don't get any health back. That's intentional.
The !fight2 loop ends here.
Settings: Hide From Command List and Command Chain !checklevel!playerdied
@user@ has been slain by @readfile@[RPG\Enemies\log\@user@CurrentMonster.txt], and lost @readfile@[RPG\Enemies\log\@user@PointPot.txt]GP... @editpoints@[@user@|-@readfile@[RPG\Enemies\log\@user@PointPot.txt]] @savefile@[RPG\Users\@user@CurrentHealth.txt,@readfile@[RPG\Users\@user@MaxHealth.txt]]
If the player dies, they lose some Points, and get their health back.
Settings: Hide From Command List!checklevel
@if@[>=||@readfile@[RPG\Users\@user@Exp.txt]||@readfile@[RPG\Users\@user@ExpToLevel.txt]||!levelup||]
When the player wins an encounter, they gain EXP. This is ran after a win to check whether they've gained enough EXP to level up.
Settings: Hide From Command List!levelup
@savefile@[RPG\Users\@user@Level.txt,@calc@[+|@readfile@[RPG\Users\@user@Level.txt]|1]] @savefile@[RPG\Users\@user@Vit.txt,@calc@[+|@readfile@[RPG\Users\@user@Vit.txt]|@rand@[0|3]]] @savefile@[RPG\Users\@user@End.txt,@calc@[+|@readfile@[RPG\Users\@user@End.txt]|@rand@[0|3]]] @savefile@[RPG\Users\@user@Str.txt,@calc@[+|@readfile@[RPG\Users\@user@Str.txt]|@rand@[0|3]]] @savefile@[RPG\Users\@user@Dex.txt,@calc@[+|@readfile@[RPG\Users\@user@Dex.txt]|@rand@[0|3]]] @savefile@[RPG\Users\@user@Int.txt,@calc@[+|@readfile@[RPG\Users\@user@Int.txt]|@rand@[0|3]]] @savefile@[RPG\Users\@user@Wis.txt,@calc@[+|@readfile@[RPG\Users\@user@Wis.txt]|@rand@[0|3]]] @savefile@[RPG\Users\@user@Luc.txt,@calc@[+|@readfile@[RPG\Users\@user@Luc.txt]|@rand@[0|3]]] @savefile@[RPG\Users\@user@ExpToLevel.txt,@calc@[*|@readfile@[RPG\Users\@user@ExpToLevel.txt]|1.5]] @savefile@[RPG\Users\@user@Exp.txt,0]
Note: This command works, but not as completely intended.Is the player has enough EXP to level up, this command will do that. It should be noted that this command does not work as intended.
What's supposed to happen is, each stat is set to increase a random amount between 0 and 3.
What really happens is, the random calculation is performed only once, and each stat is increased the same amount, between 0 and 3.
Settings: Hide From Command List
So, as of right now, that's all I've got.
The main issue revolves around the !fight2 loop, and I've banged my head on several walls trying to figure what's exactly causing issue there.
I'm sharing this because I think it's really cool, even though it's slightly broken. I'm hoping the community here can expand on this, and help make it much better.