Advertisement
TheSixth

Mime Effect Addon

Oct 30th, 2020 (edited)
2,521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.80 KB | None | 0 0
  1. =begin
  2.  
  3. - Mime Effect Addon v1.1
  4. - Made by: Sixth
  5. - Requires: Tsukihime's Mime Effect
  6.  
  7. - Description:
  8.  
  9. This short script will let you make skills that can't be mimed.
  10. From v1.1, it will also add a success rate feature for your mime skills.
  11.  
  12. - Note-tags:
  13.  
  14. Use this note-tag on the skills you do NOT want to allow to be mimed:
  15.  
  16.   <no_mime>
  17.  
  18. That's it!
  19.  
  20. Use this note-tag to setup the chance for the mime to succeed:
  21.  
  22.   <mime_chance: value>
  23.  
  24. The value must be replaced by the percentage of success.
  25. It must be an integer number from 0 to 100.
  26. 0 = 0%, 15 = 15%, 100 = 100%, and so on.
  27.  
  28.   Examples:
  29.  
  30.   <mime_chance: 30>
  31.   <mime_chance: 50>
  32.   <mime_chance: 85>
  33.  
  34. If a mime skill got no success chance note-tag, it will be set to 100%
  35. automatically.
  36.  
  37. Ohh, and the battle log for a failed mime skill expects a skill that doesn't
  38. have any effects or damage setup.
  39. If it has some effects or damage, the battle log will not display the text
  40. for the failed mime.
  41.  
  42. - Installation:
  43.  
  44. Place this script below Tsukihime's Mime Effect script!
  45.  
  46. =end
  47.  
  48. class RPG::UsableItem
  49.  
  50.   attr_accessor :mime_chance
  51.  
  52.   def can_mime?
  53.     @can_mime = !(@note =~ /<no_mime>/i) if @can_mime.nil?
  54.     return @can_mime
  55.   end
  56.  
  57.   def mime_chance
  58.     init_mime_chance if @mime_chance.nil?
  59.     return @mime_chance
  60.   end
  61.  
  62.   def init_mime_chance
  63.     @mime_chance = @note =~ /<mime_chance:(?:\s*)(\d+)>/ ? $1.to_i : 100
  64.   end
  65.  
  66. end
  67.  
  68. class Game_Action
  69.  
  70.   def can_mime?
  71.     return false unless self.item
  72.     return self.item.can_mime?
  73.   end
  74.  
  75.   def name
  76.     return self.item ? self.item.name : "nothing"
  77.   end
  78.  
  79. end
  80.  
  81. class Scene_Battle < Scene_Base
  82.  
  83.   def check_mime_action # Overwrite!
  84.     item = @subject.current_action.item
  85.     if item.mime_effect?
  86.       l_act = @subject.current_action.friends_unit.last_action
  87.       if l_act && l_act.can_mime?
  88.         if item.mime_chance > rand(100)
  89.           replace_action
  90.           @subject.use_item(item) # mime item usage
  91.         else
  92.           @log_window.mime_fail = ['fail', l_act.name ]
  93.         end
  94.       else
  95.         @log_window.mime_fail = l_act ? l_act.name : "nothing"
  96.       end
  97.     end
  98.   end
  99.  
  100. end
  101.  
  102. class Window_BattleLog < Window_Selectable
  103.  
  104.   attr_accessor :mime_fail
  105.    
  106.   alias disp_mime_fail7151 display_failure
  107.   def display_failure(target, item)
  108.     if @mime_fail.is_a?(Array)
  109.       add_text(sprintf("Failed to mime %s!", @mime_fail[1]))
  110.       wait
  111.       @mime_fail = false
  112.     elsif @mime_fail == 'nothing'
  113.       add_text("But there is nothing to be mimed!")
  114.       wait
  115.       @mime_fail = false
  116.     elsif @mime_fail.is_a?(String)
  117.       add_text(sprintf("But %s can't be mimed!", @mime_fail))
  118.       wait
  119.       @mime_fail = false
  120.     else
  121.       disp_mime_fail7151(target, item)
  122.     end
  123.   end
  124.  
  125. end
  126. # End of script!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement