Author Topic: Gold Taken by Placeables Without an Inventory  (Read 338 times)

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Gold Taken by Placeables Without an Inventory
« on: November 21, 2010, 06:04:10 pm »


               After quite a bit of testing, I have encountered a dilemna I'm wondering if anyone can help me with -

It appears that whenever a placeable is given the useable flag or if it is created 'on the fly' via a script (even just creating it via script as a static, no-inventory placeable), whenever a PC tries to drop gold on it, it actually takes it and destroys the gold. This does not happen for any items dropped on it though - only gold (I supposed because players can click exactly where they want to drop the gold...?).

This is not a huge problem for useable placeables because players can be told not to drop gold directly on them. However, for placeables that are static and unclickable with no useable options which are spawned in via script, this becomes a bigger problem. We are primarily seeing this in our player houses where the greater portion of a player's house may be covered with rugs and carpets that get spawned in 'on the fly' via script. Then, if a PC decides to drop gold on a portion of the floor covered by the rug, they get forced to the center of the rug/carpet and the never actually do the bending over animation and drop the gold, but they lose it nonetheless.

It does appear this is an engine problem since I've been able to recreate this in multiple modules, but are there any scripted solutions to getting around this? And does anyone know why (for the love of god!) static placeables spawned via script cause this behavior as well??? If you instead place a static carpet placeable via the toolset you can drop gold on it with no problem in-game...
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Gold Taken by Placeables Without an Inventory
« Reply #1 on: November 22, 2010, 11:47:53 am »


               Hello.

Use the OnUnAcquireItem module event.
If you want actual code, you have to wait that I can access my scripts -- later.
For now I will go from memory...

When a PC unacquires something... Check the Base Item Type of it.
If it is BASE_ITEM_GOLD... check the current possesor of the unacquired item (use the GetItemPossessor() function).

If the possessor is a placeable _and_ has no inventory... you know you have a problem of phantom GP.
You fix it like this:
1) get the stack size of the pile of GP dropped.
2) destroy the GP item immediately (it exists in memory, but has no physical counterpart to interact with -- it is a "zombie" nobody will ever be able to pick up)
3) Give back to the player the GP amount from point (1).

Solved.

-fox
               
               

               


                     Modifié par the.gray.fox, 22 novembre 2010 - 12:06 .
                     
                  


            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Gold Taken by Placeables Without an Inventory
« Reply #2 on: November 24, 2010, 04:46:47 am »


               Thnks for the reply fox. You were right - the following code fixed the problem as a workaround to the issue at any rate (it just drops the gold at the feet of the PC as if they had really dropped it on the floor). But I still wish I knew why this behavior exists in the first place and if there is any way to avoid it.
Regardless though, thanks for the help.

object oItem = GetModuleItemLost();
object oItemPossessor = GetItemPossessor(oItem);
if (GetObjectType(oItemPossessor) == OBJECT_TYPE_PLACEABLE && !GetHasInventory(oItemPossessor))
{
CopyObject(oItem, GetLocation(GetModuleItemLostBy()));
DestroyObject(oItem, 0.1); //Just to make sure the item/gold doesn't get dupped somehow
}
               
               

               


                     Modifié par Thayan, 24 novembre 2010 - 04:48 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Gold Taken by Placeables Without an Inventory
« Reply #3 on: November 24, 2010, 05:22:35 am »


               Gold is unique in the fact that it is not an item when it is on your character(it is just a number in the structure of the character).  When the player drops the gold it is changed into an item with its own blueprint.

The reason your static placeables react differant when they are created in the toolset vs by script has a simple answer.  Area's are a combination of three differant files.  Two of the files can not be changed by scripting.  One file holds nothing but comments placed on items in the toolset.  The other holds all the static objects (Tiles,  static placables, terrain features,, ect.) . niether one of thies two files can be reched by scripting or are ever changed durning game play.  The third file however hold all instances of objects that can be interacted with.  It is also the only file that the game changes durning game play.  So when you create a placeable in the game via a script, even if you mark it static, it is placed in the file with the instances. Allowing scripts to still reach and modify it.  The case you are stating about them taking your items when placed on the objects sounds like a bug within the engine.  Your script posted above is most likely the only way to handle it outside of engine haks.
               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Gold Taken by Placeables Without an Inventory
« Reply #4 on: November 24, 2010, 08:01:06 pm »


               Thank you for the detailed explanation Lightfoot. That definitely helps me understand it better and realize the workaround is probably the only viable option for me since we don't use haks.



Thanks for the replies!
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Gold Taken by Placeables Without an Inventory
« Reply #5 on: November 27, 2010, 03:32:06 pm »


               edit: nevermind
               
               

               


                     Modifié par the.gray.fox, 27 novembre 2010 - 03:51 .