Another post, I can't help it, it's a lot of info. With the plugin at hand, I'll try to explain using it as example.
The quest adds perk to the player via the script. Source of the script is included, so you can take a look at what contains. It's quite small, but enough to get the job done. Important options for the quest - "Start Game Enabled" and "Run Once".
For the perk, I remove the "Playable" flag and set it to "Hidden". Not playable doesn't mean you can't use it. Playable flag is mostly for perks in the level up menu. Hidden flag is for whether the perk is visible in the pip-boy. I add new perk entry, then choose Entry Point and from the list - Apply Combat Hit Spell. Then I choose the spell. You gotta have the spell already created, but I'm trying to explain how things are connected. I go to the Weapon tab of the conditions and add what's necessary.
The spell I choose for "Apply combat hit spell" for example CWMG_CritPlasmaSpell [SPEL:01000F9A]. It is added to the player's attacks. Magnitude and duration of the magic effect I got from the vanilla game. If you want to open the magic effect(or any kind of form, if referenced in another form), hold Ctrl and click on it(uuh I meant that when using FO4Edit). The magic effect runs a script called FXCastSpellOnDeath. Since it's added to player's attack, the casting type is "Fire and forget" and the Delivery type is "Contact(Touch)". In the properties of the script choose the spell for the effect on death. When the target is hit, the spell is added to it.
The spell for the critical effect(CWMG_CritPlasmaHitSpell [SPEL:01000F9C]) is added to the target upon death. The casting type is "Fire and Forget" and the delivery type is "Self". I could've probably used vanilla critical effect spell, but I created new ones. The magic effect in the spell is actually from the vanilla game, and so are the settings for magnitude and duration. The magic effect runs scripts for adding various effects and replacing the body with goo/ash piles.
If you want a custom effect with goo/ash pile, then you have to duplicate on of the vanilla crit magic effects and fill in the properties of the script with your own.
- quest adds perk to the player with a script
- perk applies combat hit spell to player attacks
- the combat hit spell adds(through script) critical effect spell to the target triggered on death
This method is based of the enchantment of the Mirelurk Queen's weapon: MirelurkQueenSpitAttackSpell "Acid" [ENCH:001B9A3A]. You can check it out and see that things are very similar. Instead of enchantment, we have a spell chosen as Combat Hit Spell in a perk. This is because enchantments aka object effects are only for armor and weapons. For npcs are used spells. The enchantment has two magic effects - one is for the acid damage and the other is for the critical effect.
Btw, effect spell, effect hit spell, not the best naming. I tried to follow some Bethesda naming when creating from existing forms. So let's say in the example:
CWMG_CritPlasmaSpell [SPEL:01000F9A] -> combat hit spell
CWMG_CritPlasmaHitSpell [SPEL:01000F9C] -> critical effect spell
About my ideas for keywords and conditions.
For red laser:
Subject.HasKeyword(ma_InstituteLaserGun [KYWD:001289BB]) = 0 AND
Subject.HasKeyword(WeaponTypeLaser [KYWD:00092A84]) = 1 OR
Subject.HasKeyword(WeaponTypeGatlingLaser [KYWD:0022575E]) = 1 OR
This will cover Laser Gun, Musket and Gatling laser, but will exclude the institute laser. hopefully this combination of AND and OR works. Could be compatible with mod added weapons even.
For blue laser:
Subject.HasKeyword(ma_InstituteLaserGun [KYWD:001289BB]) = 1 OR
Subject.HasKeyword(WeaponTypeAlienBlaster [KYWD:0016968B]) = 1 OR
Subject.HasKeyword(DLC01ma_LightningGun [KYWD:01002471]) = 1 OR
For Institute Laser, Alien Blaster and Tesla Rifle. Since using mod association keywords, it depends what keywords modded weapons use, but probably they are not compatible.
Subject.HasKeyword(WeaponTypePlasma [KYWD:00092A85]) = 1.000000 OR
Subject.HasKeyword(HasLegendary_Weapon_PlasmaBullets [KYWD:001F9B4C]) = 1.000000 OR
This will cover plasma gun and weapons with Plasma Infuse legendary effect.
Subject.HasKeyword(WeaponTypeCryolater [KYWD:0022575F]) = 1.000000 OR
Subject.HasKeyword(HasLegendary_Weapon_Cryo [KYWD:001F547A]) = 1.000000 OR
Covers the Cryolator and weapons with Freezing legendary effect.
Subject.HasKeyword(HasLegendary_Weapon_IncendiaryBullets [KYWD:001E7175]) = 1.000000 OR
Weapons with Incendiary legendary effect.
I haven't checked if bash really triggers the effect, because I don't use it as much. I still don't have ideas about conditions to filter out the player's actions(bashing/shooting).
Edit: Yep, if you happen to finish a target with bash, the effect still applies. Needs a solution if possible.
Note: When I talk about Casting/Delivery Type, I mean for the magic effect. The spell inherits those settings from the magic effect used in it. In FO4Edit these settings for the spell can be manually edited, but only to match same settings for the magic effect within it, if necessary.