kirbwarrior
Member
whats a method? and as for .default, i don't know how to use that... i just used what was in your example
module Energy
Start = {}
Start.default = 100
Gain = {}
Gain.default = 10
def self.maxe(actor)
n = Start[actor.id]
n += Gain[actor.id] * actor.level
return n
end
end
class Game_Actor
attr_reader :energy
alias_method :seph_energy_gmactr_setup, :setup
def setup(actor_id)
seph_energy_gmactr_setup(actor_id)
@energy = maxe
end
def maxe
return Energy.maxe(self)
end
end
actor.energy = current energy
actor.maxe = max enery
class Game_Actor
alias_method :seph_energyaddition_gmactr_maxe, :maxe
def maxe
n = seph_energyaddition_gmactr_maxe
# Make your additions here
return n
end
end
class RPG::Item
Energy_Restore = {}
Energy_Restore.default = 50
def energy_restore
return Energy[@id]
end
end
class Game_Battler
alias_method :seph_energyrestore_gmbtlr_ie, :item_effect
def item_effect(item)
# This will get the result of the original method call.
# If its true, the item was used on the actor.
# If false, don't bother restoring energy because it "missed"
result = seph_energyrestore_gmbtlr_ie(item)
if result
self.energy += item.energy_restore
end
return result
end
end
class Game_Battler
def energy=(energy)
@energy = [energy, maxe].min
end
end
class Game_Battler
def energy
return [@energy, maxe].min
end
end