Jump to content

Scripting Help


MimiTheAlchemist

Recommended Posts

Ever since I created my give gifts mod, I have been looking for a way

to make NPCs equip clothes, weapons, and shields that the player

has given them. I'm pretty close to figuring it out, but I still have one

question? How do you use a variable returned by a function in another

script.

 

Here are the two scripts.

 

script on player alias:

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)

(GetOwningQuest() As pgiscript).GetPlayerDialogueTarget()
if pgi.getvalueint() == 1 
     if ggclotheslist.HasForm(akBaseItem)
       kPlayerDialogueTarget.setoutfit(nooutfit)
       kPlayerDialogueTarget.equipitem(akBaseItem)
     elseif ggwpnlist.HasForm(akBaseItem) ||
     ggshieldlist.Hasform(akBaseItem)
kPlayerDialogueTarget.equipitem(akBaseItem)
       else 
pgi.setvalue(0)
endif
endif
pgi.setvalue(0)
endEvent
pgi is a global that determines if the player is giving a gift.
nooutfit is an empty outfit.
quest script (pgiscript)
Actor Function GetPlayerDialogueTarget()
Actor kPlayerDialogueTarget
Actor kPlayerRef = Game.GetPlayer()
Int iLoopCount = 10
While iLoopCount > 0
iLoopCount -= 1
kPlayerDialogueTarget = 

Game.FindRandomActorFromRef(kPlayerRef , 200.0)
If kPlayerDialogueTarget != kPlayerRef && 
kPlayerDialogueTarget.IsInDialogueWithPlayer()

Return kPlayerDialogueTarget
EndIf
EndWhile
        Return None
EndFunction

How do I take the variable kPlayerDialogueTarget from

this function and use it in my player alias script? I've

been googling for the past two days and am at a loss.

Any help would be appreciated. :smile:

Edited by MimiTheAlchemist
Link to comment
Share on other sites

I think this would work for your player alias script

 

  Reveal hidden contents

 

I noticed that the function was returning an actor value, so assigning it to an actor variable made sense. For simplicity sake I used the variable name that you were trying to use from the function but it could have been any name.

 

As a side note, I should state that the akDestContainer from the OnItemRemoved event would have yielded the actor that was receiving the items. Which means that if the pgi global variable is set to 1 when the player chooses to give an item then the function could be unnecessary. See the following:

 

  Reveal hidden contents

 

Or if you wish to be extra safe, you can cross check the destination container with the function result as in the following:

 

  Reveal hidden contents

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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