Difference between revisions of "DropAllItems"
Jump to navigation
Jump to search
imported>Haama (Added warning about using OBSE's loops) |
imported>Haama (Cleared some things up) |
||
Line 1: | Line 1: | ||
Make a quest called DropAllItems, and attach this script to it | |||
<pre>scn DropAllItemsQuestScript | |||
short DropAllItems | |||
ref ActorRef | |||
ref CurObj | |||
short CurObjNum | |||
float fquestdelaytime | |||
begin GameMode | |||
set fquestdelaytime to 0.001 | |||
if DropAllItems | |||
if ActorRef | |||
if ActorRef.GetNumItems > 0 | |||
set CurObj to ActorRef.GetInventoryObject (ActorRef.GetNumItems - 1) | |||
set CurObjNum to ActorRef.GetItemCount CurObj | |||
ActorRef.Drop CurObj CurObjNum | |||
ActorRef.RemoveItem CurObj CurObjNum | |||
else | |||
set DropAllItems to 0 | |||
endif | |||
endif | |||
endif | |||
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> | |||
Note that using OBSE's loop functions may result in a crash. See [[:Category:OBSE_Flow_Control_Functions|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 | |||
<pre>scn DropAllItemsQuestScript | |||
short DropAllItems | |||
ref ActorRef | |||
ref CurObj | |||
short CurObjNum | |||
float fquestdelaytime | |||
short InvPosition | |||
begin | |||
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 | |||
ActorRef.RemoveItem CurObj CurObjNum | |||
endif | |||
set InvPosition to (InvPosition + 1) | |||
else | |||
set DropAllItems to 0 | |||
endif | |||
endif | |||
endif | |||
end</pre> |
Revision as of 04:02, 4 July 2007
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 if ActorRef.GetNumItems > 0 set CurObj to ActorRef.GetInventoryObject (ActorRef.GetNumItems - 1) set CurObjNum to ActorRef.GetItemCount CurObj ActorRef.Drop CurObj CurObjNum ActorRef.RemoveItem 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 ActorRef.RemoveItem CurObj CurObjNum endif set InvPosition to (InvPosition + 1) else set DropAllItems to 0 endif endif endif end