I'm working on the character affinity system.
I've seen some games implement affinity levels on the character list screen. And when one of them has the maximum affinity and the player passes a special event or mission, they level up (Changing that number on their screen).
Example:
1_ You started the game and see that the affinity level number of all the characters on your list is "0".
2_ After spending too much time with "cat". You managed to reach the maximum affinity with her.
3_ A mission or special event is turned on to raise her level.
4_ You overcame that event. Now you see that in your character list the number of "cat" has changed to "1".
I would like to be able to add this to my project, but I'm having trouble creating a command to add and replace my custom level number images (lv0.png, lv1.png....) when a character in my menu increases her affinity level.
Code: Select all
########################### CHARACTER LIST SCREEN ##############################
screen button:
vbox xalign 0.95 yalign 0.05:
textbutton "List" action ui.callsinnewcontext("char_list")
define ID = 0
default characters = [
{ID: "cat", "name": "Kitty", "desc": "Kitty is an independent and quiet cat.", "points": 5, "quest": "Feed the cat.", "show": False},
{ID: "dog", "name": "Doggy", "desc": "Doggy is a brave and curious boy.", "points": 10, "quest": "Help him find his brother to take revenge.", "show": True},
{ID: "owl", "name": "Owl", "desc": "Owl is a retired professor, an avid knitter.", "points": 15, "quest": "a lot of teeeeeeext{p}teeeext", "show": True},
{ID: "man", "name": "The Man", "desc": 'As The Man likes to say, "Oh boy!"', "points": 1, "quest": "teeeeext{p}text", "show": True},
]
init python:
def char(char_id):
for n in range(0, len(characters)):
if characters[n][ID] == char_id:
return characters[n]
def insert_before(char_id, new_char):
for n in range(0, len(characters)):
if characters[n][ID] == char_id:
break
store.characters.insert(n, new_char)
screen char_list(char_n=0):
$ char = ch_filtered[char_n]
frame:
background "screens/screenlist_bg.png"
xfill True
yfill True
add f"screens/{char[ID]}.png" pos (806,200) #Name
add f"screens/photos/{char[ID]}.png" pos (50,40) #char photo with frame
if char_n > 0:
imagebutton auto "screens/prev_%s.png" pos (796,464) action Return(char_n - 1)
if char_n < len(ch_filtered) - 1:
imagebutton auto "screens/next_%s.png" pos (1696,464) action Return(char_n + 1)
button:
imagebutton auto "screens/back_%s.png" pos (1223,757) action Return(True)
frame:
background None
pos (959, 80)
xysize (720, 680)
text f'{char["desc"]}' text_align 0.5:
align (0.5, 0.5)
frame:
background None
pos (960, 675)
xysize (720, 380)
text f'{char["quest"]}' text_align 0.5:
align (0.5, 0,5)
bar:
value StaticValue(ch_filtered[char_n]["points"], 20)
#thumb
xysize (665,120)
xalign 0.785
yalign 0.55
left_bar Frame("bar/baempty.png")
right_bar Frame("bar/bafull.png")
add "bar/bframe.png" xysize (720, 180) pos (957, 495)
label char_list:
play music "audio/Dream.mp3"
$ _return = 0
$ ch_filtered = [x for x in characters if x["show"]]
label char_list_call:
call screen char_list(_return)
if type(_return) is bool:
# "Back" button was pressed
return
# "Previous" or "Next" button was pressed:
jump char_list_call
########################### END - CHARACTER LIST SCREEN ##############################
define r = Character("Rhapsy")
define k = Character("Kitty")
define p = Character("Porky")
label start:
scene bgg
show screen button # List button in the game
"Look at your character list. Porky's not there."
"..."
r "Hello?"
if not renpy.seen_image("img2"):
show img2
hide img2
$ renpy.notify(" New\nGallery\nImage")
p "Hello! My name is Porky."
$ insert_before("man", {ID: "pig", "name": "Porky", "desc": "Its a pet, not ham.","quest": "teeeeext{p}text", "points": 4, "show": True})
$ renpy.notify("Porky unlocked!")
"Look at the list. Porky is already there."
"But where is Kitty?"
k "Meooow"
if not renpy.seen_image("img1"):
show img1
hide img1
$ renpy.notify(" New\nGallery\nImage")
$ char("cat")["show"] = True
$ renpy.notify("Kitty unlocked!")
"Kitty came home! Look at your list. You must feed Kitty."
"..."
r "My cat kitty is hungry."
p "ohh...{p}Bye bye!"
"The little pig left."
"You give your cat snacks."
$ char ("cat")["points"] += 5
$ renpy.notify("+5 Kitty's afinnity.")
$ char("cat")["quest"] = "Play with Kitty."
"Kitty's quest is done. Look at the list.{p}New quest available."
k "Meooow."
"Kitty is bored."
"PAY ATTENTION TO KITTY'S AFFINITY BAR IN EVERY DECISION.{p}THERE WILL BE 2 DIFFERENT ENDINGS IF THE AFFINITY REACHES THE MAXIMUM OR ZERO."
label Kitty:
menu:
r "What should I do?"
"Play with Kitty":
$ char ("cat")["points"] += 5
$ renpy.notify("+5 Kitty's afinnity.")
"Kitty is happy"
if char ("cat")["points"] >= 20:
jump continue1
else:
jump Kitty
"Ignore":
$ char ("cat")["points"] -= 5
$ renpy.notify("-5 Kitty's afinnity.")
"Kitty is angry"
if char ("cat")["points"] <= 0:
jump Badend
else:
jump Kitty
label Badend:
k "MEOOOW!!!"
"Kitty scratched you."
r "Why? :("
"BAD END{p}Next time spend more time with your pet."
return
label continue1:
$ char ("cat")["points"] = 0 #reset cat's bar/points
#You raised the affinity level with "cat" to 1
$ char("cat")["quest"] = "No events available in this version.{p}Wait for updates."
"Kitty's quest is done. Look at the list."
"..."
"Thank you and See you later!"
return