If target has item dont run script: script
#1
Posté 18 juillet 2012 - 06:51
If (!GetIsEnemy(oPC))
{
return;
}
but for a specific item instead of it being a enemy have it be a specific item (either by resref, or tag)
#2
Posté 18 juillet 2012 - 08:47
// * Return value on error: OBJECT_INVALID
object GetItemPossessedBy(object oCreature, string sItemTag);
#4
Posté 19 juillet 2012 - 02:57
#5
Posté 19 juillet 2012 - 03:34
http://70.179.46.242.../csl/index.html
Code is largely usable as is ( copy paste what you need into your own codebase if its a simple function, actual files are on the nexus )
#6
Posté 19 juillet 2012 - 07:03
"void main()
{
object oCaster = OBJECT_SELF;
int nCasterLvl = GetCasterLevel (OBJECT_SELF);
//int nDLvl = GetLevelByclass(class_TYPE_*class, oCaster);
//int nDuration = nDLvl; im going to make the duration by characterlevel but its set to 10.0 for testing purposes
object oItem = GetObjectByTag("itemname");
object pItem = GetItemPossessedBy(oCaster, "itemname");
DelayCommand(10.0, DestroyObject (oItem));
if (pItem != OBJECT_INVALID)
{
SendMessageToPC(oCaster, "SPELL FAILED: One or more instances of spell Activated.");
return;
}
if (nCasterLvl > 10)
nCasterLvl = 10;
{
CreateItemOnObject("itemname", oCaster, nCasterLvl);
}
}"
The script wont remove the items unless i cast the spell twice...other then that everything runs perfectly
Modifié par AstoriaWMY, 19 juillet 2012 - 07:23 .
#7
Posté 20 juillet 2012 - 12:01
#8
Posté 20 juillet 2012 - 06:36
#9
Posté 20 juillet 2012 - 08:48
Your script is doing things back and forth - like deleting an item then creating it again? I think you are making it more complex than it needs to be.
#10
Posté 22 juillet 2012 - 06:10
I need it to remove the item after the set duration after the first time i cast the spell. So is the problem that it cant find the item becuase it hasnt been created yet and therefor wont remove it? and if thats the case how to I fix it so that the order the script is fired is correct?
Modifié par AstoriaWMY, 22 juillet 2012 - 06:12 .
#11
Posté 22 juillet 2012 - 06:29
void main()
{
object oCaster = OBJECT_SELF;
object oItem = GetItemPossessedBy(oCaster, "itemname");
if (GetIsObjectValid(oItem))
{
SendMessageToPC(oCaster, "SPELL FAILED: One or more instances of spell Activated.");
}
else
{
int nCasterLvl = GetCasterLevel(oCaster);
if (nCasterLvl > 10) nCasterLvl = 10;
// NB:
oItem = CreateItemOnObject("itemname", oCaster, nCasterLvl);
DelayCommand(10.f, DestroyObject(oItem));
}
}i think the problem is that oItem was not getting defined as oItem until the second pass ...
Modifié par kevL, 22 juillet 2012 - 06:46 .
#12
Posté 22 juillet 2012 - 07:55
#13
Posté 23 juillet 2012 - 10:02
Ive tried setting the the object to cursed/plot but this makes it so that the item remains in you inventory even after you use all the stacks. Ive also tried the CSLDestroyObjectDropped in the script but nothing happened, i also tried it in a heartbeat but still didnt do anything.
any suggestions?
#14
Posté 23 juillet 2012 - 10:55
Set the items cursed when they are created (or in their blueprint properties):
// When cursed, items cannot be dropped void SetItemCursedFlag(object oItem, int nCursed);
as a part of void main() in the CreateObject scope,
Then instead of the line
DelayCommand(10.f, DestroyObject(oItem));
use
DelayCommand(10.f, DestroyCursedSpellItem(oItem));
and write a subfunction at the top of the script:
void DestroyCursedSpellItem(object oItem)
{
SetItemCursedFlag(oItem, FALSE);
DestroyObject(oItem);
}- still not sure what's gonna happen if the stack is split tho; then you'll probly have to loop through Inventory ( GetFirst/GetLast etc ) such that if the tag matches, Destroy those extra stacks too -- assuming cursed item stacks can be split .....
I'm not sure how the items are being used, but assuming that a script runs you can write a similar function & use Get/SetItemStackSize(), perhaps quickly switching the flag on/off & thus let them get used up, whether or not the 10 second duration times out
can ya handle the details, the code that runs when Caster uses one item should look something like this:
void ExpendCursedSpellItem(object oItem)
{
int i = GetItemStackSize(oItem);
if (i > 1)
SetItemStackSize(oItem, i - 1);
else
{
SetItemCursedFlag(oItem, FALSE);
DestroyObject(oItem);
}
}





Retour en haut






