aura_script now inherits from gs_spell_script. Also updated spell script's handle_effect, to the new style.

This commit is contained in:
Relintai 2022-01-12 19:14:10 +01:00
parent 7d57bbbd56
commit 197dbcc1e3
3 changed files with 54 additions and 32 deletions

View File

@ -7,6 +7,9 @@
[resource] [resource]
resource_name = "Nature's Swiftness" resource_name = "Nature's Swiftness"
id = 7 id = 7
spell_type = 8
target_type = 0
target_relation_type = 7
icon = ExtResource( 3 ) icon = ExtResource( 3 )
text_name = "Nature's Swiftness" text_name = "Nature's Swiftness"
aura_time = 10.0 aura_time = 10.0

View File

@ -1,4 +1,4 @@
extends Spell extends "res://scripts/spells/gd_spell_script.gd"
class_name AuraGD class_name AuraGD
# Copyright (c) 2019-2021 Péter Magyar # Copyright (c) 2019-2021 Péter Magyar

View File

@ -36,8 +36,9 @@ func _cast_starts(info : SpellCastInfo) -> void:
if cooldown_global_cooldown_enabled and info.caster.gcd_hass() or info.caster.category_cooldown_hass(spell_type) or info.caster.cooldown_hass(id): if cooldown_global_cooldown_enabled and info.caster.gcd_hass() or info.caster.category_cooldown_hass(spell_type) or info.caster.cooldown_hass(id):
return return
if !info.caster.spell_hass_id(id): # Todo Add source info to SpellCastInfo (player, item, spell, etc)
return #if !info.caster.spell_hass_id(id):
# return
var entity_relation_type = info.caster.gets_relation_to(info.target) var entity_relation_type = info.caster.gets_relation_to(info.target)
@ -172,39 +173,57 @@ func handle_effect(info : SpellCastInfo) -> void:
shi.receiver = info.target shi.receiver = info.target
handle_spell_heal(shi) handle_spell_heal(shi)
for aura in spells_cast_on_caster: if is_aura():
var ainfo : AuraApplyInfo = AuraApplyInfo.new() var ad : AuraData = AuraData.new()
ainfo.caster = info.caster
ainfo.target = info.caster
ainfo.spell_scale = 1
ainfo.aura = aura
aura.aura_sapply(ainfo) if aura_get_aura_group():
ad = info.target.aura_gets_with_group_by_bind(info.caster, aura_get_aura_group())
else:
ad = info.target.aura_gets_by(info.caster, id)
if ad:
info.target.aura_removes_exact(ad)
var aai : AuraApplyInfo = AuraApplyInfo.new()
aai.caster_set(info.caster)
aai.target_set(info.target)
aai.spell_scale_set(info.spell_scale)
aai.set_aura(self)
aura_sapply(aai)
for spell in spells_cast_on_caster:
if !spell:
continue
var sci : SpellCastInfo = SpellCastInfo.new()
sci.caster = info.caster
sci.target = info.caster
sci.has_cast_time = spell.cast_enabled
sci.cast_time = spell.cast_cast_time
sci.spell_scale = info.spell_scale
sci.set_spell(spell)
spell.cast_starts(sci)
if info.target != null: if info.target != null:
for aura in spells_cast_on_target: for spell in spells_cast_on_target:
var ad : AuraData = null if !spell:
continue
if aura.aura_group != null:
ad = info.target.aura_gets_with_group_by(info.caster, aura.aura_group)
else:
ad = info.target.aura_gets_by(info.caster, aura.get_id())
if ad != null:
info.target.aura_removes_exact(ad)
var ainfo : AuraApplyInfo = AuraApplyInfo.new()
ainfo.caster = info.caster
ainfo.target = info.target
ainfo.spell_scale = 1
ainfo.aura = aura
aura.aura_sapply(ainfo) var sci : SpellCastInfo = SpellCastInfo.new()
sci.caster = info.caster
sci.target = info.target
sci.has_cast_time = spell.cast_enabled
sci.cast_time = spell.cast_cast_time
sci.spell_scale = info.spell_scale
sci.set_spell(spell)
spell.cast_starts(sci)
func handle_cooldown(info : SpellCastInfo) -> void: func handle_cooldown(info : SpellCastInfo) -> void:
if cooldown_cooldown > 0: if cooldown_cooldown > 0: