Letting players choose their own character....

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
User avatar
SadisticWonderland
Regular
Posts: 38
Joined: Tue Dec 18, 2012 1:22 am
Projects: 7 Days~ A Week of Twisted Sanity!
Location: Sadistic Wonderland~
Contact:

Letting players choose their own character....

#1 Post by SadisticWonderland » Wed Dec 19, 2012 10:34 pm

Yeah, this one is actually a second plan for the project I'm working on right now. If it's not possible; I'm going to stick with my first plan. My project is about school's library organization; with dictator president and his err...slaves...It's based on my own unpublished (yet) novel.

My protagonist in the novel I wrote is shy and soft. But I'm thinking to make two protagonist in this project (more reason for me to sit here in front of computer without moving :lol: ). One is a tomboyish active girl while another is the shy one I used in the book. So my question is;

1. Is it possible to make players choose between these two; because I'm thinking to make each of them has their own advantages--especially in handling the dictator president.
My friend says it's annoying to see my protagonist being bullied by the dictator every time she read my book. She wants to see a more out-loud character that can actually stands up against him. *shrugs*

2. If it's possible; how can I do it? I mean where can I get the code. I didn't see this in the cookbook.

Please and thank you. :mrgreen:
Sanity is always deformed...


User avatar
Tokzu
Newbie
Posts: 18
Joined: Thu Oct 25, 2012 3:42 am
Projects: Nigureth (story: until chapter 11, system: 100%, script: until chapter 1, character design: 0% U_U)
Location: Mexico
Contact:

Re: Letting players choose their own character....

#2 Post by Tokzu » Thu Dec 20, 2012 12:02 am

Well, you can do this with the help of persistent data. first you can show a selection screen with the help of a imagemap (like this):

Image

Depending on the selected character the user jumps to a label specific and then make use of variables to see which character was chosen:

In the main menu, instead of starting the game, you can show the selection screen

Code: Select all

screen charselection:
    imagemap:
        auto "imagemap_%s.jpg"

        hotspot (111,121,208,46) action Start("charactera")
        hotspot (99,201,232,46) action Start("characterb")
And then in your script.rpy:

Code: Select all

label charactera:
    $ischara=True
    jump continue

label characterb:
    $ischara=False
    jump continue

label continue:
    #The story of your chosen character continues here
This is broadly explained, it depends on you the details on whether it will be the same story for both (of course, but adapted to the character) or if it will be different.

Sorry if I did not explain well, I'm not very good at writing in English but if you speak Spanish you could explain it better.

User avatar
SadisticWonderland
Regular
Posts: 38
Joined: Tue Dec 18, 2012 1:22 am
Projects: 7 Days~ A Week of Twisted Sanity!
Location: Sadistic Wonderland~
Contact:

Re: Letting players choose their own character....

#3 Post by SadisticWonderland » Thu Dec 20, 2012 5:53 am

Tokzu wrote:
In the main menu, instead of starting the game, you can show the selection screen

Code: Select all

screen charselection:
    imagemap:
        auto "imagemap_%s.jpg"

        hotspot (111,121,208,46) action Start("charactera")
        hotspot (99,201,232,46) action Start("characterb")
Where actually do I put this code? In the screens.rpy?
Tokzu wrote: And then in your script.rpy:

Code: Select all

label charactera:
    $ischara=True
    jump continue

label characterb:
    $ischara=False
    jump continue

label continue:
    #The story of your chosen character continues here
Do I have to put this under the 'label start' or above it? Do I have to define the character like usual?

I tried it. I put the first you gave to me into screens.rpy and the second one in scripts.rpy. Nothing happens. And where can I get the imagemap_%s.jpg?

hotspot (111,121,208,46) action Start("charactera") <--- What does this do actually? Especially the numbers.

Sorry for the questions. I'm confused. :?
Sanity is always deformed...


User avatar
Milkymalk
Miko-Class Veteran
Posts: 752
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Letting players choose their own character....

#4 Post by Milkymalk » Thu Dec 20, 2012 9:04 am

The numbers represent x1, y1, x2, y2 of a rectangle that is the clickable area of the imagemap; top-left and lower-right corner.

