Well now, this is a challenge! I'd be glad to lend my help. I know you're not very script-savvy, so I'll try to make this step-by-step.
Setting Up:First of all, you should make all the spells you want to be added to the player via the medallion script effect. So you'd have a list of spells like this:
kaiSightSpell
kaiDetectSpell
kaiThornSpell
kaiShieldSpell
kaiEscapeSpell
One way to add these to the player under the conditions you desire requires us to utilize a script attached to the medallion eye; this script will check for the conditions under which the player may gain these blessings each time it is run. I presume that Kaikuro's medallion is an equipped item, so I think your best bet is to make an enchant with a constant ability script effect and attach it to the item. This way, the script will only run while the player has equipped the medallion. This post is only going to go over the NightEye blessing, which is probably one of the most complicated ones on there, and requires a few more things for us to do. The main thing I'm seeing is that you want your spells to activate differently depending upon how many nearby hostiles there are, so once we get that mechanic out of the way, the rest will come easily. Make sure your kaiSightSpell is an Ability type with NightEye on self.
One way I've found for successfully detecting nearby enemies is using an invisible reference object to cast a large area spell on the player, which would also affect any entities in the surrounding area.
Step One: Detecting Enemies via a Scripted Spell-Make a spell called kaiDetectEnemiesSpell
-Check the boxes for "Disallow reflect/absorb" and "Area Effect Ignores LOS"
-Add a script effect that has a range of, say, 2000, and a duration of 1. Make sure "effect is hostile" is NOT checked
The script we will attach to this will run for each target hit by the area spell, which means any entity within the 2000 unit range of the player (including the player). We will make this script determine if the reference it's running on will attack the player; each time this returns true, it will increment a variable that we will read from our main script. We need to make a global variable; one way is to add one via Gameplay>Globals in the CS, but let's make it a quest variable, because that's how I roll...
Step Two: A Global for Nearby Enemies-Make a new quest, call it Kaikuro
-Keep "Start Game Enabled" checked
-Make a new script, Type: Quest, and attach it to the Kaikuro quest
Scriptname KaikuroGlobalsshort nearbyEnemies
Easy! This just holds the variable nearbyEnemies for us. We can change it from other scripts by calling it as Kaikuro.nearbyEnemies (Questname.Variablename)
Step Three: The Detect Enemy Spell Script-We need to add a script the kaiDetectEnemiesSpell script effect; for now it does nothing
-Make a new "Magic Effect" type script, and plug in the following:
Scriptname KaiDetectEnemiesSpellScriptref selfBegin ScriptEffectStartset me to GetSelfif ( me == Player) returnendifif ( me.GetShouldAttack Player == 1 ) set Kaikuro.nearbyEnemies to ( Kaikuro.nearbyEnemies + 1 )endifEnd
For each entity this runs on, GetShouldAttack will tell us if they want to harm our player. If so, the global we just created via the Kaikuro quest will be incremented by 1. Since this will also run on the player, we have to make sure it does nothing.
Step Four: The Caster Reference-Now we have to make a reference that will cast this upon the player on demand. Make a new cell, call it kaiTestCell or something, it doesn't matter.
-Look under World Objects > Activators for something called ARSwitch01 and put one into your new cell
-Double click the object in the render window
-For the Reference ID put "kaiCastRef"
-Check both "Persistent Reference" and "Initially Disabled"
Now, the purpose of this is so that we can use it to cast any spell on the player, such as your blessings, and also our recently created kaiDetectEnemiesSpell simply by moving it to the player in our main script. But that's coming up, so don't worry just yet.
Step Five: The Main Script!Yay! We made it finally to where we began: the medallion's enchantment. This enchant needs to have an Apparel script effect.
-Make a new script, 'Magic Effect' type again
-And here's the code (get ready):
Scriptname KaikuroMedallionEffectsshort checkSightshort activateSightshort sightChanceshort checkHostilesshort randomPercentfloat timerBegin ScriptEffectUpdate;when the timer is active, the script is haltedif ( timer > 0 ) set timer to ( timer - GetSecondsPassed ) returnendif;This casts the spell that will detect nearby enemies;it calls a timer so that we have a buffer of sorts to make sure all nearby enemies are accounted for before continuingif ( checkHostiles == 1 ) set checkHostiles to 0 kaiCastRef.MoveTo Player, 0, 0, 5 kaiCastRef.Cast kaiDetectEnemySpell Player set timer to 1 returnendif;==================; SIGHT;==================;This detects when player changes cells.;It removes NightEye if its enabled, else it will check to see if it can be turned on.if ( IsPlayerMovingIntoNewSpace == 1 ) if ( Player.IsSpellTarget kaiSightSpell == 1 ) Player.RemoveSpell kaiSightSpell else set checkSight to 1 endifendif;This removes the NightEye if the player uses a torch or a light spellif ( Player.IsSpellTarget kaiSightSpell == 1 ) if ( Player.IsActorUsingATorch == 1 ) || ( Player.HasMagicEffect LGHT == 1 ) Player.RemoveSpell kaiSightSpellendif;This checks to see if NightEye can turn on.;First it checks if the player is using a torch or a Light spell,;Then if the player is inside or it's night time, begins to check for nearby enemies &;also set the flag to begin activation, but first we have to check for enemies.if ( checkSight == 1 ) set checkSight to 0 if ( Player.IsActorUsingATorch == 0 ) && ( Player.HasMagicEffect LGHT == 0 ) if ( Player.IsInInterior == 1 ) set checkHostiles to 1 set activateSight to 1 return elseif ( GetCurrentTime <= 6 && GetCurrentTime >= 20 ) set checkHostiles to 1 set activateSight to 1 return endif endifendif;Activates the NightEye spell based upon random chance, checked against the sightChance var, which is dependent upon whether or not enemies are nearbyif ( activateSight == 1 ) set activateSight to 0 set randomPercent to GetRandomPercent if ( Kaikuro.nearbyEnemies > 0 ) set sightChance to 70 else set sightChance to 50 endif if ( randomPercent <= sightChance ) Player.AddSpell kaiSightSpell endif set Kaikuro.nearbyEnemies to 0endifEnd
Now, I've included some comments to help you understand this. The basic logical flow of this script starts under the headline for SIGHT and will be as such:
-Checks to see when player changes cells
-Checks conditions for NightEye activation
-Runs the detect enemy spell to get nearby enemies
-Activates the chance to get NightEye
As of right now, this does not have the mechanic for activating upon combat. We can always add that later, but for now, I figured this is the main mechanic you're looking for.
This is a horribly complicated thing to take in at once for a beginner scripter, so I'll let you ask the questions now, as I'm sure you have a ton.