Craft Item/Destroy Ingredients
Zephirius
Member Posts: 419
Got a small script that is working partially. All but destroying the craft items that is... Just need them to go away after item creation.
Tried using DestroyObject. It works, but for only the MITHRIL_BAR. The other two ingredients remain?
Thanks in advance.
Code so far:
Tried using DestroyObject. It works, but for only the MITHRIL_BAR. The other two ingredients remain?
Thanks in advance.
Code so far:
void main() { object oPC = GetLastSpellCaster(); if (!GetIsPC(oPC)) return; if (GetLastSpell() == SPELL_STONESKIN) { object oSelf = OBJECT_SELF; // Only fire once. if ( GetLocalInt(GetModule(), "DO_ONCE__" + GetTag(OBJECT_SELF)) ) return; SetLocalInt(GetModule(), "DO_ONCE__" + GetTag(OBJECT_SELF), TRUE); // If Gumdulmach has the item "MITHRIL_BAR". if ( GetItemPossessedBy(OBJECT_SELF, "MITHRIL_BAR") != OBJECT_INVALID ) { // If Gumdulmach has the item "IRON_SPIKES". if ( GetItemPossessedBy(OBJECT_SELF, "IRON_SPIKES") != OBJECT_INVALID ) { // If Gumdulmach has the item "WOODEN_HANDLE". if ( GetItemPossessedBy(OBJECT_SELF, "WOODEN_HANDLE") != OBJECT_INVALID ) { // Give Mjordulstiehl to us. DestroyObject(GetObjectByTag("MITHRIL_BAR"), 0.3); DestroyObject(GetObjectByTag("IRON_SPIKES"), 0.6); DestroyObject(GetObjectByTag("WOODEN_HANDLE"), 0.9); ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect (VFX_FNF_MYSTICAL_EXPLOSION), OBJECT_SELF); CreateItemOnObject("mjordulstiehl", oSelf); } } } } }
0
Comments
Secondly, DestroyObject doesn't run until after the script has ended anyway (which is in case you're trying to destroy the object which the script is running on), which probably makes the delays redundant.
Thirdly and most importantly, you're destroying the first object tagged "MITHRIL_BAR", the first object tagged "IRON_SPIKES" and the first object tagged "WOODEN_HANDLE" no matter where they exist in the game, even if they aren't the ones held by the player.
The first thing you should do in the script right after finding the PC is use GetItemPossessedBy to try to find the three items on the player and assign them to object variables, then use those object variables in both the "if" and in the DestroyObject commands.
Also, did you really mean for OBJECT_SELF to refer to the object the script is running on instead of to the player? If so, then it should work. If not, you may be getting other strange effects.
Another note: I usually check for GetIsObjectValid rather than checking that the object is not equal to OBJECT_INVALID but either way should work.
Try this and see if it does what you want (untested of course): Editing to add, this script might not work correctly in some situations which could arise in a multi-player module but should work fine for single-player.