Jump to content

Please help me get this simple script working


irswat

Recommended Posts

  • Replies 135
  • Created
  • Last Reply

Top Posters In This Topic

what about using a reference alias, will that in any way help?

nevermind: I'll give calling as a form first.

one other question. I want to use event OnItemAdded in a quest script. Am I able to do something like:

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference playerRef)

to make the player the targeted container?

Edited by irswat
Link to comment
Share on other sites

what about using a reference alias, will that in any way help?

 

nevermind: I'll give calling as a form first.

 

one other question. I want to use event OnItemAdded in a quest script. Am I able to do something like:

 

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference playerRef)

to make the player the targeted container?

No. If you want something to happen when the item is added to the player's inventory, you would need to add your code to the player's OnItemAdded event. The best way to do that would be to create a referencealias that you assign to the player when you want to track the item added, then add a script to the referencealias that Extends ReferenceAlias that has an Event OnItemAdded with your code in there. I would recommend putting in some if statements to only action on the items you care about.

 

Then when you are done tracking, you can remove the reference alias.

 

After reading through some of the discussion from yesterday, I recommend adding a Player reference alias to your quest that adds the two events there.

Link to comment
Share on other sites

I'm going to try forcing the persistent flag on placeatme and then calling equipitemex with the objectreference as a form. I hope this works because I have no other tricks.

edit: did not work. trying GetBaseObject, but expecting it to give me an untempered fang blade. Maybe not with persistence.

edit: setting the persistent flag on placeatme to true, and using GetBaseObject worked.

Edited by irswat
Link to comment
Share on other sites

This is my first time messing with reference aliases so bear with me:

I create the reference alias, made references reserved, and set unique character to player.
I created a script which is attached to the referencealias, and I added the dawnfang and duskfang blade forms to the list of items.

The problem is that I want to call the questscript from the reference alias sript that is attached to it and call RegisterForSingleUpdate(1).

this is the reference alias script. If you can't tell I have no idea how to do this properly, so any suggestions would be helpful. I'm just looking to update the quest script when the item is first picked up from a table in sky haven temple.

Scriptname FangBladeRefAliasScript extends ReferenceAlias  

DawnDuskTimerScript Property DDT Auto 

Weapon property adventurerdawnfang auto
Weapon property tsasciduskblade auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	if !akSourceContainer
		AddInventoryEventFilter(adventurerdawnfang)
		AddInventoryEventFilter(tsasciduskblade)
		DDT.UpdateFangQuest(1)
	endif	
endEVENT



this is the function in quest script DawnDuskTimerScript that I'm trying to call.

Function UpdateFangQuest(int TimeUntilRefresh)
	RegisterForSingleUpdate(TimeUntilRefresh)
ENDFunction
Edited by irswat
Link to comment
Share on other sites

Well that script is totally wrong. Its the improper use of AddInventoryEventFilter. You use that in the OnInit() event to tell the script that only the passed in item can be recognized so that you are not doing unnecessary processing with a crap ton of other items.

 

This is probably more of what you are looking for:

Scriptname FangBladeRefAliasScript extends ReferenceAlias  

DawnDuskTimerScript Property DDT Auto 
Weapon Property adventurerdawnfang Auto
Weapon Property tsasciduskblade Auto
Bool FirstPickup = false

Event OnInit()
    AddInventoryEventFilter(adventurerdawnfang) 
    AddInventoryEventFilter(tsasciduskblade)
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If FirstPickup == false && !akSourceContainer   ;picked up for the first time from the world space i.e. not from a container or npc
        FirstPickup = true
        DDT.UpdateFangQuest(1)
    endif   
endEVENT

Note the use of the bool. On the outside chance that the weapon should be dropped (or removed with a disarm shout) and the player pick it up again the bool prevents it from running again.

Link to comment
Share on other sites

I added some neat functionality and fixed some bugs. tempered level is stored in a global variable and restored. tempered weapon automatically reequips to the proper hand after tempering. last thing to do is add a 7th blade level which is the upgraded version of dawnfang.

Link to comment
Share on other sites

FormLists can be worked with in either direction. backwards is the least amount of writing

 

Backwards:

Int index = SomeList.GetSize() - 1
While index >= 0
  ;do stuff
  index -= 1
EndWhile

Forwards:

Int size = SomeList.GetSize()
Int index = 0
While Index < size
  ;do stuff
  index += 1
EndWhile
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...