diff --git a/game/scripts/auras/aura_script.gd b/game/scripts/auras/aura_script.gd index 34f9dea2..86efc7b0 100644 --- a/game/scripts/auras/aura_script.gd +++ b/game/scripts/auras/aura_script.gd @@ -21,6 +21,67 @@ class_name AuraGD # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. + +func _handle_aura_damage(aura_data : AuraData, damage_info : SpellDamageInfo) -> void: + randomize() + + damage_info.damage = damage_min + (randi() % (damage_max - damage_min)) + damage_info.damage_source_type = aura_data.aura.damage_type + + if (is_instance_valid(damage_info.dealer)): + damage_info.dealer.sdeal_damage_to(damage_info) + +func _handle_aura_heal(aura_data : AuraData, shi : SpellHealInfo) -> void: + randomize() + + shi.heal = heal_min + (randi() % (heal_max - heal_min)) + shi.heal_source_type = aura_data.aura.aura_type + + shi.dealer.sdeal_heal_to(shi) + +func _sapply(info : AuraApplyInfo) -> void: +# var add : bool = false + var ad : AuraData = info.target.sget_aura_by(info.caster, info.aura.id) + + if ad == null: +# add = true + ad = AuraData.new() + + setup_aura_data(ad, info); + + for i in range(get_aura_stat_attribute_count()): + var stat_attribute : AuraStatAttribute = get_aura_stat_attribute(i) + var stat : Stat = info.target.get_stat_enum(stat_attribute.stat) + stat.add_modifier(id, stat_attribute.base_mod, stat_attribute.bonus_mod, stat_attribute.percent_mod) + + if states_add != 0: + for i in range(EntityEnums.ENTITY_STATE_TYPE_INDEX_MAX): + var t : int = 1 << i + + if states_add & t != 0: + info.target.sadd_state_ref(i) + + + info.target.sadd_aura(ad); + else: + ad.remaining_time = time + + +func _sdeapply(data : AuraData) -> void: + for i in range(get_aura_stat_attribute_count()): + var stat_attribute : AuraStatAttribute = get_aura_stat_attribute(i) + + var stat : Stat = data.owner.get_stat_enum(stat_attribute.stat) + + stat.remove_modifier(id) + + if states_add != 0: + for i in range(EntityEnums.ENTITY_STATE_TYPE_INDEX_MAX): + var t : int = 1 << i + + if states_add & t != 0: + data.owner.sremove_state_ref(i) + func _con_aura_added(data : AuraData) -> void: if data.owner.get_character_skeleton() == null or data.owner.get_character_skeleton().root_attach_point == null: return diff --git a/game/scripts/spells/gd_spell_script.gd b/game/scripts/spells/gd_spell_script.gd index e99150a8..6f03199f 100644 --- a/game/scripts/spells/gd_spell_script.gd +++ b/game/scripts/spells/gd_spell_script.gd @@ -21,6 +21,141 @@ class_name SpellGD # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. + +func _sstart_casting(info : SpellCastInfo) -> void: + if info.caster.sis_casting(): + return + + if cooldown_global_cooldown_enabled and info.caster.gets_has_global_cooldown() or info.caster.hass_category_cooldown(spell_type) or info.caster.hass_cooldown(id): + return + + if !info.caster.hass_spell_id(id): + return + + if cast_enabled: + info.caster.sstart_casting(info) + return + + info.caster.sspell_cast_success(info) + + if info.target: + info.target.son_cast_finished_target(info) + + handle_cooldown(info) + + if projectile != null: + handle_projectile(info) + else: + handle_effect(info) + + handle_gcd(info) + +func _sfinish_cast(info : SpellCastInfo) -> void: + info.caster.son_cast_finished(info) + info.caster.sspell_cast_success(info) + + if is_instance_valid(info.target): + info.target.son_cast_finished_target(info) + + if projectile != null: + handle_projectile(info) + else: + handle_effect(info) + + handle_cooldown(info) + handle_gcd(info) + + + +func _son_cast_player_moved(info): + if !cast_can_move_while_casting: + info.caster.sfail_cast() + +func handle_projectile(info : SpellCastInfo): + pass +# if projectile_type == SPELL_PROJECTILE_TYPE_FOLLOW: +# var sp : WorldSpellGD = WorldSpellGD.new() +# +# info.get_caster().get_parent().add_child(sp) +# sp.owner = info.get_caster().get_parent() +# +# sp.launch(info, projectile, projectile_speed) + +func _son_spell_hit(info): + handle_effect(info) + +func handle_effect(info : SpellCastInfo) -> void: + if target_type == SPELL_TARGET_TYPE_TARGET: + if info.target == null: + return + +# var ok : bool = false + +# if (target_relation_type & TARGET_SELF): +# ok = true + +# if not ok and (target_relation_type & TARGET_ENEMY and info.target is Entity): +# ok = true +# +# if not ok and (target_relation_type & TARGET_FRIENDLY and info.target is Player): +# ok = true + +# if not ok: +# return + + elif target_type == SPELL_TARGET_TYPE_SELF: + info.target = info.caster + + if damage_enabled and info.target: + var sdi : SpellDamageInfo = SpellDamageInfo.new() + + sdi.damage_source = self + sdi.dealer = info.caster + sdi.receiver = info.target + + handle_spell_damage(sdi) + + for aura in caster_aura_applys: + var ainfo : AuraApplyInfo = AuraApplyInfo.new() + + ainfo.caster = info.caster + ainfo.target = info.caster + ainfo.spell_scale = 1 + ainfo.aura = aura + + aura.sapply(ainfo) + + if info.target != null: + for aura in target_aura_applys: + var ad : AuraData = null + + if aura.aura_group != null: + ad = info.target.sget_aura_with_group_by(info.caster, aura.aura_group) + else: + ad = info.target.sget_aura_by(info.caster, aura.get_id()) + + if ad != null: + info.target.sremove_aura_exact(ad) + + var ainfo : AuraApplyInfo = AuraApplyInfo.new() + + ainfo.caster = info.caster + ainfo.target = info.target + ainfo.spell_scale = 1 + ainfo.aura = aura + + aura.sapply(ainfo) + + + +func handle_cooldown(info : SpellCastInfo) -> void: + if cooldown_cooldown > 0: + info.caster.adds_cooldown(id, cooldown_cooldown) + +func handle_gcd(info : SpellCastInfo) -> void: + if cooldown_global_cooldown_enabled and cast_cast_time < 0.01: + info.caster.sstart_global_cooldown(info.caster.get_gcd().scurrent) + func add_spell_cast_effect(info : SpellCastInfo) -> void: var basic_spell_effect : SpellEffectVisualBasic = visual_spell_effects as SpellEffectVisualBasic