From f23ec89a58da9b1bde266a645413f181761aba99 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 21 Feb 2020 14:10:09 +0100 Subject: [PATCH] Implemented spell target relations. --- game/scripts/spells/gd_spell_script.gd | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/game/scripts/spells/gd_spell_script.gd b/game/scripts/spells/gd_spell_script.gd index f42dc47c..0d416222 100644 --- a/game/scripts/spells/gd_spell_script.gd +++ b/game/scripts/spells/gd_spell_script.gd @@ -26,8 +26,6 @@ func _sstart_casting(info : SpellCastInfo) -> void: if needs_target and info.target == null: return - - if info.caster.sis_casting(): return @@ -36,6 +34,21 @@ func _sstart_casting(info : SpellCastInfo) -> void: if !info.caster.hass_spell_id(id): return + + var entity_relation_type = info.caster.gets_relation_to(info.target) + + var ok = false + + if target_relation_type & TARGET_FRIENDLY or target_relation_type & TARGET_SELF: + if entity_relation_type == EntityEnums.ENTITY_RELATION_TYPE_FRIENDLY or entity_relation_type == EntityEnums.ENTITY_RELATION_TYPE_NEUTRAL: + ok = true + + if target_relation_type & TARGET_ENEMY: + if entity_relation_type == EntityEnums.ENTITY_RELATION_TYPE_HOSTILE: + ok = true + + if !ok: + return if cast_enabled: info.caster.sstart_casting(info)