Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #==============================================================================#
  2. #  #*****************#                                                         #
  3. #  #*** By Falcao ***#          * Falcao Pets Servants System 1.3              #
  4. #  #*****************#          This script allow you to have pet servants     #
  5. #                               that perform a avance command system helping   #
  6. #       RMVXACE                 the game player to complete tasks.             #
  7. #                               Date: Octuber 4 2012                           #
  8. #                                                                              #
  9. # Falcao RGSS site:  http://falcaorgss.wordpress.com                           #
  10. # Falcao Forum site: http://makerpalace.com                                    #
  11. #                                                                              #
  12. #==============================================================================#
  13.  
  14. # 1.3 change log
  15. # - Fixed minor bug when mood overload with other mood commands
  16. # - Added option to enable or disable the followers spot for the pet
  17.  
  18. #-------------------------------------------------------------------------------
  19. # * Installation
  20. #
  21. # Paste this script above main, no graphics required just copy and paste it into
  22. # your project, 5 item have been created in the database, witch are the gift
  23. # bundle items, if you are using my FA Interactive system 2.0 paste this script
  24. # below it, commons events has been created, to show how to make custom commands
  25. #
  26. #-------------------------------------------------------------------------------
  27. # * Features
  28. #
  29. # - Create as many pets you want at the pet factory below
  30. # - Assigns commands to the pets (you can create as many command you want)
  31. # - Pets level up
  32. # - Pets have a mood bar
  33. # - Pets give a gift bunndle when mood reach the maximun
  34. # - Each pet  give special bonus when is in use
  35. # - A avance command action system is implemented such as
  36. #   pet Steal, pet Grab objects, Pet Trigger targets, Pet Climb etc
  37. # - Pet minder Shop available!
  38. # - You can assign unique commands for each pet
  39. # - Pet are able to: create item, weapons, armor, gold, heal party, increase
  40. #   mood when dancing or playing with pet
  41. # - Custom command system implemented, so you can create your own fully
  42. #   custamizable commands via common events.
  43. # - Commands cooldown system, that mean you can assigh waiting time to each
  44. #   command available
  45. # - Mouse system buttons support!, you can select targets with the mouse in case
  46. #   you are using my mouse system buttons script
  47. #  
  48. #-------------------------------------------------------------------------------
  49. # * Compatibility
  50. #
  51. # Despite the complex of this system, i design this script to be compatible with
  52. # any other script, tested with ABS systems, pixel movement system etc
  53. #-------------------------------------------------------------------------------
  54. # * License
  55. #
  56. # For non-comercial games only
  57. # If you need this script for comercial games contact me  falmc99@gmail.com
  58. #-------------------------------------------------------------------------------
  59.  
  60. #-------------------------------------------------------------------------------
  61. #                            * Game flow usage
  62. #
  63. # Use the following events comments tags to complete pet tasks
  64. #
  65. # /PET TRIGGER             - The event start when touched by the pet, it is
  66. #                            usable with 'Trigger Targets cmd'
  67. # /PET CLIMB               - This make the event as a referencial point for
  68. #                            the command climb
  69. # /PET GRAB                - The event become grab-able for the pet
  70. #
  71. # /PET STEAL ITEM x        - Intead x put the item id you want the pet to steal
  72. #                            from the event. ex: PET STEAL ITEM 1
  73. # /PET STEAL WEAPON x      - Instead x put weapon id you want the pet to steal
  74. #                            from the event. ex: /PET STEAL WEAPON 5
  75. # /PET STEAL ARMOR x       - Instead x put armor id you want the pet to steal
  76. #                            from the event. ex: /PET STEAL ARMOR 3
  77. # /PET STEAL GOLD x        - Instead x put gold amount you want the pet to steal
  78. #                            from the event. ex: /PET STEAL GOLD 35
  79. # /PET STEAL CHANCE 1 / x  - Instead x put the probability to steal any kind
  80. #                            ex: /PET STEAL CHANCE 1 / 3 (chance one of three)
  81. # /IGNORE TARGETING          The tags above use a event target to perform action
  82. #                            this will avoid events on map from being targeted
  83. #
  84. # Important note:
  85. # The pet take only one task from the steal command per event, so if you assign
  86. # steal items, the pet going to steal items nothing else.
  87. #-------------------------------------------------------------------------------
  88. #                       * In-Game script calls
  89. #
  90. # SceneManager.call(Scene_PetShop)      Call the pet minder Shop
  91. # SceneManager.call(Scene_PetCommands)  Call manually the pet command window
  92. #
  93. # $game_player.gamepet.mood_cmd(x)      Instead x put mood command id to add  
  94.  
  95. # $game_player.adopt_pet(x)             If you dont want to buy pets from the
  96. #                                       shop you can add them manually, instead
  97. #                                       x put pet id from the pet factory
  98. #
  99. # See game demo for details and examples.
  100. #-------------------------------------------------------------------------------
  101.  
  102. module FalPet
  103.  
  104. #=============================================================================
  105. # * Pets global settings
  106.  
  107. # Starting Mood Maximun
  108.   StartingMoodMax = 30
  109.  
  110. # After how many gifts the pet level up?
  111.   Growing = 3
  112.  
  113. # Amount added to to the StartingMoodMax value when pet level up
  114.   MoodMaxPlus = 18
  115.  
  116. # The pet give you a gift when level up, define here the level and the gift
  117. # The maximun level will be the maximun gift
  118. # A = pet level   B = Item id
  119.   GiftBundle = {
  120.  
  121.   1 => 17,
  122.   2 => 18,
  123.   3 => 19,
  124.   4 => 20,
  125.   5 => 21,
  126.  
  127.   }
  128.  
  129. # Ballon id showed when the pet play
  130.   BalloonPlaying = 1
  131.  
  132. # Balloon played when pet play dead
  133.   PlayDeadBalloon = 8
  134.  
  135. # BGM played when pet dancing
  136.   DancingBgm = "Town7"
  137.  
  138. # Mood text when pet mood is low
  139.   MoodLowText = 'Cảm Thấy Buồn...'
  140.  
  141. # Mood text when pet mood is overage
  142.   MoodOverageText = 'Cảm Thấy Vui!'
  143.  
  144. # Mood text when pet mood is medium
  145.   MoodMediumText = 'Yêu Quá À!'
  146.  
  147. # Mood text when pet mood is hight
  148.   MoodHight = 'Tuyệt Vời!'
  149.  
  150. # Cursor icon index showed when selecting and event target
  151.   CursorIcon = 389
  152.  
  153. # Pet get stacked sometimes when performing action task such as Climb, Grab etc
  154. # after how many stucked times pet give up?
  155.   StuckCount = 15
  156.  
  157. # Buttom to call the pet commands, (W key from the keyboard)
  158.   CommandsKey = :R
  159.  
  160. # Do you want to use the key? you can call the scene commands manually
  161.   UseKey = true
  162.  
  163. # Allow the followers to yiled spot for the pet? change true or false
  164.   YieldSpot = true
  165. #=============================================================================
  166. #                      * Pet Factory
  167. #
  168. # You can create as many pets you want, set the prices, set speciallity skills
  169. # for each pet and give the entire party a bonus when using the pet, 10 pets
  170. # has been created as examples.
  171. #
  172.  
  173.   Pets = {
  174.                                                 #-----------------------------#
  175.                                                 #           * Sounds          #
  176.                                                 #
  177. # Pet Id      Graphic    Index     Name            Voice       Vol     Pitch
  178.     1   =>  ["kudo",     0,    "Phê Cần Xa",       "Dog",       80,     150],
  179.     2   =>  ["Animal",     1,    "Mitcha",        "Cat",       80,     100],
  180.     3   =>  ["$robot",  0,    "KSUI",         "Ice1",      100,    100],
  181.     4   =>  ["Animal",     3,    "Gordura",       "Coin",      80,     100],
  182.     5   =>  ["Animal",     4,    "Fart Cow",      "Cow",       80,     100],
  183.     6   =>  ["kusi",     5,    "Lucky",      "Horse",     80,     120],
  184.     7   =>  ["kudo",     1,    "Sói Sám",        "Wolf",     100,     150],
  185.     8   =>  ["Monster3",   5,    "Draconic",      "Monster6",  80,     150],
  186.     9   =>  ["$Spider",   0,    "Người Nhện",   "Monster3",  80,     150],
  187.     10  =>  ["Monster3",   4,    "Rataliony",     "Miss",      80,     100],
  188.  
  189.   }
  190.  
  191. # Edit the pet prices, this will be the price displayed at the pet shop
  192.   Price = {
  193.  
  194. #   Pet id   Price
  195.      1  =>   10000,
  196.      2  =>   200,
  197.      3  =>   700,
  198.      4  =>   100,
  199.      5  =>   500,
  200.      6  =>   3000,
  201.      7  =>   6000,
  202.      8  =>   8000,
  203.      9  =>   5000,
  204.      10 =>   900,
  205.      
  206.      
  207.  
  208.   }
  209.  
  210. # You can assign especific specialities for each pet, there are 16 commands
  211. # Availables listed below. (listed default ones only, you can create more!)
  212.  
  213. # 10 = Trigger Targets  14 = Heal Party       18 = Create Gold   22 = Custom4
  214. # 11 = Steal Items      15 = Create Items     19 = Rainsing S    23 = Custom5
  215. # 12 = Grab objects     16 = Create Weapons   20 = Custom2       24 = Custom6
  216. # 13 = Climb            17 = Create Armors    21 = Custom3       25 = Custom7
  217. #
  218. # Each command id going inside the arrays below
  219.   Speciality = {
  220.  
  221. # Pet id    Command Speciality ids
  222.     1  =>  [10, 11, 12, 13, 14, 15, 16, 17, 18],
  223.     2  =>  [16],
  224.     3  =>  [14, 19, 21],
  225.     4  =>  [17],
  226.     5  =>  [15],
  227.     6  =>  [12],
  228.     7  =>  [11],
  229.     8  =>  [10, 20],
  230.     9  =>  [13],
  231.     10 =>  [18],
  232.    
  233.   }
  234.  
  235.  
  236. # Game party guarantee a bonus when using specific pet, each parameters is added
  237. # when the pet is in use, and it is losed when you equip another pet
  238. # This is oriented to the 8 parameters available in game, this make a huge
  239. # diference for each pet. see examples below
  240.  
  241.   Bonus = {
  242.  
  243. # Pet id                 * Bonus Parameters
  244.     1  => [mhp =  10,   mmp =   0,   atk =   0,  defe =   0,
  245.            mat =   0,   mdf =   0,   agi =   0,  luk  =   0],
  246.          
  247.     2  => [mhp =  20,   mmp =  20,   atk =   2,  defe =  10,
  248.            mat =   1,   mdf =   1,   agi =  10,  luk  =  10],
  249.          
  250.     3  => [mhp = 200,   mmp = 200,   atk =   0,  defe =   20,
  251.            mat =   6,   mdf =   6,   agi =   0,  luk  =   0],
  252.  
  253.     4  => [mhp =   0,   mmp =   0,   atk =  10,  defe =   120,
  254.            mat =   0,   mdf =   0,   agi =   0,  luk  =   0],
  255.          
  256.     5  => [mhp = 100,   mmp =  50,   atk =   0,  defe =   0,
  257.            mat =   0,   mdf =   0,   agi =   0,  luk  =   0],
  258.          
  259.     6  => [mhp =   0,   mmp =   0,   atk =  10,  defe =   0,
  260.            mat =   0,   mdf =   0,   agi =   0,  luk  =  50],
  261.          
  262.     7  => [mhp =   0,   mmp =   0,   atk =   0,  defe =  60,
  263.            mat =   0,   mdf =  11,   agi =  10,  luk  =  10],
  264.  
  265.     8  => [mhp =  60,   mmp =  60,   atk =   9,  defe =   0,
  266.            mat =   0,   mdf =   0,   agi =   0,  luk  =   0],
  267.          
  268.     9  => [mhp =  50,   mmp =  50,   atk =  10,  defe =   0,
  269.            mat =   0,   mdf =   0,   agi =   0,  luk  =   0],
  270.    
  271.     10 => [mhp =   0,   mmp =   0,   atk =   0,  defe =  6,
  272.            mat =   0,   mdf =   0,   agi =  14,  luk  =  11],    
  273.          
  274.   }
  275.  
  276.  
  277. #=============================================================================
  278. #               * Pet Commands configuration
  279. #
  280. # There are 3 types of commands available, Defaults, Mood gain and Speciality
  281. #
  282. #- Defaults commands are the basics and are always available for the pets
  283. #- Moods gain commands are those commands that increase the mood of the pet
  284. #  by performing an act, like playing with pet, dancing atc.
  285. #- Speciality commands give the pet tasks to do, this category breaks into 3
  286. #  sub-categories such, Action, Casting and Custom
  287. #
  288. # Terms explanation
  289. #
  290. # Cmd_Name           - Command name
  291. # Cmd_IconIndex      - Command icon index
  292. # Cmd_Description    - Command short description
  293. # Cmd_CoolDown       - Cool Down is the time you have to wait to use a command
  294. #                      again, time is measured in seconds
  295. #
  296. # Cmd_MoodGain       - Amount of mood added to the pet when using a mood command
  297. # Cmd_ActionTime     - Time in frames of the command duration (only for custom)
  298. #
  299.  
  300. #===============================================================================
  301. # * Deafault commands
  302.  
  303.   # command 1
  304.   Cmd1_Name = 'Nghĩ Ngơi'
  305.   Cmd1_IconIndex = 217
  306.   Cmd1_Description = 'Cho Thú Cưng Nghĩ Ngơi'
  307.   Cmd1_CoolDown = 0
  308.  
  309.   # command 26
  310.   Cmd26_Name = 'Đổi Thú Cưng'
  311.   Cmd26_IconIndex = 168
  312.   Cmd26_Description = 'Nuôi Con Khác'
  313.   Cmd26_CoolDown = 0
  314.  
  315. #=============================================================================
  316. # * Mood gain commands (Play commands)
  317. #
  318. # There are 8 default moods commands available listed below
  319. #
  320. # 2 = Jumpa          4 = Take a breath   6 = Make a twist  8 = Dance
  321. # 3 = Turn around    5 = Chase jump      7 = Play dead     9 = Trampoline
  322. #
  323. # Moods commands are added manually to menu, use the next script calls to add
  324. # $game_player.gamepet.mood_cmd(id)       id = id of the mood command
  325.  
  326. # You can also set defaults mood commands, they will be added automatically
  327.   DeafaultMoodCommands = [2]
  328.  
  329.   # command 2
  330.   Cmd2_Name = 'Nhảy'
  331.   Cmd2_IconIndex = 122
  332.   Cmd2_Description = 'Nếu Thú Cưng Bạn Bùn Hãy Cho Chúng Nhảy'
  333.   Cmd2_CoolDown = 8
  334.   Cmd2_MoodGain = 4
  335.  
  336.   # command 3
  337.   Cmd3_Name = 'Khởi Động'
  338.   Cmd3_IconIndex = 12
  339.   Cmd3_Description = 'Khởi Động Làm Nhân Vật Vui Hơn'
  340.   Cmd3_CoolDown = 20
  341.   Cmd3_MoodGain = 8
  342.  
  343.   # command 4
  344.   Cmd4_Name = 'Take a breath'
  345.   Cmd4_IconIndex = 177
  346.   Cmd4_Description = 'Pet take a big breath'
  347.   Cmd4_CoolDown = 10
  348.   Cmd4_MoodGain = 6
  349.  
  350.   # command 5
  351.   Cmd5_Name = 'Đuổi Theo'
  352.   Cmd5_IconIndex = 176
  353.   Cmd5_Description = 'Nhảy Và Đuổi Theo Nhân Vật'
  354.   Cmd5_CoolDown = 18
  355.   Cmd5_MoodGain = 10
  356.  
  357.   # command 6
  358.   Cmd6_Name = 'Xoay Vòng'
  359.   Cmd6_IconIndex = 103
  360.   Cmd6_Description = 'Chơi Xoay Vòng'
  361.   Cmd6_CoolDown = 30
  362.   Cmd6_MoodGain = 16
  363.  
  364.   # command 7
  365.   Cmd7_Name = 'Giả Chết'
  366.   Cmd7_IconIndex = 1
  367.   Cmd7_Description = 'Chơi Trò Giả Chết'
  368.   Cmd7_CoolDown = 60
  369.   Cmd7_MoodGain = 22
  370.  
  371.   # command 8
  372.   Cmd8_Name = 'Nhảy Múa'
  373.   Cmd8_IconIndex = 118
  374.   Cmd8_Description = 'Thú Cưng Chơi Nhạc Sàn!'
  375.   Cmd8_CoolDown = 120
  376.   Cmd8_MoodGain = 46
  377.  
  378.   # command 9
  379.   Cmd9_Name = 'Trampoline'
  380.   Cmd9_IconIndex = 119
  381.   Cmd9_Description = 'Start making a trampoline!'
  382.   Cmd9_CoolDown = 120
  383.   Cmd9_MoodGain = 36
  384.  
  385. #=============================================================================
  386. # * Pet speciality commands configurations
  387. #=============================================================================
  388. # * Action commands
  389.  
  390.   # command 10
  391.   Cmd10_Name = 'Giúp Việc'
  392.   Cmd10_IconIndex = 398
  393.   Cmd10_Description = 'Chỉ Huy Pet Để Kích Hoạt Các Mục Tiêu Đã Chọn'
  394.   Cmd10_CoolDown = 0
  395.  
  396.   # command 11
  397.   Cmd11_Name = 'Ăn Cắp'
  398.   Cmd11_IconIndex = 9
  399.   Cmd11_Description = 'Chỉ Huy Thú Cưng Để Ăn Cắp Đồ Vật Và Tiền'
  400.   Cmd11_CoolDown = 0
  401.  
  402.   # command 12
  403.   Cmd12_Name = 'Lấy Đồ Vật'
  404.   Cmd12_IconIndex = 491
  405.   Cmd12_Description = 'Chỉ Huy Vật Nuôi Để Lấy Các Đối Tượng Được Lựa Chọn'
  406.   Cmd12_CoolDown = 0
  407.  
  408.   # command 13
  409.   Cmd13_Name = 'Leo Cây'
  410.   Cmd13_IconIndex = 275
  411.   Cmd13_Description = 'Chỉ Huy Các Vật Nuôi Để Giúp Các Chủ Sở Hữu Để Leo Lên'
  412.   Cmd13_CoolDown = 0
  413.  
  414. #=============================================================================
  415. # * Casting commands
  416.  
  417.   # command 14
  418.   Cmd14_Name = 'Hồi Máu'
  419.   Cmd14_IconIndex = 14
  420.   Cmd14_Description = 'Hồi Máu Cho Chủ Sở Hữu'
  421.   Cmd14_CoolDown = 60
  422.  
  423.   # This casting command heals your entire party by a percentage, there are four
  424.   # available: '25%'  '50%'   '75%'  '100%'
  425.   HealPercent = '75%'
  426. #---------------------
  427.  
  428.   # command 15
  429.   Cmd15_Name = 'Chế Tạo Vật Phẩm'
  430.   Cmd15_IconIndex = 213
  431.   Cmd15_Description = 'Tạo Vật Phẩm Ngẫu Nhiên Cho Chủ Sở Hữu'
  432.   Cmd15_CoolDown = 120
  433.  
  434.   # Animation played when pet is creating items
  435.   ItemAnime = 107
  436.  
  437.   # This command give you random items, add the participants items below
  438.   # A => B     A = Item id    B = Quantity
  439.   RandomItems = {
  440.  
  441.   1 =>  10,
  442.   2 =>  25,
  443.   6 =>  35,
  444.  
  445.   }
  446. #-----------------------
  447.  
  448.   # command 16
  449.   Cmd16_Name = 'Chế Tạo Vũ Khí'
  450.   Cmd16_IconIndex = 402
  451.   Cmd16_Description = 'Tạo Vũ Khí Ngẫu Nhiên Cho Chủ Sở Hữu'
  452.   Cmd16_CoolDown = 240
  453.  
  454.   # Animation played when pet is creating weapons
  455.   WeaponAnime = 107
  456.  
  457.   # This command give you random weapons, add the participants weapons below
  458.   # A => B     A = Weapon id    B = Quantity
  459.   RandomWeapons = {
  460.  
  461.   1 => 11,
  462.   2 => 2,
  463.   6 => 7,
  464.  
  465.   }
  466. #-------------------------
  467.  
  468.   # command 17
  469.   Cmd17_Name = 'Chế Tạo Áo Giáp'
  470.   Cmd17_IconIndex = 170
  471.   Cmd17_Description = 'Tạo Áo Giáp Ngẫu Nhiên Cho Chủ Sở Hữu'
  472.   Cmd17_CoolDown = 800
  473.  
  474.   # Animation played when pet is creating armors
  475.   ArmorAnime = 107
  476.  
  477.   # This command give you random armors, add the participants armors below
  478.   # A => B     A = Armor id    B = Quantity
  479.   RandomArmors = {
  480.  
  481.   1 => 17,
  482.   2 => 2,
  483.   6 => 8,
  484.  
  485.   }
  486. #--------------------------
  487.   # command 18
  488.   Cmd18_Name = 'Đẻ Vàng'
  489.   Cmd18_IconIndex = 344
  490.   Cmd18_Description = 'Đẻ Vàng Cho Cho Chủ Sở Hữu'
  491.   Cmd18_CoolDown = 700
  492.  
  493.   # Animation played when pet is creating gold
  494.   GoldAnime = 107
  495.  
  496.   # This command give you random gold, add the gold amount partisipant
  497.   # Random gold amount go inside the array
  498.   RandomGold = [100, 25, 77, 45, 88]
  499.  
  500.  
  501. #--------------------------
  502.   # command 19
  503.   Cmd19_Name = 'Đôi Tay Thần Thánh'
  504.   Cmd19_IconIndex = 112
  505.   Cmd19_Description = 'Sử Dụng Kĩ Năng Liên Tục Trong Thời Gian Ngắn!'
  506.   Cmd19_CoolDown = 1000
  507.  
  508.   # Instant cool down buff duration in seconds
  509.   BuffDuration = 60
  510.  
  511. #=============================================================================
  512. # * Custom commands
  513. #
  514. # Custom commands are designed to work via common events, a switch is activated
  515. # when the command time is running and it is deactivated when time ends.
  516. # So the common event should be parallel process as condition the switch
  517. # assigned below
  518.  
  519.   # Switch id that remains active when a custom command is running
  520.   CustomSwitch = 100
  521.  
  522. # List of special tasks you can give the pet inside the common event
  523. # when a custom command is running
  524. #
  525. # * Basics
  526. #
  527. # pet                  Get currently using pet
  528. # pet.cmd(id)          Get pet command (change id for command id integer)
  529. # pet.time?(x)         Get current command action time (change x for an integer)
  530. # pet.level            Get currently pet level
  531. # pet.ending?          Check if action time command is about to finish
  532. #
  533. # * Actions
  534. #
  535. # pet.prepare          Player and pet turn face to face  
  536. # pet.liedown          Pet lie down                
  537. # pet.reset_liedown    Pet stand up
  538. # pet.cast             Pet make a casting position
  539. # pet.jump_high(x,y,h) Jump higher than normal, chan x,y,h for an integer
  540. # pet.play_voice       Play the pet voice
  541. # pet.pop_mood         Pet start gaining the custom command mood assigned
  542. # pet.pop_text(t,time) Pet start poping a window with custom text, change
  543. #                      t for 'text to display' and time for time in seconds
  544. # pet.zoom(x, y)       Pet start zooming, change x,y for desire integers,  
  545. #                      zoom support decimals.
  546. # pet.reset_zoom       Reset zoom to normal size        
  547. #
  548. # Those are just special commands for the pet, since the pet is a character
  549. # he can use any command from the move route such as, move_up,
  550. # animation_id, balloon_id, move_away_from_player etc.
  551.  
  552.   # command 20
  553.   Cmd20_Name = 'Ngủ'
  554.   Cmd20_IconIndex = 6
  555.   Cmd20_Description = 'Bắt Đầu Ngủ'
  556.   Cmd20_CoolDown = 40
  557.   Cmd20_MoodGain = 12
  558.   Cmd20_ActionTime = 300
  559.   Cmd20_Type = 'Kinh Nghiệm +'
  560.  
  561.   # command 21
  562.   Cmd21_Name = 'Bảo Vệ'
  563.   Cmd21_IconIndex = 13
  564.   Cmd21_Description = 'Dùng Phép Thuật Bảo Vệ Bạn'
  565.   Cmd21_CoolDown = 120
  566.   Cmd21_MoodGain = 0
  567.   Cmd21_ActionTime = 200
  568.   Cmd21_Type = 'Phép Thuật'
  569.  
  570.   # command 22
  571.   Cmd22_Name = 'Command name'
  572.   Cmd22_IconIndex = 344
  573.   Cmd22_Description = 'Any description'
  574.   Cmd22_CoolDown = 5
  575.   Cmd22_MoodGain = 0
  576.   Cmd22_ActionTime = 200
  577.   Cmd22_Type = ''
  578.  
  579.   # command 23
  580.   Cmd23_Name = 'Command name'
  581.   Cmd23_IconIndex = 344
  582.   Cmd23_Description = 'Any description'
  583.   Cmd23_CoolDown = 5
  584.   Cmd23_MoodGain = 0
  585.   Cmd23_ActionTime = 200
  586.   Cmd23_Type = ''
  587.  
  588.   # command 24
  589.   Cmd24_Name = 'Command name'
  590.   Cmd24_IconIndex = 344
  591.   Cmd24_Description = 'Any description'
  592.   Cmd24_CoolDown = 5
  593.   Cmd24_MoodGain = 0
  594.   Cmd24_ActionTime = 200
  595.   Cmd24_Type = ''
  596.  
  597.   # command 25
  598.   Cmd25_Name = 'Command name'
  599.   Cmd25_IconIndex = 344
  600.   Cmd25_Description = 'Any description'
  601.   Cmd25_CoolDown = 5
  602.   Cmd25_MoodGain = 0
  603.   Cmd25_ActionTime = 200
  604.   Cmd25_Type = ''
  605.  
  606.   #-----------------------------------------------------------------------------
  607.   # * Commands database
  608.   Commands = {
  609.  
  610.   1 =>  [Cmd1_Name,   c = 1, ii = Cmd1_IconIndex,  t = 0,   tg = false, nil,
  611.          Cmd1_Description, Cmd1_CoolDown, 0, ty = 'Kích Hoạt'],
  612.   2 =>  [Cmd2_Name,  c = 2, Cmd2_IconIndex,      t = 160, tg = false, nil,
  613.          Cmd2_Description, Cmd2_CoolDown, Cmd2_MoodGain, ty = 'Kinh Nghiệm +'],
  614.   3 =>  [Cmd3_Name, c = 3, Cmd3_IconIndex, t = 160, tg = false, nil,
  615.          Cmd3_Description, Cmd3_CoolDown, Cmd3_MoodGain, ty = 'Kinh Nghiệm +'],
  616.   4 =>  [Cmd4_Name,      c = 4, ii = Cmd4_IconIndex,  t = 160, tg = false, nil,
  617.          Cmd4_Description, Cmd4_CoolDown, Cmd4_MoodGain, ty = 'Kinh Nghiệm +'],
  618.   5 =>  [Cmd5_Name,      c = 5, Cmd5_IconIndex,  t = 160, tg = false, nil,
  619.          Cmd5_Description, Cmd5_CoolDown, Cmd5_MoodGain, ty = 'Kinh Nghiệm+'],
  620.   6 =>  [Cmd6_Name,      c = 6, Cmd6_IconIndex,  t = 200, tg = false, nil,
  621.          Cmd6_Description, Cmd6_CoolDown, Cmd6_MoodGain, ty = 'Kinh Nghiệm +'],
  622.   7 =>  [Cmd7_Name,      c = 7, Cmd7_IconIndex,  t = 500, tg = false, nil,
  623.          Cmd7_Description, Cmd7_CoolDown, Cmd7_MoodGain, ty = 'Kinh Nghiệm +'],
  624.   8 =>  [Cmd8_Name,      c = 8, Cmd8_IconIndex,  t = 500, tg = false, nil,
  625.          Cmd8_Description, Cmd8_CoolDown, Cmd8_MoodGain, ty = 'Kinh Nghiệm +'],
  626.   9 =>  [Cmd9_Name,      c = 9, Cmd9_IconIndex,  t = 400, tg = false, nil,
  627.          Cmd9_Description, Cmd9_CoolDown, Cmd9_MoodGain, ty = 'Kinh Nghiệm +'],
  628.   #----------------------- # Actions
  629.   10 => [Cmd10_Name,    c = 10,  Cmd10_IconIndex, t = 0,   tg = true, nil,
  630.          Cmd10_Description, Cmd10_CoolDown, 0, ty = 'Hành Động'],
  631.   11 => [Cmd11_Name,    c = 11,  Cmd11_IconIndex, t = 0,   tg = true, nil,
  632.          Cmd11_Description, Cmd11_CoolDown, 0, ty = 'Hành Động'],
  633.   12 => [Cmd12_Name,    c = 12,  Cmd12_IconIndex, t = 0,   tg = true, nil,
  634.          Cmd12_Description, Cmd12_CoolDown, 0, ty = 'Hành Động'],
  635.   13 => [Cmd13_Name,    c = 13,  Cmd13_IconIndex, t = 0,   tg = true, nil,
  636.          Cmd13_Description, Cmd13_CoolDown, 0, ty = 'Hành Động'],
  637.   #-------------------- casting commands
  638.   14 => [Cmd14_Name,    c = 14,  Cmd14_IconIndex, t = 300,   tg = false, nil,
  639.          Cmd14_Description, Cmd14_CoolDown, 0, ty = 'Vật Đúc'],
  640.   15 => [Cmd15_Name,    c = 15,  Cmd15_IconIndex, t = 200,   tg = false, nil,
  641.          Cmd15_Description, Cmd15_CoolDown, 0, ty = 'Vật Đúc'],
  642.   16 => [Cmd16_Name,    c = 16,  Cmd16_IconIndex, t = 200,   tg = false, nil,
  643.          Cmd16_Description, Cmd16_CoolDown, 0, ty = 'Vật Đúc'],
  644.   17 => [Cmd17_Name,    c = 17,  Cmd17_IconIndex, t = 200,   tg = false, nil,
  645.          Cmd17_Description, Cmd17_CoolDown, 0, ty = 'Vật Đúc'],
  646.   18 => [Cmd18_Name,    c = 18,  Cmd18_IconIndex, t = 200,   tg = false, nil,
  647.          Cmd18_Description, Cmd18_CoolDown, 0, ty = 'Vật Đúc'],
  648.   19 => [Cmd19_Name,    c = 19,  Cmd19_IconIndex, t = 200,   tg = false, nil,
  649.          Cmd19_Description, Cmd19_CoolDown, 0, ty = 'Vật Đúc'],
  650.          
  651.   #----------------------- custom commands      
  652.   20 => [Cmd20_Name, c = 20, Cmd20_IconIndex, Cmd20_ActionTime, tg = false, nil,
  653.          Cmd20_Description, Cmd20_CoolDown, Cmd20_MoodGain, Cmd20_Type],
  654.   21 => [Cmd21_Name, c = 21, Cmd21_IconIndex, Cmd21_ActionTime, tg = false, nil,
  655.          Cmd21_Description, Cmd21_CoolDown, Cmd21_MoodGain, Cmd21_Type],
  656.   22 => [Cmd22_Name, c = 22, Cmd22_IconIndex, Cmd22_ActionTime, tg = false, nil,
  657.          Cmd22_Description, Cmd22_CoolDown, Cmd22_MoodGain, Cmd22_Type],
  658.   23 => [Cmd23_Name, c = 23, Cmd23_IconIndex, Cmd23_ActionTime, tg = false, nil,
  659.          Cmd23_Description, Cmd23_CoolDown, Cmd23_MoodGain, Cmd23_Type],
  660.   24 => [Cmd24_Name, c = 24, Cmd24_IconIndex, Cmd24_ActionTime, tg = false, nil,
  661.          Cmd24_Description, Cmd24_CoolDown, Cmd24_MoodGain, Cmd24_Type],
  662.   25 => [Cmd25_Name, c = 25, Cmd25_IconIndex, Cmd25_ActionTime, tg = false, nil,
  663.          Cmd25_Description, Cmd25_CoolDown, Cmd25_MoodGain, Cmd25_Type],
  664.   #--------------------------------------------------------------
  665.   26 => [Cmd26_Name,    c = 26,  Cmd26_IconIndex, t = 0,   tg = false, s = true,
  666.          Cmd26_Description, Cmd26_CoolDown, 0, ty = 'Mặc Định'],
  667.          
  668.   #----this is the command return, this is not listed, it cannot be changed
  669.   27 => [nil, nil, nil, nil, nil, nil,
  670.          nil, nil, nil, nil],
  671.          
  672.   #-----------------------------------------------------------------------------
  673.   # Need more custom commands? you can create as many custom commands you need
  674.   # the next command on database would be 28, see examples below
  675.   #  28 => ['name', id, icon_index, action_time, target, nil,
  676.   #          'Description', Cool down, mood gainig, type],
  677.   #
  678.   #  So the command should be as follows
  679.   #
  680.   # 28 => ['Any name', id = 28, icon = 19, action_time = 200, false, nil,
  681.   #        'Any description', cooldown = 5, mood_gain = 0, type = 'Any type'],
  682.   #
  683.   #
  684.   # Do not change the values  "false, nil" from the commands data, they are
  685.   # defaults for the action commands.
  686.   #-----------------------------------------------------------------------------
  687.   # * Start creating new custom commands here
  688.  
  689.  
  690.  
  691.   }
  692.  
  693. end
  694.  
  695.  
  696. #-------------------------------------------------------------------------------
  697. # Game Pet class
  698.  
  699. class Game_Pet < Game_Character
  700.   include FalPet
  701.   attr_accessor :command, :stucked, :lastspot, :action_time, :short_jump
  702.   attr_accessor :chase_event_id, :mood, :cooldown, :unlock_command,:reservedmood
  703.   attr_accessor :pet_level, :grow_inflation, :lvup_pop, :stealed_item, :pet_id
  704.   attr_accessor :character_name, :character_index, :petname, :sounds, :casting
  705.   attr_accessor :randomitem, :custom_mode, :stuck_count, :instantcd, :through
  706.   def initialize
  707.     super
  708.     @pet_id = 0
  709.     @priority_type = 1
  710.     @mood = 0
  711.     @pet_level = 1
  712.     @cooldown = []
  713.     FalPet::Commands.keys.size.times do ; @cooldown.push(0) ; end
  714.     @unlock_command = DeafaultMoodCommands
  715.     @grow_inflation = [StartingMoodMax, grow = 0, GiftBundle.max_by{|k,v| v}[0]]
  716.     @lvup_pop = false
  717.     @instantcd = 0
  718.     @reservedmood = 0
  719.     reset_pet
  720.   end
  721.  
  722.   def reset_pet
  723.     @command = 0
  724.     @stucked = 0
  725.     @action_time = 0
  726.     @short_jump = false
  727.     @lastspot = nil
  728.     @casting = false
  729.     @custom_mode = nil
  730.     @stuck_count = 0
  731.     @through = true
  732.     $game_switches[CustomSwitch] = false if $game_switches[CustomSwitch]
  733.   end
  734.  
  735.   # set up
  736.   def setup_pet(id)
  737.     get_bonus(@pet_id, sub = true) if @pet_id > 0
  738.     @pet_id = id
  739.     set = Pets[@pet_id]
  740.     @character_name = set[0]
  741.     @character_index = set[1]
  742.     @petname = set[2]
  743.     @sounds = [set[3], set[4], set[5]]
  744.     @balloon_id = 1 if SceneManager.scene_is?(Scene_Map)
  745.     play_voice
  746.     get_bonus(@pet_id)
  747.   end
  748.  
  749.   def get_bonus(id, sub=false)
  750.     set = Bonus[id]
  751.     for member in $game_party.members
  752.       for i in 0...8
  753.         sub ? member.add_param(i, -set[i]) : member.add_param(i, set[i])
  754.       end
  755.     end
  756.   end
  757.  
  758.   def play_voice
  759.     RPG::SE.new(@sounds[0],@sounds[1],@sounds[2]).play
  760.   end
  761.  
  762.   def busy?
  763.     @command > 0
  764.   end
  765.  
  766.   def custom_command?
  767.     return true if @command.between?(20, 25)
  768.     return true if @command.between?(28, FalPet::Commands.keys.size)
  769.     return false
  770.   end
  771.  
  772.   def time?(t)
  773.     t == @action_time
  774.   end
  775.  
  776.   def prepare
  777.     $game_player.prepare_petact
  778.   end
  779.  
  780.   def pop_text(text, time)
  781.     $game_player.gamepet.custom_mode = text
  782.     $game_player.petpop_time = time * 60
  783.   end
  784.  
  785.   def pop_mood
  786.     $game_player.start_poping_window(1, 3)
  787.   end
  788.  
  789.   def level
  790.     return @pet_level
  791.   end
  792.  
  793.   def cast
  794.     @casting = true
  795.   end
  796.  
  797.   def ending?
  798.     @action_time == 2
  799.   end
  800.  
  801.   def cmd?(c)
  802.     c == @command
  803.   end
  804.  
  805.   def play_balloon
  806.     @balloon_id = BalloonPlaying
  807.   end
  808.  
  809.   def zoom(x, y)
  810.     @zoomfx_x = x
  811.     @zoomfx_y = y
  812.   end
  813.  
  814.   def reset_zoom
  815.     @zoomfx_x = 1.0
  816.     @zoomfx_y = 1.0
  817.   end
  818.  
  819.   def gain_mood(n)
  820.     @mood = [[@mood + n, 0].max, @grow_inflation[0]].min
  821.   end
  822.  
  823.   def gain_level(n)
  824.     @pet_level = [[@pet_level + n, 0].max, @grow_inflation[2]].min
  825.   end
  826.  
  827.   def mood_full?
  828.     @mood == @grow_inflation[0]
  829.   end
  830.  
  831.   # apply pet growing
  832.   def apply_growing
  833.     @grow_inflation[1] += 1
  834.     if @grow_inflation[1] == Growing
  835.       if @pet_level != @grow_inflation[2]
  836.         @grow_inflation[0] = @grow_inflation[0] + MoodMaxPlus
  837.         gain_level(1)
  838.         @lvup_pop = true
  839.       end
  840.       @grow_inflation[1] = 0
  841.     end
  842.   end
  843.  
  844.   def twist(value, m)
  845.     set_direction(2) if @action_time == value
  846.     set_direction(4) if @action_time == value - m
  847.     set_direction(6) if @action_time == value - m - m
  848.     set_direction(8) if @action_time == value - m - m - m
  849.   end
  850.  
  851.   def mood_cmd(id)
  852.     return unless id.between?(2, 9)
  853.     @unlock_command.push(id) unless @unlock_command.include?(id)
  854.   end
  855.  
  856.   # gift item
  857.   def mood_item
  858.     FalPet::GiftBundle.each do |level, item_id|
  859.       if level == @pet_level
  860.         item = $data_items[item_id]
  861.         return item if !item.nil?
  862.       end
  863.     end
  864.     return $data_items[1]
  865.   end
  866.  
  867.   # radom items
  868.   def get_randomitem(type, variable)
  869.     case type
  870.     when 'item'   ; operand = $data_items
  871.     when 'weapon' ; operand = $data_weapons
  872.     when 'armor'  ; operand = $data_armors
  873.     when 'gold'   ; operand = nil
  874.     end
  875.     if operand != nil
  876.       data = []
  877.       variable.each {|id, value|  data.push([id, value])}
  878.       item = data[rand(data.size)]
  879.       @randomitem = [operand[item[0]], item[1]]
  880.     else
  881.       gold = variable[rand(variable.size)]
  882.       @randomitem = [gold]
  883.     end
  884.   end
  885.  
  886.   def update
  887.     @pattern = 0 if @casting
  888.     @move_speed = $game_player.real_move_speed if !busy?
  889.     if custom_command?
  890.       $game_switches[CustomSwitch] = true if !$game_switches[CustomSwitch]
  891.     end
  892.     for event in $game_map.events.values
  893.       if event.check_evcom("/PET GRAB")
  894.         event.priority_type = 1 if event.priority_type != 1
  895.       end
  896.     end
  897.     super
  898.   end
  899.  
  900.   def cast_item_producing(anime, ct=false)
  901.     case @action_time
  902.     when 180 ; jump_high(0, 0, 16) ; @casting = true
  903.     when 160 ; ct ? $game_player.animation_id = anime : @animation_id = anime
  904.     when 6   ; play_balloon ; play_voice
  905.     when 1   ; RPG::SE.new("Item3",80).play if !ct
  906.     ct ? $game_player.start_poping_window(13, 2) :
  907.     $game_player.start_poping_window(11, 3)
  908.     end
  909.   end
  910.  
  911.   def update_anime_pattern
  912.     @casting ? return : super
  913.   end
  914. end
  915.  
  916. #-------------------------------------------------------------------------------
  917. # * Character base new methods and variabbles
  918.  
  919. class Game_CharacterBase
  920.   attr_accessor :x, :y, :direction, :priority_type, :pattern, :through
  921.   attr_accessor :step_anime, :direction_fix, :move_speed, :egrabbing
  922.   attr_accessor :zoomfx_x
  923.   attr_accessor :zoomfx_y
  924.   attr_accessor :anglefx
  925.  
  926.   alias falcao_zoomfx_ini initialize
  927.   def initialize
  928.     @zoomfx_x = 1.0
  929.     @zoomfx_y = 1.0
  930.     @anglefx = 0.0
  931.     @layingdown = false
  932.     falcao_zoomfx_ini
  933.   end
  934.  
  935.   def liedown
  936.     set_direction(8)
  937.     @anglefx = 100
  938.     @layingdown = true
  939.   end
  940.  
  941.   def reset_liedown
  942.     @anglefx = 0.0
  943.     @layingdown = false
  944.   end
  945.  
  946.   def move_toward_char(character)
  947.     sx = distance_x_from(character.x)
  948.     sy = distance_y_from(character.y)
  949.     if sx != 0 && sy != 0
  950.       move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2)
  951.     elsif sx != 0
  952.       move_straight(sx > 0 ? 4 : 6)
  953.     elsif sy != 0
  954.       move_straight(sy > 0 ? 8 : 2)
  955.     end
  956.   end
  957.  
  958.   # jump to specific tiles
  959.   def jumpto_tile(x, y)
  960.     jumpto(0, [x, y])
  961.   end
  962.  
  963.   # jumpto character ( 0 = Game Player, 1 and up event id)
  964.   def jumpto(char_id, tilexy=nil)
  965.     char_id > 0 ? char = $game_map.events[char_id] : char = $game_player
  966.     tilexy.nil? ? condxy = [char.x, char.y] : condxy = [tilexy[0], tilexy[1]]
  967.     jx = + eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] >= @x
  968.     jy = - eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] <= @y
  969.     jx = - eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] <= @x
  970.     jy = - eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] <= @y
  971.     jx = - eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] <= @x
  972.     jy = + eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] >= @y
  973.     jx = + eval_distance(tilexy.nil? ? char : tilexy)[0] if condxy[0] >= @x
  974.     jy = + eval_distance(tilexy.nil? ? char : tilexy)[1] if condxy[1] >= @y
  975.     jump(jx, jy)
  976.   end
  977.  
  978.   def eval_distance(target)
  979.     if target.is_a?(Array)
  980.       distance_x = (@x - target[0]).abs
  981.       distance_y = (@y - target[1]).abs
  982.     else
  983.       distance_x = (@x - target.x).abs
  984.       distance_y = (@y - target.y).abs
  985.     end
  986.     return [distance_x, distance_y]
  987.   end
  988.  
  989.   # climb area
  990.   def climb_area?(target, size)
  991.     distance = (@x - target.x).abs + (@y - target.y).abs
  992.     enable   = (distance <= size-1)
  993.     return true if enable
  994.     return false
  995.   end
  996.  
  997.   # controlled jump x, y , height
  998.   def jump_high(x_plus, y_plus, heigh)
  999.     if x_plus.abs > y_plus.abs
  1000.       set_direction(x_plus < 0 ? 4 : 6) if x_plus != 0
  1001.     else
  1002.       set_direction(y_plus < 0 ? 8 : 2) if y_plus != 0
  1003.     end
  1004.     @x += x_plus
  1005.     @y += y_plus
  1006.     distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
  1007.     @jump_peak = heigh + distance - @move_speed
  1008.     @jump_count = @jump_peak * 2
  1009.     @stop_count = 0
  1010.     straighten ; @priority_type = 2
  1011.   end
  1012.  
  1013.   def samepos?(target)
  1014.     @x == target.x and @y == target.y
  1015.   end
  1016.  
  1017.   # get distance passable tile_x and tile_y
  1018.   def tiles_pass
  1019.     dir = @direction
  1020.     operand = 17 if dir == 4 || dir == 6
  1021.     operand = 13 if dir == 2 || dir == 8
  1022.     for i in 1...operand
  1023.       return [@x, @y + i] if dir == 2 and $game_map.passable?(@x, @y + i, dir)
  1024.       return [@x, @y - i] if dir == 8 and $game_map.passable?(@x, @y - i, dir)
  1025.       return [@x - i, @y] if dir == 4 and $game_map.passable?(@x - i, @y, dir)  
  1026.       return [@x + i, @y] if dir == 6 and $game_map.passable?(@x + i, @y, dir)  
  1027.     end
  1028.     return nil
  1029.   end
  1030.  
  1031.   def adjustpxy
  1032.     push_x, push_y =   0,   1 if @direction == 2
  1033.     push_x, push_y = - 1,   0 if @direction == 4
  1034.     push_x, push_y =   1,   0 if @direction == 6
  1035.     push_x, push_y =   0, - 1 if @direction == 8
  1036.     return [push_x, push_y]
  1037.   end
  1038.  
  1039. end
  1040.  
  1041. #-------------------------------------------------------------------------------
  1042. # * Game player new methods and variabbles
  1043.  
  1044. class Game_Player < Game_Character
  1045.   attr_reader   :gamepet
  1046.   attr_reader   :showing_pet
  1047.   attr_accessor :petpop_time
  1048.   attr_accessor :petpop_refresh
  1049.   attr_accessor :petpop_type
  1050.   attr_accessor :adopted_pets
  1051.   attr_accessor :just_jumped
  1052.   alias falcao_pet_ini initialize
  1053.   def initialize
  1054.     @gamepet = Game_Pet.new
  1055.     @showing_pet = false
  1056.     @petpop_refresh = false
  1057.     @petpop_time = 0
  1058.     @petpop_type = 0
  1059.     @climb_wait = 0
  1060.     @adopted_pets = []
  1061.     @just_jumped = false
  1062.     falcao_pet_ini
  1063.   end
  1064.  
  1065.   alias falcao_pet_main_update update
  1066.   def update
  1067.     update_gamepet
  1068.     falcao_pet_main_update
  1069.   end
  1070.  
  1071.   def adopt_pet(id)
  1072.     @adopted_pets.include?(id) ? return :  @adopted_pets.push(id)
  1073.     @gamepet.setup_pet(id)
  1074.     @showing_pet = true
  1075.   end
  1076.  
  1077.   def have_pet?
  1078.     !@adopted_pets.empty?
  1079.   end
  1080.  
  1081.   def update_gamepet
  1082.     return unless have_pet?
  1083.    
  1084.     if @gamepet.action_time > 0
  1085.       @gamepet.action_time -= 1
  1086.       globalpet_reset if @gamepet.action_time == 0
  1087.     end
  1088.     @petpop_time -= 1 if @petpop_time > 0
  1089.     @climb_wait -= 1 if @climb_wait > 0
  1090.     @gamepet.update if @showing_pet
  1091.     update_path_manager
  1092.     update_call_commands
  1093.     case @gamepet.command
  1094.     when 1
  1095.       update_command_showhide
  1096.     when 2..9
  1097.       update_command_play
  1098.     when 10
  1099.       update_command_startevet(@gamepet.chase_event_id)
  1100.     when 11
  1101.       update_command_steal(@gamepet.chase_event_id)
  1102.     when 12
  1103.       update_command_grab(@gamepet.chase_event_id)
  1104.     when 13
  1105.       update_command_climb(@gamepet.chase_event_id)
  1106.     when 14
  1107.       update_command_heal
  1108.     when 15
  1109.       update_command_randomitems
  1110.     when 16
  1111.       update_command_randomweapons
  1112.     when 17
  1113.       update_command_randomarmors
  1114.     when 18
  1115.       update_command_randomgold
  1116.     when 19
  1117.       update_command_instantcd
  1118.     when 27
  1119.       update_command_return
  1120.     end
  1121.     update_poppetwindow
  1122.   end
  1123.  
  1124.   def update_call_commands
  1125.     return unless FalPet::UseKey
  1126.     SceneManager.call(Scene_PetCommands) if Input.trigger?(FalPet::CommandsKey)
  1127.   end
  1128.  
  1129.   # command return
  1130.   def update_command_return
  1131.     @gamepet.move_toward_character(self) unless @gamepet.moving?
  1132.     globalpet_reset if @gamepet.x == @x and @gamepet.y == @y
  1133.   end
  1134.  
  1135.   # path manager
  1136.   def update_path_manager
  1137.     return unless @gamepet.command == 27 || @gamepet.command.between?(10, 13)
  1138.     @gamepet.stucked += 1 if not @gamepet.moving?
  1139.     @gamepet.stucked = 0 if @gamepet.moving?
  1140.     @gamepet.stucked = 0 if @climb_wait > 0 and !@gamepet.moving?
  1141.     if @gamepet.stuck_count >= FalPet::StuckCount
  1142.       @gamepet.command = 27
  1143.       @gamepet.stuck_count = 0
  1144.       start_poping_window(12, 3)
  1145.     end
  1146.     #------------------------------------------
  1147.     if @gamepet.stucked == 45
  1148.       if @gamepet.command == 27
  1149.         event = $game_map.events[@gamepet.chase_event_id] rescue nil
  1150.         @gamepet.turn_toward_character(self)
  1151.         if @gamepet.tiles_pass != nil
  1152.           tilex, tiley = @gamepet.tiles_pass[0], @gamepet.tiles_pass[1]
  1153.           @gamepet.jumpto_tile(tilex, tiley)
  1154.           event.jumpto_tile(tilex,tiley) if !event.nil? && !event.egrabbing.nil?
  1155.         else
  1156.           @gamepet.jumpto(0)
  1157.           event.jumpto(0) if !event.nil? and !event.egrabbing.nil?
  1158.         end
  1159.      
  1160.         # command activate / steal / grab / climb
  1161.       elsif @gamepet.command.between?(10, 13)
  1162.         event = $game_map.events[@gamepet.chase_event_id]
  1163.         @gamepet.turn_toward_character(event)
  1164.         if @gamepet.tiles_pass != nil
  1165.           if @gamepet.climb_area?(event, 3)
  1166.             @gamepet.jumpto(@gamepet.chase_event_id)
  1167.             return
  1168.           end
  1169.           @gamepet.jumpto_tile(@gamepet.tiles_pass[0], @gamepet.tiles_pass[1])
  1170.         else
  1171.           @gamepet.jumpto(@gamepet.chase_event_id)
  1172.         end
  1173.       end
  1174.       @gamepet.stucked = 0
  1175.       @gamepet.stuck_count += 1
  1176.     end
  1177.   end
  1178.  
  1179.   def start_poping_window(type, time, seconds=true)
  1180.     @petpop_type = type
  1181.     seconds ? @petpop_time = time * 60 : @petpop_time = time
  1182.   end
  1183.  
  1184.   # comand showhide
  1185.   def update_command_showhide
  1186.     # hide
  1187.     if @showing_pet
  1188.       @gamepet.balloon_id = 1
  1189.       unless @gamepet.jumping?
  1190.         @showing_pet = false
  1191.         @gamepet.reset_pet
  1192.       end
  1193.       # show
  1194.     else
  1195.       @gamepet.balloon_id = 4
  1196.       @showing_pet = true
  1197.       @gamepet.reset_pet
  1198.     end
  1199.   end
  1200.  
  1201.   # play with pet
  1202.   def update_command_play
  1203.     prepare_petact
  1204.     time = @gamepet.action_time
  1205.     case @gamepet.command
  1206.     when 2 # jump jump
  1207.       @gamepet.jump(0,0) if time == 130
  1208.       @gamepet.jump(0,0) if time == 100
  1209.       @gamepet.jump(0,0) if time == 70
  1210.       @gamepet.play_balloon if time == 40
  1211.       @gamepet.play_voice  if time == 20
  1212.      
  1213.     when 3 # tun r around
  1214.       @gamepet.jump(0,0) if time == 130
  1215.       @gamepet.twist(100, 10)
  1216.       @gamepet.turn_toward_character(self) if time == 50
  1217.       @gamepet.play_balloon if time == 30
  1218.       @gamepet.play_voice if time == 20
  1219.      
  1220.     when 4 # zoom
  1221.       if time > 90 and time < 130
  1222.         @gamepet.zoomfx_x += 0.02
  1223.         @gamepet.zoomfx_y += 0.02
  1224.       elsif time > 30 and time < 70
  1225.         @gamepet.zoomfx_x -= 0.02
  1226.         @gamepet.zoomfx_y -= 0.02
  1227.       end
  1228.       @gamepet.play_balloon if time == 30
  1229.       @gamepet.play_voice if time == 20
  1230.      
  1231.     when 5 #chase jump
  1232.       if time == 130
  1233.         @gamepet.lastspot = [@gamepet.x, @gamepet.y]
  1234.         @gamepet.jumpto(0)
  1235.       elsif time == 90
  1236.         @gamepet.jumpto_tile(@gamepet.lastspot[0], @gamepet.lastspot[1])
  1237.       end
  1238.       @gamepet.move_forward if time == 70
  1239.       @gamepet.turn_toward_character(self) if time == 50
  1240.       @gamepet.move_forward if time == 10
  1241.       @gamepet.play_balloon if time == 30
  1242.       @gamepet.play_voice if time == 20
  1243.      
  1244.     when 6 # twist
  1245.       @gamepet.move_away_from_player if time == 170
  1246.       @gamepet.turn_toward_character(self) if time == 150
  1247.       @gamepet.twist(140, 5) ; @gamepet.twist(120, 5)
  1248.       @gamepet.twist(100, 5) ; @gamepet.twist(80, 5)
  1249.       @gamepet.twist(60, 5)  ; @gamepet.twist(40, 10)
  1250.       @gamepet.play_balloon if time == 20
  1251.       @gamepet.play_voice if time == 10
  1252.       @gamepet.jump(0,0) if time == 10
  1253.       @gamepet.turn_toward_character(self) if time == 10
  1254.      
  1255.     when 7 # play dead
  1256.       @gamepet.move_away_from_player if time == 470
  1257.       @gamepet.turn_toward_character(self) if time == 450
  1258.       @gamepet.balloon_id = FalPet::PlayDeadBalloon if  time == 400
  1259.       @gamepet.liedown if time == 430
  1260.       @gamepet.play_balloon if time == 20
  1261.       @gamepet.play_voice if time == 10
  1262.       @gamepet.turn_toward_character(self) if time == 10
  1263.      
  1264.     when 8 # dance
  1265.       RPG::BGM.fade(1 * 1000) if time == 590
  1266.       @gamepet.move_away_from_player if time == 470
  1267.       @gamepet.turn_toward_character(self) if time == 450
  1268.       if time == 410
  1269.         $game_system.save_bgm
  1270.         RPG::BGM.new(FalPet::DancingBgm,80).play
  1271.         @gamepet.step_anime = true
  1272.         @gamepet.move_speed = 5
  1273.       end
  1274.       @gamepet.move_forward if time == 320
  1275.       @gamepet.move_backward if time == 260
  1276.       @gamepet.jump(0, 0) if time == 220
  1277.       @gamepet.jump(0, 0) if time == 205
  1278.       @gamepet.twist(180, 5) ; @gamepet.twist(160, 5)
  1279.       @gamepet.turn_toward_character(self) if time == 130
  1280.       @gamepet.move_speed = 4 if time == 125
  1281.       @gamepet.liedown if time == 120
  1282.       @gamepet.reset_liedown if time == 110
  1283.       @gamepet.play_balloon if time == 40
  1284.       @gamepet.play_voice if time == 40
  1285.       @gamepet.move_toward_player if time == 30
  1286.       $game_system.replay_bgm if time == 2
  1287.      
  1288.     when 9 # trampoline
  1289.       case time
  1290.       when 350; @gamepet.jump_high(0,0, 20); RPG::SE.new("Jump2",80,).play
  1291.       when 300; jump_high(0, 0, 20); ; RPG::SE.new("Jump2",80,).play
  1292.       when 250; @gamepet.jump_high(0,0, 20); RPG::SE.new("Jump2",80,).play
  1293.       when 200; jump_high(0, 0, 20); ; RPG::SE.new("Jump2",80,).play
  1294.       when 150; @gamepet.jump_high(0,0, 20); RPG::SE.new("Jump2",80,).play
  1295.       when 112; @gamepet.liedown; RPG::SE.new("Crossbow",80,).play
  1296.                 $game_map.screen.start_shake(7, 7, 20)
  1297.       when 80;  @gamepet.play_balloon; RPG::SE.new("Miss",80,).play
  1298.       when 10;  @gamepet.reset_liedown; @gamepet.play_voice
  1299.                 @gamepet.turn_toward_player
  1300.       end
  1301.     end
  1302.     start_poping_window(1, 3) if time == 1
  1303.   end
  1304.  
  1305.   # reseting
  1306.   def globalpet_reset
  1307.     @gamepet.reset_pet
  1308.     @gamepet.zoomfx_x = 1.0
  1309.     @gamepet.zoomfx_y = 1.0
  1310.     @gamepet.reset_liedown
  1311.     @vastored = nil
  1312.     @gamepet.step_anime = false
  1313.     @gamepet.direction_fix = false
  1314.     @gamepet.priority_type = 1
  1315.     @climb_wait = 0
  1316.     if @gamepet.chase_event_id != nil
  1317.       event = $game_map.events[@gamepet.chase_event_id]
  1318.       if !event.nil? and !event.egrabbing.nil?
  1319.         event.egrabbing = nil
  1320.         event.move_speed = @gvdata[0]
  1321.         event.move_type = @gvdata[1]
  1322.         event.priority_type = @gvdata[2]
  1323.       end
  1324.     end
  1325.   end
  1326.  
  1327.   def update_poppetwindow
  1328.     if @gamepet.lvup_pop and @petpop_time == 0
  1329.       start_poping_window(3, 80, false)
  1330.       @petpop_refresh = true
  1331.       @gamepet.lvup_pop = false
  1332.       RPG::SE.new("Up1",80).play
  1333.       @gamepet.jump(0, 0)
  1334.     end
  1335.     if @petpop_time == 2 * 60 and @petpop_type == 1 and
  1336.       @gamepet.reservedmood != 0
  1337.       @gamepet.gain_mood(@gamepet.reservedmood)
  1338.       @gamepet.mood_full? ? @petpop_type = 2 : @petpop_type = 1
  1339.       @petpop_refresh = true
  1340.       @gamepet.reservedmood = 0
  1341.     end
  1342.   end
  1343.  
  1344. #-------------------------------------------------------------------------------
  1345. # Pet trigger targets
  1346.   def update_command_startevet(id)
  1347.     event = $game_map.events[id]
  1348.     @gamepet.through = false if @gamepet.through
  1349.     @gamepet.move_toward_character(event) unless @gamepet.moving?
  1350.     if @gamepet.samepos?(event) && @gamepet.command == 10 && !@gamepet.jumping?
  1351.       event.check_evcom("/PET TRIGGER") ? event.start : start_poping_window(4,2)
  1352.       @gamepet.command = 27
  1353.     end
  1354.   end
  1355.  
  1356.   #-----------------------------------------------------------------------------
  1357.   # steal
  1358.  
  1359.   def update_command_steal(id)
  1360.     event = $game_map.events[id]
  1361.     @gamepet.through = false if @gamepet.through
  1362.     @gamepet.move_toward_character(event) unless @gamepet.moving?
  1363.     if @gamepet.samepos?(event) && @gamepet.command == 11 && !@gamepet.jumping?
  1364.       item   = event.check_evvar("/PET STEAL ITEM")
  1365.       weapon = event.check_evvar("/PET STEAL WEAPON")
  1366.       armor  = event.check_evvar("/PET STEAL ARMOR")
  1367.       gold   = event.check_evvar("/PET STEAL GOLD")
  1368.       chance = event.check_evvar("/PET STEAL CHANCE 1 / ")
  1369.       chance = 1 if chance == 0
  1370.       have_something = item > 0 || weapon > 0 || gold > 0 || armor > 0
  1371.       unless have_something
  1372.         start_poping_window(7, 3)
  1373.         @gamepet.play_voice
  1374.         @gamepet.command = 27
  1375.         return
  1376.       end
  1377.       if rand(chance) == 0
  1378.         if item != 0
  1379.           gain_stealed_item($data_items[item])
  1380.         elsif weapon != 0
  1381.           gain_stealed_item($data_weapons[weapon])
  1382.         elsif armor != 0
  1383.           gain_stealed_item($data_armors[armor])
  1384.         elsif gold != 0
  1385.           @gamepet.stealed_item = gold
  1386.           $game_party.gain_gold(gold)
  1387.           RPG::SE.new("Shop",80).play
  1388.           start_poping_window(5, 3)
  1389.         end
  1390.       else
  1391.         start_poping_window(6, 3)
  1392.         @gamepet.play_voice
  1393.       end
  1394.       @gamepet.command = 27
  1395.     end
  1396.   end
  1397.  
  1398.   def gain_stealed_item(stealed)
  1399.     @gamepet.stealed_item = stealed
  1400.     $game_party.gain_item(stealed, 1)
  1401.     RPG::SE.new("Item3",80).play
  1402.     start_poping_window(5, 3)
  1403.   end
  1404.  
  1405.   #-----------------------------------------------------------------------------
  1406.   # Grab
  1407.  
  1408.   def update_command_grab(id)
  1409.     event = $game_map.events[id]
  1410.     @gamepet.through = false if @gamepet.through
  1411.     @gamepet.move_toward_character(event) unless @gamepet.moving?
  1412.     if @gamepet.samepos?(event) && @gamepet.command == 12 && !@gamepet.jumping?
  1413.       @gvdata = [event.move_speed, event.move_type, event.priority_type]
  1414.       event.check_evcom("/PET GRAB") ? event.egrabbing = true :
  1415.       start_poping_window(8, 2)
  1416.       @gamepet.command = 27
  1417.     end
  1418.   end
  1419.  
  1420.   #-----------------------------------------------------------------------------
  1421.   # Climb CLIMB MIERDDAAAAAAAAAAAAAAAAAAAA
  1422.  
  1423.   def update_command_climb(id)
  1424.     event = $game_map.events[id]
  1425.     event.priority_type = 0 if event.priority_type != 0
  1426.     event.through = true if !event.through
  1427.     @gamepet.through = false if @gamepet.through
  1428.     @gamepet.move_toward_character(event) if !@gamepet.moving? and
  1429.     @climb_wait == 0
  1430.     @gamepet.turn_toward_character(self) if @climb_wait > 0
  1431.     if @climb_wait == 1 and @gamepet.x == event.x and @gamepet.y == event.y
  1432.       @gamepet.command = 27
  1433.       return
  1434.     end
  1435.     if climb_area?(event, 7) and @climb_wait > 0 and !moving?
  1436.       if @gamepet.x == @x and @gamepet.y == @y
  1437.         globalpet_reset
  1438.         return
  1439.       end
  1440.       # jump to cimb aerea player
  1441.       if !passable?(@x, @y, @direction) and @gamepet.x == event.x and
  1442.         @gamepet.y == event.y and Input.dir8 != 0
  1443.         jumpto(event.id)
  1444.         self.followers.reverse_each do |f|
  1445.           f.move_toward_player ; f.move_toward_player ; f.move_toward_player
  1446.           f.jumpto(event.id)
  1447.         end
  1448.         RPG::SE.new("Shot1",80).play
  1449.         globalpet_reset
  1450.       end
  1451.     end
  1452.     if @gamepet.samepos?(event) && @climb_wait == 0 && !@gamepet.jumping?
  1453.       if event.check_evcom("/PET CLIMB")
  1454.         unless @gamepet.x == @x and @gamepet.y == @y
  1455.           start_poping_window(9, 1)
  1456.           @gamepet.play_voice
  1457.           @gamepet.jump(0, 0)
  1458.           @climb_wait = 12 * 60
  1459.         end
  1460.       end
  1461.     end
  1462.   end
  1463.  
  1464.   # preparation for pet acting
  1465.   def prepare_petact
  1466.     if @vastored.nil?
  1467.       turn_toward_character(@gamepet) ; @gamepet.turn_toward_character(self)
  1468.       @vastored = true ; followers.gather
  1469.     end
  1470.   end
  1471.  
  1472.   #-----------------------------------------------------------------------------
  1473.   # heal command
  1474.  
  1475.   def update_command_heal
  1476.     prepare_petact
  1477.     @gamepet.move_away_from_player if @gamepet.action_time == 270
  1478.     @gamepet.turn_toward_character(self) if @gamepet.action_time == 250
  1479.     if @gamepet.action_time == 210
  1480.       @gamepet.jump_high(0, 0, 18)
  1481.       @gamepet.casting = true
  1482.     end
  1483.     $game_map.screen.start_shake(5, 5, 60) if @gamepet.action_time == 160
  1484.     if @gamepet.action_time == 120
  1485.       @gamepet.balloon_id = 1
  1486.       @gamepet.play_voice
  1487.     end
  1488.     self.animation_id = 40 if @gamepet.action_time == 100
  1489.     if @gamepet.action_time == 1
  1490.       for member in $game_party.members
  1491.         case FalPet::HealPercent
  1492.         when '25%'  ; hp = 4    ; when '50%'  ; hp = 2
  1493.         when '75%'  ; hp = 1.32 ; when '100%' ; hp = 1
  1494.         end
  1495.         member.change_hp((member.mhp  / hp).truncate, false)
  1496.         member.mp += (member.mmp  / hp).truncate
  1497.         start_poping_window(10, 3)
  1498.       end
  1499.     end
  1500.   end
  1501.  
  1502.   #-----------------------------------------------------------------------------
  1503.   # Make random item
  1504.   def update_command_randomitems
  1505.     prepare_petact
  1506.     @gamepet.cast_item_producing(FalPet::ItemAnime)
  1507.     if @gamepet.action_time == 2
  1508.       @gamepet.get_randomitem('item', FalPet::RandomItems)
  1509.       $game_party.gain_item(@gamepet.randomitem[0], @gamepet.randomitem[1])
  1510.     end
  1511.   end
  1512.  
  1513.   #-----------------------------------------------------------------------------
  1514.   # Make random weapon
  1515.   def update_command_randomweapons
  1516.     prepare_petact
  1517.     @gamepet.cast_item_producing(FalPet::WeaponAnime)
  1518.     if @gamepet.action_time == 2
  1519.       @gamepet.get_randomitem('weapon', FalPet::RandomWeapons)
  1520.       $game_party.gain_item(@gamepet.randomitem[0], @gamepet.randomitem[1])
  1521.     end
  1522.   end
  1523.  
  1524.   #-----------------------------------------------------------------------------
  1525.   # Make random armor
  1526.   def update_command_randomarmors
  1527.     prepare_petact
  1528.     @gamepet.cast_item_producing(FalPet::ArmorAnime)
  1529.     if @gamepet.action_time == 2
  1530.       @gamepet.get_randomitem('armor', FalPet::RandomArmors)
  1531.       $game_party.gain_item(@gamepet.randomitem[0], @gamepet.randomitem[1])
  1532.     end
  1533.   end
  1534.  
  1535.   #-----------------------------------------------------------------------------
  1536.   # Make random gold
  1537.   def update_command_randomgold
  1538.     prepare_petact
  1539.     @gamepet.cast_item_producing(FalPet::GoldAnime)
  1540.     if @gamepet.action_time == 2
  1541.       @gamepet.get_randomitem('gold', FalPet::RandomGold)
  1542.       $game_party.gain_gold(@gamepet.randomitem[0])
  1543.       RPG::SE.new("Shop",80).play
  1544.     end
  1545.   end
  1546.  
  1547.   #-----------------------------------------------------------------------------
  1548.   # Command instant cooldown
  1549.   def update_command_instantcd
  1550.     prepare_petact
  1551.     @gamepet.cast_item_producing(FalPet::GoldAnime, true)
  1552.     if @gamepet.action_time == 2
  1553.       @gamepet.instantcd = FalPet::BuffDuration * 60
  1554.     end
  1555.   end
  1556.  
  1557.   #-----------------------------------------------------------------------------
  1558.   alias falcaopet_move_straight move_straight
  1559.   def move_straight(d, turn_ok = true)
  1560.     return if @layingdown
  1561.     @gamepet.move_toward_char(self) if passable?(@x, @y, d) and
  1562.     not @gamepet.busy?
  1563.     falcaopet_move_straight(d, turn_ok = true)
  1564.     @just_jumped = false if @just_jumped
  1565.   end
  1566.  
  1567.   alias falcaopet_move_diagonal move_diagonal
  1568.   def move_diagonal(horz, vert)
  1569.     @gamepet.move_toward_char(self) if diagonal_passable?(@x,@y, horz, vert) and
  1570.     not @gamepet.busy?
  1571.     falcaopet_move_diagonal(horz, vert)
  1572.   end
  1573.  
  1574.   alias falcaopet_perform_transfer perform_transfer
  1575.   def perform_transfer
  1576.     $game_system.replay_bgm if @gamepet.command == 8
  1577.     globalpet_reset
  1578.     falcaopet_perform_transfer
  1579.     @gamepet.moveto(@x, @y)
  1580.     @gamepet.set_direction(@direction)
  1581.   end
  1582.  
  1583.   alias falcaopet_get_on_vehicle get_on_vehicle
  1584.   def get_on_vehicle
  1585.     falcaopet_get_on_vehicle
  1586.     if vehicle
  1587.       @showing_pet = false
  1588.       $game_system.replay_bgm if @gamepet.command == 8 ; globalpet_reset
  1589.     end
  1590.   end
  1591. end
  1592.  
  1593. # sprite set
  1594. class Spriteset_Map
  1595.   alias falcao_pet_create_characters create_characters
  1596.   def create_characters
  1597.     create_pet_sprite
  1598.     falcao_pet_create_characters
  1599.   end
  1600.  
  1601.   alias falcao_pet_dispose dispose
  1602.   def dispose
  1603.     dispose_pet_sprite
  1604.     dispose_petpop_window
  1605.     falcao_pet_dispose
  1606.   end
  1607.  
  1608.   def create_petpop_window
  1609.     return if not @mood_window.nil?
  1610.     @mood_window = Window_Base.new(544 / 2 - 230 / 2, 0, 230, 76)
  1611.     refresh_petpop_window
  1612.   end
  1613.  
  1614.   # refresh pet pop
  1615.   def refresh_petpop_window
  1616.     return if @mood_window.nil?
  1617.     @mood_window.contents.clear
  1618.     pet = $game_player.gamepet
  1619.     if pet.custom_mode != nil
  1620.       draw_extra_text(pet.custom_mode, 0, 20)
  1621.       return
  1622.     end
  1623.     case $game_player.petpop_type
  1624.  
  1625.     # Gain mood
  1626.     when 1
  1627.       @mood_window.draw_petmoodbar(0, 38)
  1628.       case (pet.mood.to_f / pet.grow_inflation[0].to_f * 100.0)
  1629.       when  0..25  ;  text = FalPet::MoodLowText
  1630.       when 26..50  ;  text = FalPet::MoodOverageText
  1631.       when 51..75  ;  text = FalPet::MoodMediumText
  1632.       when 76..100  ; text = FalPet::MoodHight
  1633.       end
  1634.       draw_extra_text(text, 100, 5, @mood_window.normal_color)
  1635.       # Giving gift
  1636.     when 2
  1637.       @mood_window.draw_petgift(110, 20)
  1638.       draw_extra_text('Được Nhận Quà', 0, 20)
  1639.       return if pet.mood == 0
  1640.       $game_party.gain_item(pet.mood_item, 1)
  1641.       RPG::SE.new("Item3",80).play
  1642.       pet.mood = 0
  1643.       pet.apply_growing
  1644.      
  1645.     when 3;  draw_extra_text('Lên Cấp!', 0, 20, Color.new(255, 120, 0, 255))
  1646.     when 4;  draw_extra_text('Không Thể Kích Hoạt...', 0, 20)
  1647.     when 5;  @mood_window.draw_stealed_item(0, 20)
  1648.              @mood_window.draw_petname(0, -8)
  1649.     when 6;  draw_extra_text('Không Thể Ăn Cắp!', 0, 20)
  1650.     when 7;  draw_extra_text('Chẳng Có Gì!', 0, 20)
  1651.     when 8;  draw_extra_text('Tôi Không Thể Lấy Được!', 0, 20)
  1652.     when 9;  draw_extra_text('Này Lại Gấn Đây!', 0, 20)  
  1653.     when 10
  1654.       draw_extra_text("Bạn Đã Được Chữa Lành #{FalPet::HealPercent}!",0, 20)
  1655.     when 11
  1656.       item = pet.randomitem
  1657.       @mood_window.contents.fill_rect(166, -6, 30, 30, Color.new(0, 0, 0, 60))
  1658.       if item[0].is_a? Fixnum
  1659.         @mood_window.draw_icon(344, 168, 0)
  1660.         draw_extra_text("Được Tặng x#{item[0]} #{Vocab::currency_unit}!", 0, 20)
  1661.       else
  1662.         @mood_window.draw_icon(item[0].icon_index, 168, 0)
  1663.         draw_extra_text("Được Tặng #{item[0].name} x#{item[1]}!", 0, 20)
  1664.       end
  1665.     when 12; draw_extra_text('Fuck that!', 0, 20)
  1666.     when 13; draw_extra_text('Thời Gian Sử Dụng Bắt Đầu !', 0, 20)  
  1667.     end
  1668.   end
  1669.  
  1670.   def draw_extra_text(text, x, y, color=nil)
  1671.     @mood_window.contents.font.color = color if !color.nil?
  1672.     @mood_window.draw_petname(0, -8)
  1673.     @mood_window.contents.font.size = 18
  1674.     @mood_window.contents.draw_text(x, y, @mood_window.width, 32, text)
  1675.   end
  1676.  
  1677.   def dispose_petpop_window
  1678.     return if @mood_window.nil?
  1679.     @mood_window.dispose
  1680.     @mood_window = nil
  1681.   end
  1682.  
  1683.   alias falcao_pet_update update
  1684.   def update
  1685.     if $game_player.petpop_refresh
  1686.       refresh_petpop_window
  1687.       $game_player.petpop_refresh = false
  1688.     end
  1689.     $game_player.showing_pet ? create_pet_sprite : dispose_pet_sprite
  1690.     $game_player.petpop_time > 0 ? create_petpop_window : dispose_petpop_window
  1691.     @pet_sprite.update unless @pet_sprite.nil?
  1692.     falcao_pet_update
  1693.   end
  1694.  
  1695.   def create_pet_sprite
  1696.     return if not @pet_sprite.nil?
  1697.     @pet_sprite = Sprite_Character.new(@viewport1, $game_player.gamepet)
  1698.   end
  1699.  
  1700.   def dispose_pet_sprite
  1701.     return if @pet_sprite.nil?
  1702.     @pet_sprite.dispose
  1703.     @pet_sprite = nil
  1704.   end
  1705. end
  1706.  
  1707. class Game_Event < Game_Character
  1708.   attr_accessor  :move_type
  1709.   attr_accessor  :target_index
  1710.   def check_evcom(comment)
  1711.     return false if @list.nil? or @list.size <= 0
  1712.     for item in @list
  1713.       if item.code == 108 or item.code == 408
  1714.         if item.parameters[0].include?(comment)
  1715.           return true
  1716.         end
  1717.       end
  1718.     end
  1719.     return false
  1720.   end
  1721.  
  1722.   def check_evvar(comment)
  1723.     return 0 if @list.nil? or @list.size <= 0
  1724.     for item in @list
  1725.       if item.code == 108 or item.code == 408
  1726.         if item.parameters[0] =~ /#{comment}[ ]?(\d+)?/
  1727.           return $1.to_i
  1728.         end
  1729.       end
  1730.     end
  1731.     return 0
  1732.   end
  1733.  
  1734.   def on_current_screen?
  1735.     px = ($game_map.display_x).truncate
  1736.     py = ($game_map.display_y).truncate
  1737.     distance_x = @x - px
  1738.     distance_y = @y - py
  1739.     return true if distance_x.between?(0, 16) and distance_y.between?(0, 12)
  1740.     return false
  1741.   end
  1742. end
  1743.  
  1744. # data manager
  1745. class << DataManager
  1746.   alias falcaopet_setup_new_game setup_new_game unless $@
  1747.   def setup_new_game
  1748.     falcaopet_setup_new_game
  1749.     $game_player.gamepet.moveto($data_system.start_x, $data_system.start_y)
  1750.   end
  1751. end
  1752.  
  1753. # Sprite character
  1754. class Sprite_Character < Sprite_Base
  1755.   alias falcaopet_zoom_update update
  1756.   def update
  1757.     self.zoom_x = @character.zoomfx_x
  1758.     self.zoom_y = @character.zoomfx_y
  1759.     self.angle = @character.anglefx
  1760.     falcaopet_zoom_update
  1761.   end
  1762.  
  1763.   alias falcaopet_update_pos update_position
  1764.   def update_position
  1765.     falcaopet_update_pos
  1766.     if @character.egrabbing
  1767.       self.x = $game_player.gamepet.screen_x
  1768.       self.y = $game_player.gamepet.screen_y - 14
  1769.       @character.x = $game_player.gamepet.x
  1770.       @character.y = $game_player.gamepet.y
  1771.       @character.set_direction($game_player.gamepet.direction) unless
  1772.       @character.direction_fix
  1773.       @character.move_speed = 6
  1774.       @character.move_type = 0
  1775.       @character.priority_type = 1
  1776.     end
  1777.   end
  1778. end
  1779.  
  1780. # get custom command data
  1781. class Game_Interpreter
  1782.   def pet
  1783.     return $game_player.gamepet
  1784.   end
  1785. end
  1786.  
  1787. # Game followers plugin, this fit the pet with followers members
  1788. class Game_Follower < Game_Character
  1789.   def chase_preceding_character
  1790.     unless moving?
  1791.       prechar = @preceding_character
  1792.       if $game_player.showing_pet
  1793.         if prechar.is_a?(Game_Player) and !prechar.followers.gathering? and
  1794.            !prechar.just_jumped and FalPet::YieldSpot
  1795.           sx = distance_x_from(prechar.x - prechar.adjustpxy[0])
  1796.           sy = distance_y_from(prechar.y - prechar.adjustpxy[1])
  1797.         else
  1798.           sx = distance_x_from(prechar.x) ; sy = distance_y_from(prechar.y)
  1799.         end
  1800.       else
  1801.         sx = distance_x_from(prechar.x) ; sy = distance_y_from(prechar.y)
  1802.       end
  1803.       if sx != 0 && sy != 0
  1804.         move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2)
  1805.       elsif sx != 0
  1806.         move_straight(sx > 0 ? 4 : 6)
  1807.       elsif sy != 0
  1808.         move_straight(sy > 0 ? 8 : 2)
  1809.       end
  1810.     end
  1811.   end
  1812. end
  1813.  
  1814. #===============================================================================
  1815. # * Scenes and Windows
  1816. #===============================================================================
  1817.  
  1818. # Window base new methods
  1819. class Window_Base < Window
  1820.   def draw_petmoodbar(x, y)
  1821.     contents.font.color = normal_color
  1822.     mood = $game_player.gamepet.mood
  1823.     max = $game_player.gamepet.grow_inflation[0]
  1824.     contents.fill_rect(x, y, 102, 10, Color.new(0, 0, 0))
  1825.     contents.fill_rect(x+1, y+1, 100 *mood / max, 4, Color.new(180, 225, 245))
  1826.     contents.fill_rect(x+1, y+5, 100 *mood / max, 4, Color.new(20, 160, 225))
  1827.     contents.font.size = 16
  1828.     contents.draw_text(x,y -24,self.width, 32, 'Kinh Nghiệm: ' + mood.to_s + "/#{max}")
  1829.   end
  1830.  
  1831.   def draw_petname(x, y, a=0)
  1832.     contents.font.size = 18
  1833.     contents.font.color = normal_color
  1834.     lv = $game_player.gamepet.pet_level ; name = $game_player.gamepet.petname
  1835.     contents.draw_text(x, y, self.width, 32, name + " Lv #{lv}", a)
  1836.   end
  1837.  
  1838.   def draw_petgift(x, y)
  1839.     contents.fill_rect(x, y - 18, 106, 76, Color.new(0, 0, 0, 60))
  1840.     item = $game_player.gamepet.mood_item
  1841.     draw_icon(item.icon_index, x + 30, y - 3)
  1842.     contents.font.size = 15
  1843.     contents.font.color = normal_color
  1844.     contents.draw_text(x -2, y - 24, 90, 32, 'Quà Lên Cấp', 1)
  1845.     contents.draw_text(x, y + 10, 90, 32, item.name, 1)
  1846.   end
  1847.  
  1848.   def draw_stealed_item(x, y)
  1849.     contents.fill_rect(x + 160, y - 21, 30, 30, Color.new(0, 0, 0, 60))
  1850.     contents.font.color = normal_color
  1851.     contents.font.size = 18
  1852.     item = $game_player.gamepet.stealed_item
  1853.     if item.is_a? Fixnum
  1854.       draw_icon(344, x + 163, y - 19)
  1855.       text = item.to_s + " #{Vocab::currency_unit}"
  1856.     else
  1857.       text = item.name
  1858.       draw_icon(item.icon_index, x + 163, y - 19)
  1859.     end
  1860.     contents.draw_text(x, y + 1, 200, 32, "Bạn Đã Trộm #{text}!")
  1861.   end
  1862. end
  1863.  
  1864. #-------------------------------------------------------------------------------
  1865. # Pets commands selectable
  1866. class Window_PetCommands < Window_Selectable
  1867.   def initialize(x=0, y=0, w=350, h=242) #192
  1868.     super(x, y + 76,  w, h)
  1869.     self.z = 101
  1870.     refresh
  1871.     self.index = 0
  1872.     activate if !busy?
  1873.   end
  1874.  
  1875.   def busy?
  1876.     return true if $game_player.gamepet.busy? || $game_player.in_airship? ||
  1877.     $game_player.in_boat? || $game_player.in_ship?
  1878.     return false
  1879.   end
  1880.  
  1881.   def item
  1882.     return @data[self.index]
  1883.   end
  1884.  
  1885.   def refresh
  1886.     self.contents.clear if self.contents != nil
  1887.     @data = []
  1888.     FalPet::Commands.sort.reverse.each do |id, command |
  1889.       next if id == 27
  1890.       @data.push(command) if id == 1 or id == 26
  1891.       @data.push(command) if $game_player.gamepet.unlock_command.include?(id)
  1892.       next if id == 26
  1893.       next unless id.between?(10, FalPet::Commands.keys.size)
  1894.       @data.push(command) if
  1895.       FalPet::Speciality[$game_player.gamepet.pet_id].include?(id)
  1896.     end
  1897.     @item_max = @data.size
  1898.     if @item_max > 0
  1899.       self.contents = Bitmap.new(width - 32, row_max * 26)
  1900.       for i in 0...@item_max
  1901.         draw_item(i)
  1902.       end
  1903.     end
  1904.   end
  1905.  
  1906.   def draw_item(index)
  1907.     item = @data[index]
  1908.     x, y = index % col_max * (145 + 32), index / col_max  * 24
  1909.     self.contents.font.size = 18
  1910.     draw_icon(item[2], x, y, !$game_player.gamepet.busy? )
  1911.     unless busy?
  1912.       cool_down(item[1]) > 0 ? self.contents.font.color = disable_color :
  1913.       self.contents.font.color = normal_color
  1914.     else
  1915.       self.contents.font.color = disable_color
  1916.     end
  1917.     self.contents.font.color = disable_color  if item[1] != 1 and
  1918.     !$game_player.showing_pet
  1919.     self.contents.draw_text(x + 24, y, 212, 32, item[0], 0)
  1920.   end
  1921.  
  1922.   def disable_color
  1923.     return Color.new(255, 255, 255, 128)
  1924.   end
  1925.  
  1926.   def cool_down(i)
  1927.     cd = $game_player.gamepet
  1928.     cooldown = 0
  1929.     FalPet::Commands.each do |id, cmd |
  1930.       cooldown = cd.cooldown[cmd[1]-1] if i == id and cd.cooldown[cmd[1] -1] > 0
  1931.     end
  1932.     return cooldown
  1933.   end
  1934.  
  1935.   def cool_data(i)
  1936.     data = [false, nil]
  1937.     FalPet::Commands.each do |id, cmd |
  1938.       data = [true, cmd[1] - 1] if i == id
  1939.     end
  1940.     return data
  1941.   end
  1942.  
  1943.   def item_max
  1944.     return @item_max.nil? ? 0 : @item_max
  1945.   end
  1946.  
  1947.   def col_max
  1948.     return 2
  1949.   end
  1950. end
  1951.  
  1952. #-------------------------------------------------------------------------------
  1953. # Scene pet commands
  1954. class Scene_PetCommands < Scene_Base
  1955.   def start
  1956.     super
  1957.     @pet = $game_player.gamepet
  1958.     x, y  = 544 / 2 - 350 / 2, 10
  1959.     @info_window = Window_Base.new(x, y, 350, 76)
  1960.     @color = Color.new(255, 120, 0, 255)
  1961.     @petCommand_window = Window_PetCommands.new(x, y)
  1962.     @mood_window = Window_Base.new(x, y + 76 + 242, 350, 76)
  1963.     @mood_window.draw_petmoodbar(0, 38)
  1964.     @mood_window.draw_petname(0, -8)
  1965.     @mood_window.draw_character(@pet.character_name,@pet.character_index,170,54)
  1966.     @mood_window.draw_petgift(236, 20)
  1967.     @background_sprite = Sprite.new
  1968.     @background_sprite.bitmap = SceneManager.background_bitmap
  1969.     @refresh_delay = 0
  1970.     refresh_info
  1971.   end
  1972.  
  1973.   def refresh_info
  1974.     @info_window.contents.clear
  1975.     @info_window.contents.font.size = 18
  1976.     @info_window.contents.font.color = @info_window.normal_color
  1977.     @petCommand_window.busy? ? text = 'Thú Cưng Đang Bận...' :
  1978.     text = @petCommand_window.item[6]
  1979.     @info_window.contents.draw_text(- 10, 0,@info_window.width, 32, text, 1)
  1980.     action = @petCommand_window.item[9]
  1981.     mood = @petCommand_window.item[8]
  1982.     mood = '' if mood == 0
  1983.     @info_window.contents.draw_text(0, 28, @info_window.width, 32,
  1984.     'Loại :  ' + action + " #{mood}")
  1985.     cooldown > 0 ? operand = cooldown : operand = @petCommand_window.item[7] *60
  1986.     operand = @pet.instantcd if @pet.instantcd > 0
  1987.     total_sec = operand / Graphics.frame_rate
  1988.     cd = sprintf("%02d:%02d", total_sec / 60, total_sec % 60)
  1989.     if @pet.instantcd > 0
  1990.       text = "Thời Gian Còn !:  #{cd}"
  1991.       @info_window.contents.font.color = @color
  1992.     else
  1993.       text = "Thời Gian Phục Hồi :   #{cd}"
  1994.     end
  1995.     @info_window.contents.draw_text(-50, 28, 350, 32, text, 2)
  1996.   end
  1997.  
  1998.   def cooldown
  1999.     return @petCommand_window.cool_down(@petCommand_window.item[1])
  2000.   end
  2001.  
  2002.   def update
  2003.     super
  2004.     if Input.trigger?(:B)
  2005.       SceneManager.goto(Scene_Map)
  2006.       Sound.play_cancel
  2007.     end
  2008.     return if @petCommand_window.busy?
  2009.     update_refresh
  2010.     if Input.trigger?(:C)
  2011.       cmd = @petCommand_window
  2012.       if cmd.item[1] != 1
  2013.         if cooldown > 0 || !$game_player.showing_pet
  2014.           Sound.play_buzzer
  2015.           return
  2016.         end
  2017.       end
  2018.       Sound.play_ok
  2019.       if @petCommand_window.item[4]
  2020.         apply_cooldown(cmd)
  2021.         SceneManager.callp(Scene_Event, @petCommand_window.item[1])
  2022.       elsif @petCommand_window.item[5]
  2023.         apply_cooldown(cmd)
  2024.         SceneManager.goto(Scene_Pets)
  2025.       else
  2026.         apply_cooldown(cmd)
  2027.         @pet.command = @petCommand_window.item[1]
  2028.         @pet.action_time = @petCommand_window.item[3]
  2029.         if @pet.custom_command?
  2030.           @pet.action_time = @pet.action_time + 1 if (@pet.action_time%2 == 0)
  2031.         end
  2032.         @pet.jumpto(0) if @petCommand_window.item[1] == 1 and
  2033.         $game_player.showing_pet
  2034.         $game_player.petpop_time =0 if @pet.reservedmood > 0 and cmd.item[8] > 0
  2035.         @pet.reservedmood = cmd.item[8]
  2036.         SceneManager.goto(Scene_Map)
  2037.       end
  2038.     end
  2039.   end
  2040.  
  2041.   def update_refresh
  2042.     refresh_info if cooldown > 0 || @pet.instantcd > 0
  2043.     if @index != @petCommand_window.index
  2044.       @index = @petCommand_window.index
  2045.       refresh_info
  2046.     end
  2047.     @refresh_delay -= 1 if @refresh_delay > 0
  2048.     @refresh_delay = 2 if @pet.instantcd == 1
  2049.     if @refresh_delay == 1
  2050.       @petCommand_window.refresh
  2051.       refresh_info
  2052.     end
  2053.     for i in 0...@pet.cooldown.size
  2054.       if @pet.cooldown[i] == 1
  2055.         @refresh_delay = 2
  2056.       end
  2057.     end
  2058.   end
  2059.  
  2060.   def apply_cooldown(cmd)
  2061.     if cmd.cool_data(cmd.item[1])[0] and cmd.cool_down(cmd.item[1]) == 0
  2062.       index = cmd.cool_data(cmd.item[1])[1]
  2063.       @pet.cooldown[index] = @petCommand_window.item[7] * 60
  2064.     end
  2065.   end
  2066.  
  2067.   def terminate
  2068.     super
  2069.     @petCommand_window.dispose
  2070.     @background_sprite.dispose
  2071.     @info_window.dispose
  2072.   end
  2073. end
  2074.  
  2075. #-------------------------------------------------------------------------------
  2076. # Invisible window event selection
  2077. class Window_Event < Window_Selectable
  2078.   attr_reader   :participants
  2079.   def initialize(x=0, y=0, w=150, h=192)
  2080.     super(x, y,  w, h)
  2081.     self.z = 101
  2082.     @participants = []
  2083.     refresh
  2084.     self.index = 0
  2085.     self.visible = false
  2086.     activate
  2087.   end
  2088.  
  2089.   def item
  2090.     return @data[self.index]
  2091.   end
  2092.  
  2093.   def refresh
  2094.     self.contents.clear if self.contents != nil
  2095.     @data = []
  2096.     for event in $game_map.events.values
  2097.       if event.on_current_screen?
  2098.         next if event.tile_id == 0 and event.character_name == ""
  2099.         next if event.check_evcom("/IGNORE TARGETING")
  2100.         @data.push(event)
  2101.         event.target_index = @data.size - 1
  2102.         @participants.push(event)
  2103.       end
  2104.     end
  2105.     @item_max = @data.size
  2106.     if @item_max > 0
  2107.       self.contents = Bitmap.new(width - 32, row_max * 26)
  2108.       for i in 0...@item_max
  2109.         draw_item(i)
  2110.       end
  2111.     end
  2112.   end
  2113.  
  2114.   def draw_item(index)
  2115.     item = @data[index]
  2116.     x, y = index % col_max * (120 + 32), index / col_max  * 24
  2117.     self.contents.font.size = 16
  2118.     self.contents.draw_text(x + 24, y, 212, 32, item.id.to_s, 0)
  2119.   end
  2120.  
  2121.   def item_max
  2122.     return @item_max.nil? ? 0 : @item_max
  2123.   end
  2124.  
  2125.   def col_max
  2126.     return 1
  2127.   end
  2128. end
  2129.  
  2130. #-------------------------------------------------------------------------------
  2131. # Scenen events selection target
  2132. class Scene_Event < Scene_Base
  2133.   def initialize(command)
  2134.     @command = command
  2135.   end
  2136.  
  2137.   def start
  2138.     super
  2139.     @mouse_exist = defined?(Map_Buttons).is_a?(String)
  2140.     @event_window = Window_Event.new
  2141.     @info_window = Sprite.new
  2142.     @info_window.bitmap = Bitmap.new(300, 60)
  2143.     @info_window.z = 900; @info_window.x = 544/2 -200/2; @info_window.y = 180
  2144.     @info_window.bitmap.font.size = 28; @info_window.bitmap.font.bold = true
  2145.     @event_window.item.nil? ? t = 'Chưa Có Mục Tiêu!' : t = 'Chọn Mục Tiêu'
  2146.     @info_window.bitmap.draw_text(-30, 0, @info_window.width, 32, t, 1)
  2147.     @background_sprite = Sprite.new
  2148.     @background_sprite.bitmap = SceneManager.background_bitmap
  2149.     @info_time = 60
  2150.     create_cursor unless @event_window.item.nil?
  2151.   end
  2152.  
  2153.   def refresh_info(type)
  2154.     @info_window.bitmap.clear
  2155.     t = 'Không Thể Leo Lên Được!' if type == 1
  2156.     t = 'Mục Tiêu Không Hợp Lệ!' if type == 2
  2157.     @info_window.bitmap.draw_text(-30, 0, @info_window.width, 32, t, 1)
  2158.   end
  2159.  
  2160.   def create_cursor
  2161.     if @mouse_exist
  2162.       @cursor = $mouse_cursor
  2163.       @cursor_zooming = 0 ; update_cursor_position
  2164.       return
  2165.     end
  2166.    
  2167.     @cursor = Sprite.new
  2168.     icon = FalPet::CursorIcon
  2169.     @cursor.bitmap = Bitmap.new(24, 24)
  2170.     bitmap = Cache.system("Iconset")
  2171.     rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
  2172.     @cursor.bitmap.blt(0, 0, bitmap, rect)
  2173.     @cursor_zooming = 0
  2174.     update_cursor_position
  2175.   end
  2176.  
  2177.   def update
  2178.     super
  2179.     if Input.trigger?(:B)
  2180.       SceneManager.goto(Scene_PetCommands)
  2181.       Sound.play_cancel
  2182.     end
  2183.     @info_time -= 1 if @info_time > 0
  2184.     if @info_time == 0
  2185.       @info_window.opacity -= 8 if @info_window.opacity > 0
  2186.       if @info_window.opacity == 0 and @event_window.item.nil?
  2187.         Sound.play_cancel
  2188.         SceneManager.goto(Scene_PetCommands)
  2189.       end
  2190.     end
  2191.      
  2192.     return if @event_window.item.nil?
  2193.     update_cursor_position
  2194.     update_target_selection
  2195.   end
  2196.  
  2197.   # target selection
  2198.   def update_target_selection
  2199.     if Input.trigger?(:C)
  2200.       if @mouse_exist
  2201.         for event in @event_window.participants
  2202.           if Mouse.map_grid[0] == event.x and Mouse.map_grid[1] == event.y
  2203.             @event_window.select(event.target_index)
  2204.             @selected = true
  2205.           end
  2206.         end
  2207.         if @selected.nil?
  2208.           refresh_info(2)
  2209.           @info_time = 60; @info_window.opacity = 255
  2210.           Sound.play_buzzer
  2211.           return
  2212.         end
  2213.       end
  2214.       if @command == 13 and not @event_window.item.check_evcom("/PET CLIMB")
  2215.         refresh_info(1)
  2216.         @info_time = 60; @info_window.opacity = 255
  2217.         Sound.play_buzzer
  2218.         return
  2219.       end
  2220.       Sound.play_ok
  2221.       $game_player.gamepet.chase_event_id = @event_window.item.id
  2222.       $game_player.gamepet.command = @command
  2223.       SceneManager.goto(Scene_Map)
  2224.     end
  2225.   end
  2226.  
  2227.   def update_cursor_position
  2228.     if @mouse_exist
  2229.       @cursor.x = Mouse.pos[0]
  2230.       @cursor.y = Mouse.pos[1]
  2231.     else
  2232.       @cursor.x = @event_window.item.screen_x
  2233.       @cursor.y = @event_window.item.screen_y - 16
  2234.     end
  2235.     @cursor_zooming += 1
  2236.     case @cursor_zooming
  2237.     when 1..10 ; @cursor.zoom_x -= 0.01 ; @cursor.zoom_y -= 0.01
  2238.     when 11..20; @cursor.zoom_x += 0.01 ; @cursor.zoom_y += 0.01
  2239.     when 21..30; @cursor.zoom_x = 1.0   ; @cursor.zoom_y = 1.0
  2240.       @cursor_zooming = 0
  2241.     end
  2242.   end
  2243.  
  2244.   def terminate
  2245.     super
  2246.     @event_window.dispose
  2247.     @background_sprite.dispose
  2248.     @info_window.dispose
  2249.     @info_window.bitmap.dispose
  2250.     if @mouse_exist
  2251.       @cursor.zoom_x = 1.0   ; @cursor.zoom_y = 1.0 ; @selected = nil
  2252.     else
  2253.       @cursor.dispose unless @cursor.nil?
  2254.       @cursor.bitmap.dispose unless @cursor.nil?
  2255.     end
  2256.   end
  2257. end
  2258.  
  2259. #-------------------------------------------------------------------------------
  2260. # Window pets
  2261. class Window_Pets < Window_Selectable
  2262.   def initialize(shop)
  2263.     super(0, 0,  406, 122)
  2264.     self.z = 101
  2265.     @shop = shop
  2266.     refresh
  2267.     self.index = 0
  2268.     activate
  2269.   end
  2270.  
  2271.   def item
  2272.     return @data[self.index]
  2273.   end
  2274.  
  2275.   def refresh
  2276.     self.contents.clear if self.contents != nil
  2277.     @data = []
  2278.     FalPet::Pets.each do |id , pet|
  2279.       pet.push(id) unless pet.include?(id)
  2280.       @data.push(pet) if @shop
  2281.       @data.push(pet) if $game_player.adopted_pets.include?(id) and !@shop
  2282.     end
  2283.     @item_max = @data.size
  2284.     if @item_max > 0
  2285.       self.contents = Bitmap.new(width - 32, row_max * 26)
  2286.       for i in 0...@item_max
  2287.         draw_item(i)
  2288.       end
  2289.     end
  2290.   end
  2291.  
  2292.   def draw_item(index)
  2293.     item = @data[index]
  2294.     x, y = index % col_max * (107 + 32), index / col_max  * 24
  2295.     self.contents.font.size = 18
  2296.     self.contents.draw_text(x, y, 212, 32, item[2], 0)
  2297.   end
  2298.  
  2299.   def item_max
  2300.     return @item_max.nil? ? 0 : @item_max
  2301.   end
  2302.  
  2303.   def col_max
  2304.     return 3
  2305.   end
  2306. end
  2307.  
  2308. #-------------------------------------------------------------------------------
  2309. # Scene pets base, refered at pep shop and pets adopted
  2310. class Scene_PetsBase < Scene_Base
  2311.   def start
  2312.     super
  2313.     @pet = $game_player.gamepet
  2314.     SceneManager.scene_is?(Scene_PetShop) ? @shop = true : @shop = false
  2315.     @pet_window = Window_Pets.new(@shop)
  2316.     x, y = 544 / 2 -406 / 2, 0
  2317.     @pet_window.x = x
  2318.     @pet_window.y = y + 110
  2319.     @info_window = Window_Base.new(x, y, 406, 110)
  2320.     @bonus_window = Window_Base.new(x, y + 122 + 110, 406, 184)
  2321.     @background_sprite = Sprite.new
  2322.     @background_sprite.bitmap = SceneManager.background_bitmap
  2323.     refresh_infodata
  2324.   end
  2325.  
  2326.   def refresh_infodata
  2327.     @info_window.contents.clear
  2328.     @info_window.contents.font.size = 18
  2329.     @shop ? xy = [0, 0] : xy = [286, 0]
  2330.     @info_window.contents.fill_rect(xy[0], xy[1],90,76, Color.new(0,0,0,60))
  2331.     @info_window.draw_character(@pet_window.item[0],
  2332.     @pet_window.item[1], xy[0] + 45, xy[1] + 64)
  2333.     @info_window.draw_text(xy[0] + 20, xy[1] + 66, 350, 32, 'Hình Ảnh')
  2334.     create_price_info if @shop
  2335.     refresh_bonus
  2336.     return if @shop
  2337.     @info_window.contents.fill_rect(0, -18, 90, 90, Color.new(0, 0, 0, 60))
  2338.     @info_window.draw_text(0, 64, @info_window.width, 32, 'Thú Cưng Hiện Tại')
  2339.     @info_window.draw_text(-16, 0, @info_window.width, 32, @pet.petname, 1)
  2340.     @info_window.draw_character(@pet.character_name,@pet.character_index,45,64)
  2341.   end
  2342.  
  2343.   def refresh_bonus
  2344.     @bonus_window.contents.clear
  2345.     @bonus_window.contents.font.size = 20
  2346.     y = 0; manager = 0
  2347.     @bonus_window.contents.font.color = Color.new(255, 120, 0, 255)
  2348.     @bonus_window.draw_text(40, -6, 406, 32, 'Kĩ Năng Thú Cưng', 1)
  2349.     @bonus_window.draw_text(0, -6, 406, 32, 'Chỉ Số Sức Mạnh')
  2350.     @bonus_window.contents.font.color = @bonus_window.normal_color
  2351.    
  2352.     # draw speciality
  2353.     @bonus_window.contents.font.size = 16
  2354.     enable = FalPet::Speciality[@pet_window.item[6]]
  2355.     FalPet::Commands.each do |id, command |
  2356.       if enable.include?(id)
  2357.         manager += 1
  2358.         (manager%2 == 0) ? x = 260 : y += 17
  2359.         x = 128 unless (manager%2 == 0)
  2360.         @bonus_window.draw_text(x, y, @bonus_window.width, 32, command[0])
  2361.       end
  2362.     end
  2363.    
  2364.     #draw bonus parameters
  2365.     bonus = FalPet::Bonus[@pet_window.item[6]]
  2366.     y = 0
  2367.     for i in 0...8
  2368.       y += 17
  2369.       @bonus_window.draw_text(0, y, 406, 32, Vocab.param(i))
  2370.       @bonus_window.draw_text(58, y, 406, 32, "=> #{bonus[i].to_s}")
  2371.     end
  2372.   end
  2373.  
  2374.   def create_price_info
  2375.     @info_window.contents.font.size = 22
  2376.     @info_window.draw_text(156, 0, @info_window.width, 32, 'Shop Thú Cưng')
  2377.     @info_window.contents.font.size = 18
  2378.     @info_window.draw_text(156, 32, 350, 32, "Tên : #{@pet_window.item[2]}")
  2379.     v = pet_price
  2380.     @info_window.draw_text(156,64,350,18,"Giá :  $#{v} " + Vocab::currency_unit)
  2381.     @info_window.contents.fill_rect(320, -18, 62, 56, Color.new(0, 0, 0, 60))
  2382.     @info_window.draw_text(28, 0, 350, 18, $game_party.gold.to_s, 2)
  2383.     @info_window.draw_text(28, 18, 350, 18, Vocab::currency_unit, 2)
  2384.   end
  2385.  
  2386.   def pet_price
  2387.     return FalPet::Price[@pet_window.item[6]]
  2388.   end
  2389.  
  2390.   def terminate
  2391.     super
  2392.     @bonus_window.dispose
  2393.     @background_sprite.dispose
  2394.     @info_window.dispose
  2395.     @pet_window.dispose
  2396.   end
  2397. end
  2398.  
  2399. #-------------------------------------------------------------------------------
  2400. # Scene pet adopted
  2401. class Scene_Pets < Scene_PetsBase
  2402.  
  2403.   def start() super end
  2404.   def update
  2405.     super
  2406.     if Input.trigger?(:B)
  2407.       SceneManager.goto(Scene_PetCommands)
  2408.       Sound.play_cancel
  2409.     end
  2410.     if @index != @pet_window.index
  2411.       @index = @pet_window.index
  2412.       refresh_infodata
  2413.     end
  2414.     if Input.trigger?(:C)
  2415.       @pet.setup_pet(@pet_window.item[6])
  2416.       refresh_infodata    
  2417.     end
  2418.   end
  2419. end
  2420.  
  2421. #-------------------------------------------------------------------------------
  2422. # Scene pet shop
  2423.  
  2424. class Scene_PetShop < Scene_PetsBase
  2425.  
  2426.   def start
  2427.     super
  2428.     @pop_window = Window_Base.new(200, 170, 150, 110)
  2429.     @pop_window.z = 500
  2430.     @pop_time = 0
  2431.     @pop_window.visible = false
  2432.   end
  2433.  
  2434.   def refresh_pop(type)
  2435.     @pop_window.contents.clear
  2436.     @pop_window.contents.font.size = 18
  2437.     case type
  2438.     when 1
  2439.       @pop_window.draw_text(0, 0, @pop_window.width, 32, "Bạn Đã Mua!")
  2440.       @pop_window.draw_text(0, 22, @pop_window.width, 32, @pet_window.item[2])
  2441.       @pop_window.draw_text(0, 44, @pop_window.width, 32,
  2442.       Vocab::currency_unit + " -#{pet_price}")
  2443.     when 2
  2444.       @pop_window.draw_text(0, 0, 200, 32, "Bạn Không Đủ")
  2445.       @pop_window.draw_text(0, 22, 200, 32, "Tiền #{Vocab::currency_unit}")
  2446.     when 3
  2447.       @pop_window.draw_text(0, 0, @pop_window.width, 32, "Bạn Đã Sở Hữu!")
  2448.       @pop_window.draw_text(0, 22, @pop_window.width, 32, @pet_window.item[2])
  2449.     end
  2450.   end
  2451.  
  2452.   def update
  2453.     super
  2454.     if Input.trigger?(:B)
  2455.       SceneManager.goto(Scene_Map)
  2456.       Sound.play_cancel
  2457.     end
  2458.     if @index != @pet_window.index
  2459.       @index = @pet_window.index
  2460.       refresh_infodata
  2461.     end
  2462.     update_buying
  2463.   end
  2464.  
  2465.   def update_buying
  2466.     @pop_time -= 1 if @pop_time > 0
  2467.     @pop_time > 0 ? @pop_window.visible = true : @pop_window.visible = false
  2468.     if Input.trigger?(:C)
  2469.       if $game_player.adopted_pets.include?(@pet_window.item[6])
  2470.         refresh_pop(3)
  2471.         @pop_time = 2 * 60
  2472.         Sound.play_cancel
  2473.         return
  2474.       end
  2475.       if $game_party.gold >= pet_price
  2476.         $game_party.lose_gold(pet_price)
  2477.         RPG::SE.new("Shop", 80,).play
  2478.         $game_player.adopt_pet(@pet_window.item[6])
  2479.         refresh_infodata
  2480.         refresh_pop(1)
  2481.         @pop_time = 2 * 60
  2482.       else
  2483.         refresh_pop(2)
  2484.         @pop_time = 2 * 60
  2485.         Sound.play_buzzer
  2486.       end
  2487.     end
  2488.   end
  2489.  
  2490.   def terminate
  2491.     super
  2492.     @pop_window.dispose
  2493.   end
  2494. end
  2495.  
  2496. #-------------------------------------------------------------------------------
  2497.  
  2498. # update global cool down
  2499. class << Input
  2500.   unless self.method_defined?(:falcaopet_ccd_update)
  2501.     alias_method :falcaopet_ccd_update,   :update
  2502.   end
  2503.  
  2504.   def update
  2505.     update_cooldown_system
  2506.     falcaopet_ccd_update
  2507.   end
  2508.  
  2509.   def update_cooldown_system
  2510.     player = $game_player
  2511.     unless player.nil?
  2512.       player.gamepet.instantcd -= 1 if player.gamepet.instantcd > 0
  2513.       for i in 0...player.gamepet.cooldown.size
  2514.         if player.gamepet.cooldown[i] > 0 and player.gamepet.instantcd > 0    
  2515.           player.gamepet.cooldown[i] = 0 if not i == 19 - 1
  2516.         end
  2517.         player.gamepet.cooldown[i] -= 1 if player.gamepet.cooldown[i] > 0
  2518.       end
  2519.     end
  2520.   end
  2521. end
  2522.  
  2523. module SceneManager
  2524.   def self.callp(scene_class, *args)
  2525.     @scene = scene_class.new(*args)
  2526.   end
  2527. end
  2528.  
  2529. #-------------------------------------------------------------------------------
  2530. # FA Interactive System 2.0 pet plug-ins
  2531.  
  2532. class Game_Player < Game_Character
  2533.   if defined?(FalInt).is_a?(String)
  2534.     alias falcaopetplugins_fall player_start_falling
  2535.     def player_start_falling
  2536.       @showing_pet = false
  2537.       $game_system.replay_bgm if @gamepet.command == 8 ; globalpet_reset
  2538.       falcaopetplugins_fall
  2539.     end
  2540.   end
  2541. end
  2542.  
  2543. class Game_CharacterBase
  2544.   if defined?(FalInt).is_a?(String)
  2545.     alias falcaopetplugins_start_jump start_jump
  2546.     def start_jump(power)
  2547.       player = self.is_a?(Game_Player)
  2548.       if player and Input.dir4 != 0
  2549.         self.followers.reverse_each {|f| f.move_toward_player }
  2550.         self.gamepet.move_toward_player ; self.gamepet.move_toward_player
  2551.         self.gamepet.jump(0,  power)  if @direction == 2
  2552.         self.gamepet.jump(- power, 0) if @direction == 4
  2553.         self.gamepet.jump(power,  0)  if @direction == 6
  2554.         self.gamepet.jump(0, - power) if @direction == 8
  2555.         self.just_jumped = true
  2556.       end
  2557.       falcaopetplugins_start_jump(power)
  2558.     end
  2559.   end
  2560. end