Aggiorno i miei tentativi di ieri: I update my yesterday-tests: without know that you (WarRatsG) answer me so fast, I implemented this code (is so complicated, but I'll explain). Now, think that NPC1 casts a spell. this spell attaches to the target a script (for 2 sec) and a feather (for 2 seconds). How many NPC can cast a similar spell??? Anyone but the wanted NPC1 at 90%. So if I find a caster that, at the same time, had casted script+feather spell... that's it! [can I say in english "the game is done" istead of "that's it!", like in italian "il gioco è fatto"? or is no-sense?] Now, in base of my tests, I presumed that GetNthActiveEffectCaster requires the index of the active effect on the target. But the index is only an integer from 1 to the number of active effects (even: I presumed) so i made a cycle that find the presumed caster.
ref target ; target of the spell
ref caster ; will be the presumed caster of script
ref castertemp ; will be the presumed caster of feather
short effnum ; number of active effects
int rifermagia ; number from 1 to effnum
int rifermagia2 ; number from 1 to effnum
int riferscript ; the code of the [i]script effect[/i]
int riferscript2 ; the code of the [i]feather effect[/i]
short i ; controls if the cycle found the right (presumed) caster
begin scripteffectstart
set target to GetSelf
let riferscript := MECodeFromChars "SEFF" ; script
let riferscript2 := MECodeFromChars "FTHR" ; feather
set rifermagia to -1
set rifermagia to -1
set effnum to target.GetActiveEffectCount
printc "%g active effects", effnum
; first loop: search a caster of a scripted spell (hoping to be those who casted this script)
while rifermagia < effnum
set rifermagia to rifermagia + 1
set caster to GetNthActiveEffectCaster rifermagia
if caster != target && (GetNthAECode rifermagia == riferscript2)
;printc "TEST2 | I %g | Caster = %i (%n)", rifermagia, caster, caster
set i to i+1
; second loop: search same caster of a feather spell (if exist)
while rifermagia2 < effnum
set rifermagia2 to rifermagia2 + 1
set castertemp to GetNthActiveEffectCaster rifermagia2
if caster == castertemp && (GetNthAECode rifermagia2 == riferscript)
;printc "TEST2 | II %g | Caster = %i (%n)", rifermagia2, caster, caster
set i to i+1
set rifermagia2 to effnum
endif
loop
; control if, at the end of 2nd loop, the search is failed or not
if i==2
set rifermagia to effnum
else
set rifermagia2 to -1
set i to 0 ; restart cycle from last rifermagia index
endif
endif
loop
end
begin scripteffectupdate
if i == 2 ; only if cycle found the caster
; ** do stuff **
endif
end It works fine. But the limits is: if other NPC casted a spell with the same effects, the caster can (will) be wrong. Another thing: I tryed to use less than 2 seconds for the spell duration (over a target with 9 effects active). That settings cause the failure of the script. I don't know why I have to set at least 2 sec, even if the effects to the target are immediate in-game, but so it work... Ehi! E' il più complesso script che abbia mai creato per Oblivion!