EventHandler "OnMagicEffectHit" does not trigger!

Post » Mon Apr 04, 2016 6:50 am

Hello @ll,



I have quite a small problem. as it seems my Eventhandler "OnMagicEffectHit" doesnt trigger the DISE effect.



I set the eventhandler for the magic effects on the player.



SetEventHandler "OnMagicEffectHit" egmOnMagicEffectHitPlayer ref::Playerref

Then the handler function.



scn egmOnMagicEffectHitPlayer


ref target
ref rMagicEffect
long magicEFF

;egmDebugLevel 63

begin Function { target, magicEFF }

let rMagicEffect := MagicEffectFromCode magicEFF

PrintC "egmOnMagicEffectHitPlayer - Player has been Hit by MAGIC Effect: %i:%n", rMagicEffect, rMagicEffect

if eval (rMagicEffect == FIDG) ;Fire Damage
if (egmDebugLevel == 63)||(egmDebugLevel == 0)
PrintC "egmOnMagicEffectHitPlayer - Player has been Hit by Fire Effect"
endif
call egmFNsetThirstFireDamage 0

return
endif

if eval (rMagicEffect == DISE) ;Disease <--------------------------
if (egmDebugLevel == 63)||(egmDebugLevel == 0)
PrintC "egmOnMagicEffectHitPlayer - Player has been Hit by Disease Effect"
endif
;call egmFNsetSicknessDisease

return
endif

But as it seems they do not trigger DISE properly! DISE has FormID 000000 anyway.


the script engine complains in the console it couldnt create the eventlist, etc.


What am I doing wrong? Please help. Thank you.




PS:


I have chaged the above question, becuase I managed to make the handler work, just not for the DISE effect.


Is there any reason why?

User avatar
Craig Martin
 
Posts: 3395
Joined: Wed Jun 06, 2007 4:25 pm

Post » Mon Apr 04, 2016 3:33 am

Do your mod require Oblivion.esm / Nehrim.esm or some other esm, or it's masterless?

Magic effects are not initialized in masterless mods, so they have no ID and can't be used. The script may even refuse to run if it contains an unitialized magic effect.

If you want to use them in a masterless mod, use the command http://cs.elderscrolls.com/index.php?title=MagicEffectFromChars:



let rMagicEffect := MagicEffectFromCode magicEFF
if eval (rMagicEffect == MagicEffectFromChars "FIDG")
...
elseif eval (rMagicEffect == MagicEffectFromChars "DISE") ;NOTE: ElseIf is advised
...

As for DISE: unless you're creating and using spells with the DISE effect, it will never fire, as no vanilla spell use that effect (not even diseases, as they just use the individual effects they contains).

User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm

Post » Mon Apr 04, 2016 3:16 pm


Oblivion.esm and COBL.esm are master of "extend game mechanics.esp".


I will remove COBL.esm in the next releases since EGM does only need the water well script.


Yet, i dunno how to do this, thats another problem.


But I will try the above recommendation first.

User avatar
Janette Segura
 
Posts: 3512
Joined: Wed Aug 22, 2007 12:36 am

Post » Mon Apr 04, 2016 7:23 am


no, it doesnt recognize the DISE effect.


But the script doesnt throw errors anymore, and all effects are recognized by the first PRINTC notifying about every magic effect.


the magic effects caused by a disease effect, drain attr/sk etc., are printed to console though.


but not the PRINTC within


if eval (rMagicEffect == MagicEffectFromChars "DISE") ;Disease


PRINTC....


endif



I guess Disease is not a magic effect, but a spelltype.


Is there an easy way to query the spell, which hit the player? or if the magic effect came from a disease spell?


Like an event handler for OnSpellHit?



Here is my changed handler function.



scn egmOnMagicEffectHitPlayer


ref target
ref rMagicEffect
long magicEFF

;egmDebugLevel 63

begin Function { target, magicEFF }

let rMagicEffect := MagicEffectFromCode magicEFF

if (egmDebugLevel == 63)||(egmDebugLevel == 0)
PrintC "egmOnMagicEffectHitPlayer - Player has been Hit by MAGIC Effect: %i:%n", rMagicEffect, rMagicEffect
endif


if eval (rMagicEffect == MagicEffectFromChars "FIDG") ;Fire Damage
if (egmDebugLevel == 63)||(egmDebugLevel == 0)
PrintC "egmOnMagicEffectHitPlayer - Player has been Hit by FIRE Effect: %i:%n", rMagicEffect, rMagicEffect
endif
call egmFNsetThirstFireDamage 0

return
endif

if eval (rMagicEffect == MagicEffectFromChars "DISE") ;Disease
if (egmDebugLevel == 63)||(egmDebugLevel == 0)
PrintC "egmOnMagicEffectHitPlayer - Player has been Hit by DISEASE Effect: %i:%n", rMagicEffect, rMagicEffect
endif
;call egmFNsetSicknessDisease

return
endif





end
User avatar
benjamin corsini
 
Posts: 3411
Joined: Tue Jul 31, 2007 11:32 pm

Post » Mon Apr 04, 2016 9:58 am

I repeat: DISE is not unused in the game, not even by diseases. I guess it's part of an old implementation which was abandoned during the development.


Diseases just fire the effects they contains (if the disease contains a DRAT and a DRHE effect, it will fire those 2 effects).



OnSpellHit? I'm afraid OBSE doesn't have it (and I'm still wondering why). We only have:


- OnMagicEffectHit, which gives you the target actor and the effect code, so just FOAT, FIDG, ..., without any information on those effect nor on the spell they come from.


- OnMagicApply, which gives you the caster, the target and all informations for every single effect (magnitude, effect code, ... , so it include all OnMagicEffectHit informations), and fires for every single effect in a spell... but it gives you no informations about the spell itself!



Then there is OnSpellCast which gives you informations about the caster and the spell... but you have no 100% accurate way to know if that spell projectile hit the target.


I'm not sure if OnHitWith fires for spells to (you can try), but you have no clue about the attacker (unless you do many inaccurate steps by mixing OnHit and OnHitWith).

User avatar
Phillip Brunyee
 
Posts: 3510
Joined: Tue Jul 31, 2007 7:43 pm

Post » Mon Apr 04, 2016 8:08 am

Simple as this. thank you again, forli.


maybe alenet could do some magic here....



btw, do you know if Skyrim has improved in escpecially this stuff?

User avatar
OTTO
 
Posts: 3367
Joined: Thu May 17, 2007 6:22 pm

Post » Mon Apr 04, 2016 8:15 am

Well, despite I have Skyrim and I finished it once, I don't care about modding it.


Surely Skyrim (due to it's still big community and due to all experience made by previous Oblivion's modders) is able surpass the Oblivion limits, but there's some drawback, especially in the scripts part.



In Oblivion everything is contained in the esp, including the script's source code. Just open the esp and you can view/edit/compile everything.


In Skyrim every script is compiled and saved in it's own file, without source code. I'm not sure if it's possible to decompile them with some tool or if the author need to provide the source code separately (like a *.dll plugin), and not every author do it...



Also, Skyrim's script engine is heavier and slower: you can't expect to run an heavy script every single frame (fQuestDelayTime = 0.001) like you do in Oblivion.


In Skyrim a script is queued, and the engine will run it IF and WHEN it will have some resources available, and depending on the machine and the other mods installed, this may happens even after few seconds (in my case, a mod called Frostfall which was supposed to run every 3-5 seconds, was running about every 15 seconds, making it unplayable on my laptop, but it was mainly my CPU's fault).

User avatar
Steven Hardman
 
Posts: 3323
Joined: Sun Jun 10, 2007 5:12 pm

Post » Mon Apr 04, 2016 1:11 pm

oh well, I didnt know that. And I am surprised!


I really think they will announce elder scrolls 6 in june, and I am most curious if they will mark the spot this time.



Frostfall has been released in version 3, claiming to use much less runtime. Did you try the latest version?


But yes, Skyrim seems so advanced... :wink_smile:

User avatar
CArlos BArrera
 
Posts: 3470
Joined: Wed Nov 21, 2007 3:26 am


Return to IV - Oblivion

cron