Using the RPG frame [NEW PROBLEM]

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.
Message
Author
Shadow Ninja
Regular
Posts: 38
Joined: Wed Jan 07, 2009 7:31 pm
Projects: Untilted
Location: Canada
Contact:

Re: Using the RPG frame [2 new questions]

#16 Post by Shadow Ninja »

JQuartz wrote: Yes. Use the if current_hp>=max_hp + 1 then current_hp=max_hp. Where to put this? I have no idea since I can't understand the your rpg frame anymore (it's a beyond me).
:lol:

thx for the help. i think i know where to put it. the frame im using isnt pretty, but it works. now... if i only had some BG art... :cry:

well, until i can figure out how to cut down the code for the fighting system, ill work on weapon effects, armor effects and imagemaps.
Framework coding... please wait.

Guest

Re: Using the RPG frame [2 new questions]

#17 Post by Guest »

Personally for me it's no possible to have more hp that hpmax !

Code: Select all

if current_hp > max_hp:
   $ current_hp = max_hp
for change bar stat i have change the bar stat:

Code: Select all

                
ui.bar(pvmax_stat , pv_stat ,
                          xmaximum=150,
                          left_bar=Frame("barrepv_full.png", 12, 0),
                          right_bar=Frame("barrevide.png", 12, 0),
                          thumb=None,
                          thumb_shadow=None)
ui.close()
i have two picture the first for the full bar stat the second for the empty !

ninjagrass
Regular
Posts: 104
Joined: Wed Mar 04, 2009 9:16 am
Projects: To Love Ru Trial Trouble, Bleach Battle Ignition, A new secret project...
Contact:

Re: Using the RPG frame [Solved]

#18 Post by ninjagrass »

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

TypeError: int argument required

While running game code:
 - script call at line 55 of C:\Users\ninjagrass\Documents\Other\Renpy Development\renpy-6.9.0\sample/game/script.rpy
 - script at line 48 of C:\Users\ninjagrass\Documents\Other\Renpy Development\renpy-6.9.0\sample/game/script.rpy
 - python at line 48 of C:\Users\ninjagrass\Documents\Other\Renpy Development\renpy-6.9.0\sample/game/script.rpy.
 - python at line 41 of C:\Users\ninjagrass\Documents\Other\Renpy Development\renpy-6.9.0\sample/game/script.rpy.

-- Full Traceback ------------------------------------------------------------

  File "C:\Users\ninjagrass\Documents\Other\renpy-6.9.0\renpy\bootstrap.py", line 256, in bootstrap
  File "C:\Users\ninjagrass\Documents\Other\renpy-6.9.0\renpy\main.py", line 309, in main
  File "C:\Users\ninjagrass\Documents\Other\renpy-6.9.0\renpy\main.py", line 92, in run
  File "C:\Users\ninjagrass\Documents\Other\renpy-6.9.0\renpy\execution.py", line 217, in run
  File "C:\Users\ninjagrass\Documents\Other\renpy-6.9.0\renpy\ast.py", line 560, in execute
  File "C:\Users\ninjagrass\Documents\Other\renpy-6.9.0\renpy\python.py", line 911, in py_exec_bytecode
  File "C:\Users\ninjagrass\Documents\Other\Renpy Development\renpy-6.9.0\sample/game/script.rpy", line 48, in <module>
  File "C:\Users\ninjagrass\Documents\Other\Renpy Development\renpy-6.9.0\sample/game/script.rpy", line 41, in stats_frame
TypeError: int argument required

While running game code:
 - script call at line 55 of C:\Users\ninjagrass\Documents\Other\Renpy Development\renpy-6.9.0\sample/game/script.rpy
 - script at line 48 of C:\Users\ninjagrass\Documents\Other\Renpy Development\renpy-6.9.0\sample/game/script.rpy
 - python at line 48 of C:\Users\ninjagrass\Documents\Other\Renpy Development\renpy-6.9.0\sample/game/script.rpy.
 - python at line 41 of C:\Users\ninjagrass\Documents\Other\Renpy Development\renpy-6.9.0\sample/game/script.rpy.


Ren'Py Version: Ren'Py 6.9.0h

Code: Select all

# You can place the script of your game in this file.

init:
    # Declare images below this line, using the image statement.
    # eg. image eileen happy = "eileen_happy.png"
    
    $ povname = ("Lelouch")
    $ e = ("sample")
    
    # Declare characters used by this game.
    $ myhp = 9
    $ mymaxhp = 10
    $ mylevel = 1

    $ wolfhp = 19
    $ wolfmaxhp = 20
    $ wolflevel = 1