You can put screen code anywhere. Screens.rpy is just where all the predefined screens were placed, it actually doesn't matter whether you put your own screens there, in script.rpy or in a newly created rpy file (all rpy in the game directory are automatically loaded). The same goes for labels: Put them in any file in any order. BUT: If you dont "jump" or "return" from a label, the script just continues to execute and will follow any statements that are below. Think of labels as the numbers in a "Choose your own Adventure" book: When you are not told to go somewhere else, you just read on :)
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
MioSegami
Regular
Posts: 189
Joined: Thu Nov 15, 2012 11:40 pm
Projects: PATUKA PRIVATE PARADISE
Organization: BlueAngelService
Contact:

Re: Letting players choose their own character....

#5 Post by MioSegami » Thu Dec 20, 2012 9:05 am

Code: Select all

screen charselection:
    imagemap:
        auto "imagemap_%s.jpg"

        hotspot (111,121,208,46) action Start("charactera")
        hotspot (99,201,232,46) action Start("characterb")

Code: Select all

label charactera:
    $ischara=True
    jump continue
hotspot (111,121,208,46) action Start("charactera") <--- What does this do actually? Especially the numbers.

Sorry for the questions. I'm confused. :?[/quote]

Well the first part goes under screens.rpy, scroll down into you see the text that says main menu

Code: Select all

##############################################################################
# Main Menu 
#
# Screen that's used to display the main menu, when Ren'Py first starts
# http://www.renpy.org/doc/html/screen_special.html#main-menu

screen main_menu:
something like that. The numbers are hotspots on the screen, where the position of the clickable area. The "charcactera" is just the name you can change however you want. While on the other half "imagemap_%s.jpg" Is the image that you put in the screen for ex. your characters that you are making it selectable. The "imagemap_%s.jpg" is just used as an example. Hope this helped :)
Image
CLICK IT------------->viewtopic.php?f=43&t=40639&p=430149#p430149
Projects: PATUKA PRIVATE ISLAND
Story: 15% complete
Script: 0%
Art: 35%
Outline: 15%
Code: 10%

User avatar
SadisticWonderland
Regular
Posts: 38
Joined: Tue Dec 18, 2012 1:22 am
Projects: 7 Days~ A Week of Twisted Sanity!
Location: Sadistic Wonderland~
Contact:

Re: Letting players choose their own character....

#6 Post by SadisticWonderland » Thu Dec 20, 2012 9:24 am

MioSegami wrote:While on the other half "imagemap_%s.jpg" Is the image that you put in the screen for ex. your characters that you are making it selectable. The "imagemap_%s.jpg" is just used as an example.
So that means while I'm drawing my characters; I can use some random pics for it? Gee, thank you very much! This clears things up a bit. :D
Sanity is always deformed...


User avatar
MioSegami
Regular
Posts: 189
Joined: Thu Nov 15, 2012 11:40 pm
Projects: PATUKA PRIVATE PARADISE
Organization: BlueAngelService
Contact:

Re: Letting players choose their own character....

#7 Post by MioSegami » Thu Dec 20, 2012 9:37 am

SadisticWonderland wrote:
MioSegami wrote:While on the other half "imagemap_%s.jpg" Is the image that you put in the screen for ex. your characters that you are making it selectable. The "imagemap_%s.jpg" is just used as an example.
So that means while I'm drawing my characters; I can use some random pics for it? Gee, thank you very much! This clears things up a bit. :D
Well basically yes, you're drawing your characters. You could use a random pic for it :) It all depends on you and you're welcome :)
Image
CLICK IT------------->viewtopic.php?f=43&t=40639&p=430149#p430149
Projects: PATUKA PRIVATE ISLAND
Story: 15% complete
Script: 0%
Art: 35%
Outline: 15%
Code: 10%

User avatar
SadisticWonderland
Regular
Posts: 38
Joined: Tue Dec 18, 2012 1:22 am
Projects: 7 Days~ A Week of Twisted Sanity!
Location: Sadistic Wonderland~
Contact:

Re: Letting players choose their own character....

#8 Post by SadisticWonderland » Thu Dec 20, 2012 11:55 am

