package Invisible import SetupObject function onChangeVisibility() let id = GetSpellAbilityId() if id == MAKE_UNIT_VISIBLE_ID or id == MAKE_UNIT_INVISIBLE_ID let caster = GetSpellAbilityUnit() let dta = caster.getEntity() if dta instanceof SetupObject let data = dta castTo SetupObject if id == MAKE_UNIT_VISIBLE_ID data.actor..removeAbility(GHOST_INVIS_ID)..addAbility(GHOST_VIS_ID) data.setup..removeAbility(MAKE_UNIT_VISIBLE_ID)..addAbility(MAKE_UNIT_INVISIBLE_ID) else if id == MAKE_UNIT_INVISIBLE_ID data.actor..removeAbility(GHOST_VIS_ID)..addAbility(GHOST_INVIS_ID) data.setup..removeAbility(MAKE_UNIT_INVISIBLE_ID)..addAbility(MAKE_UNIT_VISIBLE_ID) else if id == MAKE_UNIT_VISIBLE_ID caster..removeAbility(GHOST_INVIS_ID)..addAbility(GHOST_VIS_ID) caster..removeAbility(MAKE_UNIT_VISIBLE_ID)..addAbility(MAKE_UNIT_INVISIBLE_ID) else if id == MAKE_UNIT_INVISIBLE_ID if caster.hasAbility(GHOST_VIS_ID) caster.removeAbility(GHOST_VIS_ID) caster..addAbility(GHOST_INVIS_ID) ..removeAbility(MAKE_UNIT_INVISIBLE_ID) ..addAbility(MAKE_UNIT_VISIBLE_ID) init EventListener.add(EVENT_PLAYER_UNIT_SPELL_CAST, () -> onChangeVisibility())