I'd love to know your take on this, then. I've been working on a mod along the same lines for companions - to make enemies attack the player rather than the companion. It's extensible to horses and summons, though.
This is where I last left it. The script below is attached to a summoned creature.
ScN tejonArsSummonedCreatureScriptshort initlong indexarray_var eachref actorref selfref casterbegin GameMode if (init == 0) let init := 1 StopCombatAlarmOnActor; let self := GetSelf; let actor := playerRef; while (actor); if (actor != self); ForEach each <- (actor.GetActiveEffectCodes); let index := each["value"]; if (MagicEffectUsesCreatureC index); let index := each["key"]; if (self == actor.GetNthAESummonRef index); let caster := actor; BREAK; endif; endif; Loop; endif; if (caster); BREAK; elseif (actor == playerRef); let actor := GetFirstRef 69 2; else; let actor := GetNextRef; endif; Loop; if (caster); let actor := GetFirstRef 69 2; while (actor); if (actor != self) && (actor != caster); let index := (actor.GetDisposition caster) - (actor.GetDisposition self) + 5; if (index > 0); actor.ModDisposition self index; endif; endif; let actor := GetNextRef; Loop; endif endifend
You'll note that most of the script is commented out. That's because after some preliminary testing I found that just the StopCombatAlarmOnActor line gave pretty good results all by itself. The rest of the script loops over every loaded actor twice, which is a significant amount of processing and might be nice to avoid. More testing is needed, though.
StopCombatAlarmOnActor all by itself doesn't prevent anyone from attacking the summon, but it does re-shuffle their target priority list. Depending on positioning and whether the summon immediately attacks
them, they might go right back to it -- but at least there's some AI involved, and it's not a sure thing. I kind of like this, but like I said, it needs more testing -- if it turns out to still be easily exploited, I'd want to use the heavier solution.
The first loop runs through every loaded actor (player first) looking for the summon effect to which it is attached. Believe it or not, this is the only way I know of to find a summon's caster -- Andalaybay actually borrowed the code for his Oblivion XP update.
The second loop runs through every actor again, forcing their disposition toward the summon to be 5 points higher than their disposition toward its caster. (Might need to be more than +5 depending on how distance figures in; that was just a preliminary number.) Again, this isn't a 100% guarantee that they'll never attack the summon, particularly if it starts wailing on them; but that strikes me as realistic behavior.