Advertisement
Fomar0153

Fomar0153 - Cook Skill 1.0

Jun 3rd, 2012
779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.29 KB | None | 0 0
  1. =begin
  2. Cook Skill
  3. by Fomar0153
  4. Version 1.0
  5. ----------------------
  6. Notes
  7. ----------------------
  8. Allows you to cook enemies and cause them to drop a set item.
  9. ----------------------
  10. Instructions
  11. ----------------------
  12. By default an enemy is only eatable if you set them to have
  13. a cooked drop item. To set it notetag the enemy:
  14. <cook_itemid x>
  15. where x is the id of the item.
  16.  
  17. By default an enemy has to be under 20% health in order for the
  18. cook skill to work. You can edit this by notetagging the enemy:
  19. <cook_chance x>
  20. where x is the chance e.g. 20 -> 20%
  21.  
  22. To set up the skill in the custom damage formula box enter:
  23. b.cook
  24. ----------------------
  25. Known bugs
  26. ----------------------
  27. None
  28. =end
  29. class Game_Enemy < Game_Battler
  30.   #--------------------------------------------------------------------------
  31.   # * Object Initialization
  32.   #--------------------------------------------------------------------------
  33.   alias cook_initialize initialize
  34.   def initialize(index, enemy_id)
  35.     cook_initialize(index, enemy_id)
  36.     @cooked = false
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # * Can you smell what Thalzon is cooking?
  40.   #--------------------------------------------------------------------------
  41.   def cook
  42.     return if enemy.cook_chance == 0 or enemy.cook_itemid == 0
  43.     if @hp < (enemy.cook_chance * mhp)/100
  44.       @cooked = true
  45.       damage = @hp
  46.       add_state(1)
  47.       damage
  48.     else
  49.       0
  50.     end
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Create Array of Dropped Items
  54.   #--------------------------------------------------------------------------
  55.   alias cook_make_drop_items make_drop_items
  56.   def make_drop_items
  57.     if @cooked
  58.       cook_make_drop_items + [$data_items[enemy.cook_itemid]]
  59.     else
  60.       cook_make_drop_items
  61.     end
  62.   end
  63. end
  64.  
  65. class RPG::Enemy
  66.  
  67.   def cook_chance
  68.     if @cook_chance.nil?
  69.       if @note =~ /<cook_chance (.*)>/i
  70.         @cook_chance = $1.to_i
  71.       else
  72.         @cook_chance = 20
  73.       end
  74.     end
  75.     @cook_chance
  76.   end
  77.  
  78.   def cook_itemid
  79.     if @cook_itemid.nil?
  80.       if @note =~ /<cook_itemid (.*)>/i
  81.         @cook_itemid = $1.to_i
  82.       else
  83.         @cook_itemid = 0
  84.       end
  85.     end
  86.     @cook_itemid
  87.   end
  88.  
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement