Dungeon Crawl RPG Framework
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.
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.
Re: Dungeon crawling RPG frame
Hello, this script is really great for combat and very flexible.
I have some questions,and hope I dnt disturb...
I've search in forum, but I cant find a way to add events or graphic effects on skills:
example: (dialogues during combat or the effects of fire, thunder, lightning etc. for hits of skills).
is there a way to put them? or is it too complicated?
Also I can put healing skill?
I know a few things of python, sorry if I ask stupid questions...
I have some questions,and hope I dnt disturb...
I've search in forum, but I cant find a way to add events or graphic effects on skills:
example: (dialogues during combat or the effects of fire, thunder, lightning etc. for hits of skills).
is there a way to put them? or is it too complicated?
Also I can put healing skill?
I know a few things of python, sorry if I ask stupid questions...
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Dungeon crawling RPG frame
You can use renpy.show to show images inside of python code.
To make skill varieties, add a new attribute "type" on skill class and evaluate it when a skill is used. For example,
To make skill varieties, add a new attribute "type" on skill class and evaluate it when a skill is used. For example,
Code: Select all
class skill(type="", image="",wait=.3):
......
class actor():
.....
def command(self,target):
......
if self.skill.type=="attack"
self.attack(self,skill,target)
elif self.skill.type=="heal"
self.heal(self,skill)
def attack(self,skill,target):
renpy.show(self.skill.image)
renpy.pause(self.skill.wait,hard=True)
if self.skill.hit<renpy.random.randint (0,100):
.......
renpy.hide(self.skill.image) #Usually, hide is needed to work the next animation correctly
def heal(self,skill)
self.hp += self.skill.power
Re: Dungeon crawling RPG frame
Thanks for your kind reply.nyaatrap wrote:You can use renpy.show to show images inside of python code.
To make skill varieties, add a new attribute "type" on skill class and evaluate it when a skill is used. For example,
The images work well, but for the variety of skills I have a invalid syntax
Code: Select all
if self.skill.type=="attack"
Code: Select all
init -1 python:
class Skill():
def __init__(self, name, hit, power):
self.name = name
self.hit = hit
self.power = power
class Actor(renpy.store.object):
def __init__(self, name, max_hp=0, skills=[]):
self.name=name
self.max_hp=max_hp
self.hp=max_hp
self.skills = skills
def command(self, target):
self.skill = renpy.call_screen("command")
target.skill = renpy.random.choice(target.skills)
self.attack(self.skill, target)
if self.skill.=="attack"
self.attack(self,skill,target)
elif self.skill.type=="heal"
self.heal(self,skill)
if target.hp < 1:
return
target.attack(target.skill, self)
def attack(self,skill,target):
if self.skill.hit<renpy.random.randint (0,100):
def heal(self,skill)
self.hp += self.skill.power
narrator ("{} dodged {}'s attack".format(target.name,self.name))
else:
target.hp -= self.skill.power
narrator ("{} got {} damage".format(target.name, self.skill.power))
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Dungeon crawling RPG frame
It's __ini__ which creates attributes when objects are created.
Then create objects:
So you can evaluate heal.type.
Code: Select all
class Skill():
def __init__(self, name, hit, power, type="attack"):
self.name = name
self.hit = hit
self.power = power
self.type = type
Code: Select all
label start:
$ thunder = SKill("Thunder", 80, 15)
$ heal = Skill("Heal", 0, 10, "heal")
-
- Miko-Class Veteran
- Posts: 745
- Joined: Fri Nov 02, 2012 8:41 am
- Projects: Red eyes in the darkness
- Contact:
Re: Dungeon crawling RPG frame
@Zebragirl
self.skill. <--something is missing hereCode: Select all
if self.skill.=="attack" self.attack(self,skill,target)
Re: Dungeon crawling RPG frame
Thanks for your earlier help. However, I've hit another roadblock.
I've been tweaking the fighting part of the script to do some stuff, so I've changed the some of the skills to work with some variables that I've defined earlier in other parts of the game, outside of the python script.
The last [] is for the status changing attacks, as you kindly suggested. When I tried the script, it worked, and the player's attack did 5 damage, as intended.
The problem begins when I try to change the stats. I've created a level up part where every stat us raised by 1. I can see the stats being changed in-game, however, the HP stays at 50, the MP stays at 50, and it doesn't matter how much I change the stats, the attack keeps doing 5 damage.
How can I refresh the variables? Do I need to add the fight code again every time the character levels up? Do I need to define the player part every time I change the stats?
I've been tweaking the fighting part of the script to do some stuff, so I've changed the some of the skills to work with some variables that I've defined earlier in other parts of the game, outside of the python script.
Code: Select all
$ level = 1
$ STR = 5
$ END = 5
$ AGI = 5
$ INT = 5
$ LDR = 5
$ LCK = 5
$ GOLD = 0
$ Attack = Skill("Attack", 0, (50+AGI/2), STR, "none")
$ player = Fighter (charname, (END*10), (INT*10), [Attack, Wait], [])
The problem begins when I try to change the stats. I've created a level up part where every stat us raised by 1. I can see the stats being changed in-game, however, the HP stays at 50, the MP stays at 50, and it doesn't matter how much I change the stats, the attack keeps doing 5 damage.
How can I refresh the variables? Do I need to add the fight code again every time the character levels up? Do I need to define the player part every time I change the stats?
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Dungeon crawling RPG frame
It just makes things difficult when you mix instances and variables. You should put anything in instances.
Add these variable on the class, and define level up method, then call it when an actor levels up.
Add these variable on the class, and define level up method, then call it when an actor levels up.
Code: Select all
class Actor(renpy.store.object):
def __init__(self, name, max_hp=0, level=1, str=1, ....., skills=[]):
self.name=name
......
def levelup(self):
self.level += 1
self.hp += 5
.......
Code: Select all
label start:
$player = Actor("name", max_hp=50, level=1, str=5, ........)
label battle_end:
$player.levelup()
Re: Dungeon crawling RPG frame
I've changed the class to hold the stats, but my script doesn't seem to work anymore.
When I change the skills using the stat name, I get "NameError: name 'agi' is not defined."
How can I fix that? Here is the code.
When I change the skills using the stat name, I get "NameError: name 'agi' is not defined."
How can I fix that? Here is the code.
Code: Select all
class Fighter(renpy.store.object):
def __init__(self, name, str, end, agi, int, max_hp, max_mp, skills, effect):
self.name = name
self.str = str
self.end = end
self.agi = agi
self.int = int
self.max_hp = end*10
self.max_mp = int*10
self.skills = skills
self.effect = effect
(Rest of the script...)
label start:
$ Attack = Skill("Attack", 0, (50+agi/2), str, "none")
$ player = Fighter ("Charname", 5, 5, 5, 5, 50, 50, [Attack, Wait])
-
- Miko-Class Veteran
- Posts: 745
- Joined: Fri Nov 02, 2012 8:41 am
- Projects: Red eyes in the darkness
- Contact:
Re: Dungeon crawling RPG frame
Problem is order of things there
"agi" is not defined.
Only the line
$ player = Fighter ("Charname", 5, 5, 5, 5, 50, 50, [Attack, Wait])
defines that player.agi is defined. But you already need Attack there.
I had a similar problem with my own dungeon crawler (which I'm currently reworking).
Would be interesting what others made there as solution (only thing I came up with is that you had to give the "mob" the skill belongs to to the call parameter of the skill
which is a bit inconvenient).
"agi" is not defined.
Only the line
$ player = Fighter ("Charname", 5, 5, 5, 5, 50, 50, [Attack, Wait])
defines that player.agi is defined. But you already need Attack there.
I had a similar problem with my own dungeon crawler (which I'm currently reworking).
Would be interesting what others made there as solution (only thing I came up with is that you had to give the "mob" the skill belongs to to the call parameter of the skill
which is a bit inconvenient).
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Dungeon crawling RPG frame
You should adjust skill parameters when method is called, rather than when creating these instances.
Code: Select all
class Actor():
def attack(self,self.skill):
hitrate = self.skill.hit+self.agi/2
Attack = Skill("Attack", 0, 50, 0, "none")
Re: Dungeon crawling RPG frame
Thanks very much! This is super helpful. I was curious if anyone could tell me how to change the player's name into the dynamic character name I use elsewhere. This is the code I used to set it up.
inti:
$ player_name = ""
$ y = DynamicCharacter("player_name", color="#c8ffc8")
label start:
$ Char_name = "player1"
label name:
show Nora happy
n "First, what is your name?"
$ player_name = renpy.input("Your name")
$ player_name = player_name.strip()
if player_name == "":
$ player_name="Jaden"
n "Well I will be calling you %(player_name)s then!"
$ Char_name = "%(player_name)s"
y "Sure seems that way."
********************
Now, I am trying to modify the name here. Let me know if this is not the right place:
init python:
# Create skills (name, hit, power)
Slash = Skill("Slash", 70, 20)
# Create battle actors (name, max_hp, skills)
player = Actor("[???]",100, [Slash])
Goblin = Actor("Goblin",40,[Slash])
As far as player name goes, I have tried "player_name," "[player_name]", and "%(player_name)s" and none work. This is only my third day attempting python so my apologies if this is a really dumb question! I really have been appreciating the help of all the kind, intelligent people on these forums.
inti:
$ player_name = ""
$ y = DynamicCharacter("player_name", color="#c8ffc8")
label start:
$ Char_name = "player1"
label name:
show Nora happy
n "First, what is your name?"
$ player_name = renpy.input("Your name")
$ player_name = player_name.strip()
if player_name == "":
$ player_name="Jaden"
n "Well I will be calling you %(player_name)s then!"
$ Char_name = "%(player_name)s"
y "Sure seems that way."
********************
Now, I am trying to modify the name here. Let me know if this is not the right place:
init python:
# Create skills (name, hit, power)
Slash = Skill("Slash", 70, 20)
# Create battle actors (name, max_hp, skills)
player = Actor("[???]",100, [Slash])
Goblin = Actor("Goblin",40,[Slash])
As far as player name goes, I have tried "player_name," "[player_name]", and "%(player_name)s" and none work. This is only my third day attempting python so my apologies if this is a really dumb question! I really have been appreciating the help of all the kind, intelligent people on these forums.
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Dungeon crawling RPG frame
Code: Select all
lavel start:
$playername=renpy.input()
$player.name=playername
Re: Dungeon crawling RPG frame
I've gotten a bit more accustomed to Python now, but I'm having a hard time with something here..
Is it possible to keep the same battle actor, yet change skills?
If I for instance wanted to have my character learn a new skill in the midst of a battle, how would that be done?
I have also added a leveling system, so it would be best if I could reuse the same battle actor, even though he will learn new skills in the future.
Is it possible to keep the same battle actor, yet change skills?
If I for instance wanted to have my character learn a new skill in the midst of a battle, how would that be done?
I have also added a leveling system, so it would be best if I could reuse the same battle actor, even though he will learn new skills in the future.
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Dungeon crawling RPG frame
It's simply
Code: Select all
$player.skills.append(skillInstance)
$player.max_hp += 5
Re: Dungeon crawling RPG frame
That worked out, however I also need to know how to remove spells, in case I need to remove some bugs to the game.
I watched the stuff about the leveling system, and just as the previous guy said, the stats go up, but there is no change in my HP and my stats don't do the change they are supposed to do. Can someone help me out there?
I watched the stuff about the leveling system, and just as the previous guy said, the stats go up, but there is no change in my HP and my stats don't do the change they are supposed to do. Can someone help me out there?
Who is online
Users browsing this forum: No registered users