Holty1-5 Posted May 14, 2010 Share Posted May 14, 2010 void main() { object oDestroy = GetFirstItemInInventory( GetFirstPC() ); while( GetIsObjectValid( oDestroy ) ) { if( GetTag( oDestroy ) == "rancorblood" ) DestroyObject( oDestroy, 0.00, FALSE, 0.00 ); oDestroy = GetNextItemInInventory( GetFirstPC() ); object oItem=CreateItemOnObject( "rancorstim", GetFirstPC()); } } See the above script heres what its ment to do Take away the Item RancorBlood and give you 1 rancor stim But for some Unknown reason i Was Given 11 Stims not 1 What going on? Is it a Scripting Error? Help? ~Holty Link to comment Share on other sites More sharing options...
newbiemodder Posted May 14, 2010 Share Posted May 14, 2010 I'm not a scripting guru, but I think this line object oItem=CreateItemOnObject( "rancorstim", GetFirstPC()); should read object oItem=CreateItemOnObject( "rancorstim", GetFirstPC(),1,0); Link to comment Share on other sites More sharing options...
Istorian Posted May 15, 2010 Share Posted May 15, 2010 Well, I'm not a scripting guru, either, but, I think there is a certain logic problem here..This script checks the PC's inventory for every item that has the tag "rancorblood", and for each one it finds, it gives you 1 rancor stim. Thus, if you have 11 rancor blood in the inventory, the script destroys all of them, and you get 11 rancor stims in the inventory... Try this one, instead, where the command to create the "rancorstim" is out of the while loop: void main() { object oDestroy = GetFirstItemInInventory( GetFirstPC() ); while( GetIsObjectValid( oDestroy ) ) { if( GetTag( oDestroy ) == "rancorblood" ) DestroyObject( oDestroy, 0.00, FALSE, 0.00 ); oDestroy = GetNextItemInInventory( GetFirstPC() ); } object oItem=CreateItemOnObject( "rancorstim", GetFirstPC()); } Hope this helps! Link to comment Share on other sites More sharing options...
Holty1-5 Posted May 15, 2010 Author Share Posted May 15, 2010 Well Guys thanks for the Help, I'll try Newbiemodders, @Istorian I understand that Loop thing but the Odd bit was i only Had 1 of the Blood item and it gave me 11 stims talk about Bonus Link to comment Share on other sites More sharing options...
Darth333 Posted May 15, 2010 Share Posted May 15, 2010 Well Guys thanks for the Help, I'll try Newbiemodders, @Istorian I understand that Loop thing but the Odd bit was i only Had 1 of the Blood item and it gave me 11 stims talk about Bonus It depends on how the script is fired...the same happened to me when I first started modding kotor back in 2004 I don't recall this happening when running a script from a dlg file but it happens when opening containers and entering new areas. Add a variable to make sure the item is not already in the inventory or does not already exist (but I could be wrong as it's been a while since I've done any kotor modding). Link to comment Share on other sites More sharing options...
Holty1-5 Posted May 15, 2010 Author Share Posted May 15, 2010 Lol at The Pic xD When i did the Exchange Newbiemodder suggest i didnt get 11 stims I got 9 lol I'll keep playin around with it and see what happens Link to comment Share on other sites More sharing options...
logan23 Posted May 17, 2010 Share Posted May 17, 2010 Code: void main() { object oDestroy = GetFirstItemInInventory( GetFirstPC() ); while( GetIsObjectValid( oDestroy ) ) { if( GetTag( oDestroy ) == "rancorblood" ) DestroyObject( oDestroy, 0.00, FALSE, 0.00 ); oDestroy = GetNextItemInInventory( GetFirstPC() ); } object oItem=CreateItemOnObject( "rancorstim", GetFirstPC()); } Hope this helps! This helps with limiting the stim creation to 1. The only issue is if I have 2 boma blood items and then go through this script it only gives me one Stim. Is there a way to make it give the number of stim based on the number of bomablood items? Thanks Logan Link to comment Share on other sites More sharing options...
Istorian Posted May 17, 2010 Share Posted May 17, 2010 You mean you want to get as many stims as the number of boma blood items you have in the inventory? or in a different rate? (e.g. 1 stim for every 2 boma blood items) Link to comment Share on other sites More sharing options...
logan23 Posted May 17, 2010 Share Posted May 17, 2010 Trying to get 2 bomablood = 2 boma stims, ....and so on... basically the number of bomablood will equal the number of boma stims... Thanks Link to comment Share on other sites More sharing options...
Istorian Posted May 17, 2010 Share Posted May 17, 2010 Well, I think that this will give you the result you'd like! void main() { object oDestroy = GetFirstItemInInventory( GetFirstPC() ); while( GetIsObjectValid( oDestroy ) ) { if( GetTag( oDestroy ) == "[color=LimeGreen]YOUR_BOMABLOOD_TAG_HERE[/color]" ) DestroyObject( oDestroy, 0.00, FALSE, 0.00 ); oDestroy = GetNextItemInInventory( GetFirstPC() ); object oItem=CreateItemOnObject( "[color=LimeGreen]YOUR_STIM_TAG_HERE[/color]", GetFirstPC()); } } Hope this helps! Link to comment Share on other sites More sharing options...
logan23 Posted May 17, 2010 Share Posted May 17, 2010 I believe thats the same script that was originally shown in first post. If so it ends up cashing kotor2 ,as if its trying to give you unlimited items, Correct if im wrong about the two scripts. Im look at this on my cell so cant see whole page at once. Thanks Link to comment Share on other sites More sharing options...
Istorian Posted May 18, 2010 Share Posted May 18, 2010 Actually it is, but even though I'm not a scripting guru or something like that, as far as I'm concerned, it works. I also made a quick module and tested it, and it works fine in my game...If it crashes in yours let me know, and I'll see what I can do! Link to comment Share on other sites More sharing options...
logan23 Posted May 19, 2010 Share Posted May 19, 2010 I will do some testing with he script you have and place it in a new dlg file, and also try different .uti's to see the core of the freeze. Thanks Link to comment Share on other sites More sharing options...
logan23 Posted May 22, 2010 Share Posted May 22, 2010 Nope it crashes. I tested if it is the item , but it did not matter Now this is for kotor2. I do not know if this matters. Let me know if you have any other ideas. Edit: Never mind I found a way using a script that i found on the forums: int DestroyOneItem(object oItem) { if (GetIsObjectValid(oItem)) { int nStack = GetItemStackSize(oItem); if (nStack > 1) SetItemStackSize(oItem, nStack - 1); else DestroyObject(oItem); return TRUE; } return FALSE; } void main () { object oPC = GetFirstPC(); object oSaber = GetItemPossessedBy(oPC, "bomablood"); if (DestroyOneItem(oSaber)) return; //oSaber = GetItemPossessedBy(oPC, "g_w_lghtsbr01"); //if (DestroyOneItem(oSaber)) //return; } I then will just place a create a boma stim on the next dlg line to keep it clean. I just have to send the PC back to the beginning dlg line so that you can keep going over an over. Will later look at shrinking the script so you don't have to do one at a time but this will solve it and make if work. Thanks everyone!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.