Difference between revisions of "DropAllItems"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Scruggs
(looping version)
imported>Haama
(Fixed the bottom script)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
scn DropAllItemsQuestScript
Make a quest called DropAllItems, and attach this script to it
<pre>scn DropAllItemsQuestScript
   
   
short DropAllItems
short DropAllItems
ref ActorRef
ref ActorRef
ref CurObj
ref CurObj
short CurObjNum
short CurObjNum
float fquestdelaytime
float fquestdelaytime
   
   
   
   
begin GameMode
begin GameMode
set fquestdelaytime to 0.001
  set fquestdelaytime to 0.001
 
if ActorRef && DropAllItems == 1
  if DropAllItems
if ActorRef.GetNumItems > 0
    if ActorRef
set CurObj to ActorRef.GetInventoryObject (ActorRef.GetNumItems - 1)
      set CurObj to ActorRef.GetInventoryObject 0
set CurObjNum to ActorRef.GetItemCount CurObj
      if CurObj
ActorRef.Drop CurObj CurObjNum
        set CurObjNum to ActorRef.GetItemCount CurObj
ActorRef.RemoveItem CurObj CurObjNum
        ActorRef.Drop CurObj CurObjNum
endif
      else
if ActorRef.GetNumItems == 0
        set DropAllItems to 0
set DropAllItems to 0
      endif
endif
    endif
endif
  endif
end
end</pre>
Whenever you want an actor to drop all of their items, use these lines in the calling script
<pre>set DropAllItems.ActorRef to Actor
set DropAllItems.DropAllItems to 1</pre>


make this a quest script, attach it to a quest named DropAllItems. In your script
Note that using OBSE's loop functions may result in a crash. See [[:Category:OBSE_Flow_Control_Functions|this link]] for more information.


  scn MyScript
Also, dropping quest items from the player will probably be bad, so here's a more complex script to ensure that doesn't happen
<pre>scn DropAllItemsQuestScript
   
short DropAllItems
ref ActorRef
ref CurObj
short CurObjNum
float fquestdelaytime
short InvPosition
   
   
ref actor
   
   
begin onActivate
begin GameMode
set Actor to GetActionRef
  set fquestdelaytime to 0.001
messageBox "Good job dropping everything."
 
set DropAllItems.ActorRef to Actor
  if (DropAllItems == 1)
set DropAllItems.DropAllItems to 1
    set DropAllItems to 2
end
    set InvPosition to 0
 
   elseif (DropAllItems == 2)
Using OBSE's looping functions, you can speed things up a bit:
     if ActorRef
<pre>ref item
      set CurObj to (ActorRef.GetInventoryObject InvPosition)
short quant
      if CurObj
short numItems
        if (IsQuestItem CurObj == 0) || (ActorRef != player)
 
          set CurObjNum to (ActorRef.GetItemCount CurObj)
begin gameMode
          ActorRef.Drop CurObj CurObjNum
   if ( timeToDropItems )
        else
     set numItems to getNumItems
          set InvPosition to (InvPosition + 1)
    Label 10; start of loop
        endif
    if ( numItems )
       else
      set numItems to numItems - 1
        set DropAllItems to 0
      set item to getInventoryObject numItems
       endif
       set quant to getItemCount item
      drop item quant
       GoTo 10
     endif
     endif
   endif
   endif
end</pre>
end</pre>
[[Category: Useful Code]]

Latest revision as of 10:59, 7 March 2008

Make a quest called DropAllItems, and attach this script to it

scn DropAllItemsQuestScript
 
short DropAllItems
ref ActorRef
ref CurObj
short CurObjNum
float fquestdelaytime
 
 
begin GameMode
  set fquestdelaytime to 0.001
  
  if DropAllItems
    if ActorRef
      set CurObj to ActorRef.GetInventoryObject 0
      if CurObj
        set CurObjNum to ActorRef.GetItemCount CurObj
        ActorRef.Drop CurObj CurObjNum
      else
        set DropAllItems to 0
      endif
    endif
  endif
end

Whenever you want an actor to drop all of their items, use these lines in the calling script

set DropAllItems.ActorRef to Actor
set DropAllItems.DropAllItems to 1

Note that using OBSE's loop functions may result in a crash. See this link for more information.

Also, dropping quest items from the player will probably be bad, so here's a more complex script to ensure that doesn't happen

scn DropAllItemsQuestScript
 
short DropAllItems
ref ActorRef
ref CurObj
short CurObjNum
float fquestdelaytime
short InvPosition
 
 
begin GameMode
  set fquestdelaytime to 0.001
  
  if (DropAllItems == 1)
    set DropAllItems to 2
    set InvPosition to 0
  elseif (DropAllItems == 2)
    if ActorRef
      set CurObj to (ActorRef.GetInventoryObject InvPosition)
      if CurObj
        if (IsQuestItem CurObj == 0) || (ActorRef != player)
          set CurObjNum to (ActorRef.GetItemCount CurObj)
          ActorRef.Drop CurObj CurObjNum
        else
          set InvPosition to (InvPosition + 1)
        endif
      else
        set DropAllItems to 0
      endif
    endif
  endif
end