MioSegami wrote: Well basically yes, you're drawing your characters. You could use a random pic for it :) It all depends on you and you're welcome :)
I guess I have to draw everything first before doing this,right? Oh, god...That's a lot of work to do. >.<

Umm, I'm planning to make each characters to have different stats value. So far, I'm doing the 'try and error' method right now; trying anything I manage to found but keep failing. Any idea how to make each character to have their own stats? So that player can experience different personalities and abilities depending on their choice of characters? ^^;

Please and thank you. :mrgreen:
Sanity is always deformed...


User avatar
Milkymalk
Miko-Class Veteran
Posts: 752
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Letting players choose their own character....

#9 Post by Milkymalk » Thu Dec 20, 2012 12:23 pm

You can make a list of stats like this:

Code: Select all

init python:
    stats = [[1,4,3,6],[3,7,2,4],[2,5,1,3]]
This would make three sets of four stats each.
stats[0][3] would return the value 6 (always start counting with 0, so there are characters 0-2 and stats 0-3), for example. If you store the character the player chose in pchar, you could do:

Code: Select all

if stats[pchar][1] > 4:
    (do stuff)
to check if a given stat of the chosen character has a certain value and branch accordingly.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
SadisticWonderland
Regular
Posts: 38
Joined: Tue Dec 18, 2012 1:22 am
Projects: 7 Days~ A Week of Twisted Sanity!
Location: Sadistic Wonderland~
Contact:

Re: Letting players choose their own character....

#10 Post by SadisticWonderland » Thu Dec 20, 2012 1:09 pm

Milkymalk wrote:You can make a list of stats like this:

Code: Select all

init python:
    stats = [[1,4,3,6],[3,7,2,4],[2,5,1,3]]
This would make three sets of four stats each.
stats[0][3] would return the value 6 (always start counting with 0, so there are characters 0-2 and stats 0-3), for example. If you store the character the player chose in pchar, you could do:

Code: Select all

if stats[pchar][1] > 4:
    (do stuff)
to check if a given stat of the chosen character has a certain value and branch accordingly.
Okay....This one is quite tricky. I'll try some more try and errors...But do I still have to do this in my script?;

Code: Select all

init python:
    register_stat("Strength", "strength", 10, 180)
    register_stat("Intelligence", "intelligence", 15, 180)
    register_stat("Confidence", "confidence", 10,180)
:?
Sanity is always deformed...


User avatar
Tokzu
Newbie
Posts: 18
Joined: Thu Oct 25, 2012 3:42 am
Projects: Nigureth (story: until chapter 11, system: 100%, script: until chapter 1, character design: 0% U_U)
Location: Mexico
Contact:

Re: Letting players choose their own character....

#11 Post by Tokzu » Thu Dec 20, 2012 1:21 pm

Yes, like this:

Code: Select all

init python:
    register_stat("Strength", "strength", 10, 180)
    register_stat("Intelligence", "intelligence", 15, 180)
    register_stat("Confidence", "confidence", 10,180)

label start:
    # Something else

User avatar
SadisticWonderland
Regular
Posts: 38
Joined: Tue Dec 18, 2012 1:22 am
Projects: 7 Days~ A Week of Twisted Sanity!
Location: Sadistic Wonderland~
Contact:

Re: Letting players choose their own character....

#12 Post by SadisticWonderland » Thu Dec 20, 2012 9:57 pm

Milkymalk wrote:You can make a list of stats like this:

Code: Select all

init python:
    stats = [[1,4,3,6],[3,7,2,4],[2,5,1,3]]
This would make three sets of four stats each.
stats[0][3] would return the value 6 (always start counting with 0, so there are characters 0-2 and stats 0-3), for example. If you store the character the player chose in pchar, you could do:

Code: Select all

if stats[pchar][1] > 4:
    (do stuff)
to check if a given stat of the chosen character has a certain value and branch accordingly.
I tried it but there are errors. :( Can you explain more? And what actually those number do? Sorry...I'm a bit numerically challenged. :cry:
Sanity is always deformed...


Post Reply

Who is online

Users browsing this forum: proller, Triority