Kexikus

Block "Item Lost/Received" message

Recommended Posts

I'm working on a script that swaps a hidden item on a partymember. So what I'm doing is basically this (sItem is a string with the item's tag):

object oOldItem = GetItemInSlot(INVENTORY_SLOT_CARMOUR, OBJECT_SELF);  
object oNewItem = CreateItemOnObject(sItem, OBJECT_SELF);

if (GetIsObjectValid(oOldItem)) {
  DestroyObject(oOldItem);
}
DelayCommand(0.2, ActionEquipItem(oNewItem, INVENTORY_SLOT_CARMOUR, TRUE));

And that's working perfectly fine. However, when I run this script in a dialog, I always get the pop-up message that I lost and gained an item. I'd very much prefer it this message did not appear as these Creature Hide items are a hidden game mechanic that the player shouldn't be informed about. Is there any way to do that?

 

Edit: Oh, and a second question: Are there switch-cases possible in KotOR / TSL or do I have to use if-else statements all the time?

Share this post


Link to post
Share on other sites

For your second question:

void main(){
    int nParam = GetScriptParameter(1);
    switch(nParam){
        case 0:
        {
            //Do stuff when called with dialog parameter 1 == 0
        }
        break;
        case 1:
        {
            //Do stuff when called with dialog parameter 1 == 1
        }
        break;
        default:
        {
            //Default case
        }
        break;
    }
}

This is basically how all my dialog scripts look in TSL.

 

A very important note: you can leave out the {braces} between case and break; as long as there are no variable definitions in there. But if there are, the compiler does not give any warning and will compile the script, but you will get all kinds of problems in the game that make absolutely no sense and you can waste a lot of time figuring out what's wrong if you don't know about this. So especially in kotor scripting, it is a very good practice to always write the braces. break; can be left out to allow falling through to the next case, just like in C++.

 

As for your first question, no idea, sorry. I hope there is a way – it sounds pretty useful! :D

Edited by bead-v

Share this post


Link to post
Share on other sites

Thank you for your replies.

 

It looks like they did not block this message in a_swapimplant.nss but instead used a completely different method by adding the effects directly to Canderous. The problem here is that ClearAllEffects() will clear these effects which makes the entire thing pretty pointless.

Share this post


Link to post
Share on other sites

Have you tried emulating commented out code from a_swapimplant.nss?

 

Changing this:

object oNewItem = CreateItemOnObject(sItem, OBJECT_SELF);

To this:

object oNewItem = CreateItemOnObject(sItem, OBJECT_SELF, 1, TRUE);
  • Like 1

Share this post


Link to post
Share on other sites

No, I didn't... And now I feel like an idiot. I didn't check the commented out part at all but that was indeed the solution. Thank you very much :)

 

So to answer my original question:

At least in TSL you can add "TRUE" as an additional argument to both CreateItemOnObject() and DestroyObject() and it won't show the "Item received/lost" message.

  • Like 1

Share this post


Link to post
Share on other sites

 

Have you tried emulating commented out code from a_swapimplant.nss?

 

 

 

Changing this:

object oNewItem = CreateItemOnObject(sItem, OBJECT_SELF);

To this:

object oNewItem = CreateItemOnObject(sItem, OBJECT_SELF, 1, TRUE);

 

Is this the same as Kotor 1?

 

 

No, I didn't... And now I feel like an idiot. I didn't check the commented out part at all but that was indeed the solution. Thank you very much :D

 

I thought it was strange that p_mandalore.utc has a hide item already placed in his items. I thought the script applies the bonuses twice when I first read a_swapimplant.nss

Share this post


Link to post
Share on other sites

Is this the same as Kotor 1?

 

I don't think so or they would have used it for the HK upgrades. The documentation in K1's nwsscript.nss has no information on that either. The latter is also true for TSL but that's probably due to Obsidian not updating the documentation properly when updating the function.
  • Like 1

Share this post


Link to post
Share on other sites

I don't think so or they would have used it for the HK upgrades. The documentation in K1's nwsscript.nss has no information on that either. The latter is also true for TSL but that's probably due to Obsidian not updating the documentation properly when updating the function.

 

Ah that's fair play. 

Share this post


Link to post
Share on other sites

The new functionality of the CreateItemOnObject and DestroyObject functions are advancements made by Obsidian and won't work in K1. The CreateItemOnObject function has an optional bHideMessage argument at the very end that defaults to 0 (FALSE). This argument will hide the popup.

 

The DestroyObject function has the optional bHideFeedback argument, which I would assume prevents the entry from being posted to the Feedback screen.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.