Advertisement
Fomar0153

Fomar0153 - Transformation States 1.0

Mar 5th, 2012
3,606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.77 KB | None | 0 0
  1. =begin
  2. Transformation States
  3. by Fomar0153
  4. Version 1.0
  5. ----------------------
  6. Notes
  7. ----------------------
  8. This script allows you to transform in battle through the
  9. application of states.
  10. ----------------------
  11. Instructions
  12. ----------------------
  13. Notetag the states:
  14. <transformclass x>
  15. Where x is the class id of the class you want to use.
  16. <transformequips x>
  17. <transformequips x,x>
  18. <transformequips x,x,x,x,x>
  19. Where x = -1 -> Use the original equipment
  20. Where x = 0  -> Blank the equipment
  21. Where x > 0  -> Use the equipment of id
  22. Note your current equipment is copied and then the changes
  23. are applied. So you only need as many entries to cover you
  24. upto the last piece of equipment you want to change.
  25.  
  26. Note: Both are optional so use them as you want.
  27. <transformequips 0> for example could be used for a disarm state.
  28. ----------------------
  29. Known bugs
  30. ----------------------
  31. None
  32. =end
  33. class Game_Actor < Game_Battler
  34.  
  35.   def transform_class
  36.     for state in @states
  37.       if $data_states[state].transform_class > 0
  38.         return $data_states[state].transform_class
  39.       end
  40.     end
  41.     return 0
  42.   end
  43.  
  44.   def transform_equips
  45.     for state in @states
  46.       unless $data_states[state].transform_equips == []
  47.         return $data_states[state].transform_equips
  48.       end
  49.     end
  50.     return []
  51.   end
  52.  
  53.   alias ft_class class
  54.   def class
  55.     if transform_class > 0
  56.       $data_classes[transform_class]
  57.     else
  58.       ft_class
  59.     end
  60.   end
  61.  
  62.   alias ft_skills skills
  63.   def skills
  64.     if transform_class > 0
  65.       skills = []
  66.       self.class.learnings.each do |learning|
  67.         skills.push($data_skills[learning.skill_id]) if learning.level <= @level
  68.       end
  69.       return skills
  70.     else
  71.       ft_skills
  72.     end
  73.   end
  74.  
  75.   alias ft_equips equips
  76.   def equips
  77.     unless transform_equips == []
  78.       equip_ids = transform_equips
  79.       new_equips = ft_equips
  80.       for i in 0..equip_ids.size - 1
  81.         if equip_ids[i] == -1
  82.           new_equips[i] = @equips[i].object
  83.         elsif equip_ids[i] == 0
  84.           new_equips[i] = nil
  85.         else
  86.           if index_to_etype_id(i) == 0
  87.             new_equips[i] = $data_weapons[equip_ids[i]]
  88.           else
  89.             new_equips[i] = $data_armors[equip_ids[i]]
  90.           end
  91.         end
  92.       end
  93.       return new_equips
  94.     else
  95.       ft_equips
  96.     end
  97.   end
  98.  
  99. end
  100.  
  101. module RPG
  102.   class State
  103.    
  104.     def transform_class
  105.       if @note =~ /<transformclass (.*)>/i
  106.         return $1.to_i
  107.       end
  108.       return 0
  109.     end
  110.    
  111.     def transform_equips
  112.       if @note =~ /<transformequips (.*)>/i
  113.         equips = []
  114.         for equip in $1.split(",")
  115.           equips.push(equip.to_i)
  116.         end
  117.         return equips
  118.       end
  119.       return []
  120.     end
  121.    
  122.   end
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement