Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # Tags on actors (that are personas)
  2. # ==============================================================================
  3. # You can specify which actor is a persona by simply adding the following tag:
  4. # <Persona>
  5. # By adding the tag bellow:
  6. # <User: actor_id[, actor_id[, ...]]>
  7. # on a persona actor you can specify the users that can equip the specific
  8. # persona. Remember that for the <User: ...> tag to work the actor must be a
  9. # persona. Also, you can specify as many persona users as you want in the list.
  10. # For convenience, you can set the default users of a persona that doesn't have
  11. # that tag through the options module.
  12. # Personas can't learn an infinite number of skills. You can specify the
  13. # maximum number of skills a persona can learn by using the following tag:
  14. # <Max skills: number>
  15. # The default number of maximum skills for all personas is set to 4, but you can
  16. # change it through the options module! Lastly, a persona has the ability to evolve
  17. # into a stronger one when it reaches a specific arcana rank! You can specify the
  18. # rank of the arcana at which the persona will evolve with the following tag:
  19. # <Evolve at: rank>
  20. # and the persona to which it will evolve to with the following one:
  21. # <Evolve to: persona_name>
  22. # Additionally, you can set arcana rank and player level
  23. # requirements to personas, so that a user can only equip
  24. # that persona when they meet those requirements.
  25. # To apply a minimum arcana rank requirement for a specific
  26. # persona you use the following tag:
  27. # <Arcana rank: rank>
  28. # To apply a minimum player level requirement for a specific persona
  29. # you use the following tag:
  30. # <Player level: level>
  31. # ------------------------------------------------------------------------------
  32. # Tags on actors (that use personas)
  33. # ==============================================================================
  34. # You can specify that a specific actor can use ONLY one (which will be
  35. # automatically equipped) by using the following tag:
  36. # <Persona: actor_id>
  37. # Also, to specify which persona will be equipped in Battle test on a specific
  38. # ctor, you can use the following tag:
  39. # <Battletest persona: actor_id>
  40. # ------------------------------------------------------------------------------
  41. # Tags on classes (Arcana)
  42. # ==============================================================================
  43. # You can specify which classes represent an arcana by adding the tag
  44. # bellow:
  45. # <Arcana>
  46. # Each arcana's current rank is stored in a game variable. Those variables
  47. # can be set for each Arcana separately by adding the following tag:
  48. # <Rank variable: variable_id>
  49. # Of course, you can set the maximum rank of each arcana by adding the
  50. # tag bellow on each arcana:
  51. # <Max rank: rank>
  52. # The default maximum rank is set to 10, but can be changed through the
  53. # options module. As in the original game, each arcana has its own social link(s).
  54. # You can specify who is or are those links by adding the following tags
  55. # to specify by actor id:
  56. # <Social links actors: actor_id[,actor_id[,...]]>
  57. # and to specify by variable id (in which actor ids are stored):
  58. # <Social links actors: actor_id[,actor_id[,...]]>
  59. # As far as naming those social links and their description goes, you can
  60. # use the tag bellow to specify the name of the social link:
  61. # <Social target: name>
  62. # and the one bellow to specify its description:
  63. # <Description: description>
  64. # You can specify the description of an actor's social link by adding
  65. # this tag:
  66. # <Social description: description>
  67. # ------------------------------------------------------------------------------
  68. # Tags on enemies
  69. # ==============================================================================
  70. # There is only one tag that is used on enemies and it specifies the card
  71. # that an enemy can drop:
  72. # <Card drop: card_name, chance>
  73. # The chance is specified by a floating number and not a percentage, for
  74. # example using the tag bellow on an enemy, has a 30% chance to drop the
  75. # Ghoul card:
  76. # <Card drop: Ghoul, 0.3>
  77. # ------------------------------------------------------------------------------
  78. # Add persona to party
  79. # ==============================================================================
  80. # You can add a persona to your party by calling the following script:
  81. # $game_party.add_persona(actor_id)
  82. # It is important to remember that you cannot have duplicate personas in
  83. # your party! Also, for developing purposes a message box will be displayed
  84. # if you try adding an actor as a persona that is not actually a persona!
  85. # Personas can also be acquired through the Shuffle Time that happens after
  86. # a battle and if the enemy troop has dropped any cards. You can learn
  87. # more about Shuffle Time by going to the back of the room.
  88. # ------------------------------------------------------------------------------
  89. # Remove social link through variable
  90. # ==============================================================================
  91. # If you have specified someone as a social link of an arcana via
  92. # variables (see Tags on class (Arcanas)) you can remove a social
  93. # link by setting the specific variable's value to -1. Do remember
  94. # that if you have specified that social link through the actor social
  95. # link tag, then even if you remove that actor they will still be a
  96. # social link. Social links specified via actor ids cannot be removed!
  97. # ------------------------------------------------------------------------------
  98. # Increase/Decrease arcana rank
  99. # ==============================================================================
  100. # You can increase an arcana's rank by making the following script
  101. # call:
  102. # $game_player.arcana_rank_up(arcana_name).
  103. # You can also decrease an arcana's rank by making the following
  104. # script call:
  105. # $game_player.arcana_rank_down(arcana_name).
  106. # The minimum arcana rank can be set though the persona module!
  107. # For convenience you can use the script call bellow to increase the
  108. # arcana's rank by
  109. # multiple ranks:
  110. # $game_party.arcana_rank_up_by(arcana_name, ranks)
  111. # The same can be done to decrease the arcana's rank by multiple ranks
  112. # by making the following script call:
  113. # $game_party.arcana_rank_down_by(arcana_name, ranks)
  114. # ------------------------------------------------------------------------------
  115. # Persona in party or equipped
  116. # ==============================================================================
  117. # You can check if a persona is in the party by using the following
  118. # script call:
  119. # $game_party.persona_in_party(persona_name).
  120. #
  121. # You can check if a persona is currently equipped by simply calling
  122. # the following script:
  123. # $game_party.persona_equipped(persona_name)
  124. #
  125. # Also, you can check if a persona is equipped by a specific actor
  126. # with the following script call:
  127. # $game_party.persona_equipped_by(actor_id, persona_name)
  128. # ------------------------------------------------------------------------------
  129. # Shuffle Time
  130. # ==============================================================================
  131. # Shuffle Time happens after battle and gives the player a chance to
  132. # receive new Persona cards. Shuffle Time happens only if the enemies have
  133. # dropped at least two cards. Of course, you can change this number
  134. # through the options module. There are three types of cards in Shuffle
  135. # Time:
  136. # Persona cards,
  137. # Blank cards and
  138. # Penalty cards.
  139. # When a Blank card is picked, nothing happens whereas when a Penalty
  140. # card is picked, the player gains no battle rewards! There are also
  141. # two different shuffle methods:
  142. # Rotating card either horizontally, diagonally or a combination
  143. # of both and
  144. # Memory match, where player matches two cards and has at most
  145. # five attempts.
  146. # You can change the maximum number of tries the player has through
  147. # the options module! Also, you can force the next Shuffle Time method
  148. # to be a specific one (among the available) by setting the value of
  149. # the variable with ID 1 to the method you want. For example "Horizontal"
  150. # if you want the next Shuffle Time method to be Horizontal or "Matching"
  151. # if you want it to be the Matching one. Of course, you can change which
  152. # variable you want to specify the method, though the options module.
  153. # Lastly, you can call the shuffle scene with whichever cards you want
  154. # by firstly setting the variable with ID 2 to a script call with a
  155. # list of persona names like this:
  156. # ["name_1", "name_2", ...]
  157. # and then by calling the scene with the following command:
  158. # $game_system.shuffle_time
  159. # It is important to remember that you cannot have duplicate personas
  160. # in your party! Additionally, a message box will be displayed if you
  161. # try running Shuffle Time without setting the list of cards to be included!
  162. # You can access the result of the last shuffle time by simply calling
  163. # the following script command:
  164. # $game_system.shuffle_result.
  165. # ------------------------------------------------------------------------------
  166. # Fusion
  167. # ==============================================================================
  168. # Fusion is the system in which two or more personas are combined
  169. # together to create a new persona. You can use the following tag
  170. # bellow on a persona to specify which personas need to be fused to
  171. # create that one:
  172. # <Fusion parents: actor_id1, actor_id2>
  173. # For example, if you use the following tag on Himiko:
  174. # <Fusion parents: 13, 14>
  175. # then when you try fusing Andras with Forneus, the fusion will result
  176. # to... Himiko.
  177. # You can also fuse three personas together to create special
  178. # ones too! To specify the parents of a "special" persona you can
  179. # use the following tag:
  180. # <Special fusion: actor_id1, actor_id2, actor_id3>
  181. # Last but not least! To call the persona fusion scene you use the
  182. # following script call:
  183. # $game_system.fuse_personas(2).
  184. # For the special fusion scene you use the following script call:
  185. # $game_system.fuse_personas(3).
  186. # ------------------------------------------------------------------------------
  187. # Persona and user parameters
  188. # ==============================================================================
  189. # Personas can be equiped through the main menu command called
  190. # "Persona". Personas add percentages of their parameters and
  191. # stats to the actor they're equiped on. The default percentage
  192. # is set to 100%, but can be changed through the persona options
  193. # module. You can also change the percentage of the user's parameters
  194. # that are added to the end result. The default percentage is also
  195. # set to 100% and can be changed though the options module too.
  196. # ==============================================================================
  197. # Mady by vFoggy
  198. # ==============================================================================
  199. #
  200. #-------------------------------------------------------------------------------
  201. # ____ __ __ _ _
  202. # | _ \ ___ _ __ ___ ___ _ __ __ _ | \/ | ___ __| |_ _| | ___
  203. # | |_) / _ \ '__/ __|/ _ \| '_ \ / _` | | |\/| |/ _ \ / _` | | | | |/ _ \
  204. # | __/ __/ | \__ \ (_) | | | | (_| | | | | | (_) | (_| | |_| | | __/
  205. # |_| \___|_| |___/\___/|_| |_|\__,_| |_| |_|\___/ \__,_|\__,_|_|\___|
  206. #
  207. # ___ _ _
  208. # / _ \ _ __ | |_(_) ___ _ __ ___
  209. # | | | | '_ \| __| |/ _ \| '_ \/ __|
  210. # | |_| | |_) | |_| | (_) | | | \__ \
  211. # \___/| .__/ \__|_|\___/|_| |_|___/
  212. # |_|
  213. # Persona Module Options
  214. #-------------------------------------------------------------------------------
  215. module Persona
  216. PERSONA_EXP_GAIN_MULTIPLIER = 1.0
  217.  
  218. # phys, gun, fire, ice, lightning, wind, psi, nuclear, light, dark
  219. PERSONA_ELE_ICON_INDEXES = [528, 529, 530, 531, 532, 533, 534, 535, 536, 537]
  220. # icon index that indicates that indicates the persona's strong element
  221. # -1 will just show "Str"
  222. PERSONA_STRONG_ELE_ICON = -1
  223. # icon index that indicates that indicates the persona's weak element
  224. # -1 will just show "Wk"
  225. PERSONA_WEAK_ELE_ICON = -1
  226. # icon index that indicates that indicates the persona's normal element
  227. # -1 will just show "-"
  228. PERSONA_NORMAL_ELE_ICON = -1
  229.  
  230. # rates multipliers. if all are the same only one number can be used for all
  231. USER_ELEMENT_RATE_MULTIPLIER = 0.0
  232. USER_DEBUFF_RATE_MULTIPLIER = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  233. USER_STATE_RATE_MULTIPLIER = 0.0
  234. PERSONA_ELEMENT_RATE_MULTIPLIER = 1.0
  235. PERSONA_DEBUFF_RATE_MULTIPLIER = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
  236. PERSONA_STATE_RATE_MULTIPLIER = 1.0
  237.  
  238. # parameter multipliers. if all are the same only one number can be used for all
  239. USER_PARAM_MULTIPLIER = [1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  240. USER_XPARAM_MULTIPLIER = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
  241. USER_SPARAM_MULTIPLIER = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
  242. PERSONA_PARAM_MULTIPLIER = [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
  243. PERSONA_XPARAM_MULTIPLIER = [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  244. PERSONA_SPARAM_MULTIPLIER = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  245.  
  246. # Name of the persona option in the menu and battle command
  247. PERSONA_MENU_NAME = "Change P." # alternative name for persona.
  248.  
  249. # index of persona command in battle commands window
  250. PERSONA_BATTLE_COMMAND_INDEX = 2
  251. # index of persona command in main menu
  252. PERSONA_MENU_COMMAND_INDEX = 1
  253.  
  254. # name of the button images displayed in the persona list menu window
  255. SELECT_PERSONA_BUTTON_IMG_NAME = "select_persona_button"
  256. EQUIP_PERSONA_BUTTON_IMG_NAME = "equip_persona_button"
  257.  
  258. # better keep a space at the beginning of the text
  259. SELECT_PERSONA_TEXT = " Show status"
  260. EQUIP_PERSONA_TEXT = " Equip persona"
  261. # written on actor's personas list when no personas are available
  262. NO_PERSONAS_MSG = "No available personas."
  263.  
  264. # key used to equip persona
  265. EQUIP_PERSONA_KEY = :X
  266.  
  267. # ids of the default users for a persona that has no users specified
  268. # can be an empty list
  269. DEFAULT_PERSONA_USERS = [1]
  270.  
  271. # if true then skills of both user and persona will appear under user's skill
  272. # list
  273. UNIFIED_SKILLS = true
  274. # when UNIFIED_SKILLS is false, this color is used to differentiate persona's
  275. # skills from user's skills in the battle's skills list.
  276. # use Color.new(0, 0, 0) for normal color
  277. PERSONA_SKILLS_COLOR = Color.new(255, 255, 255) # green
  278. # index from which the persona's skill commands start (for multiple skill types)
  279. PERSONA_SKILLS_COMMAND_INDEX = 4
  280.  
  281. #-------------------------------------------------------------------------------
  282. # ____ _ _ _ _ _____ _
  283. # / ___|| | _(_) | | | ___|__ _ __ __ _ ___| |_
  284. # \___ \| |/ / | | | | |_ / _ \| '__/ _` |/ _ \ __|
  285. # ___) | <| | | | | _| (_) | | | (_| | __/ |_
  286. # |____/|_|\_\_|_|_| |_| \___/|_| \__, |\___|\__|
  287. # |___/
  288. # __ __ _ _ ___ _ _
  289. # | \/ | ___ __| |_ _| | ___ / _ \ _ __ | |_(_) ___ _ __ ___
  290. # | |\/| |/ _ \ / _` | | | | |/ _ \ | | | | '_ \| __| |/ _ \| '_ \/ __|
  291. # | | | | (_) | (_| | |_| | | __/ | |_| | |_) | |_| | (_) | | | \__ \
  292. # |_| |_|\___/ \__,_|\__,_|_|\___| \___/| .__/ \__|_|\___/|_| |_|___/
  293. # |_|
  294. # Skill Forget Module Options
  295. #-------------------------------------------------------------------------------
  296. # max number of skills a persona can have
  297. DEFAULT_MAX_PERSONA_SKILLS = 8
  298.  
  299. #-------------------------------------------------------------------------------
  300. # _ __ __ _ _
  301. # / \ _ __ ___ __ _ _ __ __ _ | \/ | ___ __| |_ _| | ___
  302. # / _ \ | '__/ __/ _` | '_ \ / _` | | |\/| |/ _ \ / _` | | | | |/ _ \
  303. # / ___ \| | | (_| (_| | | | | (_| | | | | | (_) | (_| | |_| | | __/
  304. # /_/ \_\_| \___\__,_|_| |_|\__,_| |_| |_|\___/ \__,_|\__,_|_|\___|
  305. #
  306. # ___ _ _
  307. # / _ \ _ __ | |_(_) ___ _ __ ___
  308. # | | | | '_ \| __| |/ _ \| '_ \/ __|
  309. # | |_| | |_) | |_| | (_) | | | \__ \
  310. # \___/| .__/ \__|_|\___/|_| |_|___/
  311. # |_|
  312. # Arcana Module Options
  313. #-------------------------------------------------------------------------------
  314. # min arcana rank. arcanas start with 0 rank and will be shown only
  315. # when at MIN_RANK or higher
  316. MIN_RANK = 1
  317. DEFAULT_MAX_RANK = 10 # default maximum rank of persona arcana
  318.  
  319. # folder of the arcana cards images
  320. ARCANA_IMG_FOLDER = "Persona/Arcanas/" # inside Graphics folder
  321.  
  322. # name of the social links in the menu
  323. ARCANA_MENU_NAME = "Confidants" # alternative name for Social Links
  324. ARCANA_MENU_COMMAND_INDEX = 2
  325.  
  326. # file names for the arcana rank progression bar
  327. ARCANA_RANKS_BAR_IMG_NAME = "bar"
  328. ARCANA_PROGRESS_IMG_NAME = "progress"
  329. ARCANA_PROGRESS_EMPTY_IMG_NAME = "progress_empty"
  330.  
  331. #-------------------------------------------------------------------------------
  332. # _____ _ _ _ __ __ _ _
  333. # | ____|_ _____ | |_ _| |_(_) ___ _ __ | \/ | ___ __| |_ _| | ___
  334. # | _| \ \ / / _ \| | | | | __| |/ _ \| '_ \ | |\/| |/ _ \ / _` | | | | |/ _ \
  335. # | |___ \ V / (_) | | |_| | |_| | (_) | | | | | | | | (_) | (_| | |_| | | __/
  336. # |_____| \_/ \___/|_|\__,_|\__|_|\___/|_| |_| |_| |_|\___/ \__,_|\__,_|_|\___|
  337. #
  338. # ___ _ _
  339. # / _ \ _ __ | |_(_) ___ _ __ ___
  340. # | | | | '_ \| __| |/ _ \| '_ \/ __|
  341. # | |_| | |_) | |_| | (_) | | | \__ \
  342. # \___/| .__/ \__|_|\___/|_| |_|___/
  343. # |_|
  344. # Evolution Module Options
  345. #-------------------------------------------------------------------------------
  346. # ID of common event that runs when a persona is being evolved
  347. COMMON_EVENT_ID = 1
  348.  
  349. # variable id in which the name of the persona that is being evolved is stored
  350. EVOLVING_PERSONA_VAR_ID = 13
  351. # variable id in which the name of the persona to which the persona will be evolved
  352. RESULTING_PERSONA_VAR_ID = 14
  353.  
  354. #-------------------------------------------------------------------------------
  355. # _____ _ __ __ _ _
  356. # | ___| _ ___(_) ___ _ __ | \/ | ___ __| |_ _| | ___
  357. # | |_ | | | / __| |/ _ \| '_ \ | |\/| |/ _ \ / _` | | | | |/ _ \
  358. # | _|| |_| \__ \ | (_) | | | | | | | | (_) | (_| | |_| | | __/
  359. # |_| \__,_|___/_|\___/|_| |_| |_| |_|\___/ \__,_|\__,_|_|\___|
  360. #
  361. # ___ _ _
  362. # / _ \ _ __ | |_(_) ___ _ __ ___
  363. # | | | | '_ \| __| |/ _ \| '_ \/ __|
  364. # | |_| | |_) | |_| | (_) | | | \__ \
  365. # \___/| .__/ \__|_|\___/|_| |_|___/
  366. # |_|
  367. # Fusion Module Options
  368. #-------------------------------------------------------------------------------
  369. # list of actor ids whose personas can be fused.
  370. # example: if [1, 4, 6] then the player can fuse personas that belong to
  371. # the actors with id 1, 4 and 6
  372. CAN_USE_ACTORS_PERSONAS = [12]
  373.  
  374. # color of the special fusion result in the fusion results window. RGB values
  375. SPECIAL_FUSION_COLOR = Color.new(255, 255, 0) # yellow
  376.  
  377. # method to calculate the fusion resulting persona extra exp
  378. def self.FUSION_EXP_CALC(persona)
  379. # you can use this method to calculate the total experience the persona
  380. # child will earn from the fusion process. keep the first line
  381. return 0 unless persona.persona? || persona.nil?
  382. [persona.arcana_rank, 0].max * 500 + persona.level * 75 + rand(25)
  383. end
  384.  
  385. # if true, then the player has to choose the fusing personas in the order
  386. # in which they are specified in the tag.
  387. ORDER_MATTERS = false
  388.  
  389. #-------------------------------------------------------------------------------
  390. # ____ _ __ __ _ __ __ _ _
  391. # / ___|| |__ _ _ / _|/ _| | ___ | \/ | ___ __| |_ _| | ___
  392. # \___ \| '_ \| | | | |_| |_| |/ _ \ | |\/| |/ _ \ / _` | | | | |/ _ \
  393. # ___) | | | | |_| | _| _| | __/ | | | | (_) | (_| | |_| | | __/
  394. # |____/|_| |_|\__,_|_| |_| |_|\___| |_| |_|\___/ \__,_|\__,_|_|\___|
  395. #
  396. # ___ _ _
  397. # / _ \ _ __ | |_(_) ___ _ __ ___
  398. # | | | | '_ \| __| |/ _ \| '_ \/ __|
  399. # | |_| | |_) | |_| | (_) | | | \__ \
  400. # \___/| .__/ \__|_|\___/|_| |_|___/
  401. # |_|
  402. # Shuffle Module Options
  403. #-------------------------------------------------------------------------------
  404. # possible window positions
  405. WINDOW_POSITIONS = [
  406. "BL", # Bottom Left
  407. "BR", # Bottom Right
  408. "TL", # Top Left
  409. "TR" # Top Right
  410. ]
  411.  
  412. # folder of images of cards
  413. CARD_IMG_FOLDER = "Persona/Cards/" # inside Graphics folder
  414. # name of the image of the back of the cards
  415. CARD_BACK_NAME = "Back" # should be inside CARD_IMG_FOLDER
  416. # background file of shuffle time
  417. SHUFFLE_BACKGROUND = "Shuffle_Background" # should be inside Persona folder
  418.  
  419. # index of window position (WINDOW_POSITIONS) for shuffle time accept window
  420. ACCEPT_POSITION = 1
  421. # index of window position (WINDOW_POSITIONS) that displays the tries left
  422. # for the matching method
  423. COUNTER_POSITION = 1
  424.  
  425. MATCHING_TRIES = 5
  426.  
  427. # max numbers of cards displayed per row in shuffle time (before shuffling
  428. # and during the matching) must be set according to the image size of the
  429. # cards if there are too many per row they will go out of screen
  430. MAX_CARDS_PER_ROW = 5
  431.  
  432. # minimum number of penalty and blank cards a shuffle time must have
  433. MIN_PENALTY_CARDS = 1
  434. MIN_BLANK_CARDS = 1
  435. # maximum number of penalty and blank cards a shuffle time must have
  436. MAX_PENALTY_CARDS = 2
  437. MAX_BLANK_CARDS = 2
  438. # number of cards required to be dropped (without blank and penalty)
  439. # to initiate shuffle time
  440. MIN_CARDS_TO_SHUFFLE = 2
  441.  
  442. # variable id from which the next shuffle method is set
  443. FORCE_SHUFFLE_METHOD_VAR_ID = 10
  444.  
  445. # variable id from which the next shuffle cards are set
  446. SHUFFLE_ITEMS_VAR_ID = 11
  447. # if true then duplicates cards will be included in the shuffle time
  448. # does not apply to blank and penalty cards. use the
  449. # MIN/MAX_PENALTY/BLANK_CARDS options
  450. ALLOW_DUPLICATES = false
  451. # if true then the cards set with the variable will be filtered according
  452. # to MIN/MAX_PENALTY_CARDS etc.
  453. FILTER_MANUAL_CARDS = false
  454.  
  455. # Messages
  456. # message displayed when player loses at the matching shuffle method
  457. MATCHING_LOSE_MESSAGE = "You lost!"
  458.  
  459. # message displayed when no card was drawn (only happens in matching method)
  460. NO_CARD_DRAW_MSG = "You didn't draw any card!"
  461. # message dispalyed in the battle results when no card is drawn
  462. NO_CARD_RESULT_MSG = "Nothing happened."
  463.  
  464. # message displayed when the blank card is drawn
  465. BLANK_CARD_DRAW_MSG = "You drew a Blank Card..."
  466. # message dispalyed in the battle results when the blank card is drawn
  467. BLANK_CARD_RESULT_MSG = "Nothing happened."
  468.  
  469. # message displayed when the penalty card is drawn
  470. PENALTY_CARD_DRAW_MSG = "You drew a Penalty Card..."
  471. # message displayed in the battle results when the penalty card is drawn
  472. PENALTY_CARD_RESULT_MSG = "All the rewards you gained from this battle \nhave vanished..."
  473.  
  474. # message that is displayed when a card is picked. must have the %s which
  475. # is where the persona's name will be put
  476. PERSONA_CARD_DRAW_MSG = "You drew a card of the Persona %s!"
  477.  
  478. # [Audio file directory, Volume level, Pitch]
  479. # music to play while shuffling
  480. SHUFFLE_BGM = ["Audio/BGM/Field2", 100, 100]
  481. # could be the sound of cards
  482. SHUFFLE_BGS = nil
  483. SHUFFLE_PENALTY_SOUND = ["Audio/SE/Collapse1", 100, 100]
  484. SHUFFLE_BLANK_SOUND = ["Audio/SE/Blind", 100, 100] # same sound plays for no card too
  485. SHUFFLE_CARD_SOUND = ["Audio/SE/Applause2", 100, 100]
  486.  
  487. # you can change the method below and make it decide the shuffle method
  488. # however you want
  489. def self.SHUFFLE_SELECTION(cards)
  490. if cards.size <= 6
  491. return ["Horizontal", "Diagonal"].sample
  492. elsif cards.size <= 10
  493. return "Combination"
  494. elsif cards.size <= 15
  495. return "Matching"
  496. end
  497. end
  498. end
  499. #-------------------------------------------------------------------------------
  500. #-------------------------------------------------------------------------------
  501. # _____ _ __ _ _
  502. # | ____|_ __ __| | ___ / _| ___ _ __ | |_(_) ___ _ __ ___
  503. # | _| | '_ \ / _` | / _ \| |_ / _ \| '_ \| __| |/ _ \| '_ \/ __|
  504. # | |___| | | | (_| | | (_) | _| | (_) | |_) | |_| | (_) | | | \__ \
  505. # |_____|_| |_|\__,_| \___/|_| \___/| .__/ \__|_|\___/|_| |_|___/
  506. # |_|
  507. # _
  508. # _ __ __ _ _ __| |_
  509. # | '_ \ / _` | '__| __|
  510. # | |_) | (_| | | | |_
  511. # | .__/ \__,_|_| \__|
  512. # |_|
  513. #
  514. #-------------------------------------------------------------------------------
  515. #-------------------------------------------------------------------------------
  516.  
  517. #-------------------------------------------------------------------------------
  518. # ____ __ __ _ _
  519. # | _ \ ___ _ __ ___ ___ _ __ __ _ | \/ | ___ __| |_ _| | ___
  520. # | |_) / _ \ '__/ __|/ _ \| '_ \ / _` | | |\/| |/ _ \ / _` | | | | |/ _ \
  521. # | __/ __/ | \__ \ (_) | | | | (_| | | | | | (_) | (_| | |_| | | __/
  522. # |_| \___|_| |___/\___/|_| |_|\__,_| |_| |_|\___/ \__,_|\__,_|_|\___|
  523. #
  524. # Persona Module
  525. #-------------------------------------------------------------------------------
  526. class RPG::Actor < RPG::BaseItem
  527. def persona?
  528. note =~ /<Persona>/ ? true : false
  529. end
  530.  
  531. def users
  532. # returns list of actors that can use specific persona
  533. matches = /<User: (\d+(,[ ]?\d+)*)?>/.match(note)
  534. return Persona::DEFAULT_PERSONA_USERS if matches.nil?
  535. user_str = matches[1]
  536. user_str.split(",").collect{ |i| i.to_i }
  537. end
  538.  
  539. def only_persona
  540. note =~ /<Persona: (\d+)>/ ? $1.to_i : nil
  541. end
  542.  
  543. def min_player_level
  544. # min player level required to fuse persona
  545. note =~ /<Player level: (\d+)>/ ? $1.to_i : 0
  546. end
  547.  
  548. def battletest_persona
  549. # get persona to use for battletest
  550. note =~ /<Battletest persona: (\d+)>/ ? $1.to_i : 0
  551. end
  552. end
  553.  
  554. module Cache
  555. def self.persona_file(filename)
  556. load_bitmap("Graphics/Persona/", filename)
  557. end
  558. end
  559.  
  560. module DataManager
  561. class <<self
  562. alias persona_cgo create_game_objects
  563. def create_game_objects
  564. persona_cgo
  565. $game_personas = Game_Personas.new
  566. end
  567. end
  568. end
  569.  
  570. class Game_Actor < Game_Battler
  571. include Persona
  572.  
  573. attr_reader :users, :only_persona, :min_player_level
  574. alias persona_su setup
  575. def setup(actor_id)
  576. @persona = nil
  577. @changed_persona = false
  578. persona_su(actor_id)
  579. setup_persona
  580. end
  581.  
  582. def setup_persona
  583. @is_persona = actor.persona?
  584. @users = actor.users
  585. @only_persona = actor.only_persona
  586. @min_player_level = actor.min_player_level
  587. end
  588.  
  589. def persona?
  590. @is_persona
  591. end
  592.  
  593. def persona
  594. @persona
  595. end
  596.  
  597. def can_change_persona
  598. !@changed_persona
  599. end
  600.  
  601. def persona_change_ok?(persona)
  602. return false if @changed_persona
  603. return false if @persona == persona
  604. return false if !can_equip_persona(persona)
  605. return true
  606. end
  607.  
  608. def change_persona(persona)
  609. return if !persona_change_ok?(persona)
  610. return if $game_party.personas.find{|p| p.id == persona.id}.nil?
  611. # when changing persona keep the same hp rate the actor had with the
  612. # previous one
  613.  
  614. prev_hp_rate = hp_rate
  615. prev_mp_rate = mp_rate
  616.  
  617. @persona = persona
  618. @changed_persona = true if $game_party.in_battle
  619. refresh
  620.  
  621. @hp = (mhp * prev_hp_rate).to_i
  622. @mp = (mmp * prev_mp_rate).to_i
  623. end
  624.  
  625. def force_change_persona(persona_id)
  626. return if $game_party.personas.find{|p| p.id == persona_id}.nil?
  627. # force change persona without checking if it is ok
  628. prev_hp_rate = hp_rate
  629. prev_mp_rate = mp_rate
  630.  
  631. @persona = $game_personas[persona_id]
  632. @changed_persona = true if $game_party.in_battle
  633. refresh
  634.  
  635. @hp = (mhp * prev_hp_rate).to_i
  636. @mp = (mmp * prev_mp_rate).to_i
  637. end
  638.  
  639. def remove_persona
  640. prev_hp_rate = hp_rate
  641. prev_mp_rate = mp_rate
  642.  
  643. @persona = nil
  644.  
  645. @hp = (mhp * prev_hp_rate).to_i
  646. @mp = (mmp * prev_mp_rate).to_i
  647. end
  648.  
  649. alias persona_ast added_skill_types
  650. def added_skill_types
  651. # get skill types of actor and their persona
  652. skill_types = persona_ast
  653. skill_types |= persona_added_skill_types if UNIFIED_SKILLS
  654. return skill_types
  655. end
  656.  
  657. alias persona_s skills
  658. def skills
  659. # get skills of actor and their persona
  660. skills = persona_s
  661. skills |= persona_skills if UNIFIED_SKILLS
  662. return skills
  663. end
  664.  
  665. def persona_skills
  666. return @persona.skills if !persona? && !@persona.nil?
  667. return []
  668. end
  669.  
  670. def persona_added_skill_types
  671. return @persona.added_skill_types if !persona? && !@persona.nil?
  672. return []
  673. end
  674.  
  675. def state_resist?(state_id)
  676. actor_resists = state_resist_set.include?(state_id)
  677. persona_resists = false
  678. if !persona? && !@persona.nil?
  679. persona_resists = @persona.state_resist_set.include?(state_id)
  680. end
  681. return actor_resists || persona_resists
  682. end
  683.  
  684. alias persona_param param
  685. def param(param_id)
  686. # get the value of the actor's parameter
  687. value = persona_param(param_id)
  688. if !persona? && !@persona.nil?
  689. # get the actor's and persona's multiplier and add both of their parameters
  690. # with their respective multiplier
  691. user_mult = USER_PARAM_MULTIPLIER.is_a?(Array) ? USER_PARAM_MULTIPLIER[param_id] : USER_PARAM_MULTIPLIER
  692. persona_mult = PERSONA_PARAM_MULTIPLIER.is_a?(Array) ? PERSONA_PARAM_MULTIPLIER[param_id] : PERSONA_PARAM_MULTIPLIER
  693. value = (value * user_mult) + (@persona.param(param_id) * persona_mult)
  694. end
  695. return value.to_i
  696. end
  697.  
  698. alias fog_er element_rate
  699. def element_rate(element_id)
  700. # get the value of the actor's element rate
  701. value = features_pi(FEATURE_ELEMENT_RATE, element_id)
  702. if !persona? && !@persona.nil?
  703. # get the actor's and persona's multiplier and add both of their element rate
  704. # with their respective multiplier
  705. user_mult = USER_ELEMENT_RATE_MULTIPLIER.is_a?(Array) ? USER_ELEMENT_RATE_MULTIPLIER[xparam_id] : USER_ELEMENT_RATE_MULTIPLIER
  706. persona_mult = PERSONA_ELEMENT_RATE_MULTIPLIER.is_a?(Array) ? PERSONA_ELEMENT_RATE_MULTIPLIER[xparam_id] : PERSONA_ELEMENT_RATE_MULTIPLIER
  707. value = (value * user_mult) + (@persona.features_pi(FEATURE_ELEMENT_RATE, element_id) * persona_mult)
  708. end
  709. return value
  710. end
  711.  
  712. alias fog_dr debuff_rate
  713. def debuff_rate(param_id)
  714. # get the value of the actor's debuff rate
  715. value = features_pi(FEATURE_DEBUFF_RATE, param_id)
  716. if !persona? && !@persona.nil?
  717. # get the actor's and persona's multiplier and add both of their debuff rate
  718. # with their respective multiplier
  719. user_mult = USER_DEBUFF_RATE_MULTIPLIER.is_a?(Array) ? USER_DEBUFF_RATE_MULTIPLIER[xparam_id] : USER_DEBUFF_RATE_MULTIPLIER
  720. persona_mult = PERSONA_DEBUFF_RATE_MULTIPLIER.is_a?(Array) ? PERSONA_DEBUFF_RATE_MULTIPLIER[xparam_id] : PERSONA_DEBUFF_RATE_MULTIPLIER
  721. value = (value * user_mult) + (@persona.features_pi(FEATURE_DEBUFF_RATE, param_id) * persona_mult)
  722. end
  723. return value
  724. end
  725.  
  726. alias fog_sr state_rate
  727. def state_rate(state_id)
  728. # get the value of the actor's state rate
  729. value = features_pi(FEATURE_STATE_RATE, state_id)
  730. if !persona? && !@persona.nil?
  731. # get the actor's and persona's multiplier and add both of their state rate
  732. # with their respective multiplier
  733. user_mult = USER_STATE_RATE_MULTIPLIER.is_a?(Array) ? USER_STATE_RATE_MULTIPLIER[xparam_id] : USER_STATE_RATE_MULTIPLIER
  734. persona_mult = PERSONA_STATE_RATE_MULTIPLIER.is_a?(Array) ? PERSONA_STATE_RATE_MULTIPLIER[xparam_id] : PERSONA_STATE_RATE_MULTIPLIER
  735. value = (value * user_mult) + (@persona.features_pi(FEATURE_STATE_RATE, state_id) * persona_mult)
  736. end
  737. return value
  738. end
  739.  
  740. alias persona_xparam xparam
  741. def xparam(xparam_id)
  742. # get the value of the actor's x_parameter
  743. value = persona_xparam(xparam_id)
  744. if !persona? && !@persona.nil?
  745. # get the actor's and persona's multiplier and add both of their x_parameters
  746. # with their respective multiplier
  747. user_mult = USER_PARAM_MULTIPLIER.is_a?(Array) ? USER_XPARAM_MULTIPLIER[xparam_id] : USER_XPARAM_MULTIPLIER
  748. persona_mult = PERSONA_PARAM_MULTIPLIER.is_a?(Array) ? PERSONA_XPARAM_MULTIPLIER[xparam_id] : PERSONA_PARAM_MULTIPLIER
  749. value = (value * user_mult) + (@persona.xparam(xparam_id) * persona_mult)
  750. end
  751. return value
  752. end
  753.  
  754. alias persona_sparam sparam
  755. def sparam(sparam_id)
  756. # get the value of the actor's s_parameter
  757. value = persona_sparam(sparam_id)
  758. if !persona? && !@persona.nil?
  759. # get the actor's and persona's multiplier and add both of their s_parameters
  760. # with their respective multiplier
  761. user_mult = USER_PARAM_MULTIPLIER.is_a?(Array) ? USER_SPARAM_MULTIPLIER[sparam_id] : USER_SPARAM_MULTIPLIER
  762. persona_mult = PERSONA_PARAM_MULTIPLIER.is_a?(Array) ? PERSONA_SPARAM_MULTIPLIER[sparam_id] : PERSONA_SPARAM_MULTIPLIER
  763. value = (value * user_mult) + (@persona.sparam(sparam_id) * persona_mult)
  764. end
  765. return value
  766. end
  767.  
  768. def only_persona?
  769. return !only_persona.nil?
  770. end
  771.  
  772. def can_equip_persona(persona)
  773. persona.min_player_level <= @level && $game_party.persona_available(persona)
  774. end
  775.  
  776. alias persona_ge gain_exp
  777. def gain_exp(exp)
  778. persona_ge(exp)
  779. if !persona? && !@persona.nil?
  780. @persona.gain_exp(exp)
  781. end
  782. end
  783.  
  784. alias persona_fer final_exp_rate
  785. def final_exp_rate
  786. return persona_fer if !persona?
  787. return exr * Persona::PERSONA_EXP_GAIN_MULTIPLIER
  788. end
  789.  
  790. alias persona_i index
  791. def index
  792. return persona_i if !persona?
  793. # return persona's index from user's personas list
  794. user = $game_party.menu_actor
  795. return $game_party.actors_personas(user.id).index(self)
  796. end
  797.  
  798. def next_skill
  799. # return the next (closest in level) skill that the actor will learn
  800. self.class.learnings.select{ |learning| learning.level > @level}.min_by{ |learning| learning.level }
  801. end
  802.  
  803. def next_skills
  804. # return all the skills that the actor will learn
  805. self.class.learnings.select{ |learning| learning.level > @level }
  806. end
  807.  
  808. def on_battle_start
  809. super
  810. # reset flag on battle start
  811. @changed_persona = false
  812. end
  813.  
  814. def on_turn_end
  815. super
  816. # reset flag on turn end
  817. @changed_persona = false
  818. end
  819. end
  820.  
  821. class Game_Party < Game_Unit
  822. alias persona_init initialize
  823. def initialize
  824. @personas = []
  825. @menu_persona_id = 0
  826. persona_init
  827. end
  828.  
  829. def personas
  830. # returns party's personas
  831. @personas.collect{ |id| $game_personas[id] }
  832. end
  833.  
  834. alias persona_sbt setup_battle_test
  835. def setup_battle_test
  836. persona_sbt
  837. setup_test_battle_personas
  838. end
  839.  
  840. def battle_personas
  841. members.reject{|m| m.persona.nil?}.collect{|m| m.persona}
  842. end
  843.  
  844. def persona_in_party(persona_name)
  845. return !personas.find{|p| p.name == persona_name}.nil?
  846. end
  847.  
  848. def persona_equipped_by(actor_id, persona_name)
  849. actor = members.find{|m| m.id == actor_id}
  850. return false if actor.nil?
  851. return false if actor.persona.nil?
  852. return actor.persona.name == persona_name
  853. end
  854.  
  855. def persona_equipped(persona_name)
  856. persona = personas.find{|p| p.name == persona_name}
  857. return persona_available(persona)
  858. end
  859.  
  860. def setup_test_battle_personas
  861. $data_system.test_battlers.each do |battler|
  862. # get battletest persona of each battle test actor and equip them
  863. actor = $game_actors[battler.actor_id]
  864. btest_persona = $data_actors[battler.actor_id].battletest_persona
  865. if btest_persona != 0
  866. actor.change_persona($game_actors[btest_persona])
  867. end
  868. end
  869. end
  870.  
  871. def add_persona(persona_id)
  872. # inform user (script user) about the mistake just in case
  873. if $game_personas[persona_id].nil?
  874. msgbox("There was an attempt to add a persona with an invalid ID (ID=#{persona_id})")
  875. end
  876.  
  877. @personas.push(persona_id) if !@personas.include?(persona_id) && !$game_personas[persona_id].nil?
  878. # auto equip new persona if there is a member that uses only one persona
  879. user = members.find{|m| m.only_persona == persona_id}
  880. user.change_persona($game_personas[persona_id]) if !user.nil?
  881.  
  882. $game_player.refresh
  883. $game_map.need_refresh = true
  884. end
  885.  
  886. def remove_persona(persona_id)
  887. # unequip persona
  888. user = members.find{|m| !m.persona.nil? && m.persona.id == persona_id}
  889. user.remove_persona if !user.nil?
  890.  
  891. # remove persona from party
  892. @personas.delete(persona_id)
  893. $game_player.refresh
  894. $game_map.need_refresh = true
  895. end
  896.  
  897. def actors_personas(actor_id)
  898. # get the of the personas that belong to the actor
  899. ids = @personas.select{ |id| $game_personas[id].users.include?(actor_id) }
  900. # if the party has no personas that belong to the actor an empty list is returned
  901. return ids.collect{ |id| $game_personas[id] }
  902. end
  903.  
  904. def persona_available(persona)
  905. # returns if true if persona is not currently equipped by any member of the party
  906. members.inject(true){|available, m| available && m.persona != persona}
  907. end
  908.  
  909. def menu_persona
  910. $game_personas[@menu_persona_id] || menu_personas[0]
  911. end
  912.  
  913. def menu_persona=(persona)
  914. @menu_persona_id = persona.id
  915. end
  916.  
  917. def menu_personas
  918. # returns personas currently being shown in menu
  919. actors_personas(menu_actor.id)
  920. end
  921.  
  922. def menu_persona_next
  923. # calculate the index of the next persona
  924. index = menu_personas.index(menu_persona) || -1
  925. # if next index is higher than the size of menu_personas, it rounds it down
  926. # to the start
  927. index = (index + 1) % menu_personas.size
  928. self.menu_persona = actors_personas(menu_actor.id)[index]
  929. end
  930.  
  931. def menu_persona_prev
  932. # calculate the index of the previous persona
  933. index = menu_personas.index(menu_persona) || 1
  934. # if previous index is lower than 0, it basically rounds it back to the end
  935. index = (index + menu_personas.size - 1) % menu_personas.size
  936. self.menu_persona = actors_personas(menu_actor.id)[index]
  937. end
  938. end
  939.  
  940. class Game_Personas
  941. def initialize
  942. @data = []
  943. end
  944.  
  945. def [](actor_id)
  946. return nil if !$data_actors[actor_id]
  947. return nil if !$data_actors[actor_id].persona?
  948. @data[actor_id] ||= Game_Actor.new(actor_id)
  949. end
  950. end
  951.  
  952. class Window_ActorCommand < Window_Command
  953. alias persona_mcl make_command_list
  954. def make_command_list
  955. persona_mcl
  956. return unless @actor
  957. add_persona_command
  958. add_persona_skills_command if !Persona::UNIFIED_SKILLS
  959. end
  960.  
  961. def add_persona_command
  962. name = Persona::PERSONA_MENU_NAME
  963. ext = nil
  964. command = { :name=>name,
  965. :symbol=>:persona,
  966. :enabled=>@actor.can_change_persona,
  967. :ext=>ext}
  968. index = Persona::PERSONA_BATTLE_COMMAND_INDEX - 1
  969. index = [[0, index].max, @list.length].min
  970. @list.insert(index, command)
  971. end
  972.  
  973. def add_persona_skills_command
  974. return if @actor.persona.nil?
  975. index = Persona::PERSONA_SKILLS_COMMAND_INDEX
  976. @actor.persona_added_skill_types.sort.each do |stype_id|
  977. name = "#{Persona::PERSONA_MENU_NAME} #{$data_system.skill_types[stype_id]}"
  978. ext = stype_id
  979. command = { :name=>name,
  980. :symbol=>:persona_skills,
  981. :enabled=>true,
  982. :ext=>ext}
  983. index = [[0, index].max, @list.length].min
  984. @list.insert(index, command)
  985. index += 1
  986. end
  987. end
  988.  
  989. def refresh_persona_change
  990. setup(@actor)
  991. refresh
  992. end
  993. end
  994.  
  995. class Window_BattlePersonas < Window_Command
  996. def initialize(actor)
  997. @actor = actor
  998. @personas = $game_party.actors_personas(@actor.id)
  999. super(0, 0)
  1000. select_last
  1001. end
  1002.  
  1003. def actor=(actor)
  1004. return if @actor == actor
  1005. @actor = actor
  1006. @personas = $game_party.actors_personas(@actor.id)
  1007. refresh
  1008. select_last
  1009. end
  1010.  
  1011. def refresh
  1012. contents.clear
  1013. draw_all_items
  1014. end
  1015.  
  1016. def window_width
  1017. Graphics.width
  1018. end
  1019.  
  1020. def window_height
  1021. Graphics.height / 4
  1022. end
  1023.  
  1024. def item_width
  1025. (width - standard_padding * 2 + spacing) / col_max - spacing
  1026. end
  1027.  
  1028. def col_max
  1029. 2
  1030. end
  1031.  
  1032. def item_height
  1033. line_height
  1034. end
  1035.  
  1036. def visible_line_number
  1037. 4
  1038. end
  1039.  
  1040. def item_max
  1041. @personas.size
  1042. end
  1043.  
  1044. def process_handling
  1045. return unless open? && active
  1046. return process_equip if equip_enabled? && Input.trigger?(:C)
  1047. return process_cancel if cancel_enabled? && Input.trigger?(:B)
  1048. end
  1049.  
  1050. def item
  1051. @personas && index >= 0 ? @personas[index] : nil
  1052. end
  1053.  
  1054. def enable?(persona)
  1055. @actor && @actor.persona_change_ok?(persona)
  1056. end
  1057.  
  1058. def current_item_enabled?
  1059. enable?($game_party.actors_personas(@actor.id)[index])
  1060. end
  1061.  
  1062. def process_equip
  1063. if current_item_enabled?
  1064. RPG::SE.new("Persona_Summon", 95, 100).play
  1065. Input.update
  1066. call_equip_handler
  1067. else
  1068. Sound.play_buzzer
  1069. end
  1070. end
  1071.  
  1072. def call_equip_handler
  1073. call_handler(:ok)
  1074. end
  1075. def equip_enabled?
  1076. handle?(:ok)
  1077. end
  1078.  
  1079. def draw_item_background(index)
  1080. equiped_persona_index = @personas.index(@actor.persona)
  1081. if index == equiped_persona_index
  1082. color = pending_color
  1083. color.alpha = 100
  1084. contents.fill_rect(item_rect(index), color)
  1085. end
  1086. end
  1087.  
  1088. def draw_persona_name_level(persona, rect, enabled)
  1089. change_color(system_color, enabled)
  1090. draw_text(rect, Vocab::level_a)
  1091. x = rect.x + text_size(Vocab::level_a).width
  1092. y = rect.y
  1093. txt = "#{persona.level} #{persona.name}"
  1094. change_color(normal_color, enabled)
  1095. draw_text(x, y, rect.width, rect.height, txt)
  1096. end
  1097.  
  1098. def draw_item(index)
  1099. persona = @personas[index]
  1100. rect = item_rect(index)
  1101. enabled = enable?(persona)
  1102. draw_item_background(index)
  1103. draw_persona_name_level(persona, rect, enabled)
  1104. end
  1105.  
  1106. def process_ok
  1107. super
  1108. persona = @personas[index]
  1109. $game_party.menu_persona = persona
  1110. end
  1111.  
  1112. def select_last
  1113. if $game_party.menu_persona.nil?
  1114. select(0)
  1115. else
  1116. select($game_party.menu_persona.index || 0)
  1117. end
  1118. end
  1119.  
  1120. def pending_index=(index)
  1121. last_pending_index = @pending_index
  1122. @pending_index = index
  1123. redraw_item(@pending_index)
  1124. redraw_item(last_pending_index)
  1125. end
  1126. end
  1127.  
  1128. class Window_BattleSkill < Window_SkillList
  1129. def draw_item_name(item, x, y, enabled = true, width = 172)
  1130. return unless item
  1131. draw_icon(item.icon_index, x, y, enabled)
  1132. if !@actor.persona_skills.index(item).nil?
  1133. change_color(Persona::PERSONA_SKILLS_COLOR, enabled)
  1134. else
  1135. change_color(normal_color, enabled)
  1136. end
  1137. draw_text(x + 24, y, width, line_height, item.name)
  1138. end
  1139. end
  1140.  
  1141. class Window_Keys < Window_Base
  1142. include Persona
  1143. def initialize
  1144. width = 200
  1145. height = line_height
  1146. super(Graphics.width - width, Graphics.height - height, width, height)
  1147. determine_window_size
  1148. draw_content
  1149. self.visible = false
  1150. end
  1151.  
  1152. def determine_window_size
  1153. # determines window's size according to the size of the button images
  1154. @select_button = Cache.persona_file(SELECT_PERSONA_BUTTON_IMG_NAME)
  1155. @equip_button = Cache.persona_file(EQUIP_PERSONA_BUTTON_IMG_NAME)
  1156. # largest height and width between the two button images
  1157. height = [@select_button.height, @equip_button.height].max
  1158. width = [@select_button.width, @equip_button.width].max
  1159. # increase width by largest width between two texts
  1160. width += [text_size(SELECT_PERSONA_TEXT).width, text_size(EQUIP_PERSONA_TEXT).width].max
  1161.  
  1162. # max width of window is half the width of the game window so that it doesn't
  1163. # overlap with the personas window
  1164. self.width = [width + standard_padding * 2, Graphics.width / 2].min
  1165. self.height = height * 2 + line_height + standard_padding
  1166.  
  1167. self.x = Graphics.width - self.width
  1168. self.y = Graphics.height - self.height
  1169.  
  1170. create_contents
  1171. end
  1172.  
  1173. def draw_content
  1174. contents.clear
  1175.  
  1176. # draw top button (select)
  1177. x = @select_button.width
  1178. txt_height = text_size(SELECT_PERSONA_TEXT).height
  1179. btn_height = @select_button.height
  1180. y = [txt_height, btn_height].max / 2
  1181. contents.blt(0, y - btn_height / 2, @select_button, @select_button.rect)
  1182. draw_text(x, y - txt_height/2, self.width - x - standard_padding, line_height, SELECT_PERSONA_TEXT)
  1183.  
  1184. # draw bottom button (equip)
  1185. x = @select_button.width
  1186. txt_height = text_size(EQUIP_PERSONA_TEXT).height
  1187. btn_height = @equip_button.height
  1188. y = contents.height / 2 + [txt_height, btn_height].max / 2
  1189. contents.blt(0, y - btn_height / 2, @equip_button, @equip_button.rect)
  1190. draw_text(x, y - txt_height / 2, self.width - x - standard_padding, line_height, EQUIP_PERSONA_TEXT)
  1191. end
  1192. end
  1193.  
  1194. class Window_MenuCommand < Window_Command
  1195. alias persona_mcl make_command_list
  1196. def make_command_list
  1197. persona_mcl
  1198. add_persona_command
  1199. end
  1200.  
  1201. def add_persona_command
  1202. # add persona command to main menu
  1203. name = Persona::PERSONA_MENU_NAME
  1204. ext = nil
  1205. command = { :name=>name,
  1206. :symbol=>:persona,
  1207. :enabled=>main_commands_enabled,
  1208. :ext=>ext}
  1209. index = Persona::PERSONA_MENU_COMMAND_INDEX - 1
  1210. index = [index, @list.length].min
  1211. @list.insert(index, command)
  1212. end
  1213. end
  1214.  
  1215. class Window_MenuStatus < Window_Selectable
  1216. def ok_enabled?
  1217. actor = $game_party.members[index]
  1218. # can't view persona's status for actor that can use only one persona and
  1219. # that persona is not equipped
  1220. return false if actor.only_persona? && actor.persona.nil?
  1221. handle?(:ok)
  1222. end
  1223. end
  1224.  
  1225. class Window_Personas < Window_Command
  1226. include Persona
  1227.  
  1228. def initialize(actor)
  1229. @actor = actor
  1230. @personas = $game_party.actors_personas(@actor.id)
  1231. super(0, 0)
  1232. self.visible = false
  1233. select_last
  1234. end
  1235.  
  1236. def actor=(actor)
  1237. return if @actor == actor
  1238. @actor = actor
  1239. @personas = $game_party.actors_personas(@actor.id)
  1240. refresh
  1241. select_last
  1242. end
  1243.  
  1244. def personas
  1245. @personas
  1246. end
  1247.  
  1248. def window_width
  1249. Graphics.width / 2
  1250. end
  1251.  
  1252. def window_height
  1253. Graphics.height
  1254. end
  1255.  
  1256. def item_height
  1257. (height - standard_padding * 2) / visible_line_number
  1258. end
  1259.  
  1260. def visible_line_number
  1261. 4
  1262. end
  1263.  
  1264. def item_max
  1265. @personas.size
  1266. end
  1267.  
  1268. def current_persona
  1269. @personas[index]
  1270. end
  1271.  
  1272. def process_handling
  1273. return unless open? && active
  1274. return process_equip if equip_enabled? && Input.trigger?(EQUIP_PERSONA_KEY)
  1275. super
  1276. end
  1277.  
  1278. def process_equip
  1279. if persona_equippable?
  1280. RPG::SE.new("Persona_Summon", 95, 100).play
  1281. Input.update
  1282. call_equip_handler
  1283. else
  1284. Sound.play_buzzer
  1285. end
  1286. end
  1287.  
  1288. def call_equip_handler
  1289. call_handler(:equip)
  1290. end
  1291.  
  1292. def equip_enabled?
  1293. handle?(:equip)
  1294. end
  1295.  
  1296. def refresh
  1297. super
  1298. contents.clear
  1299. draw_all_items
  1300. end
  1301.  
  1302. def draw_all_items
  1303. draw_no_personas_msg if @personas.empty?
  1304. super
  1305. end
  1306.  
  1307. def draw_no_personas_msg
  1308. draw_text(0, 0, width, line_height, NO_PERSONAS_MSG)
  1309. end
  1310.  
  1311. def draw_item(index)
  1312. persona = @personas[index]
  1313.  
  1314. enabled = @actor.can_equip_persona(persona)
  1315. rect = item_rect(index)
  1316. draw_item_background(index)
  1317. draw_actor_face(persona, rect.x + 1, rect.y + 1, enabled)
  1318. draw_actor_simple_status(persona, rect.x + 108, rect.y, enabled)
  1319. end
  1320.  
  1321. def draw_actor_simple_status(actor, x, y, enabled)
  1322. change_color(normal_color, enabled)
  1323. draw_actor_name(actor, x, y)
  1324. draw_actor_nickname(actor, x, y + line_height)
  1325. draw_actor_level(actor, x, y + line_height * 2)
  1326. change_color(normal_color)
  1327. end
  1328.  
  1329. def draw_item_background(index)
  1330. equiped_persona_index = @personas.index(@actor.persona)
  1331. if index == equiped_persona_index
  1332. color = pending_color
  1333. color.alpha = 100
  1334. contents.fill_rect(item_rect(index), color)
  1335. end
  1336. end
  1337.  
  1338. def persona_equippable?
  1339. persona = @personas[index]
  1340. return @actor.can_equip_persona(persona)
  1341. end
  1342.  
  1343. def process_ok
  1344. Sound.play_ok
  1345. Input.update
  1346. deactivate
  1347.  
  1348. persona = @personas[index]
  1349. $game_party.menu_persona = persona
  1350. call_ok_handler
  1351. end
  1352.  
  1353. def current_item_enabled?
  1354. persona = @personas[index]
  1355. enabled = $game_party.persona_available(persona) || @actor.persona == persona
  1356. return enabled
  1357. end
  1358.  
  1359. def select_last
  1360. if @personas.nil? || $game_party.menu_persona.nil?
  1361. select(-1)
  1362. else
  1363. select($game_party.menu_persona.index || 0)
  1364. end
  1365. end
  1366.  
  1367. def pending_index=(index)
  1368. last_pending_index = @pending_index
  1369. @pending_index = index
  1370. redraw_item(@pending_index)
  1371. redraw_item(last_pending_index)
  1372. end
  1373. end
  1374.  
  1375. class Window_PersonaStatus < Window_Command
  1376. include Persona
  1377.  
  1378. def initialize(persona)
  1379. @persona = persona
  1380. super(0, 0)
  1381. self.visible = false
  1382. select_last
  1383. end
  1384.  
  1385. def window_width
  1386. Graphics.width
  1387. end
  1388.  
  1389. def window_height
  1390. Graphics.height
  1391. end
  1392.  
  1393. def persona
  1394. @persona
  1395. end
  1396.  
  1397. def persona=(persona)
  1398. return if @persona == persona
  1399. @persona = persona
  1400. refresh
  1401. end
  1402.  
  1403. def process_handling
  1404. return unless open? && active
  1405. return process_equip if equip_enabled? && Input.trigger?(EQUIP_PERSONA_KEY)
  1406. return process_cancel if cancel_enabled? && Input.trigger?(:B)
  1407. super
  1408. end
  1409.  
  1410. def process_equip
  1411. if persona_equippable?
  1412. RPG::SE.new("Persona_Summon", 95, 100).play
  1413. Input.update
  1414. call_equip_handler
  1415. else
  1416. Sound.play_buzzer
  1417. end
  1418. end
  1419.  
  1420. def persona_equippable?
  1421. return $game_party.menu_actor.can_equip_persona(@persona)
  1422. end
  1423.  
  1424. def call_equip_handler
  1425. call_handler(:equip)
  1426. end
  1427.  
  1428. def equip_enabled?
  1429. handle?(:equip)
  1430. end
  1431.  
  1432. def refresh
  1433. contents.clear
  1434. draw_everything if !@persona.nil?
  1435. end
  1436.  
  1437. def draw_everything
  1438. draw_block1 (line_height * 0)
  1439. draw_horz_line(line_height * 1)
  1440. draw_block2 (line_height * 2)
  1441. draw_horz_line(line_height * 6)
  1442. draw_block3 (line_height * 7)
  1443. draw_horz_line(line_height * 13)
  1444. draw_block4 (line_height * 14)
  1445. end
  1446.  
  1447. def draw_block1(y)
  1448. draw_actor_name(@persona, 4, y)
  1449. draw_actor_nickname(persona, 128, y)
  1450. end
  1451.  
  1452. def draw_block2(y)
  1453. draw_actor_face(@persona, 8, y)
  1454. draw_basic_info(136, y)
  1455. draw_exp_info(136, y)
  1456. draw_next_skill(136, y + line_height * 3)
  1457. end
  1458.  
  1459. def draw_block3(y)
  1460. draw_parameters(10, y)
  1461. draw_skills(100, y)
  1462. end
  1463.  
  1464. def draw_block4(y)
  1465. draw_ele_rates(30, y)
  1466. end
  1467.  
  1468. def draw_horz_line(y)
  1469. line_y = y + line_height / 2 - 1
  1470. contents.fill_rect(0, line_y, contents_width, 2, line_color)
  1471. end
  1472.  
  1473. def line_color
  1474. color = normal_color
  1475. color.alpha = 48
  1476. color
  1477. end
  1478.  
  1479. def draw_basic_info(x, y)
  1480. draw_actor_level(@persona, x, y + line_height * 0)
  1481. draw_actor_icons(@persona, x, y + line_height * 1)
  1482. end
  1483.  
  1484. def draw_parameters(x, y)
  1485. 6.times {|i| draw_actor_param(@persona, x, y + line_height * i, i + 2) }
  1486. end
  1487.  
  1488. def draw_actor_param(actor, x, y, param_id)
  1489. change_color(system_color)
  1490. draw_text(x, y, 120, line_height, Vocab::param(param_id))
  1491. change_color(normal_color)
  1492. draw_text(x + 30, y, 36, line_height, actor.param(param_id), 2)
  1493. end
  1494.  
  1495. def draw_exp_info(x, y)
  1496. s1 = @persona.max_level? ? "-------" : @persona.exp
  1497. s2 = @persona.max_level? ? "-------" : @persona.next_level_exp - @persona.exp
  1498. s_next = sprintf(Vocab::ExpNext, Vocab::level)
  1499. change_color(system_color)
  1500. draw_text(x, y + line_height * 1, 180, line_height, Vocab::ExpTotal)
  1501. draw_text(x, y + line_height * 2, 180, line_height, s_next)
  1502. change_color(normal_color)
  1503. draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
  1504. draw_text(x, y + line_height * 2, 180, line_height, s2, 2)
  1505. end
  1506.  
  1507. def draw_next_skill(x, y)
  1508. next_skill = @persona.next_skill
  1509. return if next_skill.nil?
  1510. s_next = sprintf("Next %s at ", Vocab::skill.downcase[0...-1])
  1511. change_color(system_color)
  1512. draw_text(x, y, 180, line_height, s_next)
  1513. x += text_size(s_next).width
  1514.  
  1515. change_color(system_color)
  1516. draw_text(x, y, 180, line_height, Vocab::level_a)
  1517. x += text_size(Vocab::level_a).width
  1518.  
  1519. change_color(normal_color)
  1520. draw_text(x, y, 180, line_height, next_skill.level.to_s + ": ")
  1521. x += text_size(next_skill.level.to_s + ": ").width
  1522.  
  1523. change_color(normal_color)
  1524. skill_name = $data_skills[next_skill.skill_id].name
  1525. draw_text(x, y, 180, line_height, skill_name)
  1526. end
  1527.  
  1528. def draw_skills(x, y)
  1529. col_width = ((self.width - x) / 3).to_i
  1530. cols_max_x = [0, 0] # first and second cols only needed
  1531. @persona.skills.each_with_index do |item, i|
  1532. col = i.div(6)
  1533. offset_x = col_width * col
  1534. offset_y = line_height * i.divmod(6)[1]
  1535. draw_item_name(item, x + offset_x, y + offset_y, true, col_width - 24)
  1536. end
  1537. next_skills_i = @persona.skills.length
  1538. @persona.next_skills.each_with_index do |item, i|
  1539. i += next_skills_i
  1540. offset_x = 150 * (i/6).to_i
  1541. offset_y = line_height * i.divmod(6)[1]
  1542. draw_text(x + offset_x, y + offset_y, col_width, line_height, "-------")
  1543. end
  1544. end
  1545.  
  1546. def draw_ele_rates(x, y)
  1547. icons = PERSONA_ELE_ICON_INDEXES
  1548. 10.times do |i|
  1549. offset_x = i * (24 + 24) # icon width + space between them
  1550. new_x = x + offset_x
  1551. draw_icon(icons[i], new_x, y)
  1552. if @persona.element_rate(i+1) == 1.0
  1553. draw_normal_ele_icon(new_x, y)
  1554. elsif @persona.element_rate(i+1) > 1.0
  1555. draw_strong_ele_icon(new_x, y)
  1556. elsif @persona.element_rate(i+1) < 1.0
  1557. draw_weak_ele_icon(new_x, y)
  1558. end
  1559. end
  1560. end
  1561.  
  1562. def draw_normal_ele_icon(x, y)
  1563. if PERSONA_NORMAL_ELE_ICON == -1
  1564. draw_text(x, y + line_height, 24, line_height, "-", 1)
  1565. else
  1566. draw_icon(PERSONA_NORMAL_ELE_ICON, x, y + line_height)
  1567. end
  1568. end
  1569.  
  1570. def draw_strong_ele_icon(x, y)
  1571. if PERSONA_STRONG_ELE_ICON == -1
  1572. draw_text(x, y + line_height, 24, line_height, "Str", 1)
  1573. else
  1574. draw_icon(PERSONA_STRONG_ELE_ICON, x, y + line_height)
  1575. end
  1576. end
  1577.  
  1578. def draw_weak_ele_icon(x, y)
  1579. if PERSONA_WEAK_ELE_ICON == -1
  1580. draw_text(x, y + line_height, 24, line_height, "Wk", 1)
  1581. else
  1582. draw_icon(PERSONA_WEAK_ELE_ICON, x, y + line_height)
  1583. end
  1584. end
  1585.  
  1586. def select_last
  1587. select(-1)
  1588. end
  1589. end
  1590.  
  1591. class Scene_Battle < Scene_Base
  1592. alias persona_cacw create_actor_command_window
  1593. def create_actor_command_window
  1594. persona_cacw
  1595. @actor_command_window.set_handler(:persona, method(:command_persona))
  1596. @actor_command_window.set_handler(:persona_skills, method(:persona_skills))
  1597. @actor_command_window.set_handler(:persona_magic, method(:persona_skills))
  1598. end
  1599.  
  1600. def persona_skills
  1601. @skill_window.actor = BattleManager.actor.persona if BattleManager.actor.persona
  1602. @skill_window.stype_id = @actor_command_window.current_ext
  1603. @skill_window.refresh
  1604. @skill_window.show.activate
  1605. end
  1606.  
  1607. def command_persona
  1608. @persona_window = Window_BattlePersonas.new(BattleManager.actor)
  1609. @persona_window.select_last
  1610. @persona_window.set_handler(:ok, method(:on_persona_ok))
  1611. @persona_window.set_handler(:cancel, method(:on_persona_cancel))
  1612. end
  1613.  
  1614. def on_persona_ok
  1615. persona = @persona_window.item
  1616. BattleManager.actor.change_persona(persona)
  1617. BattleManager.actor.refresh
  1618. @persona_window.hide
  1619. @actor_command_window.activate
  1620. @actor_command_window.refresh_persona_change
  1621. @status_window.refresh
  1622. end
  1623.  
  1624. def on_persona_cancel
  1625. @persona_window.hide
  1626. @actor_command_window.activate
  1627. end
  1628.  
  1629. alias persona_oec on_enemy_cancel
  1630. def on_enemy_cancel
  1631. persona_oec
  1632. case @actor_command_window.current_symbol
  1633. when :persona_skills
  1634. @skill_window.activate
  1635. end
  1636. end
  1637.  
  1638. alias persona_oac on_actor_cancel
  1639. def on_actor_cancel
  1640. persona_oac
  1641. case @actor_command_window.current_symbol
  1642. when :persona_skills
  1643. @skill_window.activate
  1644. end
  1645. end
  1646. end
  1647.  
  1648. class Scene_Menu < Scene_MenuBase
  1649. include Persona
  1650.  
  1651. alias persona_ccw create_command_window
  1652. def create_command_window
  1653. persona_ccw
  1654. @command_window.set_handler(:persona, method(:command_persona))
  1655. end
  1656.  
  1657. def command_persona
  1658. @status_window.select_last
  1659. @status_window.activate
  1660. @status_window.set_handler(:ok, method(:on_persona_user_ok))
  1661. @status_window.set_handler(:cancel, method(:on_personal_cancel))
  1662. end
  1663.  
  1664. def on_persona_user_ok
  1665. SceneManager.call(Scene_Personas)
  1666. end
  1667. end
  1668.  
  1669. class Scene_Personas < Scene_Base
  1670. def start
  1671. super
  1672. create_background
  1673. @actor = $game_party.menu_actor
  1674. @persona = @actor.persona
  1675. create_personas_window
  1676. create_buttons_window
  1677. create_status_window
  1678. on_actor_change
  1679. end
  1680.  
  1681. def terminate
  1682. super
  1683. dispose_background
  1684. end
  1685.  
  1686. def create_background
  1687. @background_sprite = Sprite.new
  1688. @background_sprite.bitmap = SceneManager.background_bitmap
  1689. @background_sprite.color.set(16, 16, 16, 128)
  1690. end
  1691.  
  1692. def dispose_background
  1693. @background_sprite.dispose
  1694. end
  1695.  
  1696. def create_buttons_window
  1697. @buttons_window = Window_Keys.new
  1698. @buttons_window.open
  1699. end
  1700.  
  1701. def create_personas_window
  1702. @personas_window = Window_Personas.new(@actor)
  1703. @personas_window.select_last
  1704. @personas_window.set_handler(:ok, method(:on_persona_ok))
  1705. @personas_window.set_handler(:cancel, method(:return_scene))
  1706. @personas_window.set_handler(:equip, method(:persona_equip))
  1707. @personas_window.set_handler(:pagedown, method(:next_actor))
  1708. @personas_window.set_handler(:pageup, method(:prev_actor))
  1709. @personas_window.open
  1710. end
  1711.  
  1712. def create_status_window
  1713. @status_window = Window_PersonaStatus.new($game_party.menu_persona)
  1714. @status_window.set_handler(:cancel, method(:close_status))
  1715. @status_window.set_handler(:equip, method(:persona_equip))
  1716. @status_window.set_handler(:pagedown, method(:next_persona))
  1717. @status_window.set_handler(:pageup, method(:prev_persona))
  1718. @status_window.open
  1719. end
  1720.  
  1721. def on_persona_ok
  1722. @status_window.persona = @personas_window.current_persona
  1723. @status_window.show.activate
  1724. @personas_window.deactivate
  1725. end
  1726.  
  1727. def persona_equip
  1728. # get previous persona index
  1729. prev_persona_index = @personas_window.personas.index(@actor.persona)
  1730. @actor.remove_persona
  1731. # redraw that item in window
  1732. @personas_window.redraw_item(prev_persona_index) if !prev_persona_index.nil?
  1733. #equip new persona
  1734. if @status_window.active
  1735. @actor.change_persona(@persona)
  1736. else
  1737. @actor.change_persona(@personas_window.current_persona)
  1738. end
  1739. #redrwa that item
  1740. index = @personas_window.personas.index(@actor.persona)
  1741. @personas_window.redraw_item(index)
  1742. end
  1743.  
  1744. def on_actor_change
  1745. if @actor.only_persona? && !@persona.nil?
  1746. # if current (new actor after next/prev_actor) uses only one persona
  1747. # and the persona is equipped, skip to status window (does not show
  1748. # all personas that can be equipped by specific actor as he can only
  1749. # equip one and it is auto-equipped when added to the party)
  1750. @personas_window.deactivate
  1751. @personas_window.hide
  1752. @buttons_window.hide
  1753. @status_window.persona = @persona
  1754. @status_window.show.activate
  1755. else
  1756. # else show list of personas current actor can equip
  1757. @status_window.deactivate
  1758. @status_window.hide
  1759. @buttons_window.show
  1760. @personas_window.actor = @actor
  1761. @personas_window.show.activate
  1762. end
  1763. end
  1764.  
  1765. def next_actor
  1766. new_actor = $game_party.menu_actor_next
  1767. if new_actor.only_persona? && new_actor.persona.nil?
  1768. # if next actor can equip only one persona and it is not equipped (not in
  1769. # the party) then stay in current actor
  1770. $game_party.menu_actor_prev
  1771. else
  1772. @actor = new_actor
  1773. @persona = @actor.persona
  1774. on_actor_change
  1775. end
  1776. end
  1777.  
  1778. def prev_actor
  1779. new_actor = $game_party.menu_actor_prev
  1780. if new_actor.only_persona? && new_actor.persona.nil?
  1781. # if pervious actor can equip only one persona and it is not equipped (not in
  1782. # the party) then stay in current actor
  1783. $game_party.menu_actor_next
  1784. else
  1785. @actor = new_actor
  1786. @persona = @actor.persona
  1787. on_actor_change
  1788. end
  1789. end
  1790.  
  1791. def next_persona
  1792. if @actor.only_persona?
  1793. # if current actor can equip only one persona go to next actor
  1794. next_actor
  1795. else
  1796. # else go to next persona
  1797. @persona = $game_party.menu_persona_next
  1798. @status_window.persona = @persona
  1799. @status_window.activate # pagedown handler deactivates window
  1800. end
  1801. end
  1802.  
  1803. def prev_persona
  1804. if @actor.only_persona?
  1805. # if current actor can equip only one persona go to previous actor
  1806. prev_actor
  1807. else
  1808. # else go to previous persona
  1809. @persona = $game_party.menu_persona_prev
  1810. @status_window.persona = @persona
  1811. @status_window.activate # pagedown handler deactivates window
  1812. end
  1813. end
  1814.  
  1815. def close_status
  1816. if @actor.only_persona?
  1817. # if current actor can equip only one persona return scene
  1818. SceneManager.return
  1819. return
  1820. else
  1821. # else just close the status window
  1822. @status_window.deactivate
  1823. @status_window.hide
  1824. @personas_window.activate
  1825. end
  1826. end
  1827. end
  1828.  
  1829. #-------------------------------------------------------------------------------
  1830. # ____ _ _ _ _ _____ _
  1831. # / ___|| | _(_) | | | ___|__ _ __ __ _ ___| |_
  1832. # \___ \| |/ / | | | | |_ / _ \| '__/ _` |/ _ \ __|
  1833. # ___) | <| | | | | _| (_) | | | (_| | __/ |_
  1834. # |____/|_|\_\_|_|_| |_| \___/|_| \__, |\___|\__|
  1835. # |___/
  1836. # __ __ _ _
  1837. # | \/ | ___ __| |_ _| | ___
  1838. # | |\/| |/ _ \ / _` | | | | |/ _ \
  1839. # | | | | (_) | (_| | |_| | | __/
  1840. # |_| |_|\___/ \__,_|\__,_|_|\___|
  1841. #
  1842. # Skill Forget Module
  1843. #-------------------------------------------------------------------------------
  1844. class RPG::Actor < RPG::BaseItem
  1845. def max_skills
  1846. # min rank required to fuse persona
  1847. note =~ /<Max skills: (\d+)>/ ? $1.to_i : Persona::DEFAULT_MAX_PERSONA_SKILLS
  1848. end
  1849. end
  1850.  
  1851. class Game_Actor < Game_Battler
  1852. attr_accessor :extra_skills
  1853. attr_reader :max_skills
  1854.  
  1855. alias persona_forget_sp setup_persona
  1856. def setup_persona
  1857. persona_forget_sp
  1858. @extra_skills = []
  1859. @max_skills = actor.max_skills
  1860. end
  1861.  
  1862. alias persona_forget_is init_skills
  1863. def init_skills
  1864. if actor.persona?
  1865. @skills = []
  1866. # reverse learning so that persona doesn't learn low level skills
  1867. self.class.learnings.reverse.each do |learning|
  1868. learn_skill(learning.skill_id) if learning.level <= @level
  1869. # is used instead of @max_skills because persona sestup is done
  1870. # after actor initialization
  1871. break if @skills.size >= actor.max_skills
  1872. end
  1873. else
  1874. persona_forget_is
  1875. end
  1876. end
  1877.  
  1878. def level_up
  1879. @level += 1
  1880. self.class.learnings.each do |learning|
  1881. if persona? && @skills.size >= @max_skills
  1882. @extra_skills.push(learning.skill_id) if learning.level == @level
  1883. else
  1884. learn_skill(learning.skill_id) if learning.level == @level
  1885. end
  1886. end
  1887. end
  1888.  
  1889. alias persona_forget_ce change_exp
  1890. def change_exp(exp, show)
  1891. persona_forget_ce(exp, show)
  1892. if @extra_skills.size > 0
  1893. $game_party.menu_persona = self
  1894. if !SceneManager.scene_is?(Scene_Battle)
  1895. SceneManager.call(Scene_ForgetSkill)
  1896. end
  1897. end
  1898. refresh
  1899. end
  1900.  
  1901. def replace_skill(old_skill, new_skill)
  1902. index = @skills.index(old_skill.id)
  1903. @skills[index] = new_skill.id
  1904. end
  1905. end
  1906.  
  1907. class Window_NewSkill < Window_Base
  1908. def initialize(x, y)
  1909. height = line_height * 2
  1910. super(x, y, 200, height)
  1911. self.openness = 0
  1912. end
  1913.  
  1914. def text=(txt)
  1915. contents.clear
  1916. self.width = text_size(txt).width + standard_padding * 2
  1917. create_contents
  1918. draw_text(0, 0, self.width - standard_padding, line_height, txt)
  1919. end
  1920. end
  1921.  
  1922. class Window_PersonaStatus < Window_Command
  1923. alias persona_forget_init initialize
  1924. def initialize(persona)
  1925. persona_forget_init(persona)
  1926. if !extra_skills.empty?
  1927. clear_command_list
  1928. make_command_list
  1929. end
  1930. select_last
  1931. end
  1932.  
  1933. def extra_skills
  1934. @persona ? @persona.extra_skills : []
  1935. end
  1936.  
  1937. def draw_skills(x, y)
  1938. col_width = ((self.width - x) / 3).to_i
  1939. cols_max_x = [0, 0] # first and second cols only needed
  1940. @persona.skills.each_with_index do |item, i|
  1941. col = i.div(6)
  1942. offset_x = col_width * col
  1943. offset_y = line_height * i.divmod(6)[1]
  1944. draw_item_name(item, x + offset_x, y + offset_y, true, col_width - 24)
  1945. end
  1946. next_skills_i = @persona.skills.length
  1947. @persona.next_skills.each_with_index do |item, i|
  1948. i += next_skills_i
  1949. break if i >= @persona.max_skills
  1950. offset_x = 150 * (i/6).to_i
  1951. offset_y = line_height * i.divmod(6)[1]
  1952. draw_text(x + offset_x, y + offset_y, col_width, line_height, "-------")
  1953. end
  1954. end
  1955.  
  1956. alias persona_forget_pcm process_cursor_move
  1957. def process_cursor_move
  1958. persona_forget_pcm if !extra_skills.empty?
  1959. end
  1960.  
  1961. alias persona_forget_ph process_handling
  1962. def process_handling
  1963. if !extra_skills.empty?
  1964. return unless open? && active
  1965. return process_forget if forget_enabled? && Input.trigger?(:C)
  1966. return process_cancel if cancel_enabled? && Input.trigger?(:B)
  1967. else
  1968. persona_forget_ph
  1969. end
  1970. end
  1971.  
  1972. def process_forget
  1973. Sound.play_equip
  1974. Input.update
  1975. call_forget_handler
  1976. end
  1977.  
  1978. def call_forget_handler
  1979. call_handler(:forget)
  1980. end
  1981.  
  1982. def forget_enabled?
  1983. handle?(:forget)
  1984. end
  1985.  
  1986. def item_width
  1987. ((self.width - 100)/3).to_i
  1988. end
  1989.  
  1990. def row_max
  1991. [(item_max + col_max - 1) / item_max, 1].max
  1992. end
  1993.  
  1994. def item_max
  1995. @persona ? @persona.max_skills : 1
  1996. end
  1997.  
  1998. def item_rect(index)
  1999. rect = Rect.new
  2000. rect.width = item_width
  2001. rect.height = item_height
  2002. rect.x = ((index/6).to_i * item_width) + 100
  2003. rect.y = (item_height * index.divmod(6)[1]) + line_height * 7
  2004. rect
  2005. end
  2006.  
  2007. def col_max
  2008. 3
  2009. end
  2010.  
  2011. def select_last
  2012. if extra_skills.empty?
  2013. select(-1)
  2014. else
  2015. select(0)
  2016. end
  2017. end
  2018.  
  2019. def cursor_down(wrap = false)
  2020. if col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?))
  2021. select((index + 1) % item_max)
  2022. end
  2023. end
  2024.  
  2025. def cursor_up(wrap = false)
  2026. if col_max >= 2 && (index > 0 || (wrap && horizontal?))
  2027. select((index - 1 + item_max) % item_max)
  2028. end
  2029. end
  2030.  
  2031. def cursor_right(wrap = false)
  2032. new_index = [index + 6, item_max - 1].min
  2033. if wrap && index >= item_max - 1
  2034. new_index = 0
  2035. end
  2036. select(new_index)
  2037. end
  2038.  
  2039. def cursor_left(wrap = false)
  2040. new_index = [index - 6, 0].max
  2041. if wrap && index == 0
  2042. new_index = item_max - 1
  2043. end
  2044. select(new_index)
  2045. end
  2046. end
  2047.  
  2048. class Scene_ForgetSkill < Scene_Base
  2049. alias persona_forget_start start
  2050. def start
  2051. persona_forget_start
  2052. create_windows
  2053. create_background
  2054. end
  2055.  
  2056. def start_without_bg
  2057. create_windows
  2058. end
  2059.  
  2060. def create_windows
  2061. create_main_viewport
  2062. create_status_window
  2063. create_message_window
  2064. create_new_skill_window
  2065. end
  2066.  
  2067. def create_status_window
  2068. @status_window = Window_PersonaStatus.new($game_party.menu_persona)
  2069. @status_window.set_handler(:cancel, method(:cancel_forget))
  2070. @status_window.set_handler(:forget, method(:skill_forget))
  2071. @status_window.show.activate
  2072. end
  2073.  
  2074. def create_background
  2075. @background_sprite = Sprite.new
  2076. @background_sprite.bitmap = SceneManager.background_bitmap
  2077. @background_sprite.color.set(16, 16, 16, 128)
  2078. end
  2079.  
  2080. def terminate
  2081. super
  2082. dispose_background
  2083. end
  2084.  
  2085. def dispose_background
  2086. @background_sprite.dispose if @background_sprite
  2087. end
  2088.  
  2089. def post_start
  2090. super
  2091. show_message if $game_party.menu_persona.extra_skills.size > 0
  2092. end
  2093.  
  2094. def show_message
  2095. $game_message.add("#{@status_window.persona.name} can't learn any new skills!\nSelect a skill to forget")
  2096. wait_for_message
  2097. @status_window.activate
  2098. end
  2099.  
  2100. def create_new_skill_window
  2101. @new_skill_window = Window_NewSkill.new(150, 24 * 5)
  2102. @new_skill_window.open
  2103. skill_id = $game_party.menu_persona.extra_skills[0]
  2104. skill = $data_skills[skill_id]
  2105. txt = "New skill: " + skill.name
  2106. @new_skill_window.text= txt
  2107. end
  2108.  
  2109. def create_message_window
  2110. $game_message.clear
  2111. @message_window = Window_Message.new
  2112. @choice = 0
  2113. end
  2114.  
  2115. def wait_for_message
  2116. @status_window.deactivate
  2117. @message_window.activate
  2118. @message_window.update
  2119. update_basic while $game_message.visible
  2120. end
  2121.  
  2122. def cancel_forget
  2123. persona = @status_window.persona
  2124. skill = persona.skills[@status_window.index]
  2125. new_skill = $data_skills[persona.extra_skills[0]]
  2126.  
  2127. $game_message.add("Are you sure you don't want #{persona.name}\nto learn #{new_skill.name}?")
  2128. $game_message.choices.push("Yes")
  2129. $game_message.choices.push("No")
  2130. $game_message.choice_cancel_type = 2
  2131. $game_message.choice_proc = Proc.new {|n| @choice = n }
  2132. wait_for_message
  2133. index = @status_window.index
  2134. if @choice == 0
  2135. @status_window.activate
  2136. persona.extra_skills.delete_at(0)
  2137. @status_window.refresh
  2138. $game_message.add("#{persona.name} didn't learn #{new_skill.name}!")
  2139. wait_for_message
  2140. else
  2141. @status_window.activate
  2142. return
  2143. end
  2144. finish_new_skill
  2145. end
  2146.  
  2147. def skill_forget
  2148. persona = @status_window.persona
  2149. @status_window.deactivate
  2150. skill = persona.skills[@status_window.index]
  2151. new_skill = $data_skills[persona.extra_skills[0]]
  2152. $game_message.add("Are you sure you want #{persona.name} to forget\n#{skill.name} and learn #{new_skill.name}?")
  2153. $game_message.choices.push("Yes")
  2154. $game_message.choices.push("No")
  2155. $game_message.choice_cancel_type = 2
  2156. $game_message.choice_proc = Proc.new {|n| @choice = n }
  2157. wait_for_message
  2158. index = @status_window.index
  2159. if @choice == 0
  2160. persona.replace_skill(skill, new_skill)
  2161. persona.extra_skills.delete_at(0)
  2162. @status_window.refresh
  2163. $game_message.add("#{persona.name} forgot #{skill.name} and learned\n#{new_skill.name}!")
  2164. wait_for_message
  2165. else
  2166. @status_window.activate
  2167. return
  2168. end
  2169. finish_new_skill
  2170. end
  2171.  
  2172. def next_new_skill
  2173. skill_id = $game_party.menu_persona.extra_skills[0]
  2174. skill = $data_skills[skill_id]
  2175. txt = "New skill: " + skill.name
  2176. @new_skill_window.text= txt
  2177. show_message
  2178. end
  2179.  
  2180. def finish_new_skill
  2181. if !$game_party.menu_persona.extra_skills.empty?
  2182. next_new_skill
  2183. else
  2184. @status_window.activate
  2185. @status_window.close
  2186. @new_skill_window.close
  2187. update_basic while @new_skill_window.openness > 0
  2188. SceneManager.return
  2189. end
  2190. end
  2191. end
  2192.  
  2193. #-------------------------------------------------------------------------------
  2194. # _ __ __ _ _
  2195. # / \ _ __ ___ __ _ _ __ __ _ | \/ | ___ __| |_ _| | ___
  2196. # / _ \ | '__/ __/ _` | '_ \ / _` | | |\/| |/ _ \ / _` | | | | |/ _ \
  2197. # / ___ \| | | (_| (_| | | | | (_| | | | | | (_) | (_| | |_| | | __/
  2198. # /_/ \_\_| \___\__,_|_| |_|\__,_| |_| |_|\___/ \__,_|\__,_|_|\___|
  2199. #
  2200. # Arcana Module
  2201. #-------------------------------------------------------------------------------
  2202. class RPG::Actor < RPG::BaseItem
  2203. def social_description
  2204. note =~ /<Social description: [\t]*([^\n\r]*)>/ ? $1 : ""
  2205. end
  2206.  
  2207. def min_arcana_rank
  2208. # min rank required to fuse persona
  2209. note =~ /<Arcana rank: (\d+)>/ ? $1.to_i : 0
  2210. end
  2211.  
  2212. def battletest_persona
  2213. # get persona to use for battletest
  2214. note =~ /<Battletest persona: (\d+)>/ ? $1.to_i : 0
  2215. end
  2216. end
  2217.  
  2218. class RPG::Class < RPG::BaseItem
  2219. def arcana?
  2220. note =~ /<Arcana>/ ? true : false
  2221. end
  2222.  
  2223. def rank_var_id
  2224. note =~ /<Rank variable: (\d+)>/ ? $1.to_i : nil
  2225. end
  2226.  
  2227. def max_rank
  2228. note =~ /<Max rank: (\d+)>/ ? $1.to_i : Persona::DEFAULT_MAX_RANK
  2229. end
  2230.  
  2231. def arcana_is?(arcana_name)
  2232. arcana_name == self.name
  2233. end
  2234.  
  2235. def social_target
  2236. note =~ /<Social target: [\t]*([^\n\r]*)>/ ? $1 : ""
  2237. end
  2238.  
  2239. def description
  2240. note =~ /<Description: [\t]*([^\n\r]*)>/ ? $1 : ""
  2241. end
  2242.  
  2243. def social_links
  2244. # gathers both actor ids and actor ids from variables and returns them
  2245. actors = social_links_actors
  2246. vars = []
  2247. social_links_variables.each{ |v| vars.push($game_variables[v]) if $game_variables[v] != -1 }
  2248. return (actors + vars).uniq
  2249. end
  2250.  
  2251. def social_links_actors
  2252. # return actor ids from tag
  2253. actors = /<Social links actors: (\d+(,[ ]?\d+)*)?>/.match(note)
  2254. return [] if actors.nil?
  2255. return actors[1].split(",").collect{ |i| i.to_i }
  2256. end
  2257.  
  2258. def social_links_variables
  2259. # return variable ids from tag
  2260. vars = /<Social links vars: (\d+(,[ ]?\d+)*)?>/.match(note)
  2261. return [] if vars.nil?
  2262. return vars[1].split(",").collect{ |i| i.to_i }
  2263. end
  2264. end
  2265.  
  2266. module Cache
  2267. def self.arcana(filename)
  2268. load_bitmap("Graphics/" + Persona::ARCANA_IMG_FOLDER, filename)
  2269. end
  2270.  
  2271. def self.persona_file(filename)
  2272. load_bitmap("Graphics/Persona/", filename)
  2273. end
  2274. end
  2275.  
  2276. class Game_Actor < Game_Battler
  2277. include Persona
  2278.  
  2279. attr_reader :social_description, :max_arcana_rank, :min_arcana_rank
  2280. alias persona_arcana_sp setup_persona
  2281. def setup_persona
  2282. persona_arcana_sp
  2283. @social_description = actor.social_description
  2284. @is_arcana = @is_persona ? self.class.arcana? : false
  2285.  
  2286. # check if a class exists with the same name as the nickname
  2287. nickname_of_arcana = !$data_classes.find{|c| !c.nil? && c.arcana? && c.name == @nickname }.nil?
  2288. if !@is_arcana && nickname_of_arcana
  2289. # if class is not of an arcana but the nickname is then actor is an arcana
  2290. @is_arcana = true
  2291. end
  2292.  
  2293. if nickname_of_arcana
  2294. # if nickname is of arcana, get the arcana class it belongs to
  2295. arcana_class = $data_classes.find{|c| !c.nil? && c.arcana? && c.name == @nickname }
  2296. else
  2297. arcana_class = self.class
  2298. end
  2299.  
  2300. @max_arcana_rank = @is_persona ? arcana_class.max_rank : nil
  2301. @rank_var_id = arcana_class.rank_var_id
  2302. @min_arcana_rank = actor.min_arcana_rank
  2303. end
  2304.  
  2305. alias persona_arcana_cep can_equip_persona
  2306. def can_equip_persona(persona)
  2307. persona.min_arcana_rank <= persona.arcana_rank && persona_arcana_cep(persona)
  2308. end
  2309.  
  2310. def arcana_name
  2311. # return appropriate arcana name
  2312. if @is_arcana && self.class.arcana?
  2313. return self.class.name
  2314. elsif @is_arcana
  2315. return @nickname
  2316. else
  2317. return ""
  2318. end
  2319. end
  2320.  
  2321. def arcana?
  2322. @is_arcana
  2323. end
  2324.  
  2325. def arcana_rank
  2326. $game_variables[@rank_var_id] if arcana?
  2327. end
  2328.  
  2329. def special_persona?
  2330. @is_special_persona
  2331. end
  2332. end
  2333.  
  2334. class Game_Player < Game_Character
  2335. include Persona
  2336. def arcana_rank_up(arcana_name)
  2337. # increases rank of arcana by one
  2338. arcana = $data_classes.find{ |c| !c.nil? && c.arcana? && c.name == arcana_name }
  2339. return if arcana.nil?
  2340. rank = $game_variables[arcana.rank_var_id]
  2341. rank += 1
  2342. $game_variables[arcana.rank_var_id] = [rank, 0].max
  2343. end
  2344.  
  2345. def arcana_rank_down(arcana_name)
  2346. # decreases rank of arcana by one
  2347. arcana = $data_classes.find{ |c| !c.nil? && c.arcana? && c.name == arcana_name }
  2348. return if arcana.nil?
  2349. rank = $game_variables[arcana.rank_var_id]
  2350. rank -= 1
  2351. $game_variables[arcana.rank_var_id] = [rank, 0].max
  2352. end
  2353.  
  2354. def arcana_rank_up_by(arcana_name, ranks_up)
  2355. ranks_up.times.do{ arcana_rank_up(arcana_name) }
  2356. end
  2357.  
  2358. def arcana_rank_down_by(arcana_name, ranks_down)
  2359. ranks_down.times.do{ arcana_rank_down(arcana_name) }
  2360. end
  2361.  
  2362. def available_arcanas
  2363. # returns arcanas which rank is higher than MIN_RANK
  2364. arcanas = $data_classes.select{ |c| !c.nil? && c.arcana? && !c.rank_var_id.nil? }
  2365. available_arcanas = arcanas.select{ |a| $game_variables[a.rank_var_id] >= MIN_RANK }
  2366. return available_arcanas
  2367. end
  2368. end
  2369.  
  2370. class Game_Variables
  2371. alias :arcana_rank :[]
  2372. def [](variable_id)
  2373. ret_val = arcana_rank(variable_id)
  2374.  
  2375. # get all arcanas that have a variable id for their rank
  2376. arcanas = $data_classes.select{ |c| !c.nil? && c.arcana? && !c.rank_var_id.nil? }
  2377. # get their variable id
  2378. ids = arcanas.collect{ |c| c.rank_var_id }
  2379.  
  2380. if ids.index(variable_id).nil?
  2381. # return value of variable if it is not an arcana's rank
  2382. return ret_val
  2383. else
  2384. # if id is one of arcanas' rank return its rank
  2385. # or if it is nil, return default value which is Persona::MIN_RANK - 1
  2386. @data[variable_id] || 0
  2387. end
  2388. end
  2389. end
  2390.  
  2391. class Window_ArcanaInfo < Window_Base
  2392. def initialize(arcana)
  2393. super(0, 0, window_width, window_height)
  2394. @selected_arcana = arcana
  2395. @arcana_y = 0
  2396. @info_x = 0
  2397. @info_y = 0
  2398. self.openness = 0
  2399. end
  2400.  
  2401. def window_width
  2402. Graphics.width
  2403. end
  2404.  
  2405. def window_height
  2406. Graphics.height * 0.35
  2407. end
  2408.  
  2409. def draw_arcana_rank
  2410. rank_str = " Rank #{$game_variables[@selected_arcana.rank_var_id]}"
  2411. w = text_size(rank_str).width
  2412. h = text_size(rank_str).height
  2413. draw_text(0, 0, w, h, rank_str)
  2414. @arcana_y += h
  2415. end
  2416.  
  2417. def draw_arcana
  2418. bitmap = Cache.arcana(@selected_arcana.name)
  2419. ratio_h = 1.0 - ((window_height - bitmap.height - @arcana_y - standard_padding*2).abs / bitmap.height.to_f)
  2420. ratio_h += (window_height > bitmap.height ? 1.0 : 0.0)
  2421. ratio_w = ratio_h
  2422. new_w = bitmap.width * ratio_w
  2423. new_h = (bitmap.height * ratio_h) - 2
  2424. new_rect = Rect.new(0, @arcana_y, new_w, new_h)
  2425. contents.stretch_blt(new_rect, bitmap, bitmap.rect)
  2426. bitmap.dispose
  2427.  
  2428. @info_x += new_w
  2429. end
  2430.  
  2431. def draw_arcana_name
  2432. if @selected_arcana.social_target.empty?
  2433. social_target = ""
  2434. else
  2435. social_target = @selected_arcana.social_target
  2436. end
  2437.  
  2438. text = " #{@selected_arcana.name} #{social_target}"
  2439. w = window_width
  2440. h = text_size(text).height
  2441. draw_text(@info_x, 0, w, h, text)
  2442.  
  2443. @info_y += h
  2444. end
  2445.  
  2446. def draw_arcana_info
  2447. text = @selected_arcana.description
  2448. return if text.empty?
  2449.  
  2450. words = text.split(" ")
  2451. line_num = 0
  2452.  
  2453. text_line = " " + words[0]
  2454. for i in 1..words.size
  2455. if i == words.size
  2456. w = window_width - @info_x
  2457. h = line_height
  2458. draw_text(@info_x, @info_y + line_num*h, w, h, text_line)
  2459. break
  2460. end
  2461.  
  2462. new_text = text_line + " " + words[i]
  2463. line_size = text_size(new_text)
  2464. if line_size.width + @info_x > window_width
  2465. w = line_size.width
  2466. h = line_height
  2467. draw_text(@info_x, @info_y + line_num*h, w, h, text_line)
  2468. line_num += 1
  2469. text_line = (" " + words[i])
  2470. else
  2471. text_line += (" " + words[i])
  2472. end
  2473. end
  2474. end
  2475.  
  2476. def refresh
  2477. contents.clear
  2478. return if @selected_arcana.nil?
  2479. draw_arcana_rank
  2480. draw_arcana
  2481. draw_arcana_name
  2482. draw_arcana_info
  2483. end
  2484.  
  2485. def draw_item_background(index)
  2486. if index == @pending_index
  2487. contents.fill_rect(item_rect(index), pending_color)
  2488. end
  2489. end
  2490. end
  2491.  
  2492. class Window_Arcanas < Window_Command
  2493. include Persona
  2494.  
  2495. def initialize
  2496. @arcanas = $game_player.available_arcanas
  2497. load_bitmaps
  2498. super(0, 0)
  2499. select_last
  2500. @selected_arcana = nil
  2501. self.openness = 0
  2502.  
  2503. end
  2504.  
  2505. def load_bitmaps
  2506. @progress_bar = Cache.persona_file(ARCANA_RANKS_BAR_IMG_NAME)
  2507. @subbar_empty = Cache.persona_file(ARCANA_PROGRESS_EMPTY_IMG_NAME)
  2508. @subbar_filled = Cache.persona_file(ARCANA_PROGRESS_IMG_NAME)
  2509. end
  2510.  
  2511. def dispose
  2512. super
  2513. dispose_bitmaps
  2514. end
  2515.  
  2516. def dispose_bitmaps
  2517. @progress_bar.dispose
  2518. @subbar_empty.dispose
  2519. @subbar_filled.dispose
  2520. end
  2521.  
  2522. def refresh
  2523. contents.clear
  2524. draw_all_items
  2525. end
  2526.  
  2527. def window_width
  2528. Graphics.width
  2529. end
  2530.  
  2531. def window_height
  2532. Graphics.height
  2533. end
  2534.  
  2535. def item_width
  2536. (width - standard_padding * 2 + spacing) / col_max - spacing
  2537. end
  2538.  
  2539. def item_height
  2540. (height - standard_padding * 2) / visible_line_number
  2541. end
  2542.  
  2543. def visible_line_number
  2544. 3
  2545. end
  2546.  
  2547. def item_max
  2548. @arcanas.size
  2549. end
  2550.  
  2551. def process_ok
  2552. call_show_rank_handler
  2553. end
  2554.  
  2555. def call_rank_handler
  2556. call_handler(:show_rank)
  2557. end
  2558. def rank_enabled?
  2559. handle?(:show_rank)
  2560. end
  2561.  
  2562. def draw_actor_simple_status(actor, x, y, enabled)
  2563. change_color(normal_color, enabled)
  2564. draw_actor_name(actor, x, y)
  2565. change_color(normal_color)
  2566. end
  2567.  
  2568. def draw_arcana(arcana, x, y)
  2569. bitmap = Cache.arcana(arcana.name)
  2570. ratio_h = 1 - ((item_height - bitmap.height).abs / bitmap.height.to_f)
  2571. ratio_h += (item_height > bitmap.height ? 1.0 : 0.0)
  2572. ratio_w = ratio_h
  2573. new_w = bitmap.width * ratio_w
  2574. new_h = (bitmap.height * ratio_h) - 2
  2575. new_rect = Rect.new(x, y, new_w, new_h)
  2576. contents.stretch_blt(new_rect, bitmap, bitmap.rect)
  2577. bitmap.dispose
  2578. end
  2579.  
  2580. def draw_rank_progress(x, y, index, width)
  2581. offset_x = width * index
  2582. height = @subbar_filled.height
  2583. rect = Rect.new(x + offset_x, y, width, height)
  2584. contents.stretch_blt(rect, @subbar_filled, @subbar_filled.rect)
  2585. end
  2586.  
  2587. def draw_rank_remaining(x, y, index, width)
  2588. offset_x = width * index
  2589. height = @subbar_empty.height
  2590. rect = Rect.new(x + offset_x, y, width, height)
  2591. contents.stretch_blt(rect, @subbar_empty, @subbar_empty.rect)
  2592. end
  2593.  
  2594. def draw_arcana_rank(arcana, x, y)
  2595. start_x = x + 100
  2596. start_y = y
  2597.  
  2598. rank = $game_variables[arcana.rank_var_id]
  2599. rank_str = sprintf("Rank %i", rank)
  2600. w = text_size(rank_str).width
  2601. h = text_size(rank_str).height
  2602. draw_text(start_x, start_y, w, h, rank_str)
  2603.  
  2604. start_y += h
  2605.  
  2606. bar_width = contents.width - start_x
  2607. rect = Rect.new(start_x, start_y, bar_width, @progress_bar.height)
  2608. contents.stretch_blt(rect, @progress_bar, @progress_bar.rect)
  2609. subbar_width = (bar_width.to_f) / arcana.max_rank
  2610.  
  2611. arcana_rank = $game_variables[arcana.rank_var_id]
  2612. for i in 0...arcana_rank
  2613. draw_rank_progress(start_x, start_y, i, subbar_width)
  2614. end
  2615.  
  2616. for i in arcana_rank...arcana.max_rank
  2617. draw_rank_remaining(start_x, start_y, i, subbar_width)
  2618. end
  2619. end
  2620.  
  2621. def draw_item_background(index)
  2622. if index == @pending_index
  2623. contents.fill_rect(item_rect(index), pending_color)
  2624. end
  2625. end
  2626.  
  2627. def draw_item(index)
  2628. arcana = @arcanas[index]
  2629.  
  2630. rect = item_rect(index)
  2631. draw_item_background(index)
  2632. draw_arcana(arcana, rect.x + 1, rect.y + 1)
  2633. draw_arcana_rank(arcana, rect.x + 1, rect.y + 1)
  2634. end
  2635.  
  2636. def current_item_enabled?
  2637. return true
  2638. end
  2639.  
  2640. def process_ok
  2641. super
  2642. @selected_arcana = @arcanas[index]
  2643. end
  2644.  
  2645. def select_last
  2646. if $game_party.menu_persona.nil?
  2647. select(0)
  2648. else
  2649. select($game_party.menu_persona.index || 0)
  2650. end
  2651. end
  2652.  
  2653. def pending_index=(index)
  2654. last_pending_index = @pending_index
  2655. @pending_index = index
  2656. redraw_item(@pending_index)
  2657. redraw_item(last_pending_index)
  2658. end
  2659.  
  2660. def selected_arcana
  2661. return @arcanas[@index]
  2662. end
  2663. end
  2664.  
  2665. class Window_MenuCommand < Window_Command
  2666. alias persona_arcana_mc make_command_list
  2667. def make_command_list
  2668. persona_arcana_mc
  2669. add_arcana_command
  2670. end
  2671.  
  2672. def add_arcana_command
  2673. # add arcana command to main menu
  2674. name = Persona::ARCANA_MENU_NAME
  2675. ext = nil
  2676. command = { :name=>name,
  2677. :symbol=>:social_links,
  2678. :enabled=>main_commands_enabled,
  2679. :ext=>ext}
  2680. index = Persona::ARCANA_MENU_COMMAND_INDEX - 1
  2681. index = [index, @list.length].min
  2682. @list.insert(index, command)
  2683. end
  2684. end
  2685.  
  2686. class Window_SocialLinkInfo < Window_Base
  2687. def initialize(x, y, social_link)
  2688. @window_height = line_height * 4
  2689. @window_width = Graphics.width - x
  2690. y = Graphics.height - @window_height
  2691. super(x, y, @window_width, @window_height)
  2692. @social_link = social_link
  2693. self.openness = 0
  2694. end
  2695.  
  2696. def social_link=(new_link)
  2697. @social_link = new_link
  2698. refresh
  2699. end
  2700.  
  2701. def window_width
  2702. @window_width
  2703. end
  2704.  
  2705. def window_height
  2706. @window_height
  2707. end
  2708.  
  2709. def draw_link_name
  2710. name = @social_link.name
  2711. w = window_width
  2712. h = text_size(name).height
  2713. draw_text(0, 0, w, h, name)
  2714. end
  2715.  
  2716. def draw_link_info
  2717. text = @social_link.social_description
  2718.  
  2719. words = text.split(" ")
  2720. text_line = words[0]
  2721. line_num = 1
  2722. words.size.times do |i|
  2723. if i == words.size - 1
  2724. line_size = text_size(text_line)
  2725. w = window_width
  2726. h = line_size.height
  2727. draw_text(0, line_num*h, w, h, text_line)
  2728. break
  2729. end
  2730.  
  2731. new_line = text_line + " " + words[i + 1]
  2732. line_size = text_size(new_line)
  2733. if line_size.width > window_width - standard_padding * 2
  2734. w = line_size.width
  2735. h = line_size.height
  2736. draw_text(0, line_num*h, w, h, text_line)
  2737. line_num += 1
  2738. text_line = words[i + 1]
  2739. else
  2740. text_line += ((text_line.size == 0 ? "" : " ") + words[i + 1])
  2741. end
  2742. end
  2743. end
  2744.  
  2745. def refresh
  2746. contents.clear
  2747. return if @social_link.nil?
  2748. draw_link_name
  2749. draw_link_info
  2750. end
  2751. end
  2752.  
  2753. class Window_SocialLinks < Window_Command
  2754. def initialize(arcana, x, y)
  2755. @arcana = arcana
  2756. @social_links_ids = @arcana.social_links
  2757. super(x, y)
  2758. select_last
  2759. self.openness = 0
  2760. end
  2761.  
  2762. def arcana=(arcana)
  2763. return if @arcana == arcana
  2764. @arcana = arcana
  2765. @social_links_ids = @arcana.social_links
  2766. refresh
  2767. select_last
  2768. end
  2769.  
  2770. def selected_social_link
  2771. return nil if @social_links_ids[@index].nil?
  2772. $game_actors[@social_links_ids[@index]]
  2773. end
  2774.  
  2775. def refresh
  2776. contents.clear
  2777. draw_all_items
  2778. end
  2779.  
  2780. def window_width
  2781. Graphics.width * 0.3
  2782. end
  2783.  
  2784. def window_height
  2785. [@arcana.social_links.size, 1].max * line_height + standard_padding * 2
  2786. end
  2787.  
  2788. def item_width
  2789. (width - standard_padding * 2 + spacing) / col_max - spacing
  2790. end
  2791.  
  2792. def item_height
  2793. (height - standard_padding * 2) / visible_line_number
  2794. end
  2795.  
  2796. def visible_line_number
  2797. @arcana.social_links.size == 0 ? 1 : @arcana.social_links.size
  2798. end
  2799.  
  2800. def item_max
  2801. @arcana.social_links.size
  2802. end
  2803.  
  2804. def process_handling
  2805. return unless open? && active
  2806. return true if Input.trigger?(:C)
  2807. super
  2808. end
  2809.  
  2810. def draw_item(index)
  2811. return if @social_links_ids.size == 0
  2812. social_link = @social_links_ids[index]
  2813. social_link = $game_actors[social_link]
  2814.  
  2815. rect = item_rect_for_text(index)
  2816. draw_actor_name(social_link, rect.x + 1, rect.y + 1, window_width - standard_padding)
  2817. end
  2818.  
  2819. alias persona_arcana_pcm process_cursor_move
  2820. def process_cursor_move
  2821. last_index = @index
  2822. persona_arcana_pcm
  2823. if @index != last_index
  2824. call_handler(:selection_changed)
  2825. end
  2826. end
  2827.  
  2828. def select_last
  2829. select(0)
  2830. end
  2831.  
  2832. def pending_index=(index)
  2833. last_pending_index = @pending_index
  2834. @pending_index = index
  2835. redraw_item(@pending_index)
  2836. redraw_item(last_pending_index)
  2837. end
  2838.  
  2839. def update
  2840. super
  2841. self.hide if @arcana.social_links.size == 0
  2842. end
  2843. end
  2844.  
  2845. class Scene_Arcanas < Scene_Base
  2846. def start
  2847. super
  2848. create_background
  2849. create_rank_window
  2850. end
  2851.  
  2852. def terminate
  2853. super
  2854. dispose_background
  2855. end
  2856.  
  2857. def create_background
  2858. @background_sprite = Sprite.new
  2859. @background_sprite.bitmap = SceneManager.background_bitmap
  2860. @background_sprite.color.set(16, 16, 16, 128)
  2861. end
  2862.  
  2863. def dispose_background
  2864. @background_sprite.dispose
  2865. end
  2866.  
  2867. def create_rank_window
  2868. @arcanas_window = Window_Arcanas.new
  2869. @arcanas_window.select_last
  2870. @arcanas_window.set_handler(:ok, method(:on_arcana_ok))
  2871. @arcanas_window.set_handler(:cancel, method(:return_scene))
  2872. @arcanas_window.open
  2873. end
  2874.  
  2875. def create_social_links_window
  2876. arcana = @arcanas_window.selected_arcana
  2877. x = 0
  2878. y = @info_window.height
  2879. @social_links_window = Window_SocialLinks.new(arcana, x, y)
  2880. @social_links_window.select_last
  2881. @social_links_window.refresh
  2882. @social_links_window.open
  2883. @social_links_window.set_handler(:cancel, method(:arcana_info_cancel))
  2884. @social_links_window.set_handler(:selection_changed, method(:social_link_changed))
  2885. @social_links_window.open
  2886. end
  2887.  
  2888. def create_description_window
  2889. @info_window = Window_ArcanaInfo.new(@arcanas_window.selected_arcana)
  2890. @info_window.refresh
  2891. @info_window.open
  2892. end
  2893.  
  2894. def create_social_link_info_window
  2895. return if @social_links_window.selected_social_link.nil?
  2896. x = @social_links_window.width
  2897. y = @social_links_window.y + @social_links_window.height
  2898. social_link = @social_links_window.selected_social_link
  2899. @social_link_info_window = Window_SocialLinkInfo.new(x, y, social_link)
  2900. @social_link_info_window.refresh
  2901. @social_link_info_window.open
  2902. end
  2903.  
  2904. def change_social_link
  2905. @social_link.dispose if @social_link
  2906. return if @social_links_window.selected_social_link.nil?
  2907. social_link = @social_links_window.selected_social_link
  2908. file_name = social_link.name.downcase.gsub(" ", "_")
  2909. @social_link = Sprite_SocialLink.new(@viewport, file_name)
  2910. x = @social_links_window.width
  2911. @social_link.x = x + (Graphics.width - x) / 2 - @social_link.width / 2
  2912. @social_link.y = @info_window.height
  2913. end
  2914.  
  2915. def social_link_changed
  2916. @social_link_info_window.social_link = @social_links_window.selected_social_link
  2917. change_social_link
  2918. end
  2919.  
  2920. def on_arcana_ok
  2921. @arcanas_window.hide
  2922. create_description_window
  2923. create_social_links_window
  2924. change_social_link
  2925. create_social_link_info_window
  2926. end
  2927.  
  2928. def arcana_info_cancel
  2929. @social_links_window.close
  2930. @info_window.close
  2931. @social_link_info_window.close if @social_link_info_window
  2932. @social_link.dispose if @social_link
  2933. @arcanas_window.show
  2934. @arcanas_window.active = true
  2935. end
  2936. end
  2937.  
  2938. class Scene_Menu < Scene_MenuBase
  2939. alias persona_arcana_ccw create_command_window
  2940. def create_command_window
  2941. persona_arcana_ccw
  2942. @command_window.set_handler(:social_links, method(:social_links))
  2943. end
  2944.  
  2945. def social_links
  2946. SceneManager.call(Scene_Arcanas)
  2947. end
  2948. end
  2949.  
  2950. #-------------------------------------------------------------------------------
  2951. # _____ _ _ _ __ __ _ _
  2952. # | ____|_ _____ | |_ _| |_(_) ___ _ __ | \/ | ___ __| |_ _| | ___
  2953. # | _| \ \ / / _ \| | | | | __| |/ _ \| '_ \ | |\/| |/ _ \ / _` | | | | |/ _ \
  2954. # | |___ \ V / (_) | | |_| | |_| | (_) | | | | | | | | (_) | (_| | |_| | | __/
  2955. # |_____| \_/ \___/|_|\__,_|\__|_|\___/|_| |_| |_| |_|\___/ \__,_|\__,_|_|\___|
  2956. #
  2957. # Evolution Module
  2958. #-------------------------------------------------------------------------------
  2959. class RPG::Actor < RPG::BaseItem
  2960. def evolve_at
  2961. note =~ /<Arcana evolve rank: (\d+)>/ ? $1.to_i : -1
  2962. end
  2963.  
  2964. def evolve_to
  2965. note =~ /<Evolve to: (.*)>/ ? $1 : ""
  2966. end
  2967. end
  2968.  
  2969. class Game_Actor < Game_Battler
  2970. include Persona
  2971.  
  2972. attr_reader :evolve_at, :evolve_to
  2973. alias persona_evolve_sp setup_persona
  2974. def setup_persona
  2975. persona_evolve_sp
  2976. @evolve_at = arcana? ? actor.evolve_at : -1
  2977. @evolve_to = arcana? ? actor.evolve_to : ""
  2978. end
  2979. end
  2980.  
  2981. class Game_Player < Game_Character
  2982. alias persona_evolve_aru arcana_rank_up
  2983. def arcana_rank_up(arcana_name)
  2984. persona_evolve_aru(arcana_name)
  2985. check_party_persona_evolve
  2986. end
  2987.  
  2988. def check_party_persona_evolve
  2989. # check members' personas first and if one will be evolved equip it
  2990. # automatically to the actor that had the persona equipped
  2991. members = $game_party.members
  2992. members.each do |m|
  2993. next if m.persona.nil?
  2994. persona = m.persona
  2995. if persona.arcana_rank == persona.evolve_at
  2996. evolved_persona = evolve_persona(persona)
  2997. m.change_persona(evolved_persona)
  2998. play_evolution
  2999. $game_party.menu_persona = evolved_persona
  3000. SceneManager.call(Scene_EvolvedPersona)
  3001. end
  3002. end
  3003.  
  3004. # find all others and evolve them
  3005. members_personas = members.collect{|m| m.persona }
  3006. personas = $game_party.personas
  3007. personas.each do |p|
  3008. next if !members_personas.find{|mp| mp == p}.nil?
  3009. if p.arcana_rank == p.evolve_at
  3010. evolved_persona = evolve_persona(p)
  3011. play_evolution
  3012. $game_party.menu_persona = evolved_persona
  3013. SceneManager.call(Scene_EvolvedPersona)
  3014. end
  3015. end
  3016. end
  3017.  
  3018. def evolve_persona(persona)
  3019. $game_party.remove_persona(persona.id)
  3020. evolved_persona = $data_actors.find{|a| !a.nil? && a.name == persona.evolve_to}
  3021. evolved_persona = $game_personas[evolved_persona.id]
  3022. $game_party.add_persona(evolved_persona.id)
  3023. $game_variables[EVOLVING_PERSONA_VAR_ID] = persona.name
  3024. $game_variables[RESULTING_PERSONA_VAR_ID] = evolved_persona.name
  3025. return evolved_persona
  3026. end
  3027.  
  3028. def play_evolution
  3029. common_event = $data_common_events[Persona::COMMON_EVENT_ID]
  3030. if common_event
  3031. child = Game_Interpreter.new
  3032. child.setup(common_event.list, 0)
  3033. child.run
  3034. end
  3035. end
  3036. end
  3037.  
  3038. class Scene_EvolvedPersona < Scene_Base
  3039. def start
  3040. super
  3041. create_background
  3042. @persona = $game_party.menu_persona
  3043. show_evolved
  3044. end
  3045.  
  3046. def show_evolved
  3047. create_status_window
  3048. @status_window.persona = @persona
  3049. @status_window.activate
  3050. @status_window.open
  3051. end
  3052.  
  3053. def terminate
  3054. super
  3055. dispose_background
  3056. end
  3057.  
  3058. def create_background
  3059. @background_sprite = Sprite.new
  3060. @background_sprite.bitmap = SceneManager.background_bitmap
  3061. @background_sprite.color.set(16, 16, 16, 128)
  3062. end
  3063.  
  3064. def dispose_background
  3065. @background_sprite.dispose
  3066. end
  3067.  
  3068. def create_status_window
  3069. @status_window = Window_PersonaStatus.new($game_party.menu_persona)
  3070. @status_window.set_handler(:ok, method(:close_status))
  3071. @status_window.set_handler(:cancel, method(:close_status))
  3072. @status_window.show.activate
  3073. end
  3074.  
  3075. def close_status
  3076. @status_window.close
  3077. SceneManager.return
  3078. end
  3079. end
  3080.  
  3081. #-------------------------------------------------------------------------------
  3082. # _____ _ __ __ _ _
  3083. # | ___| _ ___(_) ___ _ __ | \/ | ___ __| |_ _| | ___
  3084. # | |_ | | | / __| |/ _ \| '_ \ | |\/| |/ _ \ / _` | | | | |/ _ \
  3085. # | _|| |_| \__ \ | (_) | | | | | | | | (_) | (_| | |_| | | __/
  3086. # |_| \__,_|___/_|\___/|_| |_| |_| |_|\___/ \__,_|\__,_|_|\___|
  3087. #
  3088. # Fusion Module
  3089. #-------------------------------------------------------------------------------
  3090. class RPG::Actor < RPG::BaseItem
  3091. def fuse_parents
  3092. # matches all the <Fusion parents> tag in note
  3093. matches = note.scan(/<Fusion parents: (\d+),[ ]?(\d+)>/)
  3094. if matches.empty?
  3095. return nil
  3096. else
  3097. # for each <Fusion parents> tag, append the parents to a list and return
  3098. parents = []
  3099. for m in matches
  3100. parents.push([m[0].to_i, m[1].to_i])
  3101. end
  3102. return parents
  3103. end
  3104. end
  3105.  
  3106. def special_fusion
  3107. # get ids required for special fusion. returns empty list if there are no ids
  3108. # as it is now it matches more than 3 ids, but will return only the first 3
  3109. # kept as is for the future
  3110. matches = /<Special fusion: (\d+(,[ ]?\d+)*)?>/.match(note)
  3111. return [] if matches.nil?
  3112. parents = matches[1]
  3113. parents.split(",").collect{ |i| i.to_i }[0...3]
  3114. end
  3115.  
  3116. def are_parents(persona_a_id, persona_b_id)
  3117. parents_pairs = fuse_parents # get all parents of persona
  3118. return false if parents_pairs.nil?
  3119. if Persona::ORDER_MATTERS
  3120. # if order matters search for index of pair and return true if found
  3121. return !parents_pairs.index([persona_a_id, persona_b_id]).nil?
  3122. else
  3123. # sort each pair and search for index of pair provided
  3124. return !parents_pairs.map{|p| p.sort }.index([persona_a_id, persona_b_id].sort).nil?
  3125. end
  3126. end
  3127.  
  3128. def are_special_parents(parents)
  3129. s_p = special_fusion
  3130. if Persona::ORDER_MATTERS
  3131. return parents[0] == s_p[0] && parents[1] == s_p[1] && parents[2] == s_p[2]
  3132. else
  3133. return parents.inject(true){|r, p| r && s_p.index(p).nil? }
  3134. end
  3135. end
  3136. end
  3137.  
  3138. class Game_System
  3139. attr_reader :fuse_count
  3140. alias persona_fuse_init initialize
  3141. def initialize
  3142. persona_fuse_init
  3143. @fuse_count = 0
  3144. end
  3145.  
  3146. def fuse_personas(fuse_count)
  3147. @fuse_count = fuse_count
  3148. SceneManager.call(Scene_Fuse)
  3149. Fiber.yield
  3150. end
  3151.  
  3152. def get_fusion_child(parent_a, parent_b)
  3153. # get all personas that have parents
  3154. children = $data_actors.select{|a| !a.nil? && a.persona? && !a.fuse_parents.nil? }
  3155. # find child of those parents
  3156. child = children.find{|a| a.are_parents(parent_a.id, parent_b.id) }
  3157. return nil if child.nil?
  3158. return $game_actors[child.id]
  3159. end
  3160.  
  3161. def get_special_fusion(parents)
  3162. # get all
  3163. parents_ids = parents.collect{|p| p.id}
  3164. special = $data_actors.find{|a| !a.nil? && a.are_special_parents(parents_ids) }
  3165. return nil if special.nil?
  3166. return $game_actors[special.id]
  3167. end
  3168. end
  3169.  
  3170. class Window_ExtraExp < Window_Base
  3171. def initialize(x, y)
  3172. height = line_height * 2
  3173. super(x, y, 180, height)
  3174. @current_exp = 0
  3175. @exp_changed = false
  3176. self.visible = false
  3177. end
  3178.  
  3179. def set_width(txt)
  3180. contents.clear
  3181. if text_size(txt).width > self.width - standard_padding * 2
  3182. self.width = text_size(txt).width + standard_padding * 2
  3183. create_contents
  3184. end
  3185. end
  3186.  
  3187. def text=(txt)
  3188. draw_text(0, 0, self.width - standard_padding, line_height, txt)
  3189. end
  3190.  
  3191. def exp=(exp)
  3192. @current_exp = exp
  3193. @exp_changed = true
  3194. end
  3195.  
  3196. def update
  3197. super
  3198. update_exp if @exp_changed
  3199. end
  3200.  
  3201. def update_exp
  3202. contents.clear
  3203. draw_text(0, 0, self.width - standard_padding, line_height, "Bonus EXP:")
  3204. x = text_size("Bonus EXP:").width
  3205. draw_text(x - 10, 0, self.width - standard_padding - x, line_height, @current_exp, 2)
  3206. end
  3207. end
  3208.  
  3209. class Window_Fuse < Window_Command
  3210. include Persona
  3211.  
  3212. attr_reader :result, :children
  3213. def initialize(fuse_count)
  3214. @selected_personas = []
  3215. @fuse_count = fuse_count
  3216. @children = []
  3217. @result = nil
  3218. @personas = available_personas
  3219. super(0, 0)
  3220. select_last
  3221. end
  3222.  
  3223. def selected_personas
  3224. @selected_personas
  3225. end
  3226.  
  3227. def remove_last_persona
  3228. @selected_personas.pop
  3229. @result = nil
  3230. refresh
  3231. end
  3232.  
  3233. def reset
  3234. self.active = true
  3235. select_last
  3236. @selected_personas = []
  3237. @result = nil
  3238. @personas = available_personas
  3239. refresh
  3240. end
  3241.  
  3242. def refresh
  3243. contents.clear
  3244. refresh_children
  3245. draw_all_items
  3246. end
  3247.  
  3248. def refresh_children
  3249. @children.clear
  3250. # calculate children only when the last persona is not selected
  3251. return if @fuse_count - @selected_personas.size > 1
  3252. parent_a = @selected_personas[0]
  3253.  
  3254.  
  3255. if @fuse_count == 2
  3256. # normal fusion
  3257. for parent_b in @personas
  3258. child = $game_system.get_fusion_child(parent_a, parent_b)
  3259. @children.push(child)
  3260. end
  3261. elsif @fuse_count == 3
  3262. # special fusion
  3263. for persona_c in @personas
  3264. special_parents = @selected_personas + [persona_c]
  3265. child = $game_system.get_special_fusion(special_parents)
  3266. @children.push(child)
  3267. end
  3268. end
  3269. end
  3270.  
  3271. def window_width
  3272. Graphics.width / 2
  3273. end
  3274.  
  3275. def window_height
  3276. Graphics.height
  3277. end
  3278.  
  3279. def item_width
  3280. (width - standard_padding * 2 + spacing) / col_max - spacing
  3281. end
  3282.  
  3283. def item_height
  3284. line_height
  3285. end
  3286.  
  3287. def visible_line_number
  3288. 8
  3289. end
  3290.  
  3291. def item_max
  3292. @personas.size
  3293. end
  3294.  
  3295. def process_handling
  3296. return unless open? && active
  3297. return process_status if status_enabled? && Input.trigger?(:X)
  3298. return process_cancel if cancel_enabled? && Input.trigger?(:B)
  3299. return process_ok if ok_enabled? && Input.trigger?(:C)
  3300. end
  3301.  
  3302. def process_status
  3303. Sound.play_ok
  3304. $game_party.menu_persona = @personas[index]
  3305. call_status_handler
  3306. end
  3307.  
  3308. def call_status_handler
  3309. call_handler(:status)
  3310. end
  3311. def status_enabled?
  3312. handle?(:status)
  3313. end
  3314.  
  3315. def available_personas
  3316. actors = $game_party.members.select{ |a| !CAN_USE_ACTORS_PERSONAS.index(a.id).nil? }
  3317. personas = actors.inject([]){|res, a| res += $game_party.actors_personas(a.id)}
  3318. return personas
  3319. end
  3320.  
  3321. def process_cancel
  3322. Sound.play_cancel
  3323. Input.update
  3324. if @selected_personas.size == 0
  3325. call_return_handler
  3326. deactivate
  3327. else
  3328. @selected_personas.pop
  3329. refresh
  3330. call_cancel_handler
  3331. end
  3332. end
  3333.  
  3334. def call_cancel_handler
  3335. call_handler(:cancel)
  3336. end
  3337.  
  3338. def cancel_enabled?
  3339. handle?(:cancel)
  3340. end
  3341.  
  3342. def call_return_handler
  3343. call_handler(:return)
  3344. end
  3345.  
  3346. def process_ok
  3347. if current_item_enabled?
  3348. persona = @personas[index]
  3349. @selected_personas.push(persona)
  3350. Sound.play_ok
  3351. if @selected_personas.size == @fuse_count
  3352. # the result has the same index with the last persona picked
  3353. @result = @children[index]
  3354. call_fuse_handler
  3355. else
  3356. refresh
  3357. call_ok_handler
  3358. end
  3359. else
  3360. Sound.play_buzzer
  3361. end
  3362. end
  3363.  
  3364. def call_fuse_handler
  3365. call_handler(:fuse)
  3366. end
  3367.  
  3368. def fuse_enabled?
  3369. handle?(:fuse)
  3370. end
  3371.  
  3372. def draw_actor_level(persona, x, y)
  3373. change_color(system_color)
  3374. draw_text(x, y, 32, line_height, Vocab::level_a)
  3375. change_color(normal_color)
  3376. offset_x = text_size(Vocab::level_a).width
  3377. draw_text(x + offset_x, y, 24, line_height, persona.level)
  3378. end
  3379.  
  3380. def draw_persona_info(persona, x, y, enabled)
  3381. change_color(normal_color, enabled)
  3382. offset_x = 0
  3383.  
  3384. draw_actor_nickname(persona, x + offset_x, y)
  3385. offset_x += text_size(persona.arcana_name + " ").width
  3386.  
  3387. draw_actor_level(persona, x + offset_x, y)
  3388. offset_x += text_size(Vocab::level_a + persona.level.to_s + " ").width
  3389.  
  3390. draw_actor_name(persona, x + offset_x, y)
  3391. change_color(normal_color)
  3392. end
  3393.  
  3394. def draw_item_background(index)
  3395. if !@selected_personas.index(@personas[index]).nil?
  3396. color = pending_color
  3397. color.alpha = 100
  3398. contents.fill_rect(item_rect(index), color)
  3399. end
  3400. end
  3401.  
  3402. def draw_item(index)
  3403. persona = @personas[index]
  3404.  
  3405. enabled = !@selected_personas.index(persona).nil?
  3406. rect = item_rect(index)
  3407. draw_item_background(index)
  3408. draw_persona_info(persona, rect.x, rect.y, enabled)
  3409. end
  3410.  
  3411. def current_item_enabled?
  3412. persona = @personas[index]
  3413. return false if !@selected_personas.index(persona).nil?
  3414. return true if @selected_personas.size == 0
  3415. return true if @selected_personas.size < @fuse_count - 1
  3416. return !@children[index].nil?
  3417. end
  3418.  
  3419. def select_last
  3420. select(0)
  3421. end
  3422.  
  3423. def pending_index=(index)
  3424. last_pending_index = @pending_index
  3425. @pending_index = index
  3426. redraw_item(@pending_index)
  3427. redraw_item(last_pending_index)
  3428. end
  3429. end
  3430.  
  3431. class Window_FuseResults < Window_Base
  3432. include Persona
  3433.  
  3434. def initialize
  3435. @children = []
  3436. super(window_width, 0, window_width, window_height)
  3437. end
  3438.  
  3439. def children=(children)
  3440. @children = children
  3441. refresh
  3442. end
  3443.  
  3444. def refresh
  3445. contents.clear
  3446. @children.size.times{|i| draw_item(i)}
  3447. end
  3448.  
  3449. def window_width
  3450. Graphics.width / 2
  3451. end
  3452.  
  3453. def window_height
  3454. Graphics.height
  3455. end
  3456.  
  3457. def col_max
  3458. return 1
  3459. end
  3460.  
  3461. def spacing
  3462. return 32
  3463. end
  3464.  
  3465. def item_width
  3466. (width - standard_padding * 2 + spacing) / col_max - spacing
  3467. end
  3468.  
  3469. def item_height
  3470. line_height
  3471. end
  3472.  
  3473. def item_max
  3474. @children.size
  3475. end
  3476.  
  3477. def draw_actor_level(persona, x, y, enabled=true)
  3478. change_color(system_color, enabled)
  3479. draw_text(x, y, 32, line_height, Vocab::level_a)
  3480. change_color(normal_color, enabled)
  3481. offset_x = text_size(Vocab::level_a).width
  3482. draw_text(x + offset_x, y, 24, line_height, persona.level)
  3483. end
  3484.  
  3485. def draw_actor_class(actor, x, y, width = 112, enabled=true)
  3486. change_color(normal_color, enabled)
  3487. draw_text(x, y, width, line_height, actor.arcana_name)
  3488. end
  3489.  
  3490. def draw_actor_name(actor, x, y, width = 112, enabled=true)
  3491. change_color(hp_color(actor), enabled)
  3492. draw_text(x, y, width, line_height, actor.name)
  3493. end
  3494.  
  3495. def draw_item_background(index)
  3496. if @children[index].special_persona?
  3497. contents.fill_rect(item_rect(index), Persona::SPECIAL_FUSION_COLOR)
  3498. end
  3499. end
  3500.  
  3501. def draw_persona_info(persona, x, y, enabled)
  3502. offset_x = 0
  3503.  
  3504. draw_actor_nickname(persona, x + offset_x, y)
  3505. offset_x += text_size(persona.arcana_name + " ").width
  3506.  
  3507. draw_actor_level(persona, x + offset_x, y, enabled)
  3508. offset_x += text_size(Vocab::level_a + persona.level.to_s + " ").width
  3509.  
  3510. draw_actor_name(persona, x + offset_x, y, 112, enabled)
  3511. end
  3512.  
  3513. def item_rect(index)
  3514. rect = Rect.new
  3515. rect.width = item_width
  3516. rect.height = item_height
  3517. rect.x = index % col_max * (item_width + spacing)
  3518. rect.y = index / col_max * item_height
  3519. rect
  3520. end
  3521.  
  3522. def draw_item(index)
  3523. child = @children[index]
  3524. return if child.nil?
  3525. rect = item_rect(index)
  3526. users = $game_party.members.select{|m| !child.users.index(m.id).nil? }
  3527. enabled = true
  3528. draw_item_background(index)
  3529. draw_persona_info(child, rect.x, rect.y, enabled)
  3530. end
  3531. end
  3532.  
  3533. class Window_PersonaStatus < Window_Command
  3534. alias persona_fuse_init initialize
  3535. def initialize(persona)
  3536. persona_fuse_init(persona)
  3537. @bonus_exp = 0
  3538. @start_exp = false
  3539. @step = 0
  3540. @ok_enabled = false
  3541. end
  3542.  
  3543. def disable_ok
  3544. @ok_enabled = true
  3545. end
  3546.  
  3547. def enable_ok
  3548. @ok_enabled = false
  3549. end
  3550.  
  3551. alias persona_ph process_handling
  3552. def process_handling
  3553. if SceneManager.scene_is?(Scene_Fuse)
  3554. return process_ok if ok_enabled? && Input.trigger?(:C)
  3555. return process_cancel if cancel_enabled? && Input.trigger?(:B)
  3556. else
  3557. persona_ph
  3558. end
  3559. end
  3560.  
  3561. def ok_enabled?
  3562. handle?(:ok) && !@ok_enabled
  3563. end
  3564.  
  3565. def process_ok
  3566. Sound.play_ok
  3567. Input.update
  3568. deactivate
  3569. call_ok_handler
  3570. end
  3571.  
  3572. def bonus_exp=(exp)
  3573. @bonus_exp = exp
  3574. @step = @bonus_exp/30
  3575. end
  3576.  
  3577. def bonus_exp
  3578. @bonus_exp
  3579. end
  3580.  
  3581. def done_exp
  3582. @bonus_exp == 0
  3583. end
  3584.  
  3585. alias persona_fuse_u update
  3586. def update
  3587. update_bonus_exp
  3588. persona_fuse_u
  3589. end
  3590.  
  3591. def start_exp
  3592. @start_exp = true
  3593. end
  3594.  
  3595. def update_bonus_exp
  3596. if @start_exp
  3597. @bonus_exp = [@bonus_exp-@step, 0].max
  3598. new_exp = @persona.exp + ([@step, @bonus_exp].min * @persona.final_exp_rate).to_i
  3599. @persona.change_exp(new_exp, false)
  3600. @start_exp = @bonus_exp != 0
  3601. refresh
  3602. end
  3603. end
  3604. end
  3605.  
  3606. class Scene_Fuse < Scene_Base
  3607. def start
  3608. super
  3609. create_background
  3610. create_fuse_window
  3611. create_result_window
  3612. create_message_window
  3613. create_extra_exp_window
  3614. create_status_window
  3615. end
  3616.  
  3617. def terminate
  3618. super
  3619. dispose_background
  3620. end
  3621.  
  3622. def create_extra_exp_window
  3623. @extra_exp_window = Window_ExtraExp.new(350, 24 * 5)
  3624. end
  3625.  
  3626. def create_message_window
  3627. $game_message.clear
  3628. @message_window = Window_Message.new
  3629. @choice = -1
  3630. end
  3631.  
  3632. def create_fuse_window
  3633. @fuse_window = Window_Fuse.new($game_system.fuse_count)
  3634. @fuse_window.select_last
  3635. # called when a new persona is selected
  3636. @fuse_window.set_handler(:ok, method(:on_process_ok))
  3637. # called when the last persona for the fusion was selected and opens the status window
  3638. @fuse_window.set_handler(:fuse, method(:fuse))
  3639. # called when there are no selected personas and leaves the scene
  3640. @fuse_window.set_handler(:return, method(:return_scene))
  3641. # called when there are selected personas and removes the last chosen one
  3642. @fuse_window.set_handler(:cancel, method(:on_fuse_cancel))
  3643. # shows the selected persona's status
  3644. @fuse_window.set_handler(:status, method(:on_status_ok))
  3645. @fuse_window.z -= 2
  3646. end
  3647.  
  3648. def create_status_window
  3649. @status_window = Window_PersonaStatus.new($game_party.menu_persona)
  3650. # called when confirming a fusion
  3651. @status_window.set_handler(:ok, method(:fuse_confirm))
  3652. # called when viewing a persona's status and returns to fuse windows
  3653. @status_window.set_handler(:cancel, method(:return_status))
  3654. @status_window.deactivate
  3655. @status_window.z -= 1
  3656. end
  3657.  
  3658. def create_result_window
  3659. @results_window = Window_FuseResults.new
  3660. @results_window.z -= 2
  3661. end
  3662.  
  3663. def wait_for_message
  3664. @status_window.deactivate
  3665. @message_window.activate
  3666. @message_window.update
  3667. update_basic while $game_message.visible
  3668. @status_window.activate
  3669. end
  3670.  
  3671. def on_status_ok
  3672. @status_window.persona = $game_party.menu_persona
  3673. @status_window.show
  3674. @status_window.disable_ok
  3675. @fuse_window.deactivate
  3676. @status_window.activate
  3677. end
  3678.  
  3679. def return_status
  3680. return if @message_window.open?
  3681. @status_window.deactivate
  3682. @status_window.hide
  3683. @extra_exp_window.hide
  3684.  
  3685. @fuse_window.activate
  3686. @fuse_window.selected_personas.pop if @fuse_window.selected_personas.length == $game_system.fuse_count
  3687. end
  3688.  
  3689. def create_background
  3690. @background_sprite = Sprite.new
  3691. @background_sprite.bitmap = SceneManager.background_bitmap
  3692. @background_sprite.color.set(16, 16, 16, 128)
  3693. end
  3694.  
  3695. def dispose_background
  3696. @background_sprite.dispose
  3697. end
  3698.  
  3699. def on_process_ok
  3700. if @fuse_window.selected_personas.size == $game_system.fuse_count - 1
  3701. @results_window.children = @fuse_window.children
  3702. end
  3703. end
  3704.  
  3705. def on_fuse_cancel
  3706. @results_window.children = @fuse_window.children
  3707. end
  3708.  
  3709. def fuse
  3710. @status_window.persona = $game_personas[@fuse_window.result.id]
  3711. @fuse_window.deactivate
  3712. @status_window.enable_ok
  3713.  
  3714. persona = @fuse_window.result
  3715. bonus_exp = Persona.FUSION_EXP_CALC(persona).to_i
  3716. @status_window.bonus_exp = bonus_exp
  3717. txt = "Bonus EXP:"
  3718. @extra_exp_window.text = txt
  3719. @extra_exp_window.exp = bonus_exp
  3720. @extra_exp_window.set_width("Bonus EXP:#{bonus_exp}")
  3721.  
  3722. @status_window.show.activate
  3723. @extra_exp_window.show
  3724. end
  3725.  
  3726. def wait_for_exp
  3727. @status_window.start_exp
  3728. while !@status_window.done_exp
  3729. @extra_exp_window.exp= @status_window.bonus_exp
  3730.  
  3731. @extra_exp_window.update
  3732. @status_window.update
  3733. Graphics.update
  3734. end
  3735. @extra_exp_window.exp = @status_window.bonus_exp
  3736.  
  3737. @extra_exp_window.update
  3738. @status_window.update
  3739. end
  3740.  
  3741. def fuse_confirm
  3742. return if @choice == 0 # return if already accepted fusion
  3743. return if @fuse_window.result.nil?
  3744. $game_message.add("Are you sure you want to create the #{@fuse_window.result.name}")
  3745. $game_message.add("persona?")
  3746. $game_message.choices.push("Yes")
  3747. $game_message.choices.push("No")
  3748. $game_message.choice_cancel_type = 2
  3749. $game_message.choice_proc = Proc.new {|n| @choice = n }
  3750. wait_for_message
  3751. if @choice == 0
  3752. wait_for_exp
  3753. fusing = @fuse_window.selected_personas.collect{|p| p.name }.join(" + ")
  3754. $game_message.add("Fused #{fusing} into\n#{@fuse_window.result.name}!")
  3755. wait_for_message
  3756. for persona in @fuse_window.selected_personas
  3757. $game_party.remove_persona(persona.id)
  3758. end
  3759. $game_party.add_persona(@status_window.persona.id)
  3760.  
  3761. @extra_exp_window.hide
  3762. @status_window.hide
  3763. @results_window.children = []
  3764. @fuse_window.reset
  3765. @choice = -1
  3766. else
  3767. @message_window.close
  3768. @choice = -1
  3769. @fuse_window.remove_last_persona
  3770. return
  3771. end
  3772. end
  3773. end
  3774.  
  3775. #-------------------------------------------------------------------------------
  3776. # ____ _ __ __ _ __ __ _ _
  3777. # / ___|| |__ _ _ / _|/ _| | ___ | \/ | ___ __| |_ _| | ___
  3778. # \___ \| '_ \| | | | |_| |_| |/ _ \ | |\/| |/ _ \ / _` | | | | |/ _ \
  3779. # ___) | | | | |_| | _| _| | __/ | | | | (_) | (_| | |_| | | __/
  3780. # |____/|_| |_|\__,_|_| |_| |_|\___| |_| |_|\___/ \__,_|\__,_|_|\___|
  3781. #
  3782. # Shuffle Module
  3783. #-------------------------------------------------------------------------------
  3784. class RPG::Enemy < RPG::BaseItem
  3785. def drop_cards
  3786. return note.scan(/<Card drop: (.*), ([0-9][.]?[0-9]+)>/)
  3787. end
  3788. end
  3789.  
  3790. module Cache
  3791. def self.card(filename)
  3792. load_bitmap("Graphics/" + Persona::CARD_IMG_FOLDER, filename)
  3793. end
  3794. end
  3795.  
  3796. class Scene_Battle < Scene_Base
  3797. def hide_actor_window
  3798. @status_window.hide
  3799. 10.times do
  3800. @status_window.update
  3801. end
  3802. end
  3803. end
  3804.  
  3805. module BattleManager
  3806. class <<self
  3807. include Persona
  3808.  
  3809. attr_reader :cards_dropped
  3810.  
  3811. alias persona_shuffle_pv process_victory
  3812. def process_victory
  3813. @cards_dropped = $game_troop.make_drop_cards
  3814.  
  3815. @cards_dropped = $game_system.filter_cards(@cards_dropped)
  3816.  
  3817. if !@cards_dropped.empty?
  3818. SceneManager.scene.hide_actor_window
  3819. # call personastatus scene, start it and
  3820. # wait until scene has finished
  3821. # this is done because scene is not changing when called by the
  3822. # usual way (SceneManager.call(Scene_ForgetSkill)
  3823. # or maybe i'm doing something wrong (?). same with scene_personastatus
  3824. # in gain_exp method
  3825. SceneManager.call(Scene_Shuffle)
  3826. SceneManager.scene.start
  3827. wait_for_shuffle
  3828. end
  3829.  
  3830. if $game_system.shuffle_result == "Penalty"
  3831. # if player drew a penalty card then skip battle rewards
  3832. $game_message.add(PENALTY_CARD_RESULT_MSG)
  3833. $game_message.add(sprintf(Vocab::Victory, $game_party.name))
  3834. wait_for_message
  3835. SceneManager.return
  3836. battle_end(0)
  3837. replay_bgm_and_bgs
  3838. return true
  3839. else
  3840. if $game_system.shuffle_result == ""
  3841. $game_message.add(NO_CARD_RESULT_MSG)
  3842. elsif $game_system.shuffle_result == "Blank"
  3843. $game_message.add(BLANK_CARD_RESULT_MSG)
  3844. end
  3845. persona_shuffle_pv
  3846. end
  3847. end
  3848.  
  3849. alias persona_shuffle_ge gain_exp
  3850. def gain_exp
  3851. persona_shuffle_ge
  3852. $game_party.battle_personas.each do |m|
  3853. next if m.extra_skills.empty?
  3854. $game_party.menu_persona = m
  3855. SceneManager.call(Scene_ForgetSkill)
  3856. SceneManager.scene.start_without_bg
  3857. SceneManager.scene.show_message
  3858. SceneManager.scene.update while SceneManager.scene_is?(Scene_ForgetSkill)
  3859. end
  3860. end
  3861.  
  3862. alias persona_shuffle_bs battle_start
  3863. def battle_start
  3864. persona_shuffle_bs
  3865. $game_system.reset_shuffle_result
  3866. end
  3867.  
  3868. def wait_for_shuffle
  3869. # wait for shuffle_time to finish
  3870. SceneManager.scene.update while SceneManager.scene_is?(Scene_Shuffle)
  3871. Graphics.transition(30)
  3872. end
  3873. end
  3874. end
  3875.  
  3876. class Game_Enemy < Game_Battler
  3877. def make_drop_cards
  3878. cards = []
  3879. enemy.drop_cards.each do |card, prob|
  3880. if rand < prob.to_f * drop_item_rate
  3881. cards.push(card)
  3882. end
  3883. end
  3884. return cards
  3885. end
  3886. end
  3887.  
  3888. class Game_Message
  3889. alias persona_shuffle_init initialize
  3890. def initialize
  3891. persona_shuffle_init
  3892. shuffle_clear
  3893. end
  3894.  
  3895. def shuffle_busy?
  3896. shuffle_has_text?
  3897. end
  3898.  
  3899. def shuffle_clear
  3900. @shuffle_texts = []
  3901. end
  3902.  
  3903. def shuffle_add(text)
  3904. @shuffle_texts.push(text)
  3905. end
  3906.  
  3907. def shuffle_has_text?
  3908. @shuffle_texts.size > 0
  3909. end
  3910.  
  3911. def shuffle_all_text
  3912. @shuffle_texts.inject("") {|r, text| r += text + "\n" }
  3913. end
  3914. end
  3915.  
  3916. class Game_System
  3917. include Persona
  3918.  
  3919. attr_accessor :shuffle_result
  3920. alias persona_shuffle_init initialize
  3921. def initialize
  3922. persona_shuffle_init
  3923. @shuffle_result = nil
  3924. end
  3925.  
  3926. def reset_shuffle_result
  3927. @shuffle_result = nil
  3928. end
  3929.  
  3930. def shuffle_time
  3931. SceneManager.call(Scene_Shuffle)
  3932. Fiber.yield
  3933. end
  3934.  
  3935. def filter_cards(cards)
  3936. if !ALLOW_DUPLICATES
  3937. blanks = cards.count("Blank")
  3938. penalties = cards.count("Penalty")
  3939. # keep unique cards except blank and penalty
  3940. cards = cards.uniq.select{|c| ["Blank", "Penalty"].index(c).nil? }
  3941. # add blanks and penalties back
  3942. cards += (["Blank"] * blanks + ["Penalty"] * penalties)
  3943. end
  3944.  
  3945. if cards.uniq.sort == ["Blank", "Penalty"] || cards.empty?
  3946. # if there are only blank and penalty cards then just empty the
  3947. # list and return, so that there is no shuffle time
  3948. return []
  3949. elsif cards.select{|c| c != "Blank" || c != "Penalty"}.length < MIN_CARDS_TO_SHUFFLE
  3950. return []
  3951. end
  3952.  
  3953. # count penalty and blank cards dropped
  3954. penalty_cnt = cards.count("Penalty")
  3955. blank_cnt = cards.count("Blank")
  3956.  
  3957. # check for min and max penalty/blank cards and "fix" the number
  3958.  
  3959. if penalty_cnt < MIN_PENALTY_CARDS
  3960. (MIN_PENALTY_CARDS - penalty_cnt).times{ cards.push("Penalty") }
  3961. elsif penalty_cnt > MAX_PENALTY_CARDS
  3962. cards.delet("Penalty")
  3963. MAX_PENALTY_CARDS.times{ cards.push("Penalty") }
  3964. end
  3965.  
  3966. if penalty_cnt < MIN_BLANK_CARDS
  3967. (MIN_BLANK_CARDS - penalty_cnt).times{ cards.push("Blank") }
  3968. elsif penalty_cnt > MAX_BLANK_CARDS
  3969. cards.delet("Blank")
  3970. MAX_BLANK_CARDS.times{ cards.push("Blank") }
  3971. end
  3972. return cards.shuffle
  3973. end
  3974. end
  3975.  
  3976. class Game_Troop < Game_Unit
  3977. def make_drop_cards
  3978. dead_members.inject([]) {|r, enemy| r += enemy.make_drop_cards }
  3979. end
  3980. end
  3981.  
  3982. class Window_AcceptShuffle < Window_Command
  3983. include Persona
  3984.  
  3985. def initialize
  3986. clear_command_list
  3987. make_command_list
  3988. x, y = get_window_position
  3989. super(x, y)
  3990. self.z = 250
  3991. self.openness = 0
  3992. refresh
  3993. select(0)
  3994. activate
  3995. end
  3996.  
  3997. def get_window_position
  3998. case WINDOW_POSITIONS[ACCEPT_POSITION]
  3999. when "BL"
  4000. x = 0
  4001. y = Graphics.height - window_height
  4002. when "BR"
  4003. x = Graphics.width - window_width
  4004. y = Graphics.height - window_height
  4005. when "TL"
  4006. x = 0
  4007. y = 0
  4008. when "TR"
  4009. x = Graphics.width - window_width
  4010. y = 0
  4011. end
  4012. return x, y
  4013. end
  4014.  
  4015. def update_open
  4016. self.openness += 16
  4017. @opening = false if open?
  4018. end
  4019.  
  4020. def visible_line_number
  4021. 2
  4022. end
  4023.  
  4024. def make_command_list
  4025. add_command("Accept", :accept, true)
  4026. add_command("Decline", :decline, true)
  4027. end
  4028. end
  4029.  
  4030. class Window_MatchCounter < Window_Base
  4031. include Persona
  4032. def initialize(max_tries)
  4033. @max_tries = max_tries
  4034. @tries_left = max_tries + 1
  4035. height = fitting_height(1)
  4036. x, y = get_window_position
  4037. super(x, y, window_width, window_height)
  4038. self.z = 250
  4039. self.openness = 0
  4040. tried
  4041. end
  4042.  
  4043. def get_window_position
  4044. case WINDOW_POSITIONS[ACCEPT_POSITION]
  4045. when "BL"
  4046. x = 0
  4047. y = Graphics.height - window_height
  4048. when "BR"
  4049. x = Graphics.width - window_width
  4050. y = Graphics.height - window_height
  4051. when "TL"
  4052. x = 0
  4053. y = 0
  4054. when "TR"
  4055. x = Graphics.width - window_width
  4056. y = 0
  4057. end
  4058. return x, y
  4059. end
  4060.  
  4061. def window_width
  4062. 180
  4063. end
  4064.  
  4065. def window_height
  4066. fitting_height(1)
  4067. end
  4068.  
  4069. def tried
  4070. @tries_left -= 1
  4071. txt = "Tries left: #{@tries_left}/#{@max_tries}"
  4072. contents.clear
  4073. draw_text(0, 0, self.width - standard_padding, line_height, txt)
  4074. end
  4075.  
  4076. def lost?
  4077. return @tries_left == 0
  4078. end
  4079. end
  4080.  
  4081. class Window_ShuffleMessage < Window_Message
  4082. def update_fiber
  4083. if @fiber
  4084. @fiber.resume
  4085. elsif $game_message.shuffle_busy? && !$game_message.scroll_mode
  4086. @fiber = Fiber.new { fiber_main }
  4087. @fiber.resume
  4088. else
  4089. $game_message.visible = false
  4090. end
  4091. end
  4092.  
  4093. def fiber_main
  4094. $game_message.visible = true
  4095. update_background
  4096. update_placement
  4097. loop do
  4098. process_all_text if $game_message.shuffle_has_text?
  4099. process_input
  4100. $game_message.shuffle_clear
  4101. @gold_window.close
  4102. Fiber.yield
  4103. break unless text_continue?
  4104. end
  4105. close_and_wait
  4106. $game_message.visible = false
  4107. @fiber = nil
  4108. end
  4109.  
  4110. def process_all_text
  4111. open_and_wait
  4112. text = convert_escape_characters($game_message.shuffle_all_text)
  4113. pos = {}
  4114. new_page(text, pos)
  4115. process_character(text.slice!(0, 1), text, pos) until text.empty?
  4116. end
  4117.  
  4118. def text_continue?
  4119. $game_message.shuffle_has_text? && !settings_changed?
  4120. end
  4121.  
  4122. def new_page(text, pos)
  4123. contents.clear
  4124. reset_font_settings
  4125. pos[:x] = 0
  4126. pos[:y] = 0
  4127. pos[:new_x] = 0
  4128. pos[:height] = calc_line_height(text)
  4129. clear_flags
  4130. end
  4131. end
  4132.  
  4133. class Scene_Shuffle < Scene_Base
  4134. include Persona
  4135.  
  4136. def start
  4137. super
  4138. create_attributes
  4139. create_acceptance_window
  4140. create_counter_window
  4141. create_background
  4142. create_paths
  4143. start_cards_appear
  4144. setup_music
  4145. end
  4146.  
  4147. def terminate
  4148. super
  4149. @cards.each{|c| c.dispose}
  4150. @background_sprite.dispose
  4151. end
  4152.  
  4153. def start_cards_appear
  4154. @cards.each{ |card| card.start_effect(:appear)}
  4155. end
  4156.  
  4157. def setup_music
  4158. @last_bgm = RPG::BGM.last
  4159. @last_bgs = RPG::BGS.last
  4160.  
  4161. Audio.bgm_play(*SHUFFLE_BGM) if !SHUFFLE_BGM.nil?
  4162. Audio.bgs_play(*SHUFFLE_BGS) if !SHUFFLE_BGS.nil?
  4163. end
  4164.  
  4165. def create_attributes
  4166. get_cards
  4167. # center of screen
  4168. @cx = (Graphics.width / 2).to_i
  4169. @cy = (Graphics.height / 2).to_i
  4170.  
  4171. # dimensions of the cards
  4172. card_bitmap = Cache.card("Blank")
  4173. @card_width = card_bitmap.width
  4174. @card_height = card_bitmap.height
  4175.  
  4176. # result of shuffle
  4177. @card_selected = nil
  4178.  
  4179. @message_window = Window_ShuffleMessage.new
  4180. @counter_window = nil
  4181.  
  4182. # determine shuffle method from variable or other
  4183. if $game_variables[FORCE_SHUFFLE_METHOD_VAR_ID] == 0
  4184. @shuffle_method = Persona.SHUFFLE_SELECTION(@cards)
  4185. else
  4186. @shuffle_method = $game_variables[FORCE_SHUFFLE_METHOD_VAR_ID]
  4187. $game_variables[FORCE_SHUFFLE_METHOD_VAR_ID] = 0
  4188. end
  4189. # current phase of the shuffle time process
  4190. @shuffle_phase = "Show"
  4191. @shuffle_paths = []
  4192.  
  4193. @cursor_index = 0
  4194. end
  4195.  
  4196. def get_cards
  4197. card_items = BattleManager.cards_dropped
  4198. if $game_variables[SHUFFLE_ITEMS_VAR_ID] != 0
  4199. card_items = $game_variables[SHUFFLE_ITEMS_VAR_ID]
  4200. $game_variables[SHUFFLE_ITEMS_VAR_ID] = nil
  4201. card_items = $game_system.filter_cards(card_items) if FILTER_MANUAL_CARDS
  4202. else
  4203. card_items = BattleManager.cards_dropped
  4204. end
  4205.  
  4206. if card_items.nil? || card_items == 0
  4207. msgbox("No cards were defined in variable with id #{SHUFFLE_ITEMS_VAR_ID} for the shuffle time!")
  4208. cancel_shuffle
  4209. return
  4210. end
  4211.  
  4212. @cards = card_items.collect{|c| Sprite_Card.new(@viewport, c) }
  4213. end
  4214.  
  4215. def create_acceptance_window
  4216. @acceptance_window = Window_AcceptShuffle.new
  4217. @acceptance_window.set_handler(:accept, method(:start_shuffle_time))
  4218. @acceptance_window.set_handler(:cancel, method(:cancel_shuffle))
  4219. @acceptance_window.open
  4220. end
  4221.  
  4222. def create_counter_window
  4223. @counter_window = Window_MatchCounter.new(MATCHING_TRIES)
  4224. end
  4225.  
  4226. def start_shuffle_time
  4227. @acceptance_window.close
  4228. if @shuffle_method == "Matching"
  4229. start_matching
  4230. else
  4231. start_shuffle
  4232. end
  4233. end
  4234.  
  4235. def start_shuffle
  4236. @cards.each_with_index do |card, i|
  4237. x1 = card.x
  4238. y1 = card.y
  4239. x2 = @shuffle_paths[i][0][0]
  4240. y2 = @shuffle_paths[i][0][1]
  4241. # basically makes the card wait some frames before it goes to the
  4242. # shuffle path. all cards go one by one
  4243. wait = []
  4244. (@shuffle_paths[0].size / @cards.size * i).times do |i|
  4245. wait.push([x1, y1])
  4246. end
  4247. # appends to the wait list the intermediate points between the current
  4248. # position of the card and the starting position in the shuffle path
  4249. card.current_path = wait + get_intermediate_points(x1, y1, x2, y2)
  4250. card.repeat_path = false
  4251. card.start_effect(:flip) # make the card flip face down
  4252. end
  4253.  
  4254. @shuffle_phase = "Shuffle"
  4255. # calculate all x,y indexes of the cards. used only for up and down movement
  4256. # in matching shuffle method
  4257. @card_indexes = @cards.each_with_index.collect{|n, i| [i/MAX_CARDS_PER_ROW, i%MAX_CARDS_PER_ROW]}
  4258. end
  4259.  
  4260. def start_matching
  4261. new_cards = []
  4262.  
  4263. # picks random cards and shows them for a short amount of frames
  4264. @cards.sample(@cards.size/2).each{ |c| c.tease=true }
  4265.  
  4266. # diplicates all the cards for the matching method
  4267. @cards.each{ |card| new_cards.push(Sprite_Card.new(@viewport, card.card)) }
  4268.  
  4269. # shuffles all the cards, appends them together and shuffles them again
  4270. @cards = @cards.shuffle + new_cards.shuffle
  4271. @cards.shuffle!
  4272.  
  4273. # max cards per row
  4274. max_cols = MAX_CARDS_PER_ROW
  4275. @cards.each_with_index do |card, i|
  4276. # at first make all the cards go to the center of the screen
  4277. x1 = card.x
  4278. y1 = card.y
  4279. x2 = @cx - @card_width / 2
  4280. y2 = @cy - @card_height / 2
  4281. travel1 = get_intermediate_points(x1, y1, x2, y2)
  4282.  
  4283. # make them wait there for a second
  4284. wait = []
  4285. (Graphics.frame_rate).to_i.times do |i|
  4286. wait.push([x2, y2, 100])
  4287. end
  4288.  
  4289. x1 = @cx
  4290. y1 = @cy
  4291. # calculate their position in the matching process
  4292. x2, y2, z = show_position(i/max_cols, i%max_cols, max_cols)
  4293. # create path to that position
  4294. travel2 = get_intermediate_points(x1, y1, x2, y2)
  4295.  
  4296. # add the path to the card's path
  4297. card.current_path = travel1 + wait + travel2
  4298. # card does not loop this path
  4299. card.repeat_path = false
  4300. # flips them while they go to the center of the screen
  4301. card.start_effect(:flip)
  4302. end
  4303.  
  4304. @counter_window.open
  4305. # calculate all x,y indexes of the cards. used only for up and down movement
  4306. # in matching shuffle method
  4307. @card_indexes = @cards.each_with_index.collect{|n, i| [i/MAX_CARDS_PER_ROW, i%MAX_CARDS_PER_ROW]}
  4308. end
  4309.  
  4310. def cancel_shuffle
  4311. @last_bgm.replay
  4312. @last_bgs.replay
  4313. SceneManager.return
  4314. end
  4315.  
  4316. def create_background
  4317. @background_sprite = Sprite.new
  4318. if SHUFFLE_BACKGROUND
  4319. @background_sprite.bitmap = Cache.load_bitmap("Graphics/Persona/", SHUFFLE_BACKGROUND)
  4320. else
  4321. @background_sprite.bitmap = SceneManager.background_bitmap
  4322. end
  4323. end
  4324.  
  4325. def update
  4326. super
  4327. update_cards
  4328. determine_loss_matching if @shuffle_method == "Matching"
  4329. process_input if !teasing_phase
  4330. end
  4331.  
  4332. def update_all_windows
  4333. @acceptance_window.update
  4334. @counter_window.update
  4335. end
  4336.  
  4337. def determine_loss_matching
  4338. if @counter_window.lost?
  4339. @counter_window.close
  4340. @message_window.z = 250
  4341. $game_message.shuffle_add(MATCHING_LOSE_MESSAGE)
  4342. wait_for_message
  4343. SceneManager.return
  4344. finish_shuffle
  4345. end
  4346. end
  4347.  
  4348. def update_for_matched
  4349. Graphics.update
  4350. Input.update
  4351.  
  4352. $game_timer.update
  4353. update_matches
  4354. end
  4355.  
  4356. def update_matches
  4357. @cards.each{ |c| c.update }
  4358. end
  4359.  
  4360. def update_for_wait
  4361. Graphics.update
  4362. Input.update
  4363.  
  4364. $game_timer.update
  4365. @message_window.update
  4366. @counter_window.update if @counter_window
  4367. if @card_selected
  4368. update_selected_card
  4369. update_other_cards
  4370. end
  4371. end
  4372.  
  4373. def wait_for_message
  4374. @message_window.update
  4375. update_for_wait while $game_message.visible
  4376. end
  4377.  
  4378. def update_selected_card
  4379. @card_selected.update
  4380. end
  4381.  
  4382. def update_other_cards
  4383. @cards.each do |card|
  4384. next if card == @card_selected
  4385. card.update
  4386. end
  4387. end
  4388.  
  4389. def update_cards
  4390. @cards.each_with_index do |card, i|
  4391. card.update
  4392.  
  4393. # if it's a shuffle method, set its path in the shuffling and
  4394. # make it repeat it
  4395. if @shuffle_phase == "Shuffle"
  4396. if card.path_indx == card.current_path.size - 1 && !card.repeat_path
  4397. # if the card has reached its destination in the shuffle path
  4398. card.current_path = @shuffle_paths[i]
  4399. card.repeat_path = true
  4400. end
  4401. end
  4402. end
  4403. end
  4404.  
  4405. def teasing_phase
  4406. @cards.select{|c| c.teasing? }.length > 0
  4407. end
  4408.  
  4409. def cards_done_moving
  4410. @cards.inject(true){ |done, c| done && c.done_moving }
  4411. end
  4412.  
  4413. def process_input
  4414. # if last card is repeating its path then it has entered the shuffle loop
  4415. # therefore we accept input for selection
  4416. process_input_shuffle if @shuffle_phase == "Shuffle" && Input.trigger?(:C) && @cards[-1].repeat_path
  4417. process_input_matching if @shuffle_method == "Matching" && cards_done_moving
  4418. end
  4419.  
  4420. def process_input_shuffle
  4421. @shuffle_phase = "Selected"
  4422. # card selected is the one with the shortest distance between the
  4423. # center of the screen, with z value that of the max z value of the
  4424. # path the cards are following (is closer to the "screen")
  4425. Sound.play_ok
  4426. z = @cards[0].current_path.max_by{|coords| coords[2] }[2]
  4427. @card_selected = @cards.min_by{ |card| Math.sqrt((@cx - card.cx)**2 + (@cy - card.cy)**2 + (z - card.z)**2) }
  4428. show_selected_card
  4429.  
  4430. for card in @cards
  4431. next if card == @card_selected
  4432. card.start_effect(:disappear)
  4433. end
  4434.  
  4435. @card_selected.start_effect(:flip)
  4436. finish_shuffle
  4437. end
  4438.  
  4439. def process_input_matching
  4440. if @cards.inject(false){|done, c| done || c.tease }
  4441. # runs only once to quickly the cards that will be teased
  4442. @cards.each{|c| c.start_effect(:tease) if c.tease }
  4443. end
  4444.  
  4445. process_movement_input
  4446.  
  4447. if !@cards[@cursor_index].teasing? && !@cards[@cursor_index].flipping?
  4448. # if the current card is not being teased and is not being flipped
  4449. # then flash the card with red colour (meaning the cursor is on that
  4450. # card)
  4451. @cards[@cursor_index].start_effect(:matching_selected)
  4452. end
  4453.  
  4454. if Input.trigger?(:C) && !@cards[@cursor_index].match_selected?
  4455. Sound.play_ok
  4456.  
  4457. @cards[@cursor_index].revert_to_normal
  4458. # flip (show) selected card
  4459. @cards[@cursor_index].start_effect(:flip)
  4460. @cards[@cursor_index].match_selected = true
  4461.  
  4462. selected_cards = @cards.select{ |c| c.match_selected? }
  4463. if selected_cards.length == 2
  4464. # show cards for half a second
  4465. (Graphics.frame_rate / 2).to_i.times{ |i| update_for_matched }
  4466.  
  4467. if selected_cards[0].card != "Blank" && selected_cards[0].card == selected_cards[1].card
  4468. # keep selected cards face up and disappear all other
  4469. @cards.each{|c| c.start_effect(:disappear) if !c.match_selected? }
  4470. selected_cards[1].start_effect(:disappear)
  4471.  
  4472. @card_selected = selected_cards[0]
  4473. @counter_window.close
  4474. show_selected_card
  4475.  
  4476. finish_shuffle
  4477. else
  4478. Sound.play_cancel
  4479. @counter_window.tried
  4480. end
  4481.  
  4482. selected_cards.each do |c|
  4483. c.match_selected = false
  4484. c.start_effect(:flip)
  4485. end
  4486. end
  4487. end
  4488. end
  4489.  
  4490. def process_movement_input
  4491. # calculate x,y of current index
  4492. index = [@cursor_index/MAX_CARDS_PER_ROW, @cursor_index%MAX_CARDS_PER_ROW]
  4493. if Input.trigger?(:UP)
  4494. Sound.play_cursor
  4495. @cards[@cursor_index].revert_to_normal
  4496.  
  4497. # make row change more "natural"
  4498. index[0] -= 1 # previous row
  4499. # if it was first row and pressed up, go to last row
  4500. index[0] = @card_indexes[-1][0] if index[0] < 0
  4501. # if went from one row to another with different number of cards
  4502. # fix x index being more than the number of cards of that row
  4503. index[1] = @card_indexes[-1][1] if index[1] > @card_indexes[-1][1]
  4504. prev_card_x = @cards[@cursor_index].x
  4505. new_indx = index[0]*MAX_CARDS_PER_ROW + index[1]
  4506. # get all cards of new row
  4507. new_row_cards = @cards.select{|c| c.y == @cards[new_indx].y}
  4508. # get index of card in the new row with the closest x position as the
  4509. # last one
  4510. new_card = new_row_cards.each_with_index.min_by{|c, i| (c.x - prev_card_x).abs}[1]
  4511. # calculate new index in list of all cards
  4512. @cursor_index = new_card + index[0] * MAX_CARDS_PER_ROW
  4513. elsif Input.trigger?(:RIGHT)
  4514. Sound.play_cursor
  4515. @cards[@cursor_index].revert_to_normal
  4516.  
  4517. @cursor_index += 1
  4518. @cursor_index = 0 if @cursor_index > @cards.length - 1
  4519. elsif Input.trigger?(:DOWN)
  4520. Sound.play_cursor
  4521. @cards[@cursor_index].revert_to_normal
  4522.  
  4523. # same concept with :UP
  4524. index[0] += 1
  4525. index[0] = @card_indexes[0][0] if index[0] > @card_indexes[-1][0]
  4526. index[1] = @card_indexes[-1][1] if index[1] > @card_indexes[-1][1]
  4527. prev_card_x = @cards[@cursor_index].x
  4528. new_indx = index[0]*MAX_CARDS_PER_ROW + index[1]
  4529. new_row_cards = @cards.select{|c| c.y == @cards[new_indx].y}
  4530. new_card = new_row_cards.each_with_index.min_by{|c, i| (c.x - prev_card_x).abs}[1]
  4531. @cursor_index = new_card + index[0] * MAX_CARDS_PER_ROW
  4532. elsif Input.trigger?(:LEFT)
  4533. Sound.play_cursor
  4534. @cards[@cursor_index].revert_to_normal
  4535.  
  4536. @cursor_index -= 1
  4537. @cursor_index = @cards.length - 1 if @cursor_index < 0
  4538. end
  4539. end
  4540.  
  4541. def show_selected_card
  4542. x1 = @card_selected.x
  4543. y1 = @card_selected.y
  4544. x2 = @cx - @card_width / 2
  4545. y2 = @cy - @card_height
  4546. @card_selected.current_path = get_intermediate_points(x1, y1, x2, y2)
  4547. @card_selected.repeat_path = false
  4548. @card_selected.z = 150
  4549. end
  4550.  
  4551. def finish_shuffle
  4552. if @card_selected.nil?
  4553. Audio.se_play(*SHUFFLE_BLANK_SOUND)
  4554. $game_message.shuffle_add(NO_CARD_DRAW_MSG)
  4555. wait_for_message
  4556. elsif @card_selected.card == "Blank"
  4557. Audio.se_play(*SHUFFLE_BLANK_SOUND)
  4558. $game_message.shuffle_add(BLANK_CARD_DRAW_MSG)
  4559. wait_for_message
  4560. elsif @card_selected.card == "Penalty"
  4561. Audio.se_play(*SHUFFLE_PENALTY_SOUND)
  4562. $game_message.shuffle_add(PENALTY_CARD_DRAW_MSG)
  4563. wait_for_message
  4564. elsif !@card_selected.nil?
  4565. Audio.se_play(*SHUFFLE_CARD_SOUND)
  4566. $game_message.shuffle_add(sprintf(PERSONA_CARD_DRAW_MSG, @card_selected.card))
  4567. wait_for_message
  4568.  
  4569. persona = $data_actors.find{ |p| !p.nil? && p.name == @card_selected.card }
  4570. $game_party.add_persona(persona.id)
  4571. end
  4572. @last_bgm.replay
  4573. @last_bgs.replay
  4574. $game_system.shuffle_result = @card_selected.nil? ? "" : @card_selected.card
  4575. SceneManager.return
  4576. Graphics.fadeout(30)
  4577. terminate
  4578. end
  4579.  
  4580. def create_main_viewport
  4581. @viewport = Viewport.new
  4582. @viewport.z = 200
  4583. end
  4584.  
  4585. def create_paths
  4586. @cards.each_with_index do |card, i|
  4587. max_cols = MAX_CARDS_PER_ROW
  4588. x, y, z = show_position(i/max_cols, i%max_cols, max_cols)
  4589. card.starting_position(x, y)
  4590. card.current_path = [[x, y, z]]
  4591. card.repeat_path = true
  4592. end
  4593. create_shuffle_paths
  4594. end
  4595.  
  4596. def show_position(i, j, max_cols=MAX_CARDS_PER_ROW)
  4597. # number of cards on current row
  4598. row_cards = [max_cols, @cards.size - (i*max_cols)].min
  4599. # calculate y depending on the current row
  4600. y = (Graphics.height - @card_height * (@cards.size / max_cols + 1))/2 + i * @card_height
  4601. # calculate starting x depending on the number of cards in current row
  4602. start_x = Graphics.width / 2 - (@card_width / 2) * row_cards
  4603.  
  4604. # calculate x depending on width of card
  4605. x = start_x + @card_width * j
  4606. return x, y, 100
  4607. end
  4608.  
  4609. def get_intermediate_points(x1, y1, x2, y2)
  4610. dist_x = (x1 - x2).abs
  4611. dist_y = (y1 - y2).abs
  4612. up_x = x1 > x2 ? -1 : 1 # if card has to go to the right or left
  4613. up_y = y1 > y2 ? -1 : 1 # if card has to go upwards of downwards
  4614. total_pos = 15
  4615. xs = [*0..total_pos].collect{ |i| x1 + (i * up_x) * dist_x/total_pos}
  4616. ys = [*0..total_pos].collect{ |i| y1 + (i * up_y) * dist_y/total_pos}
  4617. movement_path = xs.zip(ys)
  4618. return movement_path
  4619. end
  4620.  
  4621. def create_shuffle_paths
  4622. case @shuffle_method
  4623. when "Horizontal"
  4624. @cards.size.times do |i|
  4625. @shuffle_paths.push(calculate_horizontal_path)
  4626. end
  4627. when "Diagonal"
  4628. @cards.size.times do |i|
  4629. if i % 2 == 0
  4630. @shuffle_paths.push(calculate_diagonal_path)
  4631. else
  4632. @shuffle_paths.push(calculate_diagonal_path(true))
  4633. end
  4634. end
  4635. when "Combination"
  4636. @cards.size.times do |i|
  4637. if i % 2 == 0
  4638. @shuffle_paths.push(calculate_horizontal_path)
  4639. else
  4640. @shuffle_paths.push(calculate_diagonal_path(rand > 0.5))
  4641. end
  4642. end
  4643. end
  4644. end
  4645.  
  4646. def calculate_horizontal_path
  4647. movement_path = []
  4648. xs = []
  4649. ys = []
  4650.  
  4651. sx = @card_width / 3 # left-most position
  4652. ex = Graphics.width - (@card_width + @card_width/4) # right-most position
  4653. sy = (Graphics.height - @card_height) / 2 # top-most position
  4654. width = ex - sx
  4655. total_distance = width * 2
  4656. # will take one second to make a full loop
  4657. step = (total_distance / Graphics.frame_rate)
  4658. xs = []
  4659. for i in (sx...ex).step(step)
  4660. xs.push(i)
  4661. end
  4662. xs = xs + xs.reverse
  4663.  
  4664. y_step = 3
  4665. z_step = 3
  4666. # x positions are calculated, now calculate the y and z depending on the
  4667. # x position
  4668. xs.size.times do |i|
  4669. if i <= xs.size / 4 # last quarter of the round
  4670. x = xs[i]
  4671. y = sy + i * y_step
  4672. z = 100 + i * z_step # incease z (comes closer and becomes bigger)
  4673. movement_path.push([x, y, z])
  4674. elsif i <= 2 * xs.size / 4 # first
  4675. x = xs[i]
  4676. y = movement_path[i - 1][1] - y_step
  4677. # decrease z (goes further away and becomes smaller)
  4678. z = movement_path[i - 1][2] - z_step
  4679. movement_path.push([x, y, z])
  4680. elsif i <= 3 * xs.size / 4 # second
  4681. x = xs[i]
  4682. y = movement_path[i - 1][1] - y_step
  4683. z = movement_path[i - 1][2] - z_step
  4684. movement_path.push([x, y, z])
  4685. else # third
  4686. x = xs[i]
  4687. y = movement_path[i - 1][1] + y_step
  4688. z = movement_path[i - 1][2] + z_step
  4689. movement_path.push([x, y, z])
  4690. end
  4691. end
  4692. return movement_path
  4693. end
  4694.  
  4695. def calculate_diagonal_path(mirrored=false)
  4696. movement_path = []
  4697. xs = []
  4698. ys = []
  4699.  
  4700. # left-most position
  4701. sx = @card_width / 4
  4702. # right-most position
  4703. ex = Graphics.width - @card_width
  4704. width = ex - sx
  4705. total_distance = width * 2
  4706. # will take one second to make a full loop
  4707. step = (total_distance / Graphics.frame_rate)
  4708. for i in (sx...ex).step(step)
  4709. xs.push(i)
  4710. end
  4711. # if mirrored goes from right to left first
  4712. if mirrored
  4713. xs = xs.reverse + xs
  4714. else
  4715. # else from left to right first
  4716. xs = xs + xs.reverse
  4717. end
  4718.  
  4719. # top-most position
  4720. sy = 0
  4721. # bottom-most position
  4722. ey = Graphics.height - @card_height
  4723. height = ey - sy
  4724. total_distance = height * 2
  4725. # will take one second to make a full loop
  4726. step = (total_distance / Graphics.frame_rate)
  4727. for i in (sy...ey).step(step)
  4728. ys.push(i)
  4729. end
  4730. ys = ys + ys.reverse
  4731.  
  4732. y_step = 3
  4733. z_step = 3
  4734. xs.size.times do |i|
  4735. if i <= xs.size / 4 # last quarter of loop
  4736. x = xs[i]
  4737. z = 100 + i * z_step
  4738. movement_path.push([x, ys[i], z])
  4739. elsif i <= 2 * xs.size / 4 # first
  4740. x = xs[i]
  4741. z = movement_path[i - 1][2] - z_step
  4742. movement_path.push([x, ys[i], z])
  4743. elsif i <= 3 * xs.size / 4 # second
  4744. x = xs[i]
  4745. z = movement_path[i - 1][2] - z_step
  4746. movement_path.push([x, ys[i], z])
  4747. else # last
  4748. x = xs[i]
  4749. z = movement_path[i - 1][2] + z_step
  4750. movement_path.push([x, ys[i], z])
  4751. end
  4752. end
  4753. return movement_path
  4754. end
  4755. end