This is a tutorial by egocarib, the creator of mods like Enchanted Arsenal and Enchanting Awakened. Any text not in italics is either the author's words, or the author's words slightly modified by me. This tutorial assumes you have a basic knowledge of scripting, and a rudimentary knowledge of quest design.This tutorial will teach you how to use a quest and aliases to detect actors of a certain type near to the player. It can be applied in many different ways, but is very useful and pretty simple.
To do this, I first set up a quest with several aliases that can detect nearby actors that meet that description.
Setting Up the Quest
These are images of the alias and quest data tabs.
A few things to notice:
- The quest is set up to NOT be Start Game Enabled. We only want to start this when we decide its time to detect actors.
- The first Alias is not optional, but all additional aliases ARE optional -- this is to ensure that the quest will start successfully as long as there is at least one actor that meets the conditions.
- Each alias has the same conditions, which check if the actor is one of a number of disease-spreading actor types, and if the actor is also within a close distance to the player (2500 units). You'll want your conditions to be specific to your actors. If I am looking for ANY bandit within a certain cell, then my conditions would be IsInFaction (BanditFaction) and IsInCell (MyCell). Likewise, if you're looking for any female Imperials within a radius of 3000 units, your conditions would be GetIsSex (Female), GetIsRace (Imperial) and GetDistance (3000 units away from Player). Hopefully you get the idea.
Using the Quest to Detect Actors
If (NearbyDiseaseSpreader1.GetReference() as Actor)
;you'll need to create a ReferenceAlias property if not in a script on your quest
Once you've detected whether your desired actors are nearby, and you've reacted appropriately to any actors in your aliases, you can simply stop the quest:
- It's super easy to duplicate Aliases in the creation kit. Just set up your first alias or two, and then all you have to do is right click and "Duplicate" to create as many as you need. This is useful if you want to detect, say, up to 50 actors (instead of just 3)
- If you DO have a lot of aliases, consider adding them all to an array to check whether they were filled using a simple while loop
- Just a reminder - make sure you fill all the necessary properties in your script before testing this (including your Quest and any ReferenceAlias properties you want to check)
Scriptname EA_Learn_ResistDisease extends EA_Learn_TemplateAME
;effect conditioned to be active only while in combat, so this will check at the beginning of each combat
;Note to self: I should also implement a Story Manager event for player gaining a disease, then add experience as long as it lasts.
Quest property DiseaseAntenna auto
ReferenceAlias property NearbyDiseaseSpreader1 auto
ReferenceAlias property NearbyDiseaseSpreader2 auto
ReferenceAlias property NearbyDiseaseSpreader3 auto
Event OnEffectStart(Actor target, Actor caster)
if (NearbyDiseaseSpreader1.getReference() as Actor)
diseasedCreature1 = NearbyDiseaseSpreader1.getReference()
diseasedCreature2 = NearbyDiseaseSpreader2.getReference()
diseasedCreature3 = NearbyDiseaseSpreader3.getReference()
Event OnHit(ObjectReference aggressor, Form source, Projectile proj, bool powAtk, bool snkAtk, bool bashAtk, bool hitBlocked)
if (aggressor == diseasedCreature1 || aggressor == diseasedCreature2 || aggressor == diseasedCreature3)
Event OnEffectFinish(Actor target, Actor caster)
Magic Effect Images
This is just an example of how this feature could be used. You may use it however you like.
Since the OnCombatStateChanged event doesn't work for the player, I attached this ability to the player instead, using an IsInCombat condition. What this results in, is that the script seen above will be initialized every time the player starts combat -- and thus, each time combat starts, the script will start up the DiseaseAntenna quest to check if any disease-spreaders are near the actor. If they are, I award the actor some special experience each time they are hit during this round of combat (which helps them get better at using "Resist Disease" enchantments).
And that's all there is to it! Thanks to egocarib (or on the Nexus) for the well-written tutorial.
Post what kind of tutorial you'd like to see next below.