styyx-util 1.0
Utility Header for SKSE Plugin development
Loading...
Searching...
No Matches
st-magic.h
Go to the documentation of this file.
1#pragma once
2
3namespace StyyxUtil
4{
5 struct MagicUtil
6 {
10 static bool IsSpellPlayable(const RE::SpellItem *spell)
11 {
12 using st = RE::MagicSystem::SpellType;
13 using av = RE::ActorValue;
14
15 const auto type = spell->GetSpellType();
16 const auto skill = spell->GetAssociatedSkill();
17
18 switch (type)
19 {
20 case st::kStaffEnchantment:
21 case st::kScroll:
22 case st::kSpell:
23 case st::kLeveledSpell:
24 case st::kVoicePower:
25 case st::kLesserPower:
26 case st::kPower:
27 break;
28
29 default:
30 return false;
31 }
32 switch (skill)
33 {
34 case av::kAlteration:
35 case av::kDestruction:
36 case av::kConjuration:
37 case av::kIllusion:
38 case av::kRestoration:
39 return true;
40 default:
41 return false;
42 }
43 }
44
49 static bool IsPermanent(RE::MagicItem *item)
50 {
51 switch (item->GetSpellType())
52 {
53 case RE::MagicSystem::SpellType::kDisease:
54 case RE::MagicSystem::SpellType::kAbility:
55 case RE::MagicSystem::SpellType::kAddiction:
56 return true;
57 default:
58 return false;
59 }
60 }
61
66 static void ApplySpell(RE::Actor *caster, RE::Actor *target, RE::SpellItem *spell)
67 {
68 if (IsPermanent(spell))
69 {
70 target->AddSpell(spell);
71 }
72 else
73 {
74 caster->GetMagicCaster(RE::MagicSystem::CastingSource::kInstant)
75 ->CastSpellImmediate(spell, false, target, 1.0F, false, 0.0F, nullptr);
76 }
77 }
78 };
79}
Definition st-actor.h:7
Definition st-magic.h:6
static bool IsSpellPlayable(const RE::SpellItem *spell)
Check if a spell is playable, as in, able to be cast.
Definition st-magic.h:10
static bool IsPermanent(RE::MagicItem *item)
Check if a magic item is permanent.
Definition st-magic.h:49
static void ApplySpell(RE::Actor *caster, RE::Actor *target, RE::SpellItem *spell)
Casts Spell from caster to actor. If the spell is permanent (MagicUtil::IsPermanent) it adds the spel...
Definition st-magic.h:66