Re: ORK integration
Posted: Tue Oct 13, 2020 10:44 am
1) To generate quests I call GenerateQuests() from this script:
But this one is not called after I load the game since the player already has his dailies so it skips it in the script I use to check if the dailies are available. So in the video the 2nd time I go to the quest giver board, it doesn't run this generator, should it run it again to re-create the quests?
Save key changing didn't help.
edit:
so this is what I get after loading for the quests the player hasn't picked up yet (this debug is in the script above line 24) so it seems it changes to disabled after loading, so it is saved but somehow not in a WaitingToStart state:
which is exactly what happens when I stop playing on unity editor, every quest is also turns disabled in the listener:
https://ibb.co/pPvJPpw
2) Sorry I didn't understood that.
https://ibb.co/BKZ57c1
https://ibb.co/qnD1vpf
here is how the rewards are setup. What happened is that after players got the new update with 1.2.10 QM, they rewarded with old rewards, and from their reports I understand they rewarded with as many rewards as ALL the quests they did before the new version, like 1 month quests for some people, so it was a pretty bad bug. Are these kept somewhere?
Again, it happened after updating to 1.2.10, which added some new stuff regarding old quests journal etc. which maybe triggered something. It is important we find the reason so it's not happen again, cause I feel a bit unconfortable for this to happen cause I'm live, it's a huge bug.
3) Using the generation script above, I don't get exp and general reward multipliers, tried in both parents and childs
But this one is not called after I load the game since the player already has his dailies so it skips it in the script I use to check if the dailies are available. So in the video the 2nd time I go to the quest giver board, it doesn't run this generator, should it run it again to re-create the quests?
Save key changing didn't help.
Code: Select all
using System.Collections;
using System.Collections.Generic;
using PixelCrushers.QuestMachine;
using UnityEngine;
[RequireComponent(typeof(QuestGeneratorEntity))]
public class QuestUtilities : MonoBehaviour
{
[Header("Monster Entity Type")]
public EntityType monsterType;
[Header("Amount of Kill Enemies")]
public int minEnemies;
public int maxEnemies;
[Header("Quest ID to manipulate")]
public string questIdName;
public string questerID;
[Header("Quests to Add")]
public List<Quest> quests;
void Start()
{
GetComponent<QuestGeneratorEntity>().updateWorldModel += UpdateWorldModel;
}
void UpdateWorldModel(WorldModel worldModel)
{
foreach (var fact in worldModel.facts)
{
if (IsMonster(fact.entityType))
{
int rndEntities = Random.Range(minEnemies, maxEnemies);
fact.count = Mathf.Max(fact.count, rndEntities);
Debug.Log("MONSTER: " + fact.count + " " + fact.entityType.name + " in " + fact.domainType.name);
}
}
}
private bool IsMonster(EntityType entityType)
{
var checkedEntities = new List<EntityType>();
return IsMonsterRecursive(entityType, checkedEntities);
}
private bool IsMonsterRecursive(EntityType entityType, List<EntityType> checkedEntities)
{
if (entityType == null || checkedEntities.Contains(entityType)) return false;
checkedEntities.Add(entityType);
if (entityType == monsterType) return true;
foreach (var parent in entityType.parents)
{
if (IsMonsterRecursive(parent, checkedEntities)) return true;
}
return false;
}
public void QuestAdd()
{
var generator = GetComponent<QuestGiver>();
foreach (var quest in quests)
{
string questID = quest.id.text;
if (generator.ContainsQuest(questID))
{
Debug.Log("Quest: " + questID + " already exists");
}
else
{
generator.AddQuest(quest);
}
}
}
public void QuestStateWaiting()
{
QuestMachine.SetQuestState(questIdName, QuestState.WaitingToStart, null);
Debug.Log("Quest " + questIdName + " changed state to WaitingToStart");
}
public void QuestStateAbandon()
{
QuestMachine.SetQuestState(questIdName, QuestState.Abandoned, null);
Debug.Log("Quest " + questIdName + " changed state to Abandoned");
}
public List<DomainType> domainTypes;
//Start is called before the first frame update
//Use this if the Domain is generated in runtime so it can attache a Domain entity
public void AddMyDomains()
{
var generator = GetComponent<QuestGeneratorEntity>();
var domains = new List<QuestDomain>(generator.domains);
foreach (var domain in FindObjectsOfType<QuestDomain>())
{
var wantThisDomain = domainTypes.Contains(domain.domainType);
var alreadyHaveThisDomain = domains.Find(x => x.domainType == domain.domainType) != null;
if (wantThisDomain && !alreadyHaveThisDomain)
{
domains.Add(domain);
}
}
generator.domains = domains.ToArray();
//generator.GenerateQuest();
}
public void GenerateQuests()
{
StartCoroutine("GenerateQuestCoroutine");
}
IEnumerator GenerateQuestCoroutine()
{
yield return new WaitForSeconds(1);
var generator = GetComponent<QuestGeneratorEntity>();
yield return new WaitForSeconds(1); generator.GenerateQuest();
yield return new WaitForSeconds(1); generator.GenerateQuest();
yield return new WaitForSeconds(1); generator.GenerateQuest();
//yield return new WaitForSeconds(0.1f); generator.GenerateQuest();
//yield return new WaitForSeconds(0.1f); generator.GenerateQuest();
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using PixelCrushers;
using PixelCrushers.QuestMachine;
using UnityEngine;
using ORKFramework;
public class QuestListener : MonoBehaviour, IMessageHandler
{
void OnEnable()
{
MessageSystem.AddListener(this, QuestMachineMessages.QuestStateChangedMessage, string.Empty);
}
void OnDisable()
{
MessageSystem.RemoveListener(this);
}
public void OnMessage(MessageArgs messageArgs)
{
if (messageArgs.values[0] == null) // If value 0 is null, this refer to main quest, not node.
{
var questState = (QuestState)(messageArgs.values[1]);
Debug.Log("Quest 1" + messageArgs.parameter + " change to state: " + questState);
if (questState == QuestState.Successful)
{
Debug.Log("Quest Succeed");
ORK.Game.Variables.Set("questState", "Success");
ORK.GlobalEvents.CallGlobalEvent(208, null);
}
else if (questState == QuestState.Active)
{
Debug.Log("Quest Activated");
ORK.Game.Variables.Set("questState", "Active");
ORK.GlobalEvents.CallGlobalEvent(208, null);
}
else if (questState == QuestState.WaitingToStart)
{
Debug.Log("Quest WaitingToStart");
ORK.Game.Variables.Set("questState", "Wait");
//ORK.GlobalEvents.CallGlobalEvent(208, null);
}
else if (questState == QuestState.Abandoned)
{
ORK.Game.Variables.Set("questState", "Abandoned");
Debug.Log("Quest Abandoned");
ORK.GlobalEvents.CallGlobalEvent(208, null);
}
else if (questState == QuestState.Failed)
{
Debug.Log("Quest Activated");
ORK.Game.Variables.Set("questState", "Failed");
ORK.GlobalEvents.CallGlobalEvent(208, null);
}
}
}
}
}
Code: Select all
Quest 1Kill 100 Dark Spiders 5a2e9d7b-7d13-4e3f-83cb-3a5ed26f8fa6 change to state: Disabled
UnityEngine.Debug:Log(Object)
QuestListener:OnMessage(MessageArgs) (at Assets/Scripts/QuestListener.cs:24)
PixelCrushers.MessageSystem:SendMessageWithTarget(Object, Object, String, String, Object[]) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Message System/MessageSystem.cs:338)
PixelCrushers.MessageSystem:SendMessage(Object, String, StringField, Object[]) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Message System/MessageSystem.cs:438)
PixelCrushers.QuestMachine.QuestMachineMessages:QuestStateChanged(Object, StringField, QuestState) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Utility/QuestMachineMessages.cs:160)
PixelCrushers.QuestMachine.Quest:SetState(QuestState, Boolean) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest.cs:875)
PixelCrushers.QuestMachine.Quest:DestroyInstance(Quest) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest.cs:639)
PixelCrushers.QuestMachine.QuestListContainer:DeleteQuest(Quest) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:231)
PixelCrushers.QuestMachine.QuestListContainer:DestroyQuestInstances() (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:149)
PixelCrushers.QuestMachine.QuestListContainer:OnDestroy() (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:130)
PixelCrushers.QuestMachine.QuestGiver:OnDestroy() (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestGiver.cs:218)
PixelCrushers.QuestMachine.ORKSupport.QuestGiverForORK:OnDestroy() (at Assets/Pixel Crushers/Quest Machine/Third Party Support/ORK Framework Support/Scripts/Quest List MonoBehaviours/QuestGiverForORK.cs:43)
which is exactly what happens when I stop playing on unity editor, every quest is also turns disabled in the listener:
https://ibb.co/pPvJPpw
2) Sorry I didn't understood that.
https://ibb.co/BKZ57c1
https://ibb.co/qnD1vpf
here is how the rewards are setup. What happened is that after players got the new update with 1.2.10 QM, they rewarded with old rewards, and from their reports I understand they rewarded with as many rewards as ALL the quests they did before the new version, like 1 month quests for some people, so it was a pretty bad bug. Are these kept somewhere?
Again, it happened after updating to 1.2.10, which added some new stuff regarding old quests journal etc. which maybe triggered something. It is important we find the reason so it's not happen again, cause I feel a bit unconfortable for this to happen cause I'm live, it's a huge bug.
3) Using the generation script above, I don't get exp and general reward multipliers, tried in both parents and childs