updated to 4.4, fixed levelup
This commit is contained in:
parent
ce5d12df95
commit
cd62e12389
64 changed files with 178 additions and 60 deletions
1
resources/asset_info.gd.uid
Normal file
1
resources/asset_info.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b7oqmdlfu5k6h
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
1
resources/monster_data.gd.uid
Normal file
1
resources/monster_data.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c37crtp1pdt42
|
||||
1
resources/monster_type.gd.uid
Normal file
1
resources/monster_type.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cxuxtevirvn7j
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_resource type="Resource" script_class="MonsterData" load_steps=4 format=3 uid="uid://0xqaef8uftnv"]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/monster_data.gd" id="1_2n3ph"]
|
||||
[ext_resource type="Script" uid="uid://c37crtp1pdt42" path="res://resources/monster_data.gd" id="1_2n3ph"]
|
||||
[ext_resource type="PackedScene" uid="uid://h2we7rb772hy" path="res://assets/models/round_bat/model/bat.glb" id="1_dsg0f"]
|
||||
[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="2_a4t2w"]
|
||||
|
||||
|
|
@ -13,17 +13,17 @@ thumbnail = ExtResource("2_a4t2w")
|
|||
model = ExtResource("1_dsg0f")
|
||||
primary_type = 5
|
||||
secondary_type = 17
|
||||
base_attack = 10
|
||||
base_health = 20
|
||||
base_defense = 30
|
||||
base_tempo = 40
|
||||
base_xp = 3
|
||||
base_attack = 45
|
||||
base_health = 40
|
||||
base_defense = 40
|
||||
base_tempo = 56
|
||||
base_xp = 55
|
||||
attack = 1
|
||||
current_health = 1
|
||||
health = 1
|
||||
defense = 1
|
||||
tempo = 1
|
||||
level = 1
|
||||
xp = 1
|
||||
xp = 0
|
||||
nickname = ""
|
||||
xp_for_levelup = 1
|
||||
|
|
|
|||
1
resources/save_game/save_game.gd.uid
Normal file
1
resources/save_game/save_game.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://co1n2rldtc1d1
|
||||
1
resources/save_game/save_manager.gd.uid
Normal file
1
resources/save_game/save_manager.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://fu02qhhn4vh8
|
||||
1
resources/save_game/saved_data.gd.uid
Normal file
1
resources/save_game/saved_data.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://tosto05trpfl
|
||||
Loading…
Add table
Add a link
Reference in a new issue