Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. /*
  2. Channeling energy causes a burst that affects all creatures of one type (either undead or living) in a 30-foot radius centered on the cleric.
  3. The amount of damage dealt or healed is equal to 1d6 points of damage plus 1d6 points of damage for every two cleric levels beyond 1st (2d6 at 3rd, 3d6 at 5th, and so on).
  4. Creatures that take damage from channeled energy receive a Will save to halve the damage.
  5. The DC of this save is equal to 10 + 1/2 the cleric’s level + the cleric’s Charisma modifier.
  6. Creatures healed by channel energy cannot exceed their maximum hit point total—all excess healing is lost.
  7. */
  8.  
  9. #include "nwn2_inc_spells"
  10. #include "NW_I0_SPELLS"
  11. #include "x2_inc_spellhook"
  12.  
  13. void CureNearby(effect eVis, effect eVis2, int nCasterLvl, int nMetaMagic);
  14.  
  15. void main()
  16. {
  17. if (!X2PreSpellCastCode())
  18. return;
  19.  
  20. int nCasterLvl = GetCasterLevel(OBJECT_SELF);
  21. int nMetaMagic = GetMetaMagicFeat();
  22. effect eVis = EffectVisualEffect( VFX_IMP_SUNSTRIKE );
  23. effect eVis2 = EffectVisualEffect(VFX_IMP_HEALING_G);
  24. effect eImpact = EffectVisualEffect(VFX_HIT_CURE_AOE);
  25.  
  26. ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eImpact, GetSpellTargetLocation());
  27.  
  28. CureNearby(eVis, eVis2, nCasterLvl, nMetaMagic);
  29. }
  30.  
  31. void CureObject(object oTarget, effect eVis, effect eVis2, int nCasterLvl, int nMetaMagic, int nDC)
  32. {
  33. object oSelf = OBJECT_SELF;
  34. int nDamagen, nModify, nHurt;
  35. effect eKill, eHeal;
  36. float fDelay = GetRandomDelay();
  37.  
  38. if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD )
  39. {
  40. if(GetIsEnemy(oSelf, oTarget) || GetIsReactionTypeHostile(oSelf, oTarget))
  41. {
  42. SignalEvent(oTarget, EventSpellCastAt(oSelf, GetSpellId()));
  43. if (!MyResistSpell(oSelf, oTarget, fDelay))
  44. {
  45. nModify = d6((nCasterLvl-1)/2);
  46. nModify = ApplyMetamagicVariableMods(nModify, 3 * (nCasterLvl-1));
  47. if(!GetIsObjectValid(GetSpellCastItem()))
  48. {
  49. if(GetHasFeat(FEAT_AUGMENT_HEALING) > 0)
  50. {
  51. int nSpellLvl = GetSpellLevel(GetSpellId());
  52. nModify = nModify + (2 * nSpellLvl);
  53. }
  54. }
  55. if (MySavingThrow(SAVING_THROW_WILL, oTarget, nDC, SAVING_THROW_TYPE_NONE, oSelf, fDelay))
  56. {
  57. nModify /= 2;
  58. }
  59. nHurt = nModify;
  60. eKill = EffectDamage(nHurt, DAMAGE_TYPE_POSITIVE);
  61. DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eKill, oTarget));
  62. DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
  63. }
  64. }
  65. }
  66. else
  67. {
  68. if (GetIsNeutral(oSelf, oTarget) || GetIsReactionTypeNeutral(oSelf, oTarget) || GetIsFriend(oSelf, oTarget) || GetIsReactionTypeFriendly(oSelf, oTarget))
  69. {
  70. SignalEvent(oTarget, EventSpellCastAt(oSelf, GetSpellId(), FALSE));
  71. nModify = d6((nCasterLvl-1)/2);
  72. nModify = ApplyMetamagicVariableMods(nModify, 3 * (nCasterLvl-1));
  73. if(!GetIsObjectValid(GetSpellCastItem()))
  74. {
  75. if(GetHasFeat(FEAT_AUGMENT_HEALING) > 0)
  76. {
  77. int nSpellLvl = GetSpellLevel(GetSpellId());
  78. nModify = nModify + (2 * nSpellLvl);
  79. }
  80. }
  81. eHeal = EffectHeal(nModify);
  82. DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget));
  83. DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget));
  84. }
  85. }
  86. }
  87.  
  88. void CureNearby(effect eVis, effect eVis2, int nCasterLvl, int nMetaMagic)
  89. {
  90. location lTarget = GetSpellTargetLocation();
  91. int nDC = 10 + GetLevelByClass(CLASS_TYPE_CLERIC, OBJECT_SELF) + GetAbilityModifier(ABILITY_CHARISMA);
  92. object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 30.0f, lTarget);
  93. while (GetIsObjectValid(oTarget))
  94. {
  95. if (!GetFactionEqual(oTarget, OBJECT_SELF) || GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD)
  96. {
  97. CureObject(oTarget, eVis, eVis2, nCasterLvl, nMetaMagic, nDC);
  98. }
  99. oTarget = GetNextObjectInShape(SHAPE_SPHERE, 30.0f, lTarget);
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement