Bpen's Simplistic Battle Engine

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
bluepencil
Newbie
Posts: 7
Joined: Thu Apr 26, 2007 4:14 am
Contact:

Bpen's Simplistic Battle Engine

#1 Post by bluepencil »

Hello, all. I'm a recent inductee into the Ren'Py Is Awesome club. I'm decidely not a programmer, but I've played hella lot of RPGs and helped write a gamebook.

It started with this:
http://www.sandman.connectfree.co.uk/prog/gamebook.htm

Which I thought was really cool, since had its own dice roller. However, as worked on it I realized that story branching was still as difficult as in paperbook form. For three paths, I had to reserve, say pages 10 to 60 for the first character, 70 - 150 for the next, etc ... to combine at page 300 or so.

::twitch::

Then while checking out http://ambrosine.com/resource.html , I found Ren'Py slightly below. Looking at it, I was impressed at the clean and simple interface. Then I remembered seeing once that it is possible to have a good enough RPG engine in visual novel format *coughasgaldh*. All I really needed was some variables, some operators and a random number generator.

Essentially it would still be a lot of 'yes' and 'no' choices in the same vein as a gamebook, but with the computer handling the rolls and turning the pages. As long as I thought of it that way, it doesn't seem so hard.

http://illuminati-fiction.net/bpen/files/IU3r.zip

The code is still fugly, and there are certainly far more efficient ways of handling it. Eheh. I'm still giddy with having it function, though. (Mwhahah! It woiks! It woiks!)

The above 'battle engine'
* rudimentarily incorporates levels
* utilizes equipped weapons and armor
* enforces different 'styles' of play
* handles critical hits
* handles status effects (only one so far, though)
* has a crude shop and inventory system

I uploaded the test version, so the player starts with extra gold and wins under his (or her) belt. The plot is... inconsequential to this point, but the demo is more or less playable as it is.

It doesn't have a user interface, which is something I'm lost on. I figure I could put some horizontal buttons at the left side of the screen, but how do I place text on the screen? I only need a simple bar over at the top.

Please, I'd rather not see python: and keep ui_ to a minimum.

The exponential increase in needed XP to reach the next level really throws me off. I have no idea how to do it.

I still have to incorporate team battle. I suppose a few more definitions would do it. However, after looking at the code, what would you suggest?

Something to the order of:

Image
Anyways, things to add:
* a user interface(!)
* team battle(!)
* exponential XP requirements
* more status effects (poisoned, bleeding, etc)
* ranged weapons calc (use PER check instead of STR)
* remembering the equipment of each character
* secondary items (implants) that give stat boosts or regen
* secondary skills (Medical, Traps, Heavy Weapons etc)

::scratches the tip of his nose::

Now that I think about, just changing STR to SENSORS or Mech Piloting would do just as well. Instead of buying "Spear" we just mount "Heavy Beam Cannon" in turret or purchase "120mm Rifle". Once I have an interface, I have an idea of configuring this to simulate a ship-to-ship combat system.

http://illuminati-fiction.net/bpen/files/Severance.zip



edit:

D'oh!

Code: Select all

menu: 
    "Eat the chicken.": 
         ... 
    "Eat your veggies:": 
         ... 
     "I'm full." if food_points > 10: 
Knowing that yesterday would have really simplified things. I have a feeling I'm going to be abusing that really, really soon.

Please tell me, what other things have I missed?

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

#2 Post by DaFool »

Nice demos. I played them both until the endless loop cycles. They have good production values, and really makes Ren'Py suited to the adventure games.

Can't wait till they are finished, science fiction is still a genre underrepresented in games here.

kamiomi
Newbie
Posts: 23
Joined: Sun Apr 08, 2007 2:19 am
Contact:

#3 Post by kamiomi »

What I did for exponential player XP in my RPG battle engine was to zero out the XP when the player went up a level, then just require Level*99, or whatever. So it would always be a greater amount to get from 0 to the next level requirement.

You could also do a lookup table, something like:

Code: Select all

if EXP > 99:
   level = 1
elif EXP > 299:
   level = 2
elif EXP > 599:
   level = 3
elif EXP > 999:
   level = 4
elif EXP > 1499:
   level = 5
Still, I bet there a better, more mathematical/programmer-y way to do it that I don't know.

My RPG engine, if you're interested, feel free to pick it apart:
http://lemmasoft.renai.us/forums/viewto ... c&start=28
It's also got some status effects like poison, regeneration, power up, and some user interface elements.

:mrgreen:

bluepencil
Newbie
Posts: 7
Joined: Thu Apr 26, 2007 4:14 am
Contact:

#4 Post by bluepencil »

Thanks kamiomi. Your engine intimidates me with its nested python and ui blocks. It is impressive, though. It fills me with much envy, but I'll have to settle for a simpler look.

Anyways; I've much improved the engine:

It now has:
a. a less eyehurting and wrist-cramping user interface
b. two new status effects (poisoned and bleeding)
c. scalable enemy difficulty(!) (the higher your level, the more difficult the enemy; though at appropriate bonuses to XP and GC.)
d. a better market system
e. inventory remembering (wahoo!)
f. more special skills
g. an inn or resting ability
h. two new items: implants
i. exponential XP needs


