Selling to store infinite goods
#1
Posté 26 juillet 2010 - 03:08
Anyone know?
#2
Posté 26 juillet 2010 - 03:37
Add onAquire a int to every item the pc gets. Call it PCITEM int 1.
Then everything that is sold to a store, when a store closes it destroys any item that has a PCITEM int 1 on it. We do it via on Area exit script though so after the third time the store is open by a player it clears all the itmes and remakes the store.
Would that be something that would help or did I miss the whole set up of the question and am way off base?
#3
Posté 26 juillet 2010 - 04:06
If you try to sell item that is already in store and has infinite flag, this item is immediately destroyed. Thats why I cant increase count of this item in store. The same behaviour has DestroyObject, but I can control DestroyObject and set integer on Item before I will destroy it, so in theory my UnAcquire script would look like
But thats only in theory, Im asking if anyone knows what else could destroy item, so my script would not work correctly.object oItem = GetModuleItemLost();
if(!GetIsObjectValid(oItem))
{
if(!GetLocalInt(oItem,"DestroyObject"))
{
//now this should happen only when PC sell item to store
object oPC = GetModuleItemLostBy();
object oStore = GetLocalObject(oPC,"OPENED_STORE");
if(oStore != OBJECT_INVALID)
{
string sResRef = GetLocalString(oItem,"GetResRef");
ExecuteScript("sh_store_bought",OBJECT_SELF);
}
}
}
}
Modifié par ShaDoOoW, 26 juillet 2010 - 04:12 .
#4
Posté 26 juillet 2010 - 04:46
#5
Posté 26 juillet 2010 - 05:15
Once DestroyObject() has destroyed an item, _all_ info about that item are permanently lost.
Local variables too are gone. And you can not perform any query of any type on the destroyed item.
The one thing that remains is the former OID of the object.
So, at best you can tell that the item was destroyed by DestroyObject() because the OnUnAcquireItem event will fire. You receive a valid-looking OID, but the function GetIsObjectValid() shall return FALSE for it. And that is how you can tell that the object unacquired was destroyed by DestroyObject().
If you want to keep track of an object destroyed by DestroyObject(), you have only 1 option.
You must keep a list of all objects you are interested into. And when you unacquire something, and you determine that it was destroyed by DestroyObject(), you compare the OID of the object against the OIDs you have saved in your list.
And that is how you can tell exactly what was just destroyed.
I know it looks ugly...
-fox
#6
Posté 26 juillet 2010 - 05:18
stores dont have this event, also Im not certain I want to workaround the selling via placeable/creature inventory. Also you can open via script only inventory of familiar and henchman.Genisys wrote...
Can Disturbed Inventory Work?
#7
Posté 26 juillet 2010 - 05:22
Ah shame... guess i will use another way to do it then.the.gray.fox wrote...
Local variables too are gone.
#8
Posté 26 juillet 2010 - 09:15
When My computer crashed awhile back I was messing with making a player store system. Lost most of my code and have not gotten back into it full strength yet. Never had any infinite items in them, so am not cretin as to the problems you are running into.
the.gray.fox wrote...
Once DestroyObject() has destroyed an item, _all_ info about that item are permanently lost.
Yes once an object is destroyed it can not be accessed. How ever the DestroyObject is a delayed command. So the object should not be destroyed until after the current script finishes, Even at a delay of 0.0f. If it is somehow getting destroyed with the 0.0f delay just increase the delay a little to make sure it sticks around until you are done with it.
There is no need to check for an open store. If the store is receiving an item and the OnUnquire Event is running some has to have it open. unless of course you are moving items to the store from a storage creature via ActionCommands.
When I did my player store test runs i was using a test against the tag of the store. Like this.
object oItem = GetModuleItemAcquired();
if (GetTag(GetModuleItemAcquiredFrom())=="PS_STORE_001")
SendMessageToPC(GetFirstPC(),"Received Item From Player Store");
It would be just as easy to hook all items Taken by the store this way.
object oItem = GetModuleItemAcquired();
if (GetObjectType(GetModuleItemAcquiredFrom())==OBJECT_TYPE_STORE)
SendMessageToPC(GetFirstPC(),"Received Item From a Store");
For Items sold to the store with a tag check I used:
object oItem = GetModuleItemLost();
if (GetTag(GetItemPossessor( oItem ))== "PS_STORE_001")
SendMessageToPC(GetFirstPC(),"Sold Item To Player Store");
Again for a hook of all stores just as easy.(lol, I may say easy but it took me a long time to work it out.
object oItem = GetModuleItemLost();
if ( GetObjectType(GetItemPossessor( oItem ))== OBJECT_TYPE_STORE)
SendMessageToPC(GetFirstPC(),"Sold Item To a Store");
If you wanted to have infinite Items in the store without having the inifinite flag set you could just recreate them if they where bought from the store.
In short if you wanted infinite items without having to set the Flag you could just add the item back into the store if it was ever bought. (keep in mind however that stackable items also have a mind of there own. If they get stacked with other items of there type they talk on the vars of the item they where stacked with. and lose there own. I also do not know if the Event even fires if a new stack is not created on the PC). So for inifinite nonstackable items.
object oItem = GetModuleItemAcquired();
object oStore= GetModuleItemAcquiredFrom();
if (GetObjectType(oStore)==OBJECT_TYPE_STORE)
{
if (GetLocalInt(oItem,"inifinite"))
{
object oNewItem=CopyItem(oItem,oStore,TRUE);
DeleteLocalInt(oItem,"inifinite");
}
}
Modifié par Lightfoot8, 26 juillet 2010 - 09:24 .
#9
Posté 26 juillet 2010 - 10:13
It did came into my mind, but I thought that it will not work correctly because when you buy it other items aroun this item will make tetris (lol i dont know how to describe it, not so good in english), but nope its not visible, so player wont recognize that and that exactly what I want. So thanks, I got the scripting already, just find out the GetModuleItemLost is invalid so it didnt worked.Lightfoot8 wrote...
If you wanted to have infinite Items in the store without having the
inifinite flag set you could just recreate them if they where bought
from the store.
#10
Posté 26 juillet 2010 - 10:23
In OnAquire:
void main()
{
//Declare Variables
object oPC=GetModuleItemAcquiredBy();
object oItem=GetModuleItemAcquired();
object oStore=GetModuleItemAcquiredFrom();
if (GetObjectType(oStore)==OBJECT_TYPE_STORE)
{
//Spawn object that was sold into store's inventory.
CopyItem(oItem,oStore);
}
}
I'm sure there's a way to do it without disabling infinite stocks but it'll probably be a headache.





Retour en haut







