RPG Battle Engine - Alpha 7.5, downloads in first post

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.
Message
Author
User avatar
Mole-chan
Veteran
Posts: 333
Joined: Thu Aug 27, 2009 12:46 am
Completed: DUAEL, Escape from Puzzlegate
Projects: A Bird with Gold-Mended Wings
Deviantart: mole-chan
Skype: mole-chan
itch: moleworks
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#181 Post by Mole-chan »

Jake wrote:It suddenly occurs to me that I re-jigged some of the way skills are stored since the last release - so that may work, but it may not. Let me know if it doesn't and I can knock up a 7.5-compatible version for you.
Yeah, I got a bit of an error. I edited in my last post, but here it is again for convenience.

it's a " 'str' object has no attribute 'Name'", referring to this line of code

Code: Select all

skills = filter(lambda x: x.Name == skill.Name, self._skills)

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#182 Post by Jake »

Mole-chan wrote: Yeah, I got a bit of an error. I edited in my last post, but here it is again for convenience.
Ditto!

Code: Select all

        # Remove this skill from this fighter's list of abilities
        # (Just the once, if it's there more than once!)
        def UnregisterSkill(self, skill):
            if (skill.Name in self._skillHandlers):
                # Just find the first matching skill
                skills = filter(lambda x: x == skill.Name, self._skillHandlers)
                skill = self._skillHandlers[skills[0]]
                del self._skillHandlers[skill.Name]
                
            self._skills = {}
            
            for skill in self._skillHandlers.values():
                skill.RegisterFighter(self)
