Jump to content

Mod conversion script not working


KaylaKaze

Recommended Posts

I'm trying to convert my Merchant Contract mod from Oldrim to SE but it's not working. The contract shows up where it should, but when the script runs, Int Gold = Game.GetPlayer().GetItemCount(Gold001) always equals 0 (I have gold). When I skip the gold check out and try to summon the NPC, it doesn't work either. It calls the Summon function, but no summon happens. I used coc to go to TestTony (where the NPC starts) and she's there hanging out so it seems to be a script problem entirely. Any ideas?

 

Full code:

Scriptname SummonedBuyerContract extends ObjectReference  

Actor Property SummonedBuyerActor  Auto  
Message Property SummonedBuyerMSG  Auto  
Book Property SummonBuyerContractBook  Auto  
MiscObject Property Gold001  Auto  


Event OnEquipped(Actor player)
	Int Response = -1
	Bool ExitMenu = False
	Int Gold = Game.GetPlayer().GetItemCount(Gold001)
	While !ExitMenu
		Response = SummonedBuyerMSG.Show()
		If Response == 0
			If Gold < 1000
				Debug.MessageBox("You don't have enough gold.")
				ExitMenu=True
			Else
				Game.DisablePlayerControls(false, false, false, false, false, true, false)
				utility.wait(0.1)
				Game.EnablePlayerControls(false, false, false, false, false, true, false)
				Summon(Game.GetPlayer(),SummonedBuyerActor)
				Game.GetPlayer().RemoveItem(Gold001,1000)
				ExitMenu = True
			EndIf
		Else
			ExitMenu = True
		EndIf
	EndWhile
	;SummonedBuyerActor.MoveTo(Game.GetPlayer(),120 * Math.Sin(Game.GetPlayer().GetAngleZ()), 120 * Math.Cos(Game.GetPlayer().GetAngleZ()),0, false)
EndEvent

Function Summon(ObjectReference akSummoner = None, ObjectReference akSummon = None, Float afDistance = 150.0, Float afZOffset = 0.0, ObjectReference arPortal = None, Int aiStage = 0)
        While aiStage < 6
                aiStage += 1
                If aiStage == 1 ; Shroud summon with portal
                        arPortal = akSummon.PlaceAtMe(Game.GetForm(0x0007CD55)) ; SummonTargetFXActivator disables and deletes itself
                ElseIf aiStage == 2 ; Disable Summon
                        akSummon.Disable()
                ElseIf aiStage == 3 ; Move portal in front of summoner
                        arPortal.MoveTo(akSummoner, Math.Sin(akSummoner.GetAngleZ()) * afDistance, Math.Cos(akSummoner.GetAngleZ()) * afDistance, afZOffset)
                ElseIf aiStage == 4 ; Move summon to portal
                        akSummon.MoveTo(arPortal)
			    akSummon.SetAngle(0.0,0.0,akSummoner.GetAngleZ()+180.0)
                ElseIf aiStage == 5 ; Enable summon as the portal dissipates
                        akSummon.Enable()
                EndIf
                Utility.Wait(0.6)
        EndWhile
EndFunction
Link to comment
Share on other sites

I think you have two choices.

 

 

MiscObject kGold = Game.GetFormFromFile(0x0000000F, "Skyrim.ESM") as MiscObject
Int Gold = Game.GetPlayer().GetItemCount(kGold)

 

or

 

Game.GetPlayer().GetGoldAmount()

 

Reason for the first code is that GetItemCount seems to be buggy with properties, and in theory that should get around it.

Link to comment
Share on other sites

Try

Actor Property PlayerREF Auto ; For Property value

Int Gold = (PlayerREF as ObjectReference).GetItemCount(Gold001) ; Adjusted coded




It should Auto Fill too but remember to click Properties, then, Auto Fill else it won't fill automatically

 

PS Replace all Game.GetPlayer() with PlayerREF too

Link to comment
Share on other sites

I'll try to help, but I don't think I've ever used that summon function before. So, some simple questions first.

Actor Property SummonedBuyerActor Auto 
Message Property SummonedBuyerMSG Auto 
Book Property SummonBuyerContractBook Auto 
MiscObject Property Gold001 Auto 

Are these properties filled?

            If Gold < 1000
                Debug.MessageBox("You don't have enough gold.")
                ExitMenu=True

Does this message actually show when you equip the contract without enough gold?

EDIT: Everyone's beating me to it, lol

Edited by Fantafaust
Link to comment
Share on other sites

Try

Actor Property PlayerREF Auto ; For Property value

Int Gold = (PlayerREF as ObjectReference).GetItemCount(Gold001) ; Adjusted coded




It should Auto Fill too but remember to click Properties, then, Auto Fill else it won't fill automatically

 

PS Replace all Game.GetPlayer() with PlayerREF too

 

Nope. That doesn't do it.

Link to comment
Share on other sites

I think you have two choices.

MiscObject kGold = Game.GetFormFromFile(0x0000000F, "Skyrim.ESM") as MiscObject
Int Gold = Game.GetPlayer().GetItemCount(kGold)

or

Game.GetPlayer().GetGoldAmount()

Reason for the first code is that GetItemCount seems to be buggy with properties, and in theory that should get around it.

 

The GetGold works, but it seems that none of the properties being loaded are working, so the SummonedBuyerMSG never comes up, and I'm guessing the summon doesn't work because it's not loading SummonedBuyerActor.

Link to comment
Share on other sites

I think you have two choices.

MiscObject kGold = Game.GetFormFromFile(0x0000000F, "Skyrim.ESM") as MiscObject
Int Gold = Game.GetPlayer().GetItemCount(kGold)

or

Game.GetPlayer().GetGoldAmount()

Reason for the first code is that GetItemCount seems to be buggy with properties, and in theory that should get around it.

 

Thanks for the help. It pointed me in the right direction. Turns out the properties hadn't linked properly when I loaded and I had to relink them. THEN I had to revert back to a save from before I loaded the mod in the first place because the broken links seem to have been part of the save. All working now. Thanks.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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