Advertisement
Fomar0153

Fomar0153 - Extra Traits/Features on Level Up

Mar 3rd, 2012
2,466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.50 KB | None | 0 0
  1. =begin
  2. Extra Traits/Features on Level Up
  3. by Fomar0153
  4. Version 1.0
  5. ----------------------
  6. Notes
  7. ----------------------
  8. This script allows you to gain traits/features when you level up.
  9. ----------------------
  10. Instructions
  11. ----------------------
  12. To add a trait when you level you need to set it up so that you learn
  13. a skill at that level, I reccomend making a new catagory called passive
  14. and having them be part of that. Give it an appropriate name e.g.
  15. "Half MP Cost" etc, in messages it will be followed by " was learned."
  16. Then in the note box for the learning use the following notetag:
  17. <extratrait x>
  18. Then all the traits from the source data with that id will be added to
  19. the character.
  20. Source data can refer to weapons, armours or states.
  21. Set EXTRA_FEATURES_SOURCE to:
  22. 0 -> Weapons
  23. 1 -> Armours
  24. 2 -> States
  25. By default it is set to states
  26. ----------------------
  27. Known bugs
  28. ----------------------
  29. None
  30. =end
  31. class Game_Actor < Game_Battler
  32.   # Set this constant to determine the source of the extra features.
  33.   EXTRA_FEATURES_SOURCE = 2
  34.   #--------------------------------------------------------------------------
  35.   # ● セットアップ
  36.   #--------------------------------------------------------------------------
  37.   alias ef_setup setup
  38.   def setup(actor_id)
  39.     @extra_features = Extra_Features.new
  40.     @extra_features.features = []
  41.     ef_setup(actor_id)
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 特徴を保持する全オブジェクトの配列取得
  45.   #--------------------------------------------------------------------------
  46.   alias ef_feature_objects feature_objects
  47.   def feature_objects
  48.     ef_feature_objects + [@extra_features]
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● レベルアップ
  52.   #--------------------------------------------------------------------------
  53.   alias ef_level_up level_up
  54.   def level_up
  55.     level = @level + 1
  56.     self.class.learnings.each do |learning|
  57.       if learning.level == level
  58.         if learning.note =~ /<extratrait (.*)>/i
  59.            @extra_features.features += $data_weapons[$1.to_i].features if EXTRA_FEATURES_SOURCE == 0
  60.            @extra_features.features += $data_armors[$1.to_i].features if EXTRA_FEATURES_SOURCE == 1
  61.            @extra_features.features += $data_states[$1.to_i].features if EXTRA_FEATURES_SOURCE == 2
  62.          end
  63.        end
  64.      end
  65.      ef_level_up
  66.   end
  67. end
  68.  
  69. class Extra_Features
  70.   attr_accessor :features
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement