updated to 4.4, fixed levelup
This commit is contained in:
parent
ce5d12df95
commit
cd62e12389
64 changed files with 178 additions and 60 deletions
|
|
@ -68,23 +68,47 @@ func set_values(p_unique_id : String = "", current_values: Dictionary = {}, p_le
|
|||
## This sets the monster to the specified level
|
||||
func set_level(p_level: int) -> void:
|
||||
self.level = p_level
|
||||
#print("old: %s/%s" % [self.current_health, self.health])
|
||||
update()
|
||||
#print("new: %s/%s" % [self.current_health, self.health])
|
||||
|
||||
# Updates the values according to the current level of the monster
|
||||
func update() -> void:
|
||||
func update() -> void:
|
||||
|
||||
# INFO: the "current" values like the current_health should keep the percentage ratio
|
||||
# of the new and increased values like max_health
|
||||
var health_ratio: float = float(current_health) / float(self.health)
|
||||
#print("Ratio is %s" % str(health_ratio))
|
||||
|
||||
var new_current_health_value: int = round( float(self.health) * health_ratio )
|
||||
#print(new_current_health_value)
|
||||
|
||||
if new_current_health_value > self.current_health:
|
||||
self.current_health = new_current_health_value
|
||||
|
||||
self.attack = int((((base_attack * 2.0) * level ) / 100) + (level + 5))
|
||||
self.health = int((((base_health * 2.0) * level ) / 100) + (level + 5))
|
||||
self.defense = int((((base_defense * 2.0) * level ) / 100) + (level + 5))
|
||||
self.tempo = int((((base_tempo * 2.0) * level ) / 100) + (level + 5))
|
||||
self.xp_for_levelup = int(pow(level + 1, 3))
|
||||
|
||||
# This is the default growth rate formula: n^3
|
||||
# It calculates the total cumulative xp needed to reach level n
|
||||
# To determine the XP needed for levelup, subtract the needed absolute xp
|
||||
# for the current level from the next level
|
||||
self.xp_for_levelup = int( (pow(level + 1, 3) - pow(level, 3)) )
|
||||
|
||||
func level_up() -> void:
|
||||
print("monster_data.gd: %s leveled up!" % self.name)
|
||||
set_level(level + 1)
|
||||
|
||||
# reset the gained XP
|
||||
self.xp = 0
|
||||
|
||||
emit_signal("on_level_up")
|
||||
|
||||
func calculate_gained_xp(enemy_data: MonsterData) -> int:
|
||||
var calculated_xp: int = 0
|
||||
calculated_xp = int( (enemy_data.base_xp * enemy_data.level / 5.0) * ( float(enemy_data.level) / float(level) ) )
|
||||
calculated_xp = 1 + int( (enemy_data.base_xp * enemy_data.level / 5.0) * ( float(enemy_data.level) / float(level) ) )
|
||||
return calculated_xp
|
||||
|
||||
func add_xp(amount: int = 0) -> void:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue