customizable battle system(RPG homebrew)[beta]{news 11/22/16

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
firecat
Miko-Class Veteran
Posts: 540
Joined: Sat Oct 25, 2014 6:20 pm
Completed: The Unknowns Saga series
Projects: The Unknown Saga series
Tumblr: bigattck
Deviantart: bigattck
Skype: bigattck firecat
Soundcloud: bigattck-firecat
Contact:

customizable battle system(RPG homebrew)[beta]{news 11/22/16

#1 Post by firecat » Thu Dec 03, 2015 11:33 am

First I want to give a huge thanks to Quan Dao Dong, it would have taken 3 more months if i did it alone and Alex for inspiring me to build it.

-The story

As everyone knows, building a battle system or RPG battle takes time and really not many people had build a simple customizable system. That made me look for an answer to hopefully something that kinda is RPG, my research found this:
http://www.renpy.org/wiki/renpy/doc/coo ... e_for_RPGs

however its incomplete, yes it works but the problem is that the user(player) doesn't do anything. so did more research to find out how to use it or edit it but i only end up with the forgotten UI function language. No one in the history of ren'py touch the code, maybe it was because people want VN codes or maybe screen language was build, i dont know but thanks to whoever left the RPG_frame there was hope. the code works amazing and saw many use for it, i had to finish it but reach my limit on what i learn. i hire Quan Dao Dong to build working buttons, in a week the first alpha version was build, in two weeks i added buttons that allow users to hit any npc and thats where this beta version is currently at right now.

-Why is it better than jake's RPG or any other?

The first real world problem from the other RPG battle cames the fact that it might cause problems in androids, i try to play it in my old android 2.2 but its either too big of a screen or too small. the other RPG buttons are not built for touchscreen and that causes players to miss click. another bothersome thing is the lack of adding more enemies, yes in the old RPG you are only face with 4 or 5 enemies but this is the 21th century we should be able to fight more than 5 enemies. Not only that, you are under the rules in which the developer has added so you can't add new cool stuff without a digging into the code and wasting time on how it works.

RPG homebrew is build with android, IOS, computers and (add future system here) in mind so it will always work everytime. Also since you can move the buttons and frames, its very understandable as to why you want RPG homebrew for your phone. Lastly RPG homebrew is easy to edit, there is no huge wall of code or pictures to remove (unless you want to add pictures). It doesn't interfere with other codes, as long as there is nothing connecting to it. I have put effort into making it easy for newbies and experts alike to edit it without costing them time on game development or writing.

- how does this work? its not in screen language...

I made an easy to understand guide on how it works, now first understand that you dont have to follow my guide. if you know python it should be a breeze on how this works, it might even you ideas on making it better but if not then read on.
Screenshot1.jpg
This is the heart of the code, i highly advise beginners to not touch it. Another thing to note is that the whole code is Case-sensitive meaning HP does not mean hp, the capital letters and lower letters are something you should be looking at if you enter an error with [hp not found].
Screenshot2.jpg
The dark blue are the textbuttons, these are the the buttons you seen and played, inside is the code on what the computer/phone follows. You can add any number of textbuttons/imagebuttons, there is no limit on what you can do with them. These are not limited to only textbox, if you want an image box you need some understand in python but for beginners follow this link for a small detail on imagebox: http://www.renpy.org/wiki/renpy/doc/ref ... magebutton

The very soft-green are text, nothing happens to the code if you enter random text.

yellow is the links to which leads the computer/phone to what must happen. think of it as a jump command from renpy view, editing should be fine.

The light-blue are what you might need to edit for the computer to understand. Things that you might need to edit include hero, extraP, tiger, and evil. The fast way to edit it would be to find the magnifying glass with paper with pencil, add the names then click on replace all. Fun fact, you dont need damage to be called damage, crazy huh?
Screenshot3.jpg
I skip the blocking textbutton for a reason (check on bug reports), moving on, you'll see the heal textbutton and win or lose rule. Now i dont think $ potions_left = 10 has anything to do with this but i could be wrong. win or lose rule still needs work since the player only needs to kill them (check on improvements for info).
Screenshot4.jpg
This is where you see how the code is place, you dont need a jump action and the story works just the same.
Screenshot5.jpg
Now the ending, please note that win and lose might need to be change if you plan on having more than one fight.

- BUG report

There are bugs, its in beta version for a reason. They are not big but you should know about it:

1. having "while(hero_HP > 0)" be nothing or not having it will crash the renpy game or have the user in a never ending loading bar. Fix, however removing "while True:" will give you a error about the frame, no crash or anything else.

2. blocking does nothing, adding damage only damage the user.

3. the computer/phone will show no mercy (an old computer joke).

4. The new renpy version gui has the textbox on always which defeats the main purpose of full screen customization. Unknown if others have same problem but I will try to find an answer to removing it.

- Improvements for the future

This is what plan to fix or add:

1. RPG homebrew x RPG Overworld Engine = random encounters or title place fights

2. fixing block textbutton, i know it works but how :/

3. fixing wins or lose, i need it to be "all_enemy_HP > 0" or something like that.

4. fixing the crash so no one needs to risk editing that part.

5. adding inventory for more gameplay style.

That's all of it, if you encounter a bug that i haven't seen or if rpg homebrew is messing with other codes please post here. Code, PC, android, and IOS example download can be found here, also on the bottom. The code is under CC0 meaning public domain, it can be freely edit, place on commercial products or non-profit use. If you like please credit me (firecat) and Quan Dao Dong for acknowledging that we build this. Oh and one more thing please share with the community on how to make it better, the code was lost 1000 years ago and i hate to see it be used for one game.

This code should work everywhere:

Code: Select all

init python:
    def stats_frame(name, level, hp, maxhp, **properties):
    
        ui.frame(xfill=False, yminimum=None, **properties)
    
        ui.hbox() # (name, "HP", bar) from (level, hp, maxhp)
        ui.vbox() # name from ("HP", bar)
    
        ui.text(name, size=20)
    
        ui.hbox() # "HP" from bar
        ui.text("HP", size=20)
    
        ui.close()
        ui.close()
    
        ui.vbox() # Level from (hp/maxhp)

        ui.text("Lv. %d" % level, xalign=0.5, size=20)
        ui.text("%d/%d" % (hp, maxhp), xalign=0.5, size=20)
    
        ui.close()
        ui.close()
        
    def battle(win, lose, hero_HP, extra_HP, tiger_HP, evil_HP, **properties):
        ui.textbutton("Attack", clicked=ui.returns(("hit", True)), xalign=.3,yalign=.5)
        ui.textbutton("Defense", clicked=ui.returns(("block", True)), xalign=.5,yalign=.7)
        ui.textbutton("Heal", clicked=ui.returns(("help", True)), xalign=.7,yalign=.5)
        
        while True:
            type, value = ui.interact()
            previous_HP = hero_HP
            if type == "hit":
                ui.textbutton("tiger", clicked=ui.returns(("hunt", True)), xalign=.3,yalign=.7)
                ui.textbutton("evil", clicked=ui.returns(("hunted", True)), xalign=.3,yalign=.3)
                
                
            if type == "hunt":
                if tiger_HP > 1:
                    tiger_HP = tiger_HP - 1000
                    tiger_damage = renpy.random.randint(100, 200)
                    hero_HP -= tiger_damage
                        
            if type == "hunted":
                if evil_HP > 1:
                    evil_HP = evil_HP - 1000
                    evil_damage = renpy.random.randint(100, 200)
                    extra_HP -= evil_damage
                        
            if type == 'block':
                if hero_HP < previous_HP:
                    hero_HP = hero_HP + (previous_HP - hero_HP)/2
                    
            if type == 'help':
                ui.textbutton("Heal hero", clicked=ui.returns(("help1", True)), xalign=.8,yalign=.4)
                ui.textbutton("Heal extra", clicked=ui.returns(("help2", True)), xalign=.8,yalign=.6)
                
            if type == "help1":
                if hero_HP < 2500:
                    hero_HP = hero_HP + 1000
                    if hero_HP > 2500:
                        hero_HP = 2500
                        
            if type == "help2":
                if extra_HP < 9000:
                    extra_HP = extra_HP + 1000
                    if extra_HP > 9000:
                        extra_HP = 9000
                
            if hero_HP < 1:
                renpy.jump(lose)
            if evil_HP < 1 and tiger_HP < 1:
                renpy.jump(win)
            stats_frame("ExtraP", 9, extra_HP, extramax_HP, xalign=0.20, yalign=0.05)
            stats_frame("Tiger", 4, tiger_HP, tigermax_HP, xalign=0.98, yalign=0.8)
            stats_frame("Hero", 1, hero_HP, heromax_HP, xalign=0.02, yalign=0.05)
            stats_frame("Evil", 5, evil_HP, evilmax_HP, xalign=0.80, yalign=0.8)
            ui.textbutton("Attack", clicked=ui.returns(("hit", True)), xalign=.3,yalign=.5)
            ui.textbutton("Defense", clicked=ui.returns(("block", True)), xalign=.5,yalign=.7)
            ui.textbutton("Heal", clicked=ui.returns(("help", True)), xalign=.7,yalign=.5)
            
        

label start:
    $ potions_left = 10
    with None
    jump fight
    
label fight:
    
    python:
        
        heromax_HP = 1000
        hero_HP = 1000
        
        tigermax_HP = 2000
        tiger_HP = 2000
        
        extramax_HP = 9000
        extra_HP = 9000
        
        evilmax_HP = 5000
        evil_HP = 5000

        while True:
            
            stats_frame("ExtraP", 9, extra_HP, extramax_HP, xalign=0.20, yalign=0.05)
            stats_frame("Tiger", 4, tiger_HP, tigermax_HP, xalign=0.98, yalign=0.8)
            stats_frame("Hero", 1, hero_HP, heromax_HP, xalign=0.02, yalign=0.05)
            stats_frame("Evil", 5, evil_HP, evilmax_HP, xalign=0.80, yalign=0.8)
            battle("win", "lose", hero_HP, extra_HP, tiger_HP, evil_HP, xalign=0.5, yalign=0.5)
            
label win:
    
    "yay"
    
    return
    
label lose:
    
    "noo"
    
    return
How to add image? it almost works like renpy but with extra commands.

Code: Select all


    golf = "golf.jpg"
    renpy.show("golf")
    renpy.hide("golf")

How to add sound or music? Music should be placed in the same way, sound is different if you want to add it in RPG homebrew. Add it in any button or whatever, it shouldn't mess with the code unless you place it in the wrong place.

Code: Select all

renpy.music.play("swing.mp3", channel="sound")
How to make numbers random or do random actions? Works just the same as renpy, random actions is something i'm working on.

Code: Select all

something = renpy.random.randint(1000, 4000)
How to pause? its the same as renpy with a few things change, it shouldn't effect the code.

Code: Select all

renpy.pause(5.0)
The first game that use the code in full action: http://firecat.itch.io/the-unknowns-saga-vol-3
Attachments
bunny_bored_by_roxaspikachu-d6ox79q.gif
IOS took too long to download
bunny_bored_by_roxaspikachu-d6ox79q.gif (19.16 KiB) Viewed 4858 times
rpghomebrew1-all.zip
PC version
(26.45 MiB) Downloaded 323 times

[The extension apk has been deactivated and can no longer be displayed.]

Image


Image


special thanks to nantoka.main.jp and iichan_lolbot

Post Reply

Who is online

Users browsing this forum: No registered users