MimiTheAlchemist Posted April 23, 2014 Share Posted April 23, 2014 (edited) Ever since I created my give gifts mod, I have been looking for a wayto make NPCs equip clothes, weapons, and shields that the playerhas given them. I'm pretty close to figuring it out, but I still have onequestion? How do you use a variable returned by a function in anotherscript. 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 EndFunctionHow do I take the variable kPlayerDialogueTarget fromthis function and use it in my player alias script? I'vebeen googling for the past two days and am at a loss.Any help would be appreciated. :smile: Edited April 23, 2014 by MimiTheAlchemist Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 23, 2014 Share Posted April 23, 2014 I think this would work for your player alias script Reveal hidden contents Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) Actor kPlayerDialogueTarget =(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.setvalueint(0) endif endif pgi.setvalueint(0) endEvent 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 Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) if (pgi.getvalueint() == 1) && (akDestContainer as Actor) if ggclotheslist.HasForm(akBaseItem) (akDestContainer as Actor).setoutfit(nooutfit) (akDestContainer as Actor).equipitem(akBaseItem) elseif ggwpnlist.HasForm(akBaseItem) || ggshieldlist.Hasform(akBaseItem) (akDestContainer as Actor).equipitem(akBaseItem) else pgi.setvalueint(0) endif endif pgi.setvalueint(0) endEvent 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 Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) Actor kPlayerDialogueTarget =(GetOwningQuest() As pgiscript).GetPlayerDialogueTarget() If ((akDestContainer as Actor) == kPlayerDialogueTarget) && (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.setvalueint(0) endif endif pgi.setvalueint(0) endEvent Link to comment Share on other sites More sharing options...
MimiTheAlchemist Posted April 23, 2014 Author Share Posted April 23, 2014 Wow! I never thought of using akDestContainer as an actor. That really simplifies things.Thank you so much for your help. :) I will have to try it out. Link to comment Share on other sites More sharing options...
Recommended Posts