Comments (4)
What is the Loop Code?
from xobse.
Here's the inventory processing part of the script. I've omitted some setup lines and additional code after the loop, which aren't relevant for the loop itself.
For corpses, the script is called with rActor being the actor and sType being either -1 or -2.
The idea is that it saves the player having to inspect and loot every corpse.
The token NCCorpse is used to indicate that the accompanying quest script should highlight the corpse to tell the player to manually inspect it (because of quest items or scripted items that would otherwise be removed). And the reference to the tail slot item is because they seem to be treated differently.
scn NCProcessInventory
ref rActor
short sType
ref rItem
ref rBase
int iIndex
short sNum
short sSlot
short sGold
float fGold
float fMult
short sMerc
ref rTail
begin function { rActor sType }
SetFunctionValue 0
if 0 == IsFormValid rActor
return
elseif rActor.GetIsReference Player
return
endif
Let sMerc := Player.GetActorValue Mercantile
Let fMult := (150.0 + (sMerc * 2.0)) / 500.0
Let sGold := 0
Let rTail := 0
Let rItem := 0
ForEach rItem <- rActor
Let sNum := rItem.GetRefCount
Let sSlot := GetEquipmentSlot rItem
Let rBase := rItem.GetBaseObject
Let iIndex := GetSourceModIndex rBase
Let fGold := 1.0 * GetFullGoldValue rItem * sNum
PrintD $rActor + " has " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + "). Item is type " + $(rItem.GetObjectType) + " with slot " + $sSlot + " valued at " + $fGold + "."
if rItem.IsPlayable2 == 0
continue
elseif rItem.IsQuestItem
rActor.Call NCSetItemCount NCCorpse 1
elseif sSlot == 15
Let rTail := rBase
PrintD $rActor + " found tail item: " + $rItem + " (" + GetFormIDString rBase + ")."
elseif sSlot == 14
if GetFullGoldValue rItem > 0 && sType == -1
rActor.Call NCSetItemCount NCCorpse 1
else
PrintD $rActor + " did not surrender " + $sNum + "x " + $rItem + "."
endif
elseif rItem.GetObjectType == 39
if sType == -1
rActor.Call NCSetItemCount NCCorpse 1
else
PrintD $rActor + " did not surrender " + $sNum + "x " + $rItem + "."
endif
elseif rItem.GetBaseObject == Gold001
continue
elseif GetFullGoldValue rItem == 0 && GetWeight rItem == 0
PrintD $rActor + " did not surrender " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
elseif sSlot == 6 || sSlot == 7 || sSlot == 8
if sType != 0
PrintD $rActor + " surrendered " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
rItem.RemoveMeIR NCChestRef
else
PrintD $rActor + " did not surrender " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
endif
elseif (sSlot == 13 || sSlot == 16 || sSlot == 17) && sType >= 0
PrintD $rActor + " did not surrender " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
elseif GetEnchantment rItem
if sType != 0
PrintD $rActor + " surrendered " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
rItem.RemoveMeIR NCChestRef
else
PrintD $rActor + " did not surrender " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
endif
elseif (sSlot == 13 || sSlot == 16 || sSlot == 17) ; Processing a corpse
if rItem.IsScripted && sType == -1
rActor.Call NCSetItemCount NCCorpse 1
else
if fGold < 1.0
Let fGold := 1.0
else
Let fGold *= fMult
endif
PrintD $rActor + " sold " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ") for " + $fGold + "g."
Let sGold += Ceil fGold
rItem.RemoveMeIR
endif
elseif rItem.GetObjectType == 20
if rItem.IsScripted && sType == -1
rActor.Call NCSetItemCount NCCorpse 1
elseif NCQuest.iSellItems == 1 || sType < 0
if fGold < 1.0
Let fGold := 1.0
else
Let fGold *= fMult
endif
PrintD $rActor + " sold " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ") for " + $fGold + "g."
Let sGold += Ceil fGold
rItem.RemoveMeIR
elseif sType != 0
PrintD $rActor + " surrendered " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
rItem.RemoveMeIR NCChestRef
else
PrintD $rActor + " did not surrender " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
endif
elseif rItem.GetObjectType == 22
if rItem.IsScripted && sType == -1
rActor.Call NCSetItemCount NCCorpse 1
elseif NCQuest.iSellItems == 1 || sType < 0
if fGold < 1.0
Let fGold := 1.0
else
Let fGold *= fMult
endif
PrintD $rActor + " sold " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ") for " + $fGold + "g."
Let sGold += Ceil fGold
rItem.RemoveMeIR
elseif sType != 0
PrintD $rActor + " surrendered " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
rItem.RemoveMeIR NCChestRef
else
PrintD $rActor + " did not surrender " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
endif
elseif rItem.GetObjectType == 38 || rItem.GetObjectType == 42
if sType != 0
PrintD $rActor + " surrendered " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
NCChestRef.AddItemNS rBase sNum
rItem.RemoveMeIR
else
PrintD $rActor + " did not surrender " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
endif
else
if sType < 0
PrintD $rActor + " surrendered " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
NCChestRef.AddItemNS rBase sNum
rItem.RemoveMeIR
else
PrintD $rActor + " did not surrender " + $sNum + "x " + $rItem + " (" + GetFormIDString rBase + ")."
endif
endif
loop
if sGold > 0
rActor.AddItemNS Gold001 sGold
PrintD $rActor + "'s equipment yielded " + $sGold + " gold."
endif
SetFunctionValue 1
end
from xobse.
Hi @Gaebrial it's possible to have the complete mod to test?
from xobse.
I can only partially experience this. What I get is that there are double items, when the items come from the Base Container (and not the reference container)
OBjects that are fully present only in the reference container appears only once, without differences between equippable and non equippable objects
from xobse.
Related Issues (20)
- No event being dispatched on hit with hand to hand to "OnHitWith" event handler
- "OnDeath" event only triggers after about 2 seconds after death actually occurs in game
- OnHitWith event doesn't triggers on hitting dead bodies HOT 2
- Enhancement proposal: add functions for retrieving an amount of running EffectShaders and stopping particular amount of EffectShaders
- v22.7 Causes Crash with Feature in Maskar's Oblivion Overhaul HOT 2
- Get value from stringMap by variable HOT 14
- GetTileChildren and GetTileTraits can't utilize variables HOT 4
- Latest version breaks mod organizer 2 HOT 1
- message saying "The latest Oblivion Script Extender is not detected. morroblivion requires the latest version of xOBS€ to run, Please exit the game now and check your installation" I am using xOBSE 22.7.
- OnControlEvent returns wrong "action" when triggered by mouse buttons HOT 3
- C2 Special Combat Moves HOT 5
- Input Functions Not Working with TES4JaPatch016_beta3 HOT 10
- Apparel items do not return their icon path.
- Dynamic mesh swap mods have issues HOT 1
- Why do unvoiced npcs say "How can I help you?" and how to get rid of that? HOT 1
- Some issues regarding PushActorAway
- Rewrite and Streamline the User Function manager
- Per-Script InvenotryReferences
- GetAlchMenuApparatus doesn't work as documented HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xobse.