(As you can see, the next release's version is neater. ;-)
Server error: user 'Jake' not found

User avatar
Mole-chan
Veteran
Posts: 333
Joined: Thu Aug 27, 2009 12:46 am
Completed: DUAEL, Escape from Puzzlegate
Projects: A Bird with Gold-Mended Wings
Deviantart: mole-chan
Skype: mole-chan
itch: moleworks
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#183 Post by Mole-chan »

Jake wrote:
Mole-chan wrote: Yeah, I got a bit of an error. I edited in my last post, but here it is again for convenience.
Ditto!

Code: Select all

        # Remove this skill from this fighter's list of abilities
        # (Just the once, if it's there more than once!)
        def UnregisterSkill(self, skill):
            if (skill.Name in self._skillHandlers):
                # Just find the first matching skill
                skills = filter(lambda x: x == skill.Name, self._skillHandlers)
                skill = self._skillHandlers[skills[0]]
                del self._skillHandlers[skill.Name]
                
            self._skills = {}
            
            for skill in self._skillHandlers.values():
                skill.RegisterFighter(self)
(As you can see, the next release's version is neater. ;-)
Awesome, thanks! That one worked like a charm. 8D
and yes, the new version is quite streamlined. >V<

User avatar
azureXtwilight
Megane Procrastinator
Posts: 4118
Joined: Fri Mar 28, 2008 4:54 am
Completed: Fantasia series (ROT and ROTA), Doppleganger: Dawn of The Inverted Soul, a2 (a due), Time Labyrinth
Projects: At Regime's End
Organization: Memento-Mori VNs, Team Sleepyhead
Location: Yogyakarta, Indonesia.
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#184 Post by azureXtwilight »

Found another bug, when a character dies in a battle he/she is forever gone from the battle and cannot be back in the next one :o
Image

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#185 Post by Jake »

azureXtwilight wrote:Found another bug, when a character dies in a battle he/she is forever gone from the battle and cannot be back in the next one :o
I'm pretty sure this isn't the case since I've not had this problem in Chronicle, and I'm pretty sure I didn't change anything to cater for it.

Are you setting the fighter's health back above 0 and setting them back to Active?
Server error: user 'Jake' not found

User avatar
azureXtwilight
Megane Procrastinator
Posts: 4118
Joined: Fri Mar 28, 2008 4:54 am
Completed: Fantasia series (ROT and ROTA), Doppleganger: Dawn of The Inverted Soul, a2 (a due), Time Labyrinth
Projects: At Regime's End
Organization: Memento-Mori VNs, Team Sleepyhead
Location: Yogyakarta, Indonesia.
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#186 Post by azureXtwilight »

Jake wrote:
azureXtwilight wrote:Found another bug, when a character dies in a battle he/she is forever gone from the battle and cannot be back in the next one :o
I'm pretty sure this isn't the case since I've not had this problem in Chronicle, and I'm pretty sure I didn't change anything to cater for it.

Are you setting the fighter's health back above 0 and setting them back to Active?
I'm not sure how to do that... Do you mean we have to define the fighter every time a new battle starts? But then that means the levels that fighter has collected would be gone already.
Image

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#187 Post by Jake »

azureXtwilight wrote:
Jake wrote: Are you setting the fighter's health back above 0 and setting them back to Active?
I'm not sure how to do that... Do you mean we have to define the fighter every time a new battle starts? But then that means the levels that fighter has collected would be gone already.

No, no, not at all. You can set any of a fighter's stats directly like this:

Code: Select all

fighter.Stats.Health = 100
Or if you want to set it back to whatever the normal maximum is for that fighter:

Code: Select all

fighter.Stats.Health = fighter.BaseStats.Health
And 'Active' is just a flag on the fighter to set whether that fighter is capable of acting right now or not:

Code: Select all

fighter.Active = True
Server error: user 'Jake' not found

User avatar
azureXtwilight
Megane Procrastinator
Posts: 4118
Joined: Fri Mar 28, 2008 4:54 am
Completed: Fantasia series (ROT and ROTA), Doppleganger: Dawn of The Inverted Soul, a2 (a due), Time Labyrinth
Projects: At Regime's End
Organization: Memento-Mori VNs, Team Sleepyhead
Location: Yogyakarta, Indonesia.
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#188 Post by azureXtwilight »

Ah, I see. Sorry for the trouble, I'll try that out :)
Image

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#189 Post by Jake »

Not yet a new release (I've been snowed under with other stuff!), but if any of you played the first act of Chronicle of Mars, you probably will have noticed the cutscenes - which use the battle engine with the same tileset/elevation combination as the battles themselves, with pre-set movements and actions for the fighters.

Well, as part of Chronicle's development I wrote this lightweight cutscene coordinator, which means that instead of having to type out every single movement as a series of skill PerformAction calls or having to move the fighter sprites around individually, it's relatively simple to set up sequences of cues that the engine will then play out in parallel. I've already included it in the next release of the engine, but since I was recently asked about it, I figured I should put the code up in this thread in case people want to play around with it in advance of the next release. (Since that's taking much longer to get to than I expected!)
engine-cutscene.rpy
Cutscene coordinator
(6.07 KiB) Downloaded 88 times
If you want to use this code, simply download the attached file and place it alongside all the other engine files. Then call 'CutsceneMove' with a dict of fighters mapped to lists of cues, and it'll play them all out for you.

If you want to see it working in a simple way, then in the elevation demo code, replace the bit that says:

Code: Select all

        battle.Start()
with the following:

Code: Select all

        battle.Show()
        battle.Pause(0.1)
        
        CutsceneMove( {
                steve: [("move", 3, 4), ("move", 0, 0)]
            }, battle )
        
        battle.Start()
Firstly, we're not calling 'battle.Start()' straight away because that will implicitly give control to the player. Calling 'battle.Show()' displays everything on-screen as it will be at the start of the battle, but doesn't actually start taking battle turns and giving the player action choices and running the AI or anything.

What the CutsceneMove call above does is queue up two cutscene commands for the 'steve' fighter: Move to coordinates (3, 4), then move to coordinates (0,0). It'll start executing them immediately, and only return from CutsceneMove and carry on with the rest of the script once all the queued commands are finished. The first parameter is a dictionary mapping fighters to lists of cues for that fighter (queues of cues, heh), so you can add extra cues for other fighters by simply inserting those other fighters into the same dict with lists of instructions of their own. The system will run them all in parallel so far as it can.

There are four commands you can use as cues:
  • ("move", x y) will move the fighter to the coords specified.
  • ("wait", n) will wait n 'turns' before carrying on with the next item. One 'turn' in this context is one space worth of movement, which takes 0.5 seconds.
  • ("remove") will remove the fighter from the scene entirely
  • ("state", "statename", "facing") will change the fighter's state (have a look at the directional-animated-sprites demo and for more examples of sprite state and facing)
also:
  • ("state", "statename", "facing", "soundfile") will do the same as above, but also play the stated sound at the same time.
The thing to be wary of is that fighters move according to the normal rules of moving in a battlefield, so it's possible for them to get stuck. Generally they just wait a turn and try again, but if - say - you have two fighters moving in opposite directions, and they run into each other and each wants to move into the other's space, then they may get permanently stuck and the cutscene will never end.
If you know that it's going to be quite likely, or you want to avoid awkward situations where the order that moves resolve causes the scene to look funny*, then you can pass the optional 'passThrough' parameter to the call to CutsceneMove, which will mean that it doesn't apply the normal rules of collision and people can walk thorough each other:

Code: Select all

        CutsceneMove( {
                steve: [("move", 3, 4), ("move", 0, 0)]
            }, battle, passThrough=True )
It's probably a good idea to check your cutscenes with the passThrough param set to True anyway, and if they work without collisions then you can go on and turn it off for the finished game.



This code is far from perfect, 'cause it was knocked up as part of NaNo for a particular purpose - if anyone uses this and finds it lacking, I'd be interested in hearing what you need from it.






* in Chronicle at some point there's a patrol of five mecha walking along a road, so I set them up, five fighters in a 5-square-long line, then ran a CutsceneMove cue list which told them to move to new positions, further along the road, equally-spaced. The first time I ran it, the first two walked off while the back three waited until they were a step ahead, then the next two move and the last one waited another step, /then/ the last one moved off. What was happening was that the code was checking each fighter's next step in a different order to the order in which I'd lined them up on the screen. The first one was cued to move forwards, there was nothing in the space in front of it, so it could. But then instead of processing the second one next, it processed the third one - it was cued to move forwards, but so far the second one was still in that space, so it couldn't move - and waited a turn. Then it checked the second one, which was cued to move into the space the first one had already vacated, so it was fine to go. The same thing happened the next turn further down the line.
This was when I added the 'passThrough' parameter - with the passThrough set, each fighter didn't care whether there was anything in the space it was moving to... but since they were all moving in the same direction at the same rate, they never actually passed through each other.

The opposite situation occurs earlier in the game - five fighters all walk out of a room through the same doorway at the same time. With passThrough on, they'd merge into two or three fighters as they walked through the same spaces on their way to the door; with it off, they politely wait for other fighters to move out of their way before proceeding, and it actually looks more like five people walking through the same door.
Server error: user 'Jake' not found

DesertFox
Regular
Posts: 196
Joined: Sun Jul 28, 2013 1:29 pm
Completed: Over The Hills And Far Away
Projects: My Little Dictator
Organization: WarGirl Games
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#190 Post by DesertFox »

---
Last edited by DesertFox on Sun Nov 04, 2018 5:05 pm, edited 1 time in total.

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#191 Post by Jake »

DesertFox wrote: Which ones should I keep before I go to town on changing the coding?
Nearly all the scripts which are absolutely necessary are prefixed "engine"; you also need 'matrices.rpy'. That said, several of the non-engine scripts are necessary if you're planning on keeping some of the extra bits set up for the demos... for example, the 'assets.rpy' file creates all the skills and so on used in the demos; 'elevation.rpy' contains the code to draw elevated grids a la Chronicle; 'battle-screens.rpy' has the definitions for the RPG-shop/equip screens; 'example-items.rpy' has the definitions of the items which are used in the various demos.


If you don't know what exactly you need to keep, probably the easiest approach is to just get rid of anything which is a demo file, get rid of script.rpy and options.rpy and screens.rpy (the default Ren'Py project files) and leave everything else. To be on the safe side, keep it all in a subdirectory of your game - I tend to stick all the battle engine files in game/engine, so they're easy to replace to upgrade your game when a new version of the engine is released.
Server error: user 'Jake' not found

User avatar
Dragonstar89
Regular
Posts: 163
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: Self
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#192 Post by Dragonstar89 »

This is a great looking system. I've asked all around, but haven't got an answer nor suggestion, so I'll just ask you since you've made the battle system. Is it possible to have the battle system (stats, info screen with party/skills and equipment) but instead of having the default view of the battle engine, make it look something like the attachment? (excluding the logo, I just added that for fun.)
Attachments
My planned out battle system view
My planned out battle system view
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#193 Post by Jake »

Dragonstar89 wrote: Is it possible to have the battle system (stats, info screen with party/skills and equipment) but instead of having the default view of the battle engine, make it look something like the attachment? (excluding the logo, I just added that for fun.)
The short answer is "yes".

The slightly longer answer is "yes, even the logo if you want".

The longer and more accurate answer is "yes, but it'll take some programming".


The code was designed to be as customisable as possible - so:
  • The UI can be changed completely by writing your own UIProvider; all the battle engine requires is that whatever code you use to do so implements some fundamental functions like "pick a fighter who will be a target of a skill" or "pick a skill to use" or whatever - your UIProvider can then do this however you see fit.
  • The way elements are laid out in battles can be changed completely by writing your own Battlefield class; really, there's no limit to this as the battlefield is used for display only, so you can lay it out however you want.
Server error: user 'Jake' not found

User avatar
Dragonstar89
Regular
Posts: 163
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: Self
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#194 Post by Dragonstar89 »

Jake wrote:
Dragonstar89 wrote: Is it possible to have the battle system (stats, info screen with party/skills and equipment) but instead of having the default view of the battle engine, make it look something like the attachment? (excluding the logo, I just added that for fun.)
The short answer is "yes".

The slightly longer answer is "yes, even the logo if you want".

The longer and more accurate answer is "yes, but it'll take some programming".


The code was designed to be as customisable as possible - so:
  • The UI can be changed completely by writing your own UIProvider; all the battle engine requires is that whatever code you use to do so implements some fundamental functions like "pick a fighter who will be a target of a skill" or "pick a skill to use" or whatever - your UIProvider can then do this however you see fit.
  • The way elements are laid out in battles can be changed completely by writing your own Battlefield class; really, there's no limit to this as the battlefield is used for display only, so you can lay it out however you want.
Alright, thanks. I'll download the system then, and see what I can do with it.
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

User avatar
Dragonstar89
Regular
Posts: 163
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: Self
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: RPG Battle Engine - Alpha 7.5, downloads in first post

#195 Post by Dragonstar89 »

One last thing.

I've tried this twice: I downloaded the .zip for the latest Alpha7.5 and I've gotten the same results when I try to extract. Windows tells me that the .zip is empty. So when I try and view it's contents, it says I cannot because the file is invalid. I've had this problem one other time in my life; when it was with another game engine and I found out that data transfer loss was the problem.

Anyways; I'm on my laptop using my Android tethered USB to give me broadband internet on my 3G network, and it works fine. I've downloaded many files, including .zip's so far. So, why is the .zip for the battle system not working? Is there a place where I can just download the scripts, put them in a folder, then add it to Renpy?
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

Post Reply

Who is online

Users browsing this forum: No registered users