init python:

    def stats_frame(name, level, hp, maxhp, **properties):

        ui.frame(xfill=False, yminimum=None, **properties)

        ui.hbox() # (name, "HP", bar) from (level, hp, maxhp)
        ui.vbox() # name from ("HP", bar)

        ui.text(name, size=20)

        ui.hbox() # "HP" from bar
        ui.text("HP", size=20)
        ui.bar(maxhp, hp,
               xmaximum=150)

        ui.close()
        ui.close()

        ui.vbox() # Level from (hp/maxhp)

        ui.text("Lv. %d" % level, xalign=0.5, size=20)
        ui.text("%d/%d" % (hp, maxhp), xalign=0.5, size=20)

        ui.close()
        ui.close()
    
label fight(ename="Wolf", elevel="%(wolflevel)s", ehp="%(wolfhp)s", emaxhp="%(wolfmxhp)s", pname="%(povname)s", plevel="%(mylevel)s", php="%(myhp)s", pmaxhp="%(mymaxhp)s"):
    $ stats_frame(pname, plevel, php, pmaxhp, xalign=.02, yalign=.05)
    $ stats_frame(ename, elevel, ehp, emaxhp, xalign=.98, yalign=.05)
    
    return
    
label start:

    call fight(ename="Wolf", elevel=wolflevel, ehp=wolfhp, emaxhp="%(wolfmxhp)s") from _call_fight_1

    e "The ui functions can be also be used to show the sorts of stats you'd need if your game involves combat."

    
    
    e "Hopefully, the ui functions will let you write whatever visual novel or dating sim you want."
Sorry for reviving a dead topic. I was just trying to get the hang of ui functions. I seem to have followed the script almost identical to shadow ninja. I can't seem to get it to run. Any help?

Dusty
Regular
Posts: 126
Joined: Fri Jul 25, 2008 11:51 pm
Contact:

Re: Using the RPG frame [Solved]

#19 Post by Dusty »

*de-lurk!*

I'm pretty sure the problem is that you use quotation marks for numbers. Things like wolfmxhp are numbers and shouldn't be placed in quotation marks, so it should look something like this:
ninjagrass wrote:

Code: Select all

...
label fight(ename="Wolf", elevel=wolflevel, ehp=wolfhp, emaxhp=wolfmxhp, pname="%(povname)s", plevel=mylevel, php=myhp, pmaxhp=mymaxhp):
    $ stats_frame(pname, plevel, php, pmaxhp, xalign=.02, yalign=.05)
    $ stats_frame(ename, elevel, ehp, emaxhp, xalign=.98, yalin=.05)
    
    return
    
label start:

    call fight(ename="Wolf", elevel=wolflevel, ehp=wolfhp, emaxhp=wolfmxhp) from _call_fight_1
*re-lurk!*

ninjagrass
Regular
Posts: 104
Joined: Wed Mar 04, 2009 9:16 am
Projects: To Love Ru Trial Trouble, Bleach Battle Ignition, A new secret project...
Contact:

Re: Using the RPG frame [Solved]

#20 Post by ninjagrass »

Dusty wrote:*de-lurk!*

I'm pretty sure the problem is that you use quotation marks for numbers. Things like wolfmxhp are numbers and shouldn't be placed in quotation marks, so it should look something like this:
ninjagrass wrote:

Code: Select all

...
label fight(ename="Wolf", elevel=wolflevel, ehp=wolfhp, emaxhp=wolfmxhp, pname="%(povname)s", plevel=mylevel, php=myhp, pmaxhp=mymaxhp):
    $ stats_frame(pname, plevel, php, pmaxhp, xalign=.02, yalign=.05)
    $ stats_frame(ename, elevel, ehp, emaxhp, xalign=.98, yalin=.05)
    
    return
    
label start:

    call fight(ename="Wolf", elevel=wolflevel, ehp=wolfhp, emaxhp=wolfmxhp) from _call_fight_1
*re-lurk!*

Thank you! Now I will take over the world! j/k

JinzouTamashii
Eileen-Class Veteran
Posts: 1686
Joined: Mon Sep 21, 2009 8:03 pm
Projects: E-mail me if you wanna rock the planet
Location: USA
Contact:

Re: Using the RPG frame [Solved]

#21 Post by JinzouTamashii »

When all you have is a hammer...

Wouldn't scirra Construct or another engine like RPGmaker be better for this kind of game than Ren'Py?
Don't worry, we can get through it together. I didn't forget about you! I just got overwhelmed.
https://cherylitou.wordpress.com

Shadow Ninja
Regular
Posts: 38
Joined: Wed Jan 07, 2009 7:31 pm
Projects: Untilted
Location: Canada
Contact:

