Difference between revisions of "Talk:DuplicateAllItems"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Haama
imported>Haama
Line 11: Line 11:
:At the very, very least, I'm certain that items don't lose their script (those, as with any new item, the variables start off at 0)
:At the very, very least, I'm certain that items don't lose their script (those, as with any new item, the variables start off at 0)
:--[[User:Haama|Haama]] 00:04, 10 July 2007 (EDT)
:--[[User:Haama|Haama]] 00:04, 10 July 2007 (EDT)
:Here's the test script. It adds a key with a script on it to the player, the uses DuplicateAllItems to a persistent remote container, scans through the player's inventory and removes each of those items from the remote container, and then opens the container. When opened, the container would still have a copy of the key in it (meaning it was a different FormID), and when you took the key it's OnAdd block would fire (meaning it still had a script, and since the variables on the original were set when first added to the player, it also meant the variables of the duped item were at 0). This happened for other items with scripts on them as well.
<pre>scn aaaTestScript
;Results - health/charge/etc. doesn't seem to matter
;  However, scripted items won't have the same ID
;    Also, scripted items seem to keep their script, at least when moved to the player
;    Also, the ID for scripted objects changes each time, so whenever you duplicate you get an extra item that counts towards GetNumItems
short InvPosition
ref pInvObj
short InvObjAmount
short NumItems
begin GameMode
  player.AddItem MQ07BasementKey 1
  player.DuplicateAllItems aaaTestCont
  set InvPosition to (player.GetNumItems - 1)
  Label 1
  if (InvPosition >= 0)
    set pInvObj to (player.GetInventoryObject InvPosition)
    if (aaaTestCont.GetItemCount pInvObj)
      set InvObjAmount to (aaaTestCont.GetItemCount pInvObj)
      aaaTestCont.RemoveItem pInvObj InvObjAmount
    endif
    set InvPosition to (InvPosition - 1)
  Goto 1
  endif
set NumItems to aaaTestCont.GetNumItems
message "aaaTestCont has %.0f items", NumItems
aaaTestCont.Activate player
  StopQuest aaaTest
end</pre>
:--[[User:Haama|Haama]] 00:15, 10 July 2007 (EDT)

Revision as of 23:15, 9 July 2007

The duplicate will have a new FormID, meaning if (Original == New) will never be true

    * More importantly, meaning if any script referenced the original the duplicate
 will not work. For instance if (player.GetItemCount AmuletOfKings) will never be true
 if the player has the duplicate. 

Really? That's...weird. Are we sure about this? Scruggs 23:56, 9 July 2007 (EDT)

Try it, and yes I'm very sure... many objects were broken upon this discovery... well, ideas were broken, and a request for DuplicateAllItems2 was made
Hmm... let me see if I can find the test file, though
--Haama 00:02, 10 July 2007 (EDT)
At the very, very least, I'm certain that items don't lose their script (those, as with any new item, the variables start off at 0)
--Haama 00:04, 10 July 2007 (EDT)
Here's the test script. It adds a key with a script on it to the player, the uses DuplicateAllItems to a persistent remote container, scans through the player's inventory and removes each of those items from the remote container, and then opens the container. When opened, the container would still have a copy of the key in it (meaning it was a different FormID), and when you took the key it's OnAdd block would fire (meaning it still had a script, and since the variables on the original were set when first added to the player, it also meant the variables of the duped item were at 0). This happened for other items with scripts on them as well.
scn aaaTestScript

;Results - health/charge/etc. doesn't seem to matter
;  However, scripted items won't have the same ID
;    Also, scripted items seem to keep their script, at least when moved to the player
;    Also, the ID for scripted objects changes each time, so whenever you duplicate you get an extra item that counts towards GetNumItems

short InvPosition
ref pInvObj
short InvObjAmount

short NumItems

begin GameMode
  player.AddItem MQ07BasementKey 1
  player.DuplicateAllItems aaaTestCont
  set InvPosition to (player.GetNumItems - 1)
  Label 1
  if (InvPosition >= 0)
    set pInvObj to (player.GetInventoryObject InvPosition)
    if (aaaTestCont.GetItemCount pInvObj)
      set InvObjAmount to (aaaTestCont.GetItemCount pInvObj)
      aaaTestCont.RemoveItem pInvObj InvObjAmount
    endif
    set InvPosition to (InvPosition - 1)
   Goto 1
  endif
set NumItems to aaaTestCont.GetNumItems
message "aaaTestCont has %.0f items", NumItems
aaaTestCont.Activate player
  StopQuest aaaTest
end
--Haama 00:15, 10 July 2007 (EDT)