Question on making defined party members to act as (group)

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
Nero
Veteran
Posts: 242
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Question on making defined party members to act as (group)

#1 Post by Nero » Sat Nov 19, 2016 9:02 pm

Hey!

So I made players with class and defined them now I would like to make the act as a "party"

Code of class and defined party members:

Code: Select all

init -1 python:
    class Player(renpy.store.object):
        def __init__(self, name,hp,current_hp, weapon_equip=None, armor_equip=None):
            self.name=name
            self.hp = hp
            self.current_hp = current_hp
            self.weapon_equip=weapon_equip
            self.armor_equip=armor_equip
    player = Player("Dummy",1, 1)

Code: Select all

default bob = Player("Bob", 300, 300)
default sam = Player("Sam", 200, 200)
default eva = Player("Eva", 100, 100)
Now I would like to make characters defined in group does anyone know how to do that? Like this but the "right" way because this isn't working...

Code: Select all

default party_members = [bob, sam, eva]
So later I can use it like this if you know what I mean...

Code: Select all

if party_members.current_hp > 0:
     "Do next thing..."

User avatar
Pomeranian
Regular
Posts: 33
Joined: Wed Oct 12, 2016 6:52 pm
Contact:

Re: Question on making defined party members to act as (grou

#2 Post by Pomeranian » Sat Nov 19, 2016 9:50 pm

Wouldn't it be easier to just use the Player class itself? They're already 'grouped' by that. I'd create new methods under the Player class, like if I wanted to make a damage-taking method in a battle (for example)

Code: Select all

   def damage(self, dmg):
        self.current_hp = self.hp - dmg
        if self.current_hp == 0:
            renpy.show_screen("player_battle_screen", message="%s is dead!" %(self.name))

Nero
Veteran
Posts: 242
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Re: Question on making defined party members to act as (grou

#3 Post by Nero » Sat Nov 19, 2016 11:17 pm

I think it would be easier to use for me this way I hate that I got used so much on screen language instead of python classes I am trying to re-write this battle-engine viewtopic.php?f=8&t=39811 in python code because I want to implement more advanced stuff in there. I want to make code as similar as possible to this one so I can change core codes and make it work. Or maybe it's just too hard to make it work this way with python?

Nero
Veteran
Posts: 242
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Re: Question on making defined party members to act as (grou

#4 Post by Nero » Sat Nov 19, 2016 11:25 pm

OOOhhh never mind I got it all is fine! :lol: Actually now when I realized how this works its not that hard to make.

User avatar
Pomeranian
Regular
Posts: 33
Joined: Wed Oct 12, 2016 6:52 pm
Contact:

Re: Question on making defined party members to act as (grou

#5 Post by Pomeranian » Sun Nov 20, 2016 8:32 am

No problem - and I think I've actually figured out how to fix my own problem while thinking of yours! It was good practice!

Post Reply

Who is online

Users browsing this forum: No registered users