I'm working with a download off nwvault; a custom heal kit that does what I would like with one exception. The script fires from an item that is created and uses the Cast Spell: Activate Item - Single Use.
The script is at
http://nwvault.ign.c....Detail&id=3103
My problem is that I'm making stackable items (which stack fine), but when one item is used any others in the stack disappear. Only the one item fires. Is there something in the configuration of the item(s) that could be screwing this up? Or is there something in the scripting that is amiss?
Here is the script:
//::///////////////////////////////////////////////
//:: Bandage/Healing Kit Script
//:: it_healkit
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Custom Healing Kit Script
-Provides +Save vs. Poison, Disease (2 Hours)
-Restores HP on a curve up to 75% HP
HP < 10% = 25% Effective
HP < 25% = 50% Effective
-If in combat, kit effectiveness halves
*/
//:://////////////////////////////////////////////
//:: Created By: Kilana Evra
//:: Created On:
//:://////////////////////////////////////////////
#include "x2_inc_switches"
#include "NW_I0_GENERIC"
void ApplyKit(object oTarget, effect e1)
{ ApplyEffectToObject(DURATION_TYPE_INSTANT, e1, oTarget);
}
void ApplyProtection(object oTarget, effect e1)
{ e1 = SupernaturalEffect(e1);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, e1, oTarget, HoursToSeconds(2));
}
void main()
{ int nEvent =GetUserDefinedItemEventNumber();
if (nEvent == X2_ITEM_EVENT_ACTIVATE)
{ object oPC = GetItemActivator();
object oItem = GetItemActivated();
object oTarget = GetItemActivatedTarget();
//Only affects creatures
if(GetObjectType(oTarget) != OBJECT_TYPE_CREATURE)
{ FloatingTextStringOnCreature("This item can only be used on creatures.", oPC);
CopyItem(oItem, oPC, TRUE);
return;
}
//Can only restore up to 75% HP
int nMaxHeal = (GetMaxHitPoints(oTarget) * 3)/4;
if(GetPercentageHPLoss(oTarget) >= 75)
{ FloatingTextStringOnCreature("This item can only restore up to 75% health.", oPC, FALSE);
}
//SendMessageToPC(oPC, "Max Healable HP: " +IntToString(nMaxHeal));
int nEffectiveness = 100;
//If the target HP is 10% or lower, Kit is only 25% effective
if(GetPercentageHPLoss(oTarget) <= 10)
nEffectiveness = 25;
//If the target HP is 25% or lower, Kit is only 50% effective
else if(GetPercentageHPLoss(oTarget) <= 25)
nEffectiveness = 50;
//If the target or the healer are in combat, Kit effectiveness drops
// by another half
if(GetIsInCombat(oPC) || GetIsInCombat(oTarget))
nEffectiveness = nEffectiveness/2;
//SendMessageToPC(oPC, "Effectiveness: " +IntToString(nEffectiveness));
//Determine Kit Type +1, +2, +3,... +50
int nKitType = StringToInt(GetStringRight(GetName(oItem), 2));
if(nKitType < 1 || nKitType > 50)
StringToInt(GetStringRight(GetName(oItem), 1));
if(nKitType < 1 || nKitType > 50)
nKitType = 1;
//SendMessageToPC(oPC, "Kit Type: " +IntToString(nKitType));
//HP restored = Heal Skill + d2(KitType)
int nSkill = GetSkillRank(SKILL_HEAL, oPC);
int nHeal = nSkill + d2(nKitType);
nHeal = (nHeal * nEffectiveness) / 100;
if(nHeal > nMaxHeal - GetCurrentHitPoints(oTarget))
nHeal = nMaxHeal - GetCurrentHitPoints(oTarget);
if(nHeal <= 0) nHeal = 0;
//Determine Saves Bonus
int nSaves = 4;
if(nKitType > 4) nSaves = nKitType;
//Create and apply effects
effect eHeal = EffectHeal(nHeal);
effect eSave1 = EffectSavingThrowIncrease(SAVING_THROW_FORT, nSaves, SAVING_THROW_TYPE_DISEASE);
effect eSave2 = EffectSavingThrowIncrease(SAVING_THROW_FORT, nSaves, SAVING_THROW_TYPE_POISON);
effect eVis = EffectVisualEffect(VFX_IMP_HEALING_S);
eHeal = EffectLinkEffects(eHeal, eVis);
eVis = EffectVisualEffect(VFX_DUR_CESSATE_NEUTRAL);
eSave1 = EffectLinkEffects(eSave1, eSave2);
eSave1 = EffectLinkEffects(eSave1, eVis);
eSave1 = SupernaturalEffect(eSave1);
//Apply Effects, Prevent Kit Save stacking
int nCheck = GetLocalInt(oPC, "healedkit");
if(nCheck == FALSE)
{ SetLocalInt(oPC, "healedkit", 1);
DelayCommand(HoursToSeconds(2), DeleteLocalInt(oPC, "healedkit"));
AssignCommand(oPC, ApplyProtection(oTarget, eSave1));
SendMessageToPC(oTarget, GetName(oItem)+ " : Restoring " +IntToString(nHeal)+ " HP, granting +" +IntToString(nSaves)+ " Save vs. Disease/Poison. (" +IntToString(nEffectiveness)+ "% Effectiveness)");
}
else SendMessageToPC(oTarget, GetName(oItem)+ ": Restoring " +IntToString(nHeal)+ " HP. (" +IntToString(nEffectiveness)+ "% Effectiveness)");
if(nHeal > 0) AssignCommand(oPC, ApplyKit(oTarget, eHeal));
DestroyObject(oItem);
}
}
Thanks in advance for your input!