Darkkender Posted November 29, 2004 Share Posted November 29, 2004 Ok new question. would I use a script similiar to the give/take gold command to have items removed from an inventory slot. example would be when your in the sandpeople enclave and they take away the sandpeople robes the item gets taken right out of your inventory slot. I realize it's a disguise however unlike the spacesuit and underwater pressuresuit you actually have to put the disguise on. Now I'm assuming it makes a call to the specific spot on your body where clothes are at I'm also curious what the other body part numbers are so items can have a scripted removal from there as well? Link to comment Share on other sites More sharing options...
Darth333 Posted November 29, 2004 Share Posted November 29, 2004 I splitted the thread. When starting a new subject, please make a different thread, otherwise it gets too messy. Now, I am not sure of what you want to do. Do you want to remove a disguise effect, simply unequip a npc or also remove the item from inventory? Here is a script to simply unequip a NPC. void main () { object oNPC = GetObjectByTag("my_npc"); object oArmor = GetItemInSlot(INVENTORY_SLOT_BODY,oNPC); AssignCommand(oNPC, ActionUnequipItem(oArmor, TRUE)); } Other body slots: int INVENTORY_SLOT_HEAD = 0; int INVENTORY_SLOT_BODY = 1; int INVENTORY_SLOT_HANDS = 3; int INVENTORY_SLOT_RIGHTWEAPON = 4; int INVENTORY_SLOT_LEFTWEAPON = 5; int INVENTORY_SLOT_LEFTARM = 7; int INVENTORY_SLOT_RIGHTARM = 8; int INVENTORY_SLOT_IMPLANT = 9; int INVENTORY_SLOT_BELT = 10; int INVENTORY_SLOT_CWEAPON_L = 14; int INVENTORY_SLOT_CWEAPON_R = 15; int INVENTORY_SLOT_CWEAPON_B = 16; int INVENTORY_SLOT_CARMOUR = 17; To remove a disguise effect, you woulf use the followin: RemoveEffect(object oCreature, effect eEffect); and finally to remove from inventory, check the script I posted in this thread: http://www.lucasforums.com/showthread.php?s=&threadid=129600 (thread is about regeneration but the script can be used for any item) Link to comment Share on other sites More sharing options...
tk102 Posted November 29, 2004 Share Posted November 29, 2004 Ssomething like this: void main () { object oPC=GetFirstPC(); object oNPC=GetObjectByTag("npc_tag"); object oItem=GetItemInSlot(nSlot, oPC); if (GetTag(oItem)=="certaintag") { // one of the following AssignCommand(oNPC,ActionTakeItem(oItem,oPC)); // or AssignCommand(oPC,ActionUnequipItem(oItem)); //or DestroyObject(oItem); } } Link to comment Share on other sites More sharing options...
Darkkender Posted November 29, 2004 Author Share Posted November 29, 2004 thanks this is going to come in handy. what i'm going to do is insert this into the add remove character scripts so that custom equipment or upgraded equipment is not lost when my recruit characters fill there space. the reason is because the utc's are not saving the game data for this same as for the levelup process. I've actually been thinking about adding a script to attach to trigger points to counteract some glitches that I don't like. but on topic here in the GetItemInSlot command can I replace INVENTORY_SLOT_BODY with the number you provided for the integers Darth333? Link to comment Share on other sites More sharing options...
Darkkender Posted November 29, 2004 Author Share Posted November 29, 2004 Originally posted by tk102 Ssomething like this: void main () { oPC=GetFirstPC(); oNPC=GetObjectByTag("npc_tag"); object oItem=GetItemInSlot(nSlot, oPC); if (GetTag(oItem)=="certaintag") { // one of the following AssignCommand(oNPC,ActionTakeItem(oItem,oPC)); // or AssignCommand(oPC,ActionUnequipItem(oItem)); //or DestroyObject(oItem); } } Ok I tried Darth333's script sample above and so far it hasn't worked now I noticed there is a diiference in the variables of the ActionUnequipItem command darth's has a TRUE statement after the object while tk's only has the object. Now the scripts are compiling just not working in game. I have tried it both with the slot number's in the object scripts and the full INVENTORY_SLOT_BODY type of entry with neither yeilding results. Also Tk I noticed you use a oPC definition at the beginning wouldn't that only be needed for centering on my PC and effecting it? and one last question do you need to use the if command that you provided or is that just there as a alternate option when running the script? Link to comment Share on other sites More sharing options...
tk102 Posted November 29, 2004 Share Posted November 29, 2004 ...ActionUnequipItem command darth's has a TRUE statement ... Take a look at the nwscript.nss file. You'll see: // 33: Unequip oItem from whatever slot it is currently in. void ActionUnequipItem( object oItem, int bInstant = FALSE ); That's the definition of the function -- Darth333 passed a TRUE value to bInstant while I let it default to FALSE. It isn't documented whether it has any effect or not and I've used it successfully with FALSE. Also Tk I noticed you use a oPC definition at the beginning wouldn't that only be needed for centering on my PC and effecting it? and one last question do you need to use the if command that you provided or is that just there as a alternate option when running the script? I wasn't sure how you were going to use the script. I tossed the oPC and oNPC in for clarity and shorthand. The if statement is used to evaluate whether the item you're about to unequip is the item you're expecting. Again, I didn't know how you were going to use the script. And you should only use one of the statements that follow the if statement. My script assumed the PC would have the item equipped and that you would either a) take the item from PC and give it to the NPC, b) unequip the item from the PC or c) Destroy the item. (Not sure the DestroyObject will work on an inventory item.) Link to comment Share on other sites More sharing options...
Darkkender Posted November 29, 2004 Author Share Posted November 29, 2004 okay a couple more questions have formed I'm assuming I still need to use the object command before oPC and oNPC correct? now the oItem I would still need to replace Item with whatever word i choose like armor for body slot, gauntlet for hands etc. correct? As to clarity of what I'm trying to do. When I activate my Replace original NPC with new recruit script I am trying to take all of the equipment off of the original NPC and return it to inventory instead of it disappearing completly and never being available again. This would be useful for anybody developing a custom recruit as it allows you to keep what you sometimes have saved up for to buy. Especially if you recruit somebody new that can use that equipment and you have that NPC destroyed before you get a chance to unequip them. Thanks for all the help insofar Link to comment Share on other sites More sharing options...
tk102 Posted November 30, 2004 Share Posted November 30, 2004 I am trying to take all of the equipment off of the original NPC and return it to inventory instead of it disappearing completly and never being available again. I believe this script will serve the purpose void UnEquip(object oNPC,int nSlot) { //subroutine to unequip each item object oItem=GetItemInSlot(nSlot,oNPC); if (GetIsObjectValid(oItem)) { AssignCommand(oNPC,ActionUnequipItem(oItem)); } return; } void main () { // replace "npc_tag" with whatever object oNPC=GetObjectByTag("npc_tag"); UnEquip(oNPC,INVENTORY_SLOT_HEAD); UnEquip(oNPC,INVENTORY_SLOT_BODY); UnEquip(oNPC,INVENTORY_SLOT_HANDS); UnEquip(oNPC,INVENTORY_SLOT_RIGHTWEAPON); UnEquip(oNPC,INVENTORY_SLOT_LEFTWEAPON); UnEquip(oNPC,INVENTORY_SLOT_LEFTARM); UnEquip(oNPC,INVENTORY_SLOT_RIGHTARM); UnEquip(oNPC,INVENTORY_SLOT_IMPLANT); UnEquip(oNPC,INVENTORY_SLOT_BELT); // these are not necessary // UnEquip(oNPC,INVENTORY_SLOT_CWEAPON_L); // UnEquip(oNPC,INVENTORY_SLOT_CWEAPON_R); // UnEquip(oNPC,INVENTORY_SLOT_CWEAPON_B); // UnEquip(oNPC,INVENTORY_SLOT_CARMOUR); return; } I'm assuming I still need to use the object command before oPC and oNPC correct?Yes. object is a declaration of a variable of type object. It is needed. (And yes I've edited my scripts to include it.) Link to comment Share on other sites More sharing options...
Darkkender Posted November 30, 2004 Author Share Posted November 30, 2004 Ok I have implemented your latest version above and it compiles fine just like always but it still does not seem to work here is the script maybe you can tell me what I'm missing or need to change in order to get it to work. [size=1] void UnEquip(object oNPC,int nSlot) { //subroutine to unequip each item object oItem=GetItemInSlot(nSlot,oNPC); if (GetIsObjectValid(oItem)) { AssignCommand(oNPC,ActionUnequipItem(oItem)); } return; } void main () { // replace "npc_tag" with whatever object oNPC=GetObjectByTag("Bastila"); string sTemplate = "darkkendera"; UnEquip(oNPC,INVENTORY_SLOT_HEAD); UnEquip(oNPC,INVENTORY_SLOT_BODY); UnEquip(oNPC,INVENTORY_SLOT_HANDS); UnEquip(oNPC,INVENTORY_SLOT_RIGHTWEAPON); UnEquip(oNPC,INVENTORY_SLOT_LEFTWEAPON); UnEquip(oNPC,INVENTORY_SLOT_LEFTARM); UnEquip(oNPC,INVENTORY_SLOT_RIGHTARM); UnEquip(oNPC,INVENTORY_SLOT_IMPLANT); UnEquip(oNPC,INVENTORY_SLOT_BELT); RemovePartyMember(0); RemoveAvailableNPC(0); DestroyObject(oNPC); AddAvailableNPCByTemplate(0, sTemplate); return; } [/size] At this point I'm sure I have something wrong I just can't see it. *edit* removed superfulous code. Link to comment Share on other sites More sharing options...
tk102 Posted December 1, 2004 Share Posted December 1, 2004 Ok I have implemented your latest version above and it compiles fine just like always but it still does not seem to work here is the script maybe you can tell me what I'm missing or need to change in order to get it to work. Hmm.. works for me... I did this [size=1]void UnEquip(object oNPC,int nSlot) { //subroutine to unequip each item object oItem=GetItemInSlot(nSlot,oNPC); if (GetIsObjectValid(oItem)) { AssignCommand(oNPC,ActionUnequipItem(oItem)); } return; } void main () { // replace "npc_tag" with whatever object oNPC=GetObjectByTag("Carth"); string sTemplate = "c_dewback"; //what the hell... UnEquip(oNPC,INVENTORY_SLOT_HEAD); UnEquip(oNPC,INVENTORY_SLOT_BODY); UnEquip(oNPC,INVENTORY_SLOT_HANDS); UnEquip(oNPC,INVENTORY_SLOT_RIGHTWEAPON); UnEquip(oNPC,INVENTORY_SLOT_LEFTWEAPON); UnEquip(oNPC,INVENTORY_SLOT_LEFTARM); UnEquip(oNPC,INVENTORY_SLOT_RIGHTARM); UnEquip(oNPC,INVENTORY_SLOT_IMPLANT); UnEquip(oNPC,INVENTORY_SLOT_BELT); RemoveFromParty(oNPC); // I like this function more RemoveAvailableNPC(2); //2 for Carth DestroyObject(oNPC); AddAvailableNPCByTemplate(2, sTemplate); return; }[/size] Link to comment Share on other sites More sharing options...
Darkkender Posted December 2, 2004 Author Share Posted December 2, 2004 [size=1]void UnEquip(object oNPC,int nSlot) { //subroutine to unequip each item object oItem=GetItemInSlot(nSlot,oNPC); if (GetIsObjectValid(oItem)) { AssignCommand(oNPC,ActionUnequipItem(oItem)); ActionTakeItem(oItem, oNPC);//this is all i needed for a resolution } return; } void main () { // replace "npc_tag" with whatever object oNPC=GetObjectByTag("Carth"); UnEquip(oNPC,INVENTORY_SLOT_HEAD); UnEquip(oNPC,INVENTORY_SLOT_BODY); UnEquip(oNPC,INVENTORY_SLOT_HANDS); UnEquip(oNPC,INVENTORY_SLOT_RIGHTWEAPON); UnEquip(oNPC,INVENTORY_SLOT_LEFTWEAPON); UnEquip(oNPC,INVENTORY_SLOT_LEFTARM); UnEquip(oNPC,INVENTORY_SLOT_RIGHTARM); UnEquip(oNPC,INVENTORY_SLOT_IMPLANT); UnEquip(oNPC,INVENTORY_SLOT_BELT); return; }[/size] Ok Here is what I ended up doing above. I found since I was launching the script from a dialogue as one big package that was where my problem was at, since there seems to be a built in delay for the unequip function above. So I actually set my dialogue up as having this launched before my add/remove script gets launched and I added that ActionTakeItem command in the UnEquip function and it worked like I was hoping. I'll try this as a combined script for the heck of it but I just figured I'd pass on my solution. Link to comment Share on other sites More sharing options...
Xavier2 Posted December 5, 2004 Share Posted December 5, 2004 I have this script: void main () { object oPC=GetFirstPC(); object oItem=GetItemInSlot(nSlot, oPC); if (GetTag(oItem)=="plot_item") { // one of the following AssignCommand(oPC,ActionUnequipItem(oItem)); } What should be the nSlot if we are talking about a non usable item? Link to comment Share on other sites More sharing options...
Darkkender Posted December 5, 2004 Author Share Posted December 5, 2004 Originally posted by Xavier2 I have this script: What should be the nSlot if we are talking about a non usable item? If an item is non-useable then the script you have would not apply to the nSlot factor because it would not be equipped on the body. You would just want to use the ActionTakeItem command. Link to comment Share on other sites More sharing options...
tk102 Posted December 5, 2004 Share Posted December 5, 2004 And refer to Darth333's last post in this thread as she describes how Bioware scripted checks for possessed, but not equipped, items. Link to comment Share on other sites More sharing options...
Xavier2 Posted December 5, 2004 Share Posted December 5, 2004 Ok. I used this code: void main () { object oPC=GetFirstPC(); object oItem=GetObjectByTag("plot_item");{ AssignCommand(oPC,ActionUnequipItem(oItem)); } } It is compiling ok, but it is not working. What am i doing wrong? Link to comment Share on other sites More sharing options...
Darth333 Posted December 5, 2004 Share Posted December 5, 2004 You have to specify in what slot you want to equip the item. Check my first post in this thread to get the possible slots. Link to comment Share on other sites More sharing options...
Xavier2 Posted December 5, 2004 Share Posted December 5, 2004 Originally posted by Darth333 You have to specify in what slot you want to equip the item. Check my first post in this thread to get the possible slots. I don't want to equip. I want to unequip. And since it is a plot item none of the list in your post is a valid slot for plot items (at least i think so:D ). This script was just my poor attempt to build a script based in the functions mentioned above... Any other ideas? Link to comment Share on other sites More sharing options...
tk102 Posted December 5, 2004 Share Posted December 5, 2004 Xavier2 said: What should be the nSlot if we are talking about a non usable item? to which Darkkender replied If an item is non-useable then the script you have would not apply to the nSlot factor because it would not be equipped on the body. You would just want to use the ActionTakeItem command. So what DK is saying is that if an item isn't usable, that is non-equippable, then you don't use the ActionUnequipItem function-- use the ActionTakeItem function which doesn't use a slot. Link to comment Share on other sites More sharing options...
Xavier2 Posted December 5, 2004 Share Posted December 5, 2004 Originally posted by tk102 Xavier2 said: to which Darkkender replied So what DK is saying is that if an item isn't usable, that is non-equippable, then you don't use the ActionUnequipItem function-- use the ActionTakeItem function which doesn't use a slot. Oh my! Now i see...Thanks tk102 and sorry for my Link to comment Share on other sites More sharing options...
Darth333 Posted December 5, 2004 Share Posted December 5, 2004 Oops, I was actually on something else and I totally misread your request Well you got your answer Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.