Re: Using the RPG frame [Solved]

#22 Post by Shadow Ninja »

JinzouTamashii wrote:When all you have is a hammer...

Wouldn't scirra Construct or another engine like RPGmaker be better for this kind of game than Ren'Py?
Yes, it might be, but the idea is to create a framework that works in Ren'Py to make it a nearly universal engine. As soon as I've finished with coding and removing all unnecessary lines of script, I'm hoping to submit this as a workable frame for the Ren'Py cookbook.

That being said, I'm going to have one heck of a time changing this to make it look better... I think I'll make several versions of the RPG Frame, then people can use them the way they want (for example, if you wanted a simple turn based frame like in the Pokemon games or an ATB system like in Final Fantasy)

Would anyone use the frames if I made & explained them thoroughly?
Framework coding... please wait.

User avatar
Vatina
Miko-Class Veteran
Posts: 862
Joined: Mon May 08, 2006 2:49 am
Completed: Blue Rose, AO: Broken Memories, My Eternal Rival, Dust
Projects: AO: Fallen Star
Organization: White Cat
IRC Nick: Vatina
Tumblr: vatinyan
Deviantart: Vatina
itch: whitecat
Contact:

Re: Using the RPG frame

#23 Post by Vatina »

Yes, if I definitely would if I could figure out how to use them. This has me interested.

Shadow Ninja
Regular
Posts: 38
Joined: Wed Jan 07, 2009 7:31 pm
Projects: Untilted
Location: Canada
Contact:

Re: Using the RPG frame

#24 Post by Shadow Ninja »

NOTE: I am using Pokemon as an example because the system I am coding is based directly off the newer Pokemon games. However, you can modify it to be pretty much anything, though. Just change the names, stats, etc.

Ok, the Pokemon framework is in progress, with the hardest part being finding a way to store the stats for the Pokemon. I suppose I could remove a few unneeded elements, such as a Pokemon's "nature" and "happiness", however, it could pose problems later if someone wanted to use it for an actual Pokemon game... Nah, I think I'll just bite the bullet and add the extra code.

Hmmm... so far the HUD in the battle system is the easier part of the code. I'm thinking the best solution is going to be to program in a few Pokemon (3 starters to choose from and an enemy to battle, as if you were starting a new game), and then just document how to custom-tailor the code to add more enemies or party members later. I have a system for having a max of 6 Pokemon in your party, but you won't have more than one in the demo. I'll also document the idea for how to switch party members (like at a Poke-center PC in the games), but I won't code it unless someone really wants me to...

I'm also figuring out how to use the Ren'Py Tile engine so the player can walk around in the game... but that's a different project, one I will save for after these RPG frames.

As for the Final Fantasy Frame, the hardest part will be the ATB system, as well as calculating damage done by an attack. The weapons won't be that difficult, as they only add to a character's strength usually.

:idea: Oh, and I think I just figured out how to get the animated effect for the ATB bars or for a Pokemon's HP going down (previous system simply had it disappear). I'll explain that as well.

Thx everyone who cared enough to read to the end of my post. I'll update it ASAP.
Framework coding... please wait.

Shadow Ninja
Regular
Posts: 38
Joined: Wed Jan 07, 2009 7:31 pm
Projects: Untilted
Location: Canada
Contact:

Re: Using the RPG frame

#25 Post by Shadow Ninja »

Ok, so I'm running into a few problems with the script. For example, I need a set of variables to randomize the IV stats for Pokemon. However, after writing the code and running lint, it comes back with an error:


Traceback:

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py script.

AttributeError: 'NoneType' object has no attribute 'random'

While executing init code:

 - script at line 5 of I:\renpy run remote\renpy-6.9.3\tile test/game/script.rpy
 - python at line 5 of I:\renpy run remote\renpy-6.9.3\tile test/game/script.rpy.

-- Full Traceback ------------------------------------------------------------

  File "I:\renpy tile system\renpy run remote\renpy-6.9.3\renpy\bootstrap.py", line 260, in bootstrap
  File "I:\renpy tile system\renpy run remote\renpy-6.9.3\renpy\main.py", line 253, in main
  File "I:\renpy tile system\renpy run remote\renpy-6.9.3\renpy\execution.py", line 230, in run
  File "I:\renpy tile system\renpy run remote\renpy-6.9.3\renpy\ast.py", line 558, in execute
  File "I:\renpy tile system\renpy run remote\renpy-6.9.3\renpy\python.py", line 921, in py_exec_bytecode
  File "I:\renpy run remote\renpy-6.9.3\tile test/game/script.rpy", line 5, in <module>
  File "random.pyo", line 215, in randint
  File "random.pyo", line 189, in randrange
  File "I:\renpy tile system\renpy run remote\renpy-6.9.3\renpy\python.py", line 438, in random

AttributeError: 'NoneType' object has no attribute 'random'

While executing init code:
 - script at line 5 of I:\renpy run remote\renpy-6.9.3\tile test/game/script.rpy
 - python at line 5 of I:\renpy run remote\renpy-6.9.3\tile test/game/script.rpy.

Ren'Py Version: Ren'Py 6.9.3c
Relevant Script:

Code: Select all

# You can place the script of your game in this file.

init:

    $ hp_iv_gen = renpy.random.randint(0, 31)
    $ atk_iv_gen = renpy.random.randint(0, 31)
    $ def_iv_gen =  renpy.random.randint(0, 31)
    $ sp_atk_iv_gen = renpy.random.randint(0, 31)
    $ sp_def_iv_gen = renpy.random.randint(0, 31)
    $ spd_iv_gen = renpy.random.randint(0, 31)
Any ideas?
Framework coding... please wait.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Using the RPG frame [NEW PROBLEM]

#26 Post by PyTom »

You can't get randomness during an init block. You should move the calls to right after label start.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Shadow Ninja
Regular
Posts: 38
Joined: Wed Jan 07, 2009 7:31 pm
Projects: Untilted
Location: Canada
Contact:

Re: Using the RPG frame [NEW PROBLEM]

#27 Post by Shadow Ninja »

does that mean im going to have to move all the variables that rely on those random numbers to right after the start label as well?
Framework coding... please wait.

JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Using the RPG frame [NEW PROBLEM]

#28 Post by JQuartz »

Shadow Ninja wrote:does that mean im going to have to move all the variables that rely on those random numbers to right after the start label as well?
You mean like this?:

Code: Select all

init:

    $ hp_iv_gen = 0
    $ atk_iv_gen = 0
    $ def_iv_gen =  0
    $ sp_atk_iv_gen = 0
    $ sp_def_iv_gen = 0
    $ spd_iv_gen = 0
    

label start:

    $ hp_iv_gen = renpy.random.randint(0, 31)
    $ atk_iv_gen = renpy.random.randint(0, 31)
    $ def_iv_gen =  renpy.random.randint(0, 31)
    $ sp_atk_iv_gen = renpy.random.randint(0, 31)
    $ sp_def_iv_gen = renpy.random.randint(0, 31)
    $ spd_iv_gen = renpy.random.randint(0, 31)
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

Shadow Ninja
Regular
Posts: 38
Joined: Wed Jan 07, 2009 7:31 pm
Projects: Untilted
Location: Canada
Contact:

Re: Using the RPG frame [NEW PROBLEM]

#29 Post by Shadow Ninja »

ok. I am trying to figure out how to assign characteristics to different moves (power points, move type, whether its a physical move or special move, etc. ) any ideas on how that could work? all i have now is:

Code: Select all

if player_selected_move == "Tackle":
    $ move_type = "Normal
    $ move_power = 35
    $ move_effect = "No_Effect"
    $ move_power_points = 35
    $ move_max_power_points = 35
    $ move_accuracy = 1
    $ move_attacks_first = False
    $ move_attacks_last = False
the problem with this system is that i have to have one set of all the different moves for the player, and one for the opponent... is there an easier way of doing this?
Framework coding... please wait.

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: Using the RPG frame [NEW PROBLEM]

#30 Post by chronoluminaire »

One approach would be to create your own Character objects, which have those properties. Then your code could look like:

Code: Select all

python:
  if opponent_attack_type == 'physical':
    Player.HP -= Opponent.Physical_damage
  elif opponent_attack_type == 'magic':
    Player.HP -= Opponent.Magic_damage
  if Player.HP <= 0:
    renpy.jump('game_over')
If you don't want to go that far, another approach would be to have an array for each property such as HP, Accuracy etc. Then your code could look like:

Code: Select all

python:
  if attack_type[opponent] == 'physical':
    HP[Player] -= Physical_damage[Opponent]
  elif attack_type[opponent] == 'magic':
    HP[Player] -= Magic_damage[Opponent]
  if HP[Player] <= 0:
    renpy.jump('game_over')
That way doesn't need you to create your own objects, but it's a bit more fiddly to code.

Either way, though, you are basically going to have to be able to do some programming to write an RPG in Ren'Py. There's no way around that. If you can't program, RPG Maker or one of those products might be a better choice.
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

Post Reply

Who is online

Users browsing this forum: Google [Bot], Kia