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!
Custom Heal Kit Issue
Débuté par
Badwater
, janv. 17 2012 01:43
#1
Posté 17 janvier 2012 - 01:43
#2
Posté 17 janvier 2012 - 01:46
change the last line of code: DestroyObject(oItem);
to
to
int nStack = GetItemStackSize(oItem);
if(nStack > 1)
{
SetItemStackSize(oItem,nStack-1);
}
else
{
DestroyObject(oItem);
}
#3
Posté 17 janvier 2012 - 02:29
Now it's using two at a time from the stack (and only firing one).
I'm also getting various numbers off the radial menu, numbers other than 1, and I'm not discerning the pattern....
??
I'm also getting various numbers off the radial menu, numbers other than 1, and I'm not discerning the pattern....
??
#4
Posté 17 janvier 2012 - 02:48
I see, I didnt expect it will be done so badly - you can remove the DestroyObject part then completely.
Each use of the healing kit removes one from stack by default - even when the healing kit has no effect due to wrong target. To change this behavior, healing kit's cast spell property would have to be set to unlimited uses and then the code I posted will work properly. Its up to you what solution do you prefer.
Each use of the healing kit removes one from stack by default - even when the healing kit has no effect due to wrong target. To change this behavior, healing kit's cast spell property would have to be set to unlimited uses and then the code I posted will work properly. Its up to you what solution do you prefer.
Modifié par ShaDoOoW, 17 janvier 2012 - 02:48 .
#5
Posté 17 janvier 2012 - 02:49
If it's a single use item, does it even need the DestroyObject command? It should destroy itself automatically on use.
ShadoOow's change will work if you change it to an unlimited uses item, which is the way to go about it if you don't want the bandages to get used up if you target an invalid creature type or a placeable or such.
Edit: ShadoOow beat me to it.
ShadoOow's change will work if you change it to an unlimited uses item, which is the way to go about it if you don't want the bandages to get used up if you target an invalid creature type or a placeable or such.
Edit: ShadoOow beat me to it.
Modifié par Failed.Bard, 17 janvier 2012 - 02:49 .
#6
Posté 17 janvier 2012 - 09:56
Thanks, ShadoOoW....made your change and everything works nicely. I appreciate the help!
#7
Posté 06 février 2012 - 11:31
Now my issue is that in spite of having a different name and resref, all the heal kit items stack together...so that if I have xxxx +3, yyyy +6, zzzz +10, they all stack up as xxxx +3. I'm using the Heal Kit appearance for all so far but it doesn't make sense to me that differentiation is not being made based on resref.....what am I missing here?
#8
Posté 07 février 2012 - 12:11
Items of same type:
will stack with:
different name
different resref
won't stack with:
different tag
different icon
different properties
Hope this helps. I did testing on potions and scrolls a year or so ago to figure this out.
will stack with:
different name
different resref
won't stack with:
different tag
different icon
different properties
Modifié par The Amethyst Dragon, 07 février 2012 - 12:13 .
#9
Posté 07 février 2012 - 01:19
Thanks AD. I suspected I'd need different apps for each item but it's better to check before investing a bunch of time into something that already has taken a lot of time!





Retour en haut






