-
Notifications
You must be signed in to change notification settings - Fork 0
/
sha_spellhooks.nss
790 lines (706 loc) · 34.1 KB
/
sha_spellhooks.nss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//:::::::::::::::::::::::: Shayan's Subrace Engine :::::::::::::::::::::::::::::
//::::::::::::::::::::::: File Name: sha_spellhooks :::::::::::::::::::::::::::
//:::::::::::::::::::::::::: Include script ::::::::::::::::::::::::::::::::::::
//:: Written by: Shayan :://
//:: Contact: [email protected] :://
//
//
// Description: Spell hooking file for Shayan's Subrace Engine.
// This is an essential optional file. (Meaning you can choose
// either spell hooking option or modified spell hooks.)
//
//
#include "x2_inc_switches"
#include "x0_i0_spells"
#include "sha_subr_methds"
//::///////////////////////////////////////////////
//:: spellsCure
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Used by the 'cure' series of spells.
Will do max heal/damage if at normal or low
difficulty.
Random rolls occur at higher difficulties.
*/
//:://////////////////////////////////////////////
//:: Created By:
//:: Created On:
//:://////////////////////////////////////////////
void spellsCureSSE(int nDamage, int nMaxExtraDamage, int nMaximized, int vfx_impactHurt, int vfx_impactHeal, int nSpellID);
void spellsCureSSE(int nDamage, int nMaxExtraDamage, int nMaximized, int vfx_impactHurt, int vfx_impactHeal, int nSpellID)
{
//Declare major variables
object oTarget = GetSpellTargetObject();
int nHeal;
int nMetaMagic = GetMetaMagicFeat();
effect eHeal, eDam;
int nExtraDamage = GetCasterLevel(OBJECT_SELF); // * figure out the bonus damage
if (nExtraDamage > nMaxExtraDamage)
{
nExtraDamage = nMaxExtraDamage;
}
// * if low or normal difficulty is treated as MAXIMIZED
if(GetIsPC(oTarget) && GetGameDifficulty() < GAME_DIFFICULTY_CORE_RULES)
{
nDamage = nMaximized + nExtraDamage;
}
else
{
nDamage = nDamage + nExtraDamage;
}
//Make metamagic checks
if (nMetaMagic == METAMAGIC_MAXIMIZE)
{
nDamage = nMaximized + nExtraDamage;
// * if low or normal difficulty then MAXMIZED is doubled.
if(GetIsPC(OBJECT_SELF) && GetGameDifficulty() < GAME_DIFFICULTY_CORE_RULES)
{
nDamage = nDamage + nExtraDamage;
}
}
if (nMetaMagic == METAMAGIC_EMPOWER || GetHasFeat(FEAT_HEALING_DOMAIN_POWER))
{
nDamage = nDamage + (nDamage/2);
}
int nTouch = TouchAttackMelee(oTarget);
if (nTouch > 0)
{
if(Subrace_GetIsUndead(oTarget))
{
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpellID));
if (!MyResistSpell(OBJECT_SELF, oTarget))
{
eDam = EffectDamage(nDamage,DAMAGE_TYPE_POSITIVE);
//Apply the VFX impact and effects
DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
effect eVis = EffectVisualEffect(vfx_impactHurt);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
}
}
}
}
//::///////////////////////////////////////////////
//:: spellsInflictTouchAttack
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
nDamage: Amount of damage to do
nMaxExtraDamage: Max amount of +1 per level damage
nMaximized: Amount of damage to do if maximized
vfx_impactHurt: Impact to play if hurt by spell
vfx_impactHeal: Impact to play if healed by spell
nSpellID: SpellID to broactcast in the signal event
*/
//:://////////////////////////////////////////////
//:: Created By:
//:: Created On:
//:://////////////////////////////////////////////
void spellsInflictTouchAttackSSE(int nDamage, int nMaxExtraDamage, int nMaximized, int vfx_impactHurt, int vfx_impactHeal, int nSpellID);
void spellsInflictTouchAttackSSE(int nDamage, int nMaxExtraDamage, int nMaximized, int vfx_impactHurt, int vfx_impactHeal, int nSpellID)
{
//Declare major variables
object oTarget = GetSpellTargetObject();
int nMetaMagic = GetMetaMagicFeat();
int nTouch = TouchAttackMelee(oTarget);
int nExtraDamage = GetCasterLevel(OBJECT_SELF); // * figure out the bonus damage
if (nExtraDamage > nMaxExtraDamage)
{
nExtraDamage = nMaxExtraDamage;
}
//Check for metamagic
if (nMetaMagic == METAMAGIC_MAXIMIZE)
{
nDamage = nMaximized;
}
else
if (nMetaMagic == METAMAGIC_EMPOWER)
{
nDamage = nDamage + (nDamage / 2);
}
//Check that the target is undead.
//Edited For Shayan's Subrace Engine.
if (Subrace_GetIsUndead(oTarget))
{
effect eVis2 = EffectVisualEffect(vfx_impactHeal);
//Figure out the amount of damage to heal
//nHeal = nDamage;
//Set the heal effect
effect eHeal = EffectHeal(nDamage + nExtraDamage);
//Apply heal effect and VFX impact
ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpellID, FALSE));
}
}
void main()
{
int nSpell= GetSpellId();
int nSpellDC= GetSpellSaveDC();
int nCastLevel= GetCasterLevel(OBJECT_SELF);
object oTarget = GetSpellTargetObject();
location lTarget = GetSpellTargetLocation();
location lLoc;
effect eVisual;
effect eBad;
effect eGood;
int nHeal;
effect eHeal;
int nDamage;
int nMetaMagic;
int nTouch;
effect eVis;
effect eVis2;
effect eDam;
effect eKill;
int nModify;
effect eSun;
effect eHealVis;
effect eStrike;
float fDelay;
int bValid;
effect eRay;
effect eVisHeal;
int IsUndead = Subrace_GetIsUndead(oTarget);
switch (nSpell)
{
case SPELL_NEGATIVE_ENERGY_BURST:
eVis = EffectVisualEffect(VFX_IMP_NEGATIVE_ENERGY);
eVisHeal = EffectVisualEffect(VFX_IMP_HEALING_M);
nModify = nCastLevel/4;
if(nModify == 0)
{
nModify = 1;
}
eGood = EffectLinkEffects(EffectAbilityIncrease(ABILITY_STRENGTH, nModify), EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE));
eBad = EffectLinkEffects(EffectAbilityDecrease(ABILITY_STRENGTH, nModify), EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE));
//Apply the explosion at the location captured above.
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_LOS_EVIL_20), lTarget);
//Declare the spell shape, size and the location. Capture the first target object in the shape.
oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lTarget);
//Cycle through the targets within the spell shape until an invalid object is captured.
while (GetIsObjectValid(oTarget))
{
if(spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF))
{
//Roll damage for each target
nDamage = d8() + nCastLevel;
//Resolve metamagic
if (nMetaMagic == METAMAGIC_MAXIMIZE)
{
nDamage = 8 + nCastLevel;
}
else if (nMetaMagic == METAMAGIC_EMPOWER)
{
nDamage = nDamage + (nDamage / 2);
}
if(MySavingThrow(SAVING_THROW_WILL, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_NEGATIVE, OBJECT_SELF, fDelay))
{
nDamage /= 2;
}
//Get the distance between the explosion and the target to calculate delay
fDelay = GetDistanceBetweenLocations(lTarget, GetLocation(oTarget))/20;
// * any undead should be healed, not just Friendlies
//-------------------------------------------------------------Shayan's Subrace Engine code
if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD || Subrace_GetIsUndead(oTarget))
{
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_NEGATIVE_ENERGY_BURST, FALSE));
//Set the heal effect
eHeal = EffectHeal(nDamage);
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget));
//This visual effect is applied to the target object not the location as above. This visual effect
//represents the flame that erupts on the target not on the ground.
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisHeal, oTarget));
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eGood, oTarget));
}
else if(spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF))
{
if(GetRacialType(oTarget) != RACIAL_TYPE_UNDEAD)
{
if(!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
{
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_NEGATIVE_ENERGY_BURST));
//Set the damage effect
eDam = EffectDamage(nDamage, DAMAGE_TYPE_NEGATIVE);
// Apply effects to the currently selected target.
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
//This visual effect is applied to the target object not the location as above. This visual effect
//represents the flame that erupts on the target not on the ground.
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eBad, oTarget));
}
}
}
}
//Select the next target within the spell shape.
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lTarget);
}
SetModuleOverrideSpellScriptFinished();
break;
case SPELL_MASS_HEAL:
eVis = EffectVisualEffect(VFX_IMP_SUNSTRIKE);
eVis2 = EffectVisualEffect(VFX_IMP_HEALING_G);
eStrike = EffectVisualEffect(VFX_FNF_LOS_HOLY_10);
//Apply VFX area impact
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eStrike, lTarget);
//Get first target in spell area
oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lTarget);
while(GetIsObjectValid(oTarget))
{
fDelay = GetRandomDelay();
if ((IsUndead || GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD) && !GetIsReactionTypeFriendly(oTarget))
{
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_MASS_HEAL));
//Make a touch attack
nTouch = TouchAttackRanged(oTarget);
if (nTouch > 0)
{
if(!GetIsReactionTypeFriendly(oTarget) || Subrace_GetIsUndead(oTarget))
{
//Make an SR check
if (!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
{
//Roll damage
nModify = d4();
//make metamagic check
if (nMetaMagic == METAMAGIC_MAXIMIZE)
{
nModify = 1;
}
//Detemine the damage to inflict to the undead
nDamage = GetCurrentHitPoints(oTarget) - nModify;
//Set the damage effect
eKill = EffectDamage(nDamage, DAMAGE_TYPE_POSITIVE);
//Apply the VFX impact and damage effect
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eKill, oTarget));
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
}
}
}
}
else
{
//Make a faction check
if(GetIsFriend(oTarget) && (GetRacialType(oTarget) != RACIAL_TYPE_UNDEAD && !Subrace_GetIsUndead(oTarget)))
{
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_MASS_HEAL, FALSE));
//Determine amount to heal
nHeal = GetMaxHitPoints(oTarget);
//Set the damage effect
eHeal = EffectHeal(nHeal);
//Apply the VFX impact and heal effect
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget));
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget));
}
}
//Get next target in the spell area
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lTarget);
}
SetModuleOverrideSpellScriptFinished();
break;
case SPELL_HEALING_CIRCLE:
eVis = EffectVisualEffect(VFX_IMP_SUNSTRIKE);
eVis2 = EffectVisualEffect(VFX_IMP_HEALING_M);
if(nCastLevel > 20)
{
nCastLevel = 20;
}
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_LOS_HOLY_20), lTarget);
//Get first target in shape
oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, lTarget);
while (GetIsObjectValid(oTarget))
{
fDelay = GetRandomDelay();
//Check if racial type is undead
if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD || Subrace_GetIsUndead(oTarget))
{
if(!GetIsReactionTypeFriendly(oTarget))
{
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HEALING_CIRCLE));
//Make SR check
if (!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
{
nModify = d8() + nCastLevel;
//Make metamagic check
if (nMetaMagic == METAMAGIC_MAXIMIZE)
{
nModify = 8 + nCastLevel;
}
if (nMetaMagic == METAMAGIC_EMPOWER)
{
nModify = (3*nModify)/2; //Damage/Healing is +50%
}
//Make Fort save
if (MySavingThrow(SAVING_THROW_FORT, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_NONE, OBJECT_SELF, fDelay))
{
nModify /= 2;
}
//Set damage effect
eKill = EffectDamage(nModify, DAMAGE_TYPE_POSITIVE);
//Apply damage effect and VFX impact
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eKill, oTarget));
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
}
}
}
else
{
// * May 2003: Heal Neutrals as well
if(!GetIsReactionTypeHostile(oTarget) || GetFactionEqual(oTarget))
{
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HEALING_CIRCLE, FALSE));
nHeal = d8();
//Enter Metamagic conditions
if (nMetaMagic == METAMAGIC_MAXIMIZE)
{
nHeal = 8;//Damage is at max
}
//Set healing effect
nHeal = nHeal + nCastLevel;
if (nMetaMagic == METAMAGIC_EMPOWER)
{
nHeal = (3*nHeal)/2; //Damage/Healing is +50%
}
eHeal = EffectHeal(nHeal);
//Apply heal effect and VFX impact
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget));
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget));
}
}
//Get next target in the shape
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, lTarget);
}
SetModuleOverrideSpellScriptFinished();
break;
case SPELL_CURE_CRITICAL_WOUNDS:
if(IsUndead)
{
spellsCure(d8(4), 20, 32, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_G, GetSpellId());
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_CURE_LIGHT_WOUNDS:
if(IsUndead)
{
spellsCure(d8(), 5, 8, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_S, GetSpellId());
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_CURE_MINOR_WOUNDS:
if(IsUndead)
{
spellsCure(4, 0, 4, VFX_IMP_SUNSTRIKE, VFX_IMP_HEAD_HEAL, GetSpellId());
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_CURE_MODERATE_WOUNDS:
if(IsUndead)
{
spellsCure(d8(2), 10, 16, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_M, GetSpellId());
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_CURE_SERIOUS_WOUNDS:
if(IsUndead)
{
spellsCure(d8(3), 15, 24, VFX_IMP_SUNSTRIKE, VFX_IMP_HEALING_L, GetSpellId());
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_GREATER_RESTORATION:
eVisual = EffectVisualEffect(VFX_IMP_RESTORATION_GREATER);
eBad = GetFirstEffect(oTarget);
//Search for negative effects
while(GetIsEffectValid(eBad))
{
if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
GetEffectType(eBad) == EFFECT_TYPE_CURSE ||
GetEffectType(eBad) == EFFECT_TYPE_DISEASE ||
GetEffectType(eBad) == EFFECT_TYPE_POISON ||
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eBad) == EFFECT_TYPE_CHARMED ||
GetEffectType(eBad) == EFFECT_TYPE_DOMINATED ||
GetEffectType(eBad) == EFFECT_TYPE_DAZED ||
GetEffectType(eBad) == EFFECT_TYPE_CONFUSED ||
GetEffectType(eBad) == EFFECT_TYPE_FRIGHTENED ||
GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL ||
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eBad) == EFFECT_TYPE_SLOW ||
GetEffectType(eBad) == EFFECT_TYPE_STUNNED)
{
//Remove effect if it is not subracial effect
if(GetEffectSubType(eBad) == SUBTYPE_SUPERNATURAL)
{
if(GetEffectCreator(eBad) != oTarget)
{
RemoveEffect(oTarget, eBad);
}
}
else
{
RemoveEffect(oTarget, eBad);
}
}
eBad = GetNextEffect(oTarget);
}
if(GetRacialType(oTarget) != RACIAL_TYPE_UNDEAD)
{
//Apply the VFX impact and effects
nHeal = GetMaxHitPoints(oTarget) - GetCurrentHitPoints(oTarget);
eHeal = EffectHeal(nHeal);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
}
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_GREATER_RESTORATION, FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget);
SetModuleOverrideSpellScriptFinished();
break;
case SPELL_HARM:
nMetaMagic = GetMetaMagicFeat();
nTouch = TouchAttackMelee(oTarget);
eVis = EffectVisualEffect(246);
eVis2 = EffectVisualEffect(VFX_IMP_HEALING_G);
//Check that the target is undead
if (IsUndead)
{
//Figure out the amount of damage to heal
nHeal = GetMaxHitPoints(oTarget) - GetCurrentHitPoints(oTarget);
//Set the heal effect
eHeal = EffectHeal(nHeal);
//Apply heal effect and VFX impact
ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HARM, FALSE));
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_HEAL:
eSun = EffectVisualEffect(VFX_IMP_SUNSTRIKE);
eHealVis = EffectVisualEffect(VFX_IMP_HEALING_X);
//Check to see if the target is an undead
if (IsUndead)
{
if(!GetIsReactionTypeFriendly(oTarget) || IsUndead)
{
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HEAL));
//Make a touch attack
if (TouchAttackMelee(oTarget))
{
//Make SR check
if (!MyResistSpell(OBJECT_SELF, oTarget))
{
//Roll damage
nModify = d4();
nMetaMagic = GetMetaMagicFeat();
//Make metamagic check
if (nMetaMagic == METAMAGIC_MAXIMIZE)
{
nModify = 1;
}
//Figure out the amount of damage to inflict
nDamage = GetCurrentHitPoints(oTarget) - nModify;
//Set damage
eKill = EffectDamage(nDamage, DAMAGE_TYPE_POSITIVE);
//Apply damage effect and VFX impact
ApplyEffectToObject(DURATION_TYPE_INSTANT, eKill, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eSun, oTarget);
}
}
}
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_INFLICT_MINOR_WOUNDS:
if(IsUndead)
{
spellsInflictTouchAttack(1, 0, 1, 246, VFX_IMP_HEALING_G, nSpell);
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_INFLICT_LIGHT_WOUNDS:
if(IsUndead)
{
spellsInflictTouchAttack(d8(), 5, 8, 246, VFX_IMP_HEALING_G, nSpell);
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_INFLICT_MODERATE_WOUNDS:
if(IsUndead)
{
spellsInflictTouchAttack(d8(2), 10, 16, 246, VFX_IMP_HEALING_G, nSpell);
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_INFLICT_SERIOUS_WOUNDS:
if(IsUndead)
{
spellsInflictTouchAttack(d8(3), 15, 24, 246, VFX_IMP_HEALING_G, nSpell);
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_INFLICT_CRITICAL_WOUNDS:
if(IsUndead)
{
spellsInflictTouchAttack(d8(4), 20, 32, 246, VFX_IMP_HEALING_G, nSpell);
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_LESSER_RESTORATION:
eVisual = EffectVisualEffect(VFX_IMP_RESTORATION_LESSER);
eBad = GetFirstEffect(oTarget);
//Search for negative effects
while(GetIsEffectValid(eBad))
{
if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE)
{
//Remove effect if it is not subracial effect
if(GetEffectSubType(eBad) == SUBTYPE_SUPERNATURAL)
{
if(GetEffectCreator(eBad) != oTarget)
{
RemoveEffect(oTarget, eBad);
}
}
else
{
RemoveEffect(oTarget, eBad);
}
}
eBad = GetNextEffect(oTarget);
}
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_LESSER_RESTORATION, FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget);
SetModuleOverrideSpellScriptFinished();
break;
case SPELL_LIGHT:
if(GetIsPCLightSensitive(oTarget))
{
if(FortitudeSave(oTarget, LIGHT_SENSITIVE_SAVING_THROW_DC) == 0)
{
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectBlindness(), oTarget, RoundsToSeconds(LIGHT_STRUCK_BLIND_FOR_ROUNDS));
}
}
break;
case SPELL_NEGATIVE_ENERGY_RAY:
//---- Shayan's Subrace Engine code
if(IsUndead)
{
nMetaMagic = GetMetaMagicFeat();
if(nCastLevel > 9)
{
nCastLevel = 9;
}
nCastLevel = (nCastLevel + 1) / 2;
nDamage = d6(nCastLevel);
//Enter Metamagic conditions
if (nMetaMagic == METAMAGIC_MAXIMIZE)
{
nDamage = 6 * nCastLevel;//Damage is at max
}
else if (nMetaMagic == METAMAGIC_EMPOWER)
{
nDamage = nDamage + (nDamage/2); //Damage/Healing is +50%
}
eVis = EffectVisualEffect(VFX_IMP_NEGATIVE_ENERGY);
eDam = EffectDamage(nDamage, DAMAGE_TYPE_NEGATIVE);
eHeal = EffectHeal(nDamage);
eVisHeal = EffectVisualEffect(VFX_IMP_HEALING_M);
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_NEGATIVE_ENERGY_RAY, FALSE));
eRay = EffectBeam(VFX_BEAM_EVIL, OBJECT_SELF, BODY_NODE_HAND);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisHeal, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eRay, oTarget, 1.7);
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELL_RAISE_DEAD:
DelayCommand(2.0, ReapplySubraceAbilities(oTarget));
break;
case SPELL_RESTORATION:
//Declare major variables
eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);
eBad = GetFirstEffect(oTarget);
//Search for negative effects
while(GetIsEffectValid(eBad))
{
if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)
{
//Remove effect if it is not subracial effect
if(GetEffectSubType(eBad) == SUBTYPE_SUPERNATURAL)
{
if(GetEffectCreator(eBad) != oTarget)
{
RemoveEffect(oTarget, eBad);
}
}
else
{
RemoveEffect(oTarget, eBad);
}
}
//---------------->End Modification by Shayan.
eBad = GetNextEffect(oTarget);
}
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget);
SetModuleOverrideSpellScriptFinished();
case SPELL_RESURRECTION:
DelayCommand(2.0, ReapplySubraceAbilities(oTarget));
break;
case SPELLABILITY_BG_INFLICT_SERIOUS_WOUNDS:
if(IsUndead)
{
spellsInflictTouchAttack(d8(3), 15, 24, 246, VFX_IMP_HEALING_G, nSpell);
SetModuleOverrideSpellScriptFinished();
}
break;
case SPELLABILITY_BG_INFLICT_CRITICAL_WOUNDS:
if(IsUndead)
{
spellsInflictTouchAttack(d8(4), 20, 32, 246, VFX_IMP_HEALING_G, nSpell);
SetModuleOverrideSpellScriptFinished();
}
break;
}
}