I''d like a container item, like a magic bag, to check when items are put into it. To my knowledge, this *should* be possible, but I'm not quite sure what's going on. Below is my test code that did not work.
void main()
{
object oPC=GetModuleItemAcquiredBy();
if(GetTag(oPC)=="TEST") SetNoticeText(GetFirstPC(), "RUNNING");
}
In the function comments, it says it can return an item...but since the above didn't work, I'm not quite sure what to make of it. Any help would be appreciated.
Any way to check when an item container receives an item?
Débuté par
Guest_Chaos Wielder_*
, août 28 2010 01:08
#1
Guest_Chaos Wielder_*
Posté 28 août 2010 - 01:08
Guest_Chaos Wielder_*
#2
Posté 28 août 2010 - 01:48
I think this function might help:
int iType = GetInventoryDisturbType()
With something like this to know when something goes in or out...
switch(iType)
{
case INVENTORY_DISTURB_TYPE_ADDED:
{
do stuff..
break;
}
case INVENTORY_DISTURB_TYPE_REMOVED:
{
Do....
break;
}
That would go in Inventory Disturbed...
int iType = GetInventoryDisturbType()
With something like this to know when something goes in or out...
switch(iType)
{
case INVENTORY_DISTURB_TYPE_ADDED:
{
do stuff..
break;
}
case INVENTORY_DISTURB_TYPE_REMOVED:
{
Do....
break;
}
That would go in Inventory Disturbed...
Modifié par Morbane, 28 août 2010 - 01:50 .
#3
Guest_Chaos Wielder_*
Posté 28 août 2010 - 02:40
Guest_Chaos Wielder_*
I should have been more specific. This script is to check when/if an item is added to to a Bag/Container in the inventory of the PC character. As such, there is not an 'Inventory Disturbed' script to run. The module wide acquire script works for the PC, but it does not seem to check when the item the PC has is modified.
#4
Posté 30 août 2010 - 09:59
I don't think an on acquire script for a PC is going to fire unless something is added to his/her inventory in some way. Moving something already in his/her inventory into a container isn't going to fire anything. What you would need to do is add the script Morbane provided to the On Inventory Disturbed event of the containers. If you are using custom items then you could just update their blueprints. Otherwise you could set the On Inventory Disturbed script when container objects are acquired by your PC in the Acquired script.
#5
Posté 31 août 2010 - 10:20
I believe what the OP is trying to accomplish is with a container in the characters inventory, not an exterior container...
Which I believe cannot be done since Items (including inventory container items) dont have any direct way to have scripts attached to events that happen to the item specifically. Although only going from personal experience on that and could be well wrong.
I was doing something similar with special containers that would gain a certain skill bonus depending on items stuck inside them, such as with a bag of theives tools, each special theives tool placed inside would add a factor to a running total that would be worked into a skill bonus the tool bag would give.
The way i did it was to alter the Itemprop 2da so that inventory containers could take skill bonuses and have a 'cast spell' options (containers by defualt have no properties besides reduction of weight).
I then gave the bag a unique unlimited per day power that basicly ran through the contents of the bag, worked out the new skill bonus and reapplied the new skill bonus to it as an itemproperty, which the bag gave the player as a 'in repository' effect. The draw back is the player has to manually update the bag.
I dont think the OP can do it the way they want to as in automaticly... pitty inventory items cant have scripts, if they did (ie onaquire, onunaquire, onequip etc) we could do all sorts of neat things with out having to do tagbased scripting, missed oppertunity from Obsidian.
Which I believe cannot be done since Items (including inventory container items) dont have any direct way to have scripts attached to events that happen to the item specifically. Although only going from personal experience on that and could be well wrong.
I was doing something similar with special containers that would gain a certain skill bonus depending on items stuck inside them, such as with a bag of theives tools, each special theives tool placed inside would add a factor to a running total that would be worked into a skill bonus the tool bag would give.
The way i did it was to alter the Itemprop 2da so that inventory containers could take skill bonuses and have a 'cast spell' options (containers by defualt have no properties besides reduction of weight).
I then gave the bag a unique unlimited per day power that basicly ran through the contents of the bag, worked out the new skill bonus and reapplied the new skill bonus to it as an itemproperty, which the bag gave the player as a 'in repository' effect. The draw back is the player has to manually update the bag.
I dont think the OP can do it the way they want to as in automaticly... pitty inventory items cant have scripts, if they did (ie onaquire, onunaquire, onequip etc) we could do all sorts of neat things with out having to do tagbased scripting, missed oppertunity from Obsidian.
Modifié par BigfootNZ, 31 août 2010 - 10:32 .
#6
Guest_Chaos Wielder_*
Posté 01 septembre 2010 - 02:03
Guest_Chaos Wielder_*
Thanks Bigfoot--it never even occurred to me to edit the Itemprop 2da. 
That seems to be a good suggestion, and I'll look into it for sure.
That seems to be a good suggestion, and I'll look into it for sure.
#7
Posté 01 septembre 2010 - 01:37
For scripting you need to work with the on inventory disturbed event of the container.
But if the container is an item inside the player inventory I'am not sure you can have a script directly linked to it. But you got local VAR. Maybe with the VAR in parameter it's possible to do what you want.
But if the container is an item inside the player inventory I'am not sure you can have a script directly linked to it. But you got local VAR. Maybe with the VAR in parameter it's possible to do what you want.
#8
Posté 01 septembre 2010 - 10:56
Shallina wrote...
But if the container is an item inside the player inventory I'am not sure you can have a script directly linked to it.
This with tatar sauce. A real oversight and missed oppertunity in my opnion.
Not sure if my 2da idea will work for the OP since im not sure what the OP was trying to accomplish with checking what was stuck inside a bag, so manually do it through teh player might not be what they want.
Just had a thought, why not set it up so that on an OnInventoryDisturbed event for the character it checks to see if they have said 'bag' and if so do a quick check to see whats been stuck in or pulled out and execute some script accordingly. Since I think moving an item from the main inventory space into a bag creates a inventory disturbed event to fire?
not sure how you'd do this for a player controlled character since each character state ie controlled uncontrolled has a seperate set of scripts attached to it (theres a 2da that defines them all) so you'd have to find the script names for the 'under player control' AI scripts and add it into them as well.
The 2da is the NWN2_Scriptsets.2da and the script you'd want i think is gb_comp_distrb.nss
Not sure how they work or if editing them would work im assuming thats the script that gets fired on inventorydistrub events for a player controled character, or the actual players main character.
Modifié par BigfootNZ, 01 septembre 2010 - 11:01 .
#9
Posté 02 septembre 2010 - 01:49
The container it self has on OnItemAcquired or somethign similar. I know I have worked with container specific scripts that fire when an item is placed into them, so that is what you have to do, I will edit this post in a minute will look at the actual scripts you'll need to make.
Ok it is the OnDistrub script that you need to write and use the following functions to determine distrub item and type:
object oItem = GetInventoryDisturbItem();
//INVENTORY_DISTURB_TYPE_ADDED = 0;
//INVENTORY_DISTURB_TYPE_REMOVED = 1;
int iAction = GetInventoryDisturbType();
Ok it is the OnDistrub script that you need to write and use the following functions to determine distrub item and type:
object oItem = GetInventoryDisturbItem();
//INVENTORY_DISTURB_TYPE_ADDED = 0;
//INVENTORY_DISTURB_TYPE_REMOVED = 1;
int iAction = GetInventoryDisturbType();
Modifié par dethia, 02 septembre 2010 - 01:51 .





Retour en haut