::rubs chin::

Looking back, it's less of a battle engine than a town right now.

Instead of an arena, just have the link define $traveling_to and along the way run into a random_encounter. Instead of choosing the opponent, get_enemy could just get a random tier enemy. Required enemy encounter happens imply by jumping directly to the enemy definition block. In youwin, if the $traveling_to is set, jump to next_town instead of say, this_town.

Things to add:
* temples! (sacrifice unto your god!)
* enemy temples! (burn the infidels!)
* other locations (towns, space stations, etc)
* library (for all our textdumping needs)

Now, for specifics:

I figured out a kludge for exponential XP.

Code: Select all

label check_xp:
    $ level_adj = (hero_xp)+100
    $ level_incr = hero_level*(hero_level)
    $ next_level = 100*(level_incr)
    if next_level == 0:
        $ next_level = 100
    $ need_xp = next_level-hero_xp
    disp "You have %(hero_xp)d XP. The next level is at %(next_level)d XP."
    if hero_xp > next_level:
        disp "You have gained a level!"
        $ hero_level += 1
        $ level_incr = hero_level*(hero_level)
        $ next_level = 100*(level_incr)
        jump check_level
    jump check_level
Unfortunately this means the PC starts at level zero. I had in mind a 'training mode' anyway for the actual game.

Inventory is handled by two big $define boxes, store_inv and get_inv:

Code: Select all

    if player == 1:
        $ hero_weapon = nakur_w 
        $ hero_weapon_d = nakur_wd 
        $ hero_armor = nakur_a
        $ hero_armor_d = nakur_ad 
        $ implant_r = nakur_rgen
        $ implant_m = nakur_fgen
    if player == 2:
        $ hero_weapon = sene_w 
        $ hero_weapon_d = sene_wd 
        $ hero_armor = sene_a 
        $ hero_armor_d = sene_ad
        $ implant_r = sene_rgen
        $ implant_m = sene_fgen        
    if player == 3:
        $ hero_weapon = mons_w 
        $ hero_weapon_d = mons_wd 
        $ hero_armor = mons_a 
        $ hero_armor_d = mons_ad 
        $ implant_r = mons_rgen
        $ implant_m = mons_fgen        
And the direct opposite:

Code: Select all

label store_inv:
    if player == 1:
        $ nakur_w = hero_weapon # inventory check
        $ nakur_wd = hero_weapon_d# inventory decription check
        $ nakur_a = hero_armor # inventory check
        $ nakur_ad = hero_armor_d # inventory decription check
        $ nakur_rgen = implant_r
        $ nakur_fgen = implant_m
    if player == 2:
        $ sene_w = hero_weapon # inventory check
        $ sene_wd = hero_weapon_d# inventory decription check
        $ sene_a = hero_armor # inventory check
        $ sene_ad = hero_armor_d # inventory decription check
        $ sene_rgen = implant_r
        $ sene_fgen = implant_m
    if player == 3:
        $ mons_w = hero_weapon # inventory check
        $ mons_wd = hero_weapon_d# inventory decription check
        $ mons_a = hero_armor # inventory check
        $ mons_ad = hero_armor_d # inventory decription check
        $ mons_rgen = implant_r
        $ mons_fgen = implant_m

    jump arena_ring
I have a feeling this is gonna bite me in the ass later. This only works if the player is in control over one hero at a time. It totally fails in a party system.

::headhurt::


The inn is simply:

Code: Select all

label inn:
    $ inncharge = 5*(hero_level+1)
    if cash < inncharge:
        "You have no choice but to sleep out in the streets."
        $ renpy.play('spell.wav')
        $ hero_hp += END
        $ hero_mp += INT
        "You wake up itching and uncomfortable, having regained %(END)d HP and %(INT)d MP."
        jump arena_ring
    "You rest in the suite you most deserve for %(inncharge)s GC." 
    $ renpy.play('spell.wav')
    $ hero_hp = max_hp
    $ hero_mp = max_mp
    "You wake up happy and refreshed, having regained %(max_hp)d HP and %(max_mp)d MP."
    jump arena_ring

Please, play the game through. It's as complete as I can possibly make with my degree of ren'py knowledge for the moment. I suggest the complete experience by setting the startup variables back to zero; since the upload is again, the test version. You would start with more cash (things are lot more expensive now) and at a higher level. The goal at the end can now actually be reached. (Dying over and over again is fun! ^_^)



Questions:
1. Any way for me to keep the clicked buttons so the new choices seem to unfold on top of it? Like say:
Image
With of course, the old buttons no longer active.
2. How does the display coordinate system work? .something to .something. It... confuddles me so. ~_~
3. I still need a way to constantly display text near the top. How do I do that?
4. How do I display a screenful of text at a time? ref: the kludgy playerbio.

edit:
Silly me, uploaded the wrong version. Fixed now. ~_~

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]