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{
6{
10 static bool IsSelfTargetSpell(RE::MagicItem* a_spell)
11 {
12 if (!a_spell)
13 return false;
14 return a_spell->GetDelivery() == RE::MagicSystem::Delivery::kSelf;
15 }
16
20 static bool IsSpellPlayable(const RE::MagicItem* spell)
21 {
22 using st = RE::MagicSystem::SpellType;
23 using av = RE::ActorValue;
24
25 const auto type = spell->GetSpellType();
26 const auto skill = spell->GetAssociatedSkill();
27
28 switch (type)
29 {
30 case st::kStaffEnchantment:
31 case st::kScroll:
32 case st::kSpell:
33 case st::kLeveledSpell:
34 case st::kVoicePower:
35 case st::kLesserPower:
36 case st::kPower:
37 break;
38
39 default:
40 return false;
41 }
42 switch (skill)
43 {
44 case av::kAlteration:
45 case av::kDestruction:
46 case av::kConjuration:
47 case av::kIllusion:
48 case av::kRestoration:
49 return true;
50 default:
51 return false;
52 }
53 }
54
61 static bool IsPermanent(RE::MagicItem* item)
62 {
63 switch (item->GetSpellType())
64 {
65 case RE::MagicSystem::SpellType::kDisease:
66 case RE::MagicSystem::SpellType::kAbility:
67 case RE::MagicSystem::SpellType::kAddiction:
68 return true;
69 default:
70 return false;
71 }
72 }
73
79 static void ApplySpell(RE::Actor* caster, RE::Actor* target, RE::SpellItem* spell)
80 {
81 if (IsPermanent(spell))
82 {
83 target->AddSpell(spell);
84 }
85 else
86 {
87 caster->GetMagicCaster(RE::MagicSystem::CastingSource::kInstant)
88 ->CastSpellImmediate(spell, false, target, 1.0F, false, 0.0F, nullptr);
89 }
90 }
91};
92} // namespace StyyxUtil
Definition st-actor.h:7
Definition st-magic.h:6
static bool IsPermanent(RE::MagicItem *item)
Check if a magic item is permanent.
Definition st-magic.h:61
static bool IsSpellPlayable(const RE::MagicItem *spell)
Check if a spell is playable, as in, able to be cast.
Definition st-magic.h:20
static bool IsSelfTargetSpell(RE::MagicItem *a_spell)
Check if spell is self targeting.
Definition st-magic.h:10
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:79