Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## This is the entire script, but it also needs this file: https://github.com/renpy/ai/blob/master/game/ai.rpy
- ## It is expecting that you have certain files in your images folder - the current format requires:
- ## natalie_ body_casual.png
- ## natalie_ brow_angry.png
- ## natalie_ brow_neutral.png
- ## natalie_ brow_sad.png
- ## natalie_ eyes_closed.png
- ## natalie_ eyes_closing.png
- ## natalie_ eyes_open.png
- ## natalie_ eyes_resting.png
- ## natalie_ hair_normal_hair.png
- ## natalie_ head.png
- ## natalie_ mouth_closed.png
- ## natalie_ mouth_open.png
- ## natalie_ nose.png
- ## The script of the game goes in this file.
- define n = Character('Natalie')
- transform blinking_anim(norm_d, closing_d, blink_d):
- norm_d
- choice:#random pause
- 0.1
- choice:
- 1
- choice:
- 2
- choice:
- 3
- choice:
- 4
- closing_d
- pause .1
- blink_d
- pause .2
- closing_d
- pause .15
- repeat
- transform anim_talk_once(speak_d, norm_d, anim_time):
- speak_d
- pause anim_time*3/4
- norm_d
- pause anim_time
- transform talking_anim(speak_d, norm_d):
- choice:
- anim_talk_once(speak_d, norm_d, .3)
- choice:
- anim_talk_once(speak_d, norm_d, .4)
- repeat
- #Callbacks for lip flap and dialogue color
- init python:
- # This returns speaking art if the identified character is speaking, and done art if the
- # character is not.
- def while_speaking(ident, speak_d, done_d, st, at):
- if _last_say_who == ident:
- return talking_anim(speak_d, done_d), .5
- else:
- return done_d, None
- # Curried form of the above.
- curried_while_speaking = renpy.curry(while_speaking)
- # Displays speaking when the identified character is speaking, and done otherwise.
- def WhileSpeaking(name, speak_d, done_d=None):
- if not done_d: done_d = speak_d
- return DynamicDisplayable(curried_while_speaking(name, speak_d, done_d))
- #composite image stuff, not relevant to the ATL
- init python:
- attr_types = [
- ("body", ("casual",)),
- ("head", ()),
- ("brow", ("neutral", "sad", "angry")), #default selection first
- ("eyes", ("open", "closed", "closing", "resting")),
- ("nose", ()),
- ("hair", ("normal_hair",)),
- ("mouth", ("closed", "open")),
- ]
- def setup_attribute_image(img_name):
- attr_list = []
- for type_name, option_list in attr_types:
- if len(option_list)==0: #always-on pieces (they will never have options)
- attr_list.append(Attribute(type_name, type_name, type_name, default=True))
- else:
- for i, option in enumerate(option_list):
- if type_name == "eyes":
- attr_list.append(
- Attribute(
- type_name, #no more than one of this same type may be visible at once
- type_name+"_"+option, #the keyword to get this option with
- #closed eyes don't blink
- (type_name+"_"+option if option in ("closed", "resting")
- else blinking_anim(
- img_name+"_ "+type_name+"_"+option,
- img_name+"_ "+type_name+"_closing",
- img_name+"_ "+type_name+"_resting")), #the displayable
- default=(i==0)) #the first one appears automatically
- )
- elif type_name == "mouth":
- attr_list.append(
- Attribute(
- type_name, #no more than one of this same type may be visible at once
- type_name+"_"+option, #the keyword to get this option with
- WhileSpeaking("n",
- img_name+"_ "+type_name+"_open", #todo: closed/open from keyword
- img_name+"_ "+type_name+"_"+option), #the displayable
- default=(i==0)) #the first one appears automatically
- )
- else:
- attr_list.append(
- Attribute(
- type_name, #no more than one of this same type may be visible at once
- option, #the keyword to get this option with
- type_name+"_"+option, #the filename keywords
- default=(i==0)) #the first one appears automatically
- )
- renpy.image(img_name, AttributeImage(attr_list,
- image_format=img_name+"_ {image}",
- at=Transform(yalign=0.0),
- )
- )
- setup_attribute_image("natalie")
- label start:
- scene bg room
- show natalie
- "This is the default image."
- n "I'm talking now."
- show natalie sad
- n "Sadness."
- show natalie eyes_closed
- n "Closed eyes."
- show natalie angry
- n "Anger."
- show natalie neutral
- n "...And neutral again."
- "just blink"
- ## This ends the game.
- return
Advertisement
Add Comment
Please, Sign In to add comment