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
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

#166 Post by azureXtwilight »

I see, thanks for the tip!

... Any idea of how to make the enemy heals their own party, though?
Image

User avatar
kuri_chii
Regular
Posts: 69
Joined: Sat Apr 27, 2013 10:34 am
Completed: RHWIMY beta 1.0
Projects: Right here where I met you, Love Snatch, Monarchy High
Organization: VND - AWA
IRC Nick: Kuri
Deviantart: franzzzz002
Skype: franz.mole
Location: Somewhere in Asia
Contact:

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

#167 Post by kuri_chii »

Thnx its a good thing to have a battle engine in a VN Game...

but I need help with this...

I want to use the "Isometric square grid rotation" into my game...

My game is like "Baka to Test To Shoukanjuu"

A visual novel game but if you want to battle a character it will move to the " Isometric square grid rotation" battle engine..

How will I do that...?? please help me...

thnx :D
The best way showing your feelings is to write Novel Stories :3
Image
DeviantArt | Monarchy High | RHWIMY | Love Snatch

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

#168 Post by Jake »

tuxdude143 wrote:Er me again! I'm having trouble implimenting the movement code into the game for magic attacks. Could you help me out?
To have jumping in/out for a magic attack, you would need to make a second copy of the same class in this example, and where it says:

Code: Select all

    class JumpAttackSkill(AttackSkill):
You'd have to change it to:
a) have a different class name
and
b) descend from MagicFighterAttackSkill instead of AttackSkill:

Code: Select all

    class JumpMagicFighterAttackSkill(MagicFighterAttackSkill):
And then when you want to create an instance to assign to a fighter, just call it with the same parameters you would normally call MagicFighterAttackSkill with:

Code: Select all

jumpFireball = JumpMagicFighterAttackSkill("Fire", command=[("Magic", 5), ("Fire", 1)], attributes=['magic', 'fire'], damage=5, cost=5, range=4, sprite=BattleSprite('fire 1', anchor=(0.5, 0.8)), pause=0.4, sfx="audio/fire.wav")

...

steve.RegisterSkill(jumpFireball)

The same approach should work with any fighter-targeting skill - the only part of the previous example's code which was specific to AttackSkill was the first line where it descended from the AttackSkill class; everything after that should work for any other single-fighter-targeting skill as well.
Server error: user 'Jake' not found

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

#169 Post by Jake »

Mole-chan wrote: ahaha I am so delayed sorry. Life's been getting ahead of me. All the same, here is the code. Thanks for opting to take a look. There's some custom bits, like the EXP remaining counter, but it's mostly vanilla, a6 equipment menu.
I don't see any reason why that should have changed its behaviour, really. It's iterating through all the items, and the only thing that changes is the clicked parameter if it's available or not. Does the remove button work properly? It's doing more or less the same thing...



One thing, though. This check:

Code: Select all

if e.Name <> "Potion" and e.Name <> "Superpotion" and e.Name <> "Megapotion" and e.Name <> "Elixir" and e.Name <> "Superlixir" and e.Name <> "Megalixir" and e.Name <> "Revive":
could probably be changed to:

Code: Select all

if isinstance(e, BattleEquipment):
since it looks like you're trying to exclude all the single-use items while keeping the equipment in the list?

(You can't do it the other way around - check isinstance(e, BattleItem) - because BattleEquipment descends from BattleItem; all BattleEquipment instances are also BattleItem instances, but not all BattleItem instances are a BattleEquipment. If that makes sense!)
Server error: user 'Jake' not found

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

#170 Post by Jake »

kuri_chii wrote: I want to use the "Isometric square grid rotation" into my game...

My game is like "Baka to Test To Shoukanjuu"

A visual novel game but if you want to battle a character it will move to the " Isometric square grid rotation" battle engine..

How will I do that...?? please help me...
I don't know what "Baka to Test to Shoukanjuu" is, so if it's a game with a particular mechanic I'm afraid you're going to have to tell me a bit more detail!




If you want to include an isometric battle in your game, then probably the easiest place to start is to copy the contents of the battle engine project into a sub-folder inside your game's folder, and then copy the contents of grid_demo.rpy from this line onwards:

Code: Select all

label isometric_grid_demo:
into your game script somewhere. That'll drop the demo isometric battle into your game, which is a starting point.

It's a good idea to read through the comments in activedemo.rpy and grid_demo.rpy, because those will tell you where certain things - like fighters' names and skills - get set up. It's also worth looking in assets.rpy, where some of the sprites and skills referred to in those demos get set up.

(The alternative is to wait until the next release, which should make it easier to add battles straight from Ren'Py script without Python.)
Server error: user 'Jake' not found

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

#171 Post by Jake »

azureXtwilight wrote:... Any idea of how to make the enemy heals their own party, though?
How is it that you're trying to do it currently?


My approach to this would probably be to make a new 'heal' skill which was just used by AI fighters, set the IsAvailable method on that skill to only return True if one of that fighter's allies had been injured sufficiently, the FilterTargets method to remove all unhurt targets from the available list, and then set that skill with a higher priority than the enemy's other skills.

Like that, each turn the engine will check if there are any hurt fighters on the same side as that AI fighter to see if the skill is available - if there are, the skill becomes available for that enemy and it's likely it'll be chosen, as it has a higher weight. Once chosen, the skill will only allow targets which have actually been hurt because of the FilterTargets code, then randomly pick one of those and heal them.


Here's my example:

Code: Select all

    class HealSkill(Skill):
        def __init__(self):
            self._targets = TargetData(fighters=True, los=False, friendly=True, enemy=False, range=10)
            
            super(HealSkill, self).__init__(name="Heal", command=[("Heal", 1)], weight=1)
            
        def IsAvailable(self, fighter):
            for f in fighter._battle.FactionLists[fighter.Faction]:
                if f.Stats.Health < f.BaseStats.Health:
                    return True
            return False
        
        def FilterTargets(self, fighter, targets):
            validTargets = {}
            for t in targets:
                if t.Stats.Health < t.BaseStats.Health:
                    validTargets[t] = targets[t]
                    
            return validTargets
            
        def PerformAction(self, fighter, target):
            if (target != None):
                
                targetFighter = target[0]
                targetFighter.Damage(-50, fighter)
                
            fighter.EndTurn()
(This is just a straight heal-50-health job - the -50 damage - but that could be modified to look at a stat or whatever, of course.)

I tested it on the grid demo, adding in an extra skill line for each of the elementals, like this (for each one, at it happens):

Code: Select all

        fireElemental.RegisterSkill(Library.Skills.KnifeAttack, 1)
        fireElemental.RegisterSkill(Library.Skills.Fireball, 3)
        fireElemental.RegisterSkill(HealSkill(), 10)
The priority is set such that if there are any wounded fighters on the enemy team (including the current one taking its turn) then there's a good chance - more or less 70% - that they'll choose to heal a wounded compatriot... and the IsAvailable check ensures that the skill simply isn't there to choose if there's no wounded people on their side, so they don't needlessly waste their turns healing people who don't need it.

If you wanted to alter the conditions under which the skill gets used, simply change the IsAvailable and/or FilterTargets methods - just make sure that the skill will never end up in the situation where it's available but there are no valid targets*! So for example, if you wanted to only check for allied fighters with a health below half, you could change those two functions like this:

Code: Select all

        def IsAvailable(self, fighter):
            for f in fighter._battle.FactionLists[fighter.Faction]:
                if (f.Stats.Health / f.BaseStats.Health) < 0.5:
                    return True
            return False
        
        def FilterTargets(self, fighter, targets):
            validTargets = {}
            for t in targets:
                if (t.Stats.Health / t.BaseStats.Health) < 0.5:
                    validTargets[t] = targets[t]
It probably wouldn't work so well for a non-AI fighter - you'd want an equivalent skill without the IsAvailable and the FilterTargets for use with player fighters - because players would usually tend to expect a skill to be available and usable even when the target doesn't actually need healing... but of course, if you want that behaviour you could use it there instead.




* (In fact, it's actually possible that the skill above could end up in that situation, because I've given it a range of 10 and there's no range check in IsAvailable, so it could mark itself as available when the only wounded ally is over 10 spaces away.)
Server error: user 'Jake' not found

User avatar
kuri_chii
Regular
Posts: 69
Joined: Sat Apr 27, 2013 10:34 am
Completed: RHWIMY beta 1.0
Projects: Right here where I met you, Love Snatch, Monarchy High
Organization: VND - AWA
IRC Nick: Kuri
Deviantart: franzzzz002
Skype: franz.mole
Location: Somewhere in Asia
Contact:

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

#172 Post by kuri_chii »

Jake wrote:
kuri_chii wrote: I want to use the "Isometric square grid rotation" into my game...

My game is like "Baka to Test To Shoukanjuu"

A visual novel game but if you want to battle a character it will move to the " Isometric square grid rotation" battle engine..

How will I do that...?? please help me...
I don't know what "Baka to Test to Shoukanjuu" is, so if it's a game with a particular mechanic I'm afraid you're going to have to tell me a bit more detail!




If you want to include an isometric battle in your game, then probably the easiest place to start is to copy the contents of the battle engine project into a sub-folder inside your game's folder, and then copy the contents of grid_demo.rpy from this line onwards:

Code: Select all

label isometric_grid_demo:
into your game script somewhere. That'll drop the demo isometric battle into your game, which is a starting point.

It's a good idea to read through the comments in activedemo.rpy and grid_demo.rpy, because those will tell you where certain things - like fighters' names and skills - get set up. It's also worth looking in assets.rpy, where some of the sprites and skills referred to in those demos get set up.

(The alternative is to wait until the next release, which should make it easier to add battles straight from Ren'Py script without Python.)
OH MY ! thats it...arigatou gozaimasu! some I didnt read the posts...its just to many..

"Baka to test to shoukanjuu" its an anime that uses a RPG like battle in their class...its good to be inspired to that anime...through this Engine I can make my own game style...Thank you very much for your help... *bows*
The best way showing your feelings is to write Novel Stories :3
Image
DeviantArt | Monarchy High | RHWIMY | Love Snatch

clannadman

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

#173 Post by clannadman »

I want to try adding an Elevation Tilemap and battle system to my game. Which scripts from the download do I need code from? (Since I'm not sure which ones support the elevation.rpy)

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

#174 Post by Jake »

clannadman wrote:I want to try adding an Elevation Tilemap and battle system to my game. Which scripts from the download do I need code from? (Since I'm not sure which ones support the elevation.rpy)
Most of them, really!

The engine isn't designed to have bits and pieces taken, so the easiest option is just to copy the entire download to a 'battleengine' (or whatever) subfolder of your game. The files that aren't needed to run the engine are the ones with 'demo' or 'example' in the name (those are just examples), script.rpy, options.rpy, screens.rpy (which are the Ren'Py default project files) and assets.rpy (which is the file all the sprites, skills, equipment etc. used in the demos are defined in).

(If you want to start by copying the demo code from elevation-demo.rpy and/or grid_demo.rpy and modifying to suit your game, then you'll probably want to keep assets.rpy and maybe example-items.rpy in your game for a little while longer, until you've replaced all the graphics and skills with ones for your own game.)
Server error: user 'Jake' not found

User avatar
kukiko-tan
Regular
Posts: 62
Joined: Tue Jul 10, 2012 12:28 pm
Completed: Fear Not
Projects: The Song of the Caged Crow, Revealed Royalty, The Golden Seed
Organization: RONI
Deviantart: kukiko-tan
Contact:

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

#175 Post by kukiko-tan »

Hello! I hope you don't mind if I asked a few questions here and there too 8'D !
Firstly, I wonder if I can make the player talk to npc's/other sprites ? I mean, when the player stands next to someone and then to have an option of "talking" (to make dialogue appear or narration or stuff like that :D ) (I'm sorry for my lack of explaining skills)
Liiike this:
Image
Secondly, can the player walk around the "battlefield"/place and then reach a point, and have the option to teleport/move to some other place?
Something like this:
Image
(I'm planning to use area scenery for that, by the way 8'D)

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

#176 Post by Jake »

kukiko-tan wrote:Hello! I hope you don't mind if I asked a few questions here and there too 8'D !
Of course not!

Both of the things you're asking about will require a bit of extra programming on your part, though.
kukiko-tan wrote: Firstly, I wonder if I can make the player talk to npc's/other sprites ? I mean, when the player stands next to someone and then to have an option of "talking" (to make dialogue appear or narration or stuff like that :D ) (I'm sorry for my lack of explaining skills)
The best approach for this is probably to:
- set up a dictionary mapping pairs of characters to Ren'Py labels for conversations. Have each of those conversation labels return at the end so they go back to wherever the conversation was called from.
- create a new Skill for 'talk' (see skills-demo.rpy for examples of making your own skills), and set your talk skill to target fighters within 1 space (enemy or friendly as you prefer) and to only be available when there's a fighter within 1 space. In the PerformAction of your talk skill, have it look up the characters involved in the conversation in the conversation dictionary, then do a call_in_new_context to that label, so the cutscene plays immediately and then the battle resumes.
kukiko-tan wrote: Secondly, can the player walk around the "battlefield"/place and then reach a point, and have the option to teleport/move to some other place?
Something like this:
(I'm planning to use area scenery for that, by the way 8'D)
In some future release, I'm planning to add the ability for Positions (e.g. squares in the grid, nodes on the path battlefield, etc.) to confer stat effects and skills, just like equipment. So you'd be able to set your special squares up such that they confer the "teleport away" skill which can then be selected from the player's action menu like any other skill.

However, since that doesn't exist in the current release and probably won't in the next (which is still plodding along slowly, but work has started being hectic again :/) there is another way to do it - which I used in Chronicle of Mars, as it happens. Check in the events_demo.rpy file, look at the "Move a fighter into the right-most column for another bandit to appear" one to see how to set up an event that triggers when someone moves to a particular spot/area, and then check the engine-events.rpy file, look at the Result classes at the bottom of the file. What you'll want to do is write a Result where, in the Fire method, it asks the player if they want to teleport away and changes their Position if they do.
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

#177 Post by Mole-chan »

Heya! Quick question from me again. How would one go about removing a skill from a fighter? I have one scrolling battle that is followed shortly by two non-scrolling ones, so obviously the move skill becomes just an annoyance after that point. I tried writing up this function, but it just seems to produce an error.

Code: Select all

        def RemoveSkill (self,skill):
            if (skill.Name in self._skillHandlers) == True:
                skill = skill.Name
                del self._skillHandlers[skill]

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

#178 Post by Jake »

Mole-chan wrote:Heya! Quick question from me again. How would one go about removing a skill from a fighter?
Coincidentally, this is something that is in the next release!

The code for it there looks like this (EDIT: fixed to work in 7.5; see below):

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)
- this is in the engine-fighters.rpy file, just below the RegisterSkill function, if it makes any difference.




Congratulations on your release, by the way!
Last edited by Jake on Sat Jul 06, 2013 3:03 pm, edited 1 time in total.
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

#179 Post by Mole-chan »

Jake wrote:
Mole-chan wrote:Heya! Quick question from me again. How would one go about removing a skill from a fighter?
Coincidentally, this is something that is in the next release!

The code for it there looks like this:

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.Name == skill.Name, self._skills)
                skill = skills[0]
                self._skills.remove(skill)
- this is in the engine-fighters.rpy file, just below the RegisterSkill function, if it makes any difference.




Congratulations on your release, by the way!
Awesome! I figured it was something that was probably on your docket, but I thought I could probably rig up a ghetto version myself. Turns out not so much. But this should work nicely, thank you!

And thank you very much! >V<

edit: Unfortunately I get a 'str object has no attribute 'Name'' error when I call it, relating to this line of code.

Code: Select all

skills = filter(lambda x: x.Name == skill.Name, self._skills)
Last edited by Mole-chan on Sat Jul 06, 2013 2:29 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

#180 Post by Jake »

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.
Server error: user 'Jake' not found

Post Reply

Who is online

Users browsing this forum: No registered users