Jump to content

Help with Reference Alias scripting


Recommended Posts

What I'm trying to do is that whenever the player adds something to his inventory (picking items up from the world, buying from vendors etc.) a script checks if he gets over encumbered. If so he should drop random items from his inventory until he falls under his maximum carry weight again (like he's losing stuff because he can't hold or balance it any more).
I've studied the Creation Kit Wiki and the forums here for the past days and figured that a reference alias script was probably the way to go. I set something up, but as this is the first time I'm trying something like this I don't REALLY know what I'm doing. The mod doesn't do anything in game, maybe someone here can tell from the screenshots what I've done wrong (if the error lies within the script or with the way I set up the quest) and give me some step-by-step advice. Thanks!

 

 

 

And the code again:

 

---------------------------------------------------------------------------------------

Scriptname Overencumbrance extends ReferenceAlias

Actor Property PlayerRef Auto

Event OnInit()
AddInventoryEventFilter(none)
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
While (PlayerRef.IsOverEncumbered())
PlayerRef.DropFirstObject()
EndWhile
EndEvent

---------------------------------------------------------------------------------------

 

Link to comment
Share on other sites

This idea is funny, so I took a look.

I tested it, it works, but I made it a compeletly different way.

 

 

I made a new quest:

 

In Quest Data:

ID TheDropQuest

Priority 3 (not sure but it works)

Event Player Add Item

Allow repeated stages checked (nothing else check, no quest alias)

 

In Quest Stages

Create a new stage:

Index 0 Run on Start checked

 

Papyrus Fragment:

Create one new quest property:

TheDropQuest

(don't add the player, Game.GetPlayer() works without property)

 

If Game.GetPlayer().isoverencumbered()
Game.GetPlayer().DropFirstObject()
endif
TheDropQuest.SetStage(10)
Then create another stage:
Index 10
Papyrus Fragment:
If Game.GetPlayer().isoverencumbered()
TheDropQuest.SetStage(0)
else
TheDropQuest.Stop()
endif
That way the script will return until the player isn't over encumbered anymore, once this done, the quest will stop.
Then you need to add your quest to the SM Event Node
Section Player Add Item
Open the window, right clic on stacked event Node: Player AddItem on the top of the list.
Hit New Branch Node
Give it the ID TheDropQuestBranchNode
Then right clic On that new branch node you just created
Hit New Quest Node
Give it the ID TheDropQuestNode
Then right clic On that quest node you just created
Hit Add Quest
Add your quest, No condition are needed.
That's all.

 

 

Edited by GePalladium
Link to comment
Share on other sites

Hey Palladium, thanks for your help! I followed your guide and it really works. BUT I found out that after reinstalling the game, Creation Kit and the Script Extender my version suddenly worked too. I must have messed up my installation somehow. So I'll playtest both mods to see if one is causing any issues. Anyway, your help's much appreciated, you've done this in a way I would have never considered, and I think I've learned a thing or two by following you along.

 

One last thing that bugs me a bit though is that 'DropFirstObject()' doesn't really randomly drop items. As described in the Wiki:

 

'The definition of "first" is up to the code, and so this basically drops a random object. However it does it in such a manner that, if called multiple times, is likely to repeatedly drop the same kind of object until that object's stack is exhausted before moving onto the "next" stack.'

Link to comment
Share on other sites

Yeah, I'm not surprise, while testing, I noticed I was only dropping objects stack by stack, first food then junk. I was actually happy to notice weapons and amors were not in the first stack.

This mod is a weird idea. I wonder what you'll do with it. I'll wait for the surprise.

 

I'm happy your quest worked. There is always 10 different ways to do the same thing.

I learnt it's better to avoid (when it's possible) the quests that are running all the time. The story manager is great for that: It starts the quest only when needed. That's a new feature in the CK.

Edited by GePalladium
Link to comment
Share on other sites

Well, it's intended just as a small mod altering the way carry weight is handled. Unfortunately when I tested it my character always threw away weapons and armor first. I have no problem with weapons slipping out of my hand (that seems somewhat logical when you have to balance a lot of stuff), but me standing there in my underwear just because I picked up an aluminium can could be seen as slightly unimmersive :-) So if I can't resolve this in some way I don't know if I'll persue this further. Maybe I'll have to come back to it when I know my way around scripting and the Creation Kit a bit better.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...