Auto generate quests - monsters not spawned

Announcements, support questions, and discussion for Quest Machine.
dlevel
Posts: 181
Joined: Wed Nov 16, 2016 6:17 pm

Auto generate quests - monsters not spawned

Post by dlevel »

Hey Tony,

I have a question regarding the auto generated quests. In my game the monsters are not spawned until the player is near (to save resources), but the areas are marked with variables and have scripts that spawn some specific monsters (randomized by 3-4 for example). How could you handle this so Quest Machine can grab what is likely to be spawned ahead and create quests for these monsters? (Kill quests for example)
dlevel
Posts: 181
Joined: Wed Nov 16, 2016 6:17 pm

Re: Auto generate quests - monsters not spawned

Post by dlevel »

I found a way to spawn a dummy clean gameobject with the entity in it and have the quest machine generator tracking it, my issue now is that I need to spawn 10 of those if I want to have 10/10 quest instead of 1/1. Any way to have the min/max in counter to work regardless how many it finds? what I mean is the min to act like a true min and use this number even it only finds 1 enemy.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Auto generate quests - monsters not spawned

Post by Tony Li »

Hi,

I don't quite follow.

If you make the entity type's Max Count In Action curve linear (a straight line going from the lower left corner to the upper right), then when there is 1 enemy the quest should require 1/1 kills. If there are 10 enemies, it should require 10/10 kills.

If you want to set a maximum per quest (say, 5/5 max), you can make it linear up to 5, then make it a straight horizontal line at 5+.

If you want to set a minimum per quest (say, 2/2 min), you can move the leftmost point up from zero to 2.

However, if the action's min and max requirements are not met, it will not use that action at all. For example, say you set the Kill action's Min value to 3. Then if there are only 2 monsters, the quest generator will not use the Kill action.
dlevel
Posts: 181
Joined: Wed Nov 16, 2016 6:17 pm

Re: Auto generate quests - monsters not spawned

Post by dlevel »

yeah exactly, if I set the action's min at 3, and only 1 monster is spawned, it will require 1/1 and not 3/3. The way my game works, is that it spawns enemies as the player is near them, so I need an action's min that works even if only 1 monster is spawned, it will require 3/3 (because it will spawn more of it later on). Hope you understand :)
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Auto generate quests - monsters not spawned

Post by Tony Li »

Hi,

Please try this:

1. Inspect the entity type.
2. Click on the Max Count In Action curve.
3. Add a key at 1 if it doesn't already exist.
4. Set its value to 3.
dlevel
Posts: 181
Joined: Wed Nov 16, 2016 6:17 pm

Re: Auto generate quests - monsters not spawned

Post by dlevel »

ok here is the result:

It asks to kill 1 (only 1 is spawned) 0/1. What I need is that even if 1 is spawned, to as for 0/3 - 0/15 (the random number between min/max)

settings:
https://ibb.co/VW6vML2
https://ibb.co/0n69hRd
https://ibb.co/Fw4dJKx
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Auto generate quests - monsters not spawned

Post by Tony Li »

The curve needs an adjustment. In the curve, right-click on the key "3.03, 3.07". Change it to "1, 3".

However, this won't resolve your issue. The generator always uses the minimum of the curve value and the actual number of entities. This is by design to prevent it from generating an impossible quests (e.g., kill 3 monsters, but there are only 2).

Can you put the entity types on spawn points instead of monsters? Then let the spawner spawn monsters at those spawn points.

Alternatively, you can assign a method to the generator's QuestGeneratorEntity.updateWorldModel event and bump up the number of monsters. Rough example:

Code: Select all

void Start()
{
    GetComponent<QuestGeneratorEntity>().updateWorldModel += UpdateWorldModel;
}

void UpdateWorldModel(WorldModel worldModel)
{
    foreach (var fact in worldModel)
    {
        fact.count = Mathf.Max(fact.count, 3);
    }
}
dlevel
Posts: 181
Joined: Wed Nov 16, 2016 6:17 pm

Re: Auto generate quests - monsters not spawned

Post by dlevel »

Yes this method does it for me :) Thanks!

BTW is there a way to get the entity and use it to this method to have some entities act differently on multipliers (using parent entities so that can help)?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Auto generate quests - monsters not spawned

Post by Tony Li »

Yes. Each Fact has a reference to an EntityType. The EntityType has a parents list of EntityTypes.

So, for example, you could recursively check an EntityType's parents to see if it's a child of the Monster EntityType.
dlevel
Posts: 181
Joined: Wed Nov 16, 2016 6:17 pm

Re: Auto generate quests - monsters not spawned

Post by dlevel »

perfect, any chance you can do me a very small example in the code you posted in the previous post as to how to reference an entity parent so I can only have the multiplier work on those entities? thanks :)
Post Reply