48 lines
874 B
Plaintext
48 lines
874 B
Plaintext
|
scn EBxReplaceFormListWithItem
|
||
|
|
||
|
; Arguments
|
||
|
ref rReplacer
|
||
|
ref rReplaceFormList
|
||
|
|
||
|
; Temp vars
|
||
|
ref rItem
|
||
|
int iCount
|
||
|
int iOutputAmount
|
||
|
int iRemainingItems
|
||
|
int i
|
||
|
|
||
|
begin Function { rReplacer, rReplaceFormList }
|
||
|
|
||
|
let iOutputAmount := GetMinOf (playerRef.GetItemCount Caps001) (playerRef.GetItemCount rReplaceFormList)
|
||
|
|
||
|
if iOutputAmount == 0
|
||
|
return
|
||
|
endif
|
||
|
|
||
|
if rReplacer == EBxBrahminMilk
|
||
|
let iOutputAmount := 1
|
||
|
endif
|
||
|
|
||
|
let iRemainingItems := iOutputAmount
|
||
|
|
||
|
while rItem := ListGetNthForm rReplaceFormList i
|
||
|
|
||
|
let iCount := playerRef.GetItemCount rItem
|
||
|
let iCount := GetMinOf iCount iRemainingItems
|
||
|
|
||
|
playerRef.RemoveItem rItem iCount 1
|
||
|
playerRef.RemoveItem Caps001 iCount 1
|
||
|
|
||
|
let iRemainingItems -= iCount
|
||
|
|
||
|
if iRemainingItems <= 0
|
||
|
break
|
||
|
endif
|
||
|
|
||
|
let i += 1
|
||
|
loop
|
||
|
|
||
|
playerRef.AddItem rReplacer iOutputAmount
|
||
|
|
||
|
end
|