Git Product home page Git Product logo

Comments (4)

llde avatar llde commented on August 11, 2024

What is the Loop Code?

from xobse.

Gaebrial avatar Gaebrial commented on August 11, 2024

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.

llde avatar llde commented on August 11, 2024

Hi @Gaebrial it's possible to have the complete mod to test?

from xobse.

llde avatar llde commented on August 11, 2024

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

@Gaebrial

from xobse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.