implementation of talk window

Discuss coding questions, pull requests, and implementation details.
Post Reply
User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: started implementation of talk window

Post by Interkarma »

Nystul wrote: "where is/person" entries only should appear if person is in same town as pc.
After re-reading to try and better understand the problem, I feel you could be using the macro as a workaround to determine where NPC is located. The home location shouldn't be used for this purpose (it's just intended for flavour text) you should be querying the SiteLinks to find the Place resource where NPC resource has been allocated (if anywhere). Keep in mind that NPCs don't have to be placed anywhere at all, they're purely virtual until "place npc" is called by script.

Do you just need a simple way to query if NPC is in same town as player? Is that correct? I can help with that. :)

Nystul wrote:And macro resolving is wrong, above link says: "If _foo_ is a Person resource then ___foo_ (three leading underscores) gives the town name where _foo_ can be found
I'd say Tipton's description is wrong in this case, or at least very limited in understanding. The NPC in M0B00Y16 does not use ___person to expand to their current location (a random dungeon). It expands to a random town in the same region. To the best of my knowledge, the only time ___person is used is for flavour. If you have a text resource where you expect the text macro to expand differently, please quote it so I can see the usage in context. Cheers. :)

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: started implementation of talk window

Post by Nystul »

Interkarma wrote: Do you just need a simple way to query if NPC is in same town as player? Is that correct? I can help with that. :)
Yes that's all I need ;)

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: started implementation of talk window

Post by Interkarma »

I'm on it mate. Will get this in code ASAP. :)

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: started implementation of talk window

Post by Interkarma »

Have added something that might help. Now I've been drinking, and have not tested at all, so my apologies if not functional. Will try again later if needed. :)

Here's how it works:
  • Get a reference to the Person resource you're interested in, e.g. Quest.GetPerson(symbol);
  • Use Person.GetAssignedPlaceSymbol() to get the symbol of Place this person was assigned to (if any). This is not set until quest calls "place npc" and will be revoked on "destroy npc" when implemented. If this returns null, then "place npc" has not been called or person was destroyed.
  • Use Person.IsPlayerInSameLocationWorldCell() to quickly check if player in same basic world cell as person was assigned to. Does not care about building, dungeon, interior, exterior. It's fast and just matches mapID of Place to player's current location.
You will need to start any quests again before testing. Quests instantiated prior to this change will not have the new data.

If you need to do more with it, grab the assigned Place reference using Quest.GetPlace(Person.GetAssignedPlaceSymbol()); for example. You then have full details of the Place to check however you like.

But remember if Person.GetAssignedPlaceSymbol() returns null then Person is either not assigned yet or has been destroyed. This is a very fast check, so no need to cache. Probably better not to cache anyway as Person can be moved around by quest.

I hope that helps! Let me know of any feedback and if anything else you need from it.

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: started implementation of talk window

Post by Nystul »

ok thanks!
how about static npcs? those are often used in quests but do not have a "place npc" - but I would need to get the location of those as well, e.g. guild quest givers always show up under "where is -> person" in vanilla when pc is in same town. I would need to get it working for those static npcs as well (basically for all npcs used as a person resource - not only those that are placed by "place npc" - see any fighters guild quest and you can see that questgivers won't receive a corresponding "place npc" command - because they are already in the gameworld...)

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: started implementation of talk window

Post by Interkarma »

NPCs such as local guild quest providers would be queried from building information rather than quest system. There will never be a matching Person resource for an NPC who is not part of an active quest. But I can handle this when NPC is injected into quest.

I can also help enumerate local service individuals, just let me know what you need. :)

Will need special handling for available shop keeper and tavern jobs too. Need to schedule these when player enters town so they can be served into the talk system. Let's tackle this one a bit later though. Have some other work I want finish first.

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: started implementation of talk window

Post by Nystul »

sure! thanks!
yeah lets go step by step - just shouted out because I was hitting a wall there

edit: when is a npc part of a quest? thought that it is that way that if there is a person resource for that npc he/she is part of it, e.g. "Person _questgiver_ group Questor male"

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: started implementation of talk window

Post by Interkarma »

Nystul wrote: edit: when is a npc part of a quest? thought that it is that way that if there is a person resource for that npc he/she is part of it, e.g. "Person _questgiver_ group Questor male"
In this case, the questor is the person who provided player with quest. You're right there's no "place npc" for these guys, but I can handle this for you so it works the same.

Do you need to query local service NPCs outside of quest system? I can't recall if these NPCs are exposed to talk window or not without already being part of an active quest.

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: started implementation of talk window

Post by Nystul »

Interkarma wrote:
Nystul wrote: edit: when is a npc part of a quest? thought that it is that way that if there is a person resource for that npc he/she is part of it, e.g. "Person _questgiver_ group Questor male"
In this case, the questor is the person who provided player with quest. You're right there's no "place npc" for these guys, but I can handle this for you so it works the same.
that would be awesome
Interkarma wrote: Do you need to query local service NPCs outside of quest system? I can't recall if these NPCs are exposed to talk window or not without already being part of an active quest.
no, just quest npcs (running quests) ;) unless we want to extend vanilla behaviour, but I don't have short-term plans for this

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: started implementation of talk window

Post by Interkarma »

Reviewing this today after some sleep, and I'd like to handle slightly differently.

Would you be happy if the methods returned more generic location data (e.g. mapID, regionIndex/locationIndex, DFLocation) rather than a Place symbol? The reason for this is that static NPCs like the Questor in your example above don't have any related Place resource, but they do have a spot in the world - which is the bit you actually need here. It would be nice to make the baseline handling consistent between all NPCs whether static or placed.

And do you also need directional information to the NPC - be they static or injected using "place npc"?

Post Reply