qwertypol012 Posted July 17, 2019 Share Posted July 17, 2019 (edited) Hi everyone, I'm currently trying to compile 2 scripts which are a RefAlias script and an ActiveMagicEffect script. The 2nd script requires the 1st script to get the number from the property. The idea is basically to check if the player is casting any of the required spells, then damage the player's magicka with a dummy spell with the set duration based on the original casted spell. The damaged magicka amount is set from the original spell's magicka cost. Here's the scripts:1. RefAlias script Scriptname qlIC_AliasScript extends ReferenceAlias {checks if the casted spell meets the requirements, then get both dur and cost of the spell and cast the dummy spell to the player if so} Spell PROPERTY ConjurationCost auto Int PROPERTY cost auto ; --- EVENTs --- EVENT OnPlayerLoadGame() ; to only work for a player alias script ENDEVENT EVENT OnSpellCast(Form akSpell) IF CheckSpell(akSpell, TRUE) actor player = Game.GetPlayer() int dur = SpellDuration(akSpell) cost = akSpell.GetEffectiveMagickaCost(player) ; get the magicka cost of the casted spell ConjurationCost.SetNthEffectDuration(0, dur) ; set the dummy spell's duration by the duration of the casted spell ConjurationCost.Cast(player) ; cast it to the player ; player.ModActorValue("Magicka", -cost) ; Utility.Wait(dur) ; player.ModActorValue("Magicka", cost) ELSE RETURN ENDIF ENDEVENT ; --- FUNCTIONs --- Bool FUNCTION CheckSpell(Form akSpell, Bool bOk) ; check if the casted spell's magic effect(s) has any of these keywords Keyword FamiliarKey = Keyword.GetKeyword("MagicSummonFamiliar") Keyword FireKey = Keyword.GetKeyword("MagicSummonFire") Keyword FrostKey = Keyword.GetKeyword("MagicSummonFrost") Keyword ShockKey = Keyword.GetKeyword("MagicSummonShock") Keyword SchoolKey = Keyword.GetKeyword("MagicSchoolConjuration") Keyword UndeadKey = Keyword.GetKeyword("MagicSummonUndead") Keyword AshKey = Keyword.GetKeyword("DLC2MagicAshSpawn") MagicEffect MGEF01 = akSpell.GetNthEffectMagicEffect(0) MagicEffect MGEF02 = akSpell.GetNthEffectMagicEffect(1) IF ( bOk ) && ( MGEF01.HasKeyword(FamiliarKey) || MGEF02.HasKeyword(FamiliarKey) ) RETURN TRUE ELSEIF ( bOk ) && ( MGEF01.HasKeyword(FireKey) || MGEF02.HasKeyword(FireKey) ) RETURN TRUE ELSEIF ( bOk ) && ( MGEF01.HasKeyword(FrostKey) || MGEF02.HasKeyword(FrostKey) ) RETURN TRUE ELSEIF ( bOk ) && ( MGEF01.HasKeyword(ShockKey) || MGEF02.HasKeyword(ShockKey) ) RETURN TRUE ELSEIF ( bOk ) && ( MGEF01.HasKeyword(SchoolKey) || MGEF02.HasKeyword(SchoolKey) ) RETURN TRUE ELSEIF ( bOk ) && ( MGEF01.HasKeyword(UndeadKey) || MGEF02.HasKeyword(UndeadKey) ) RETURN TRUE ELSEIF ( bOk ) && ( MGEF01.HasKeyword(AshKey) || MGEF02.HasKeyword(AshKey) ) RETURN TRUE ELSE RETURN False ENDIF ENDFUNCTION Int FUNCTION SpellDuration(Form akSpell) ; get the spell duration of the casted spell/effect(s) int i int dur1 = akSpell.GetNthEffectDuration(0) int dur2 = akSpell.GetNthEffectDuration(1) IF dur1 > dur2 i = dur1 ELSEIF dur1 < dur2 i = dur2 ; ELSEIF dur1 == dur2 ELSE i = dur1 ENDIF RETURN i ENDFUNCTION 2. ActiveMagicEffect script Scriptname qlIC_ConjureCostScript extends ActiveMagicEffect {attached to the dummy spell's magic effect, to apply magicka damage with the set duration} qlIC_AliasScript PROPERTY AliasScript auto Actor player Int i EVENT OnEffectStart(Actor akTarget, Actor akCaster) player = Game.GetPlayer() i = AliasScript.cost ; get the magicka cost of the casted spell from RefAlias script player.ModActorValue("Magicka", -i) ; damage the player's magicka by the amount of the magicka cost from the casted spell ENDEVENT EVENT OnEffectFinish(Actor akTarget, Actor akCaster) player.ModActorValue("Magicka", i) ; restore the player's damaged magicka ENDEVENT Can you help me to point out the incorrect part(s) which makes it fail to compile? I'm still newbie. Thanks in advance :smile: Edited July 18, 2019 by qwertypol012 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted July 17, 2019 Share Posted July 17, 2019 Compiler error report would be helpful. Link to comment Share on other sites More sharing options...
qwertypol012 Posted July 17, 2019 Author Share Posted July 17, 2019 Compiler error report would be helpful.Oh sorry about that. I used a third party application to compile the script (ie. Notepad++) by linking the compiler with the application, so the error report was shown in a cmd dialogue panel, unlike the report dialogue panel from CK which is copy-able. Basically what it showed is that some native skse functions (ie. GetEffectiveMagickaCost, GetNthEffectxxx, etc) which I'm using in the RefAlias script are not "recognizable", something like "the xxx (function) is not a function nor does it exist" or similar with that (couldn't remember the exact sentences, but that's about it). Link to comment Share on other sites More sharing options...
maxarturo Posted July 17, 2019 Share Posted July 17, 2019 The same issue in the link bellow : function does not existhttps://forums.nexusmods.com/index.php?/topic/7822598-having-issues-with-compiling-skse64-scripts/ Hope this fixes your issue. Link to comment Share on other sites More sharing options...
qwertypol012 Posted July 18, 2019 Author Share Posted July 18, 2019 (edited) The same issue in the link bellow : function does not existhttps://forums.nexusmods.com/index.php?/topic/7822598-having-issues-with-compiling-skse64-scripts/ Hope this fixes your issue.Thanks, but unfortunately it's still the same. Maybe it only works for SSE? I'm in SLE btw. And by skse plugins, you mean "skse_1_9_32.dll" and "skse_steam_loader.dll", right? Just did that but still failed to compile.FYI, i also compiled my other scripts (other than this project) which also contain some native skse functions and it compiled successfully. I compiled it using the same 3rd party method i'm using for this project. So, i naturally think it probably has something to do with the scripts itself. Edit:I confirm that the native skse functions which didn't get "recognized" are GetEffectiveMagickaCost, GetNthEffectMagicEffect, and GetNthEffectDuration. So i think i might be using it wrong, but not sure which part is it. Edited July 18, 2019 by qwertypol012 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted July 18, 2019 Share Posted July 18, 2019 GetEffectiveMagickaCost requires being used with a spell. In your script akSpell is a Form. You need to cast that into Spell first. From the wiki example on OnSpellCast: Event OnSpellCast(Form akSpell) Spell spellCast = akSpell as Spell As far as the other two, the same fix needs to be applied. Cast it into Spell and use that variable or just use (akSpell as Spell) anywhere you need it to be Spell instead of Form. Link to comment Share on other sites More sharing options...
qwertypol012 Posted July 18, 2019 Author Share Posted July 18, 2019 GetEffectiveMagickaCost requires being used with a spell. In your script akSpell is a Form. You need to cast that into Spell first. From the wiki example on OnSpellCast: Event OnSpellCast(Form akSpell) Spell spellCast = akSpell as Spell As far as the other two, the same fix needs to be applied. Cast it into Spell and use that variable or just use (akSpell as Spell) anywhere you need it to be Spell instead of Form.Omg, that's right! Just did it and it worked. What an oversight on my part, haha. Thanks, it's solved now :D Link to comment Share on other sites More sharing options...
Recommended Posts