Jump to content

Global Variable is not counting


antstubell

Recommended Posts

Hi all.

Scenario - Picked up a quest to catch 3 special salmon. First off I made a global variable (float) called SalmonCount.

I used a script on the special salmon that I had used before as a weapon collect counter, thanks to gasti89 for this...

 

GlobalVariable property WeaponCount auto

 

Quest property myQuest auto

 

Int property preReqStage auto

 

Int property StageToSet auto

 

Auto State Ready

 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

if myQuest.GetStage() == preReqStage

if akNewContainer == Game.GetPlayer()

WeaponCount.Mod(1)

Debug.MessageBox("You've found a special salmon")

if WeaponCount.GetValue() == 3

myQuest.SetStage(StageToSet)

endif

GoToState("Picked")

endif

endif

EndEvent

 

EndState

 

State Picked

EndState

 

This worked perfectly when taking objects from containers but I am catching fish in an open world. Basically when I catch a fish I get no popup and the Global Variable stays at 0.00.

Can anybody help me please?

Edited by antstubell
Link to comment
Share on other sites

You should use OnActivate() instead of OnContainerChange in this case, and attach the OnActivate to your Salmon Activator then advance the global variable with each activation of this salmon.

 

like this:

 

 

ScriptName SalmonPickup extends ObjectReference

GlobalVariable property SalmonCount auto

Quest property myQuest auto

Int property preReqStage auto

Int property StageToSet auto

Auto State Ready

Event OnActivate(ObjectReference akActivator)
if myQuest.GetStage() == preReqStage
	if akActivator == Game.GetPlayer()
		SalmonCount.Mod(1)
		Debug.MessageBox("You've found a special salmon")
			if SalmonCount.GetValue() == 3
				myQuest.SetStage(StageToSet)
			endif
				GoToState("Picked")
	endif
endif
EndEvent

EndState

State Picked
EndState 

Link to comment
Share on other sites

Thanks. Works perfectly. I am in need of furthur help if you would be so kind. Now that the player has the 3 salmon SetStage is 30 and objective is "Give salmon to XXXX" (the NPC), when the player presents the salmon how can they recieve a reward say 200 gold, a piece of enchanted jewellery, etc instead of just the dialouge "Thanks."?
Link to comment
Share on other sites

Make the "thanks" dialogue set one more stage.

 

Then in the fragment for that stage add a new property. Could be MiscObject or Armor or whatever depending on what you want as the reward.

 

Then in the fragment write:

 

Game.GetPlayer().Additem(x, y)

 

Where x is your added property name, and y is the amount to add.

Link to comment
Share on other sites

Make the "thanks" dialogue set one more stage.

 

Then in the fragment for that stage add a new property. Could be MiscObject or Armor or whatever depending on what you want as the reward.

 

Then in the fragment write:

 

Game.GetPlayer().Additem(x, y)

 

Where x is your added property name, and y is the amount to add.

 

I'm getting error everytime I try to compile. E,g,

Game.GetPlayer().Additem(Gold001, 300)

 

Failed...blah, blah "...variable Gold001 is undefined"

 

This happens also if I put for example (JeweleryGoldRing, 1)

"JeweleryGoldRing is undefined"

 

I am guessing I have to add something...somewhere to refer to as the reward but I don't know how or what.

Link to comment
Share on other sites

Then in the fragment for that stage add a new property. Could be MiscObject or Armor or whatever depending on what you want as the reward.

 

As stated, before writing something in the fragment you have to declare the properties, which aren't declaring by scripting like in other scripts.

 

Click on "properties", "add", name your property whatever and define the correct type. Then fill it with the object you want and then you can use the property name in the script.

Link to comment
Share on other sites

Then in the fragment for that stage add a new property. Could be MiscObject or Armor or whatever depending on what you want as the reward.

 

As stated, before writing something in the fragment you have to declare the properties, which aren't declaring by scripting like in other scripts.

 

Click on "properties", "add", name your property whatever and define the correct type. Then fill it with the object you want and then you can use the property name in the script.

ok, done that, works. One last issue with this quest. player has the 3 pieces of salmon meat the NPC wants, player delivers meat, gets a "Thank you" and 300 gold but meat is still in inventory. How can player give the meat to the NPC? Some sort of container change?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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