Author Topic: Elemental Absorption  (Read 309 times)

Legacy_DITB123

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Elemental Absorption
« on: August 15, 2011, 07:50:21 pm »


               Hey, I was trying to make a script that would heal the PC instead of deal a particular damage type to them, effectively 'absorbing' the damage and turning it into health. I began making an miscalaneous small item with a unique self only spell property on it that added this item property to their skin, but i had trouble putting it all together. Plus, since they must still take the original damage in order to figure out how much they should be healed, I believe my method may be flawed. Does anyyone know of a way to add this effect to a PC for one minute duration, WITHOUT them taking any damage from the original attack?

Thanks a lot
               
               

               
            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
Elemental Absorption
« Reply #1 on: August 15, 2011, 08:41:11 pm »


               Temporary immunity effect to that form of damage?
That will stop the damage...but you'll have to do something else to actually heal them instead. For NPCs, it would be a simple matter to add code in the OnDamaged event to use the GetDamageDealtByType function to figure out how much damage needs to be turned into healing, and then apply the heal. But for PCs, who have no OnDamaged event, you're out of luck unless you use something like NWNX to provide this missing PC event generation functionality as an add-on.

Maybe you could use temp immunity to stop the damage and give them a temporary regeneration effect as well to heal them over time. Not precisely what you want since the regen would be unrelated to any specific damage type but then it wouldn't heal them quite so much either so maybe it's an acceptable trade-off.
               
               

               


                     Modifié par Axe_Murderer, 15 août 2011 - 07:45 .
                     
                  


            

Legacy_DITB123

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Elemental Absorption
« Reply #2 on: August 17, 2011, 03:47:31 am »


               Ok, thanks for the help with that idea Axe_Murderer. Since it would not have worked as I had hoped, I am going to instead put it on a creature's skin as an 'on hit cast uniquie power spell' property that 'absorbs' the 4 elemental damage types (heals for double whatever they caused), but my script won't fire like i had hoped. First, the creature was hit with spells and did not get healed at all, not sure what I did wrong there. Next, The physical damage i did to him with a sword that had elemental damage on it did produce the healing effect but the healed amount did not appear as a speak string, (which links to my third problem). Lastly, the green floating text which was supposed to show how much the creature healed overall did not show above his head. If you would, it would be great if anyone could look over the script and see what I messed up on.

Here are the scripts I used:

1) "toamarutprops"

#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
switch (nEvent)
  {
  case X2_ITEM_EVENT_ACTIVATE:
ExecuteScript("ac_"+GetTag(GetItemActivated()),
OBJECT_SELF); break;
  case X2_ITEM_EVENT_EQUIP:
ExecuteScript("eq_"+GetTag(GetPCItemLastEquipped()),
OBJECT_SELF); break;
  case X2_ITEM_EVENT_UNEQUIP:
ExecuteScript("ue_"+GetTag(GetPCItemLastUnequipped())
, OBJECT_SELF); break;
  case X2_ITEM_EVENT_ACQUIRE:
ExecuteScript("aq_"+GetTag(GetModuleItemAcquired()),
OBJECT_SELF); break;
  case X2_ITEM_EVENT_UNACQUIRE:
ExecuteScript("ua_"+GetTag(GetModuleItemLost()),
OBJECT_SELF); break;
  case X2_ITEM_EVENT_SPELLCAST_AT:
ExecuteScript("sp_"+GetTag(GetModuleItemLost()),
OBJECT_SELF); break;
  case X2_ITEM_EVENT_ONHITCAST:
ExecuteScript("on_"+GetTag(GetSpellCastItem()),
OBJECT_SELF); break;
  }
}


....which links the item to this script:

2) "on_toamarutprops"

void main()
{
object oMarut = GetObjectByTag("ToA_Marut");
//object oTarget = oMarut;
int nFireDamage = GetDamageDealtByType(DAMAGE_TYPE_FIRE);
int nColdDamage = GetDamageDealtByType(DAMAGE_TYPE_COLD);
int nElectricDamage = GetDamageDealtByType(DAMAGE_TYPE_ELECTRICAL);
int nAcidDamage = GetDamageDealtByType(DAMAGE_TYPE_ACID);

string sFireDamage = IntToString(nFireDamage);
string sColdDamage = IntToString(nColdDamage);
string sElectricDamage = IntToString(nElectricDamage);
string sAcidDamage = IntToString(nAcidDamage);

effect eEffectFire = EffectHeal(2*nFireDamage);
effect eEffectCold = EffectHeal(2*nColdDamage);
effect eEffectElectric = EffectHeal(2*nElectricDamage);
effect eEffectAcid = EffectHeal(2*nAcidDamage);

eEffectFire = SupernaturalEffect(eEffectFire);
eEffectCold = SupernaturalEffect(eEffectCold);
eEffectElectric = SupernaturalEffect(eEffectElectric);
eEffectAcid = SupernaturalEffect(eEffectAcid);


if (GetDamageDealtByType(DAMAGE_TYPE_FIRE) > 0)
{
DelayCommand(0.01, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffectFire, oMarut));
DelayCommand(0.01, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HEALING_S), GetLocation(oMarut)));
FloatingTextStringOnCreature("<c € >+"+sFireDamage+"</c>", oMarut, FALSE);
}

if (GetDamageDealtByType(DAMAGE_TYPE_COLD) > 0)
{
DelayCommand(0.01, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffectCold, oMarut));
DelayCommand(0.01, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HEALING_S), GetLocation(oMarut)));
FloatingTextStringOnCreature("<c € >+"+sColdDamage+"</c>", oMarut, FALSE);
}

if (GetDamageDealtByType(DAMAGE_TYPE_ELECTRICAL) > 0)
{
DelayCommand(0.01, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffectElectric, oMarut));
DelayCommand(0.01, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HEALING_S), GetLocation(oMarut)));
FloatingTextStringOnCreature("<c € >+"+sElectricDamage+"</c>", oMarut, FALSE);
}

if (GetDamageDealtByType(DAMAGE_TYPE_ACID) > 0)
{
DelayCommand(0.01, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffectAcid, oMarut));
DelayCommand(0.01, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HEALING_S), GetLocation(oMarut)));
FloatingTextStringOnCreature("<c € >+"+sAcidDamage+"</c>", oMarut, FALSE);
}

}

Thanks again for the help
               
               

               
            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
Elemental Absorption
« Reply #3 on: August 17, 2011, 09:46:38 am »


               OnHitCast doesn't fire for skins. Only equipment.
               
               

               
            

Legacy_DITB123

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Elemental Absorption
« Reply #4 on: August 17, 2011, 08:14:01 pm »


               I moved the property and tag to a piece of armor, but it still isn't working. Any thoughts?
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Elemental Absorption
« Reply #5 on: August 17, 2011, 08:49:58 pm »


               

Axe_Murderer wrote...

OnHitCast doesn't fire for skins. Only equipment.


It works for skins; I remember using it there to wear down weapons and armor.  Onhitcast is limited to hits though.  So spells would never fire this property.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Elemental Absorption
« Reply #6 on: August 18, 2011, 12:28:47 am »


               

DITB123 wrote...

Ok, thanks for the help with that idea Axe_Murderer. Since it would not have worked as I had hoped, I am going to instead put it on a creature's skin as an 'on hit cast uniquie power spell' property that 'absorbs' the 4 elemental damage types (heals for double whatever they caused), but my script won't fire like i had hoped. First, the creature was hit with spells and did not get healed at all, not sure what I did wrong there. Next, The physical damage i did to him with a sword that had elemental damage on it did produce the healing effect but the healed amount did not appear as a speak string, (which links to my third problem). Lastly, the green floating text which was supposed to show how much the creature healed overall did not show above his head. If you would, it would be great if anyone could look over the script and see what I messed up on.

For 2 and 3, make sure that oMarut is using the correct case sensitive tag.  If oMarut is a player character then there is no tag, so you would have to use a different identifier.  If oMarut is the subject of the blow you can save time using OBJECT_SELF.
               
               

               
            

Legacy_DITB123

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Elemental Absorption
« Reply #7 on: August 18, 2011, 10:31:21 am »


               Ok, Thanks for all the help guys. I found a way for it to work, and i just put the floaty text on the PC attacker.