How Can I Spawn Custom Flats Inside Interior Buildings?

Discuss modding questions and implementation details.
Post Reply
User avatar
Magicono43
Posts: 630
Joined: Tue Nov 06, 2018 7:06 am

How Can I Spawn Custom Flats Inside Interior Buildings?

Post by Magicono43 »

Alright, so some context, i'm currently working on a mod that will allow the use of guild-services, without having to be apart of these exclusive guilds. The idea being that when the player enters an Inn, the mod will roll for the chance that a custom guild service NPC will be "spawned" in that inn, which the player can then use for whatever specific service that NPC has attached to them (at an increased cost).

So the concept is fairly simple, but i'm having some trouble on some of the basic implementation parts of it, currently the one being actually creating a "custom" flat NPC. All the mods that I can think of, don't appears to be adding in any custom NPC flats to a building, but are using the system currently in place to populate a building with NPCs based on that specific RMB block's data. So I tried looking through some of the base-scripts and I really am having trouble understanding exactly what is being done and why.

Long-story short, how would I add or even just replace an NPC inside a building interior with some behavior attached to them? Really at this point just being able to understand how to create an NPC flat in the world would be progress. Thanks.

l3lessed
Posts: 758
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: How Can I Spawn Custom Flats Inside Interior Buildings?

Post by l3lessed »

It can clearly be done. Look at this mod to see how the author uses the quest system to spawn NPC's in buildings. You would need to replicate that process and replace the random building selection with a predefined routine for the specific building/buildings you want the NPC in.

viewtopic.php?f=14&t=3982

At that point, comes the second part. You need to then make that NPC billboard/entity clickable. Not sure really where to begin here, outside looking at how the base engine sets up clickable npc billboards.

Look at this forum. I did copy and discuss the code around 2d billboards and click active. It may help some.

viewtopic.php?f=22&t=3941
My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
Magicono43
Posts: 630
Joined: Tue Nov 06, 2018 7:06 am

Re: How Can I Spawn Custom Flats Inside Interior Buildings?

Post by Magicono43 »

Thanks for the links. Yeah, I was considering using the questing engine in some way, but i'd optimally like to be able to do this purely through scripting rather than relying on quests. I'll have to look more into that populated buildings mod, it's not the "type" of entity i'm looking for, but hopefully it will lead somewhere that I can get the kind I want with the attributes and behaviors that I want.

imsobadatnicknames
Posts: 296
Joined: Sun Jun 02, 2019 4:28 pm
Location: Colombia

Re: How Can I Spawn Custom Flats Inside Interior Buildings?

Post by imsobadatnicknames »

Magicono43 wrote: Mon Aug 03, 2020 4:58 pm Thanks for the links. Yeah, I was considering using the questing engine in some way, but i'd optimally like to be able to do this purely through scripting rather than relying on quests. I'll have to look more into that populated buildings mod, it's not the "type" of entity i'm looking for, but hopefully it will lead somewhere that I can get the kind I want with the attributes and behaviors that I want.
Hello! I'm the author of the Populted Buildings mod! I'd be more than happy to explain how it works, tho I'm not sure if it can help what you wanna do.

So, let's take a look at populated buildings.

The first part is the master file

Code: Select all

Quest: PBMASTER
DisplayName: PBmaster
-- Message panels

QRC:


QBN:

Clock _delay_ 0.01:00

--	Quest start-up:

_entercity_ task:
	when pc enters city
	start timer _delay_

_delay_ task:
	start quest PB1
	start quest PB2
	start quest PB3
	start quest PB4
	start quest PB5
	start quest PB6
	start quest PB7
	start quest PBA
	start quest PBMASTER	
	end quest
So, what this does is basically, when you enter a city, it will start a one-hour clock, and once that clock reaches 0, the quest will start all other Populated Buildings quests, then start a new instance of itself, and then end.

now let's take a look at one of those quests

Code: Select all

Quest: PBA
DisplayName: Populated Buildings - Armories
-- Message panels
QRC:            

QBN:

Foe _f1_ is Knight
Foe _f2_ is Warrior
Foe _f3_ is Barbarian
Foe _f4_ is Archer
Place _fg_ local armory
Place _mg_ local armory
Clock _leave_ 01:00


--	Quest start-up:
	pc at _fg_ set _inside1_
	pc at _mg_ set _inside2_
	start timer _leave_

So, at the start of the quest, it will define 4 types of enemy, and it will then randomly choose two local "armory" type buildings. Your pressence at any of these buildings will fire up one of two tasks, called inside1 and inside2. It will also start a one-hour timer.

Code: Select all

_inside1_ task:

_inside2_ task:

_spawn1_ task:
	when _inside1_ 
	create foe _f1_ every 10 minutes 2 times with 50% success
	create foe _f2_ every 10 minutes 2 times with 50% success

_spawn2_ task:
	when _inside2_ 
	create foe _f3_ every 10 minutes 2 times with 50% success
	create foe _f4_ every 10 minutes 2 times with 50% success

_pacify1_ task:
	when _inside1_ 
	change foe _f1_ infighting true
	change foe _f2_ infighting true
	change foe _f1_ team 1
	change foe _f2_ team 1
	clear _pacify1_

_pacify2_ task:
	when _inside2_ 
	change foe _f3_ infighting true
	change foe _f4_ infighting true
	change foe _f3_ team 1
	change foe _f4_ team 1
	clear _pacify2_

_exitcity_ task:
	when pc exits city
	end quest

_leave_ task:
	remove foe _f1_
	remove foe _f2_
	remove foe _f3_
	remove foe _f4_
	end quest
When inside1 or inside2 are active, the game will start spawning the previously defined enemies, and it will also trigger a task which will change the enemies allegiance to team 1 (which means they will be allied with the player).

If you leave the city, the quest will end. When the timer runs out, the quest will end and the enemies will be despawned.



Now, I THINK I have an idea of how your mod could work to spawn the kind of entity you're looking for inside random buildings, but I'm not sure. I think you'd have to define a custom NPC group which offers the services you want. Let's call it Servicegroup for the time being.

Like, if I took the code I showed up there and I typed something like "person _npc1_ group Noble" and "person _npc2_ group Noble" and on the quest start-up section I added "place npc _npc1_ at _fg_" and "place npc _npc2_ at _mg_" it would take two random generic noble flats and put them inside the two aforementioned randomly chosen armories.

So I'm guessing if you were able to define a custom npc group called Servicegroup or something like that, you could probably do something like this:

Code: Select all

Quest: SERVICES
DisplayName: Service providers
-- Message panels
QRC:            

QBN:

Place _inn_ local tavern
Clock _end_ 01:00
Person _servicegiver_ group Servicegroup

--	Quest start-up:
	place _servicegiver_ at _inn_
	
_end_ task:
	end quest

And then you could write a master like this to fire it up every hour:

Code: Select all

Quest: SERVICESMASTER
DisplayName: Services master
-- Message panels

QRC:


QBN:

Clock _delay_ 0.01:00

--	Quest start-up:

_entercity_ task:
	when pc enters city
	start timer _delay_

_delay_ task:
	start quest SERVICES
	start quest SERVICESMASTER	
	end quest
Which means that after you enter a city, every hour a random tavern will be chosen and a random flat from the Servicegroup will be spawned inside it. You could slghtly modify it to also make them spawn in taverns in hamlets, villages and lodges. Now, this still requires some work. I have no idea how to define custom NPC group with custom services. Also, afaik, flats spawned like this through the quests system will do nothing when clicked unless you define a specific task that will trigger when you click it.

Still, it's a way to spawn the kind of enity you're looking for inside random buildings, so that's a start!
Last edited by imsobadatnicknames on Mon Aug 10, 2020 2:41 am, edited 1 time in total.
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0

User avatar
Magicono43
Posts: 630
Joined: Tue Nov 06, 2018 7:06 am

Re: How Can I Spawn Custom Flats Inside Interior Buildings?

Post by Magicono43 »

Thanks for the explanation, @imsobadatnicknames. I was coincidentally just starting to work on doing some of the first quests I had ever done with the built in questing system and the quest scripting language, so your examples of "non-conventional" quests are a nice thing to see, where tasks are being done, but there are no defined goal and such besides the execution of said tasks, also did not realize you could chain quests inside other quests like that, very interesting.

I'm sure I will find this information useful at some point, and maybe even for this specific mod as well, for the time i'm taking a small break from this mod and a few others to make some simple quests that I think would make a good addition to the currently somewhat limited pool of "simple" dungeon crawl quests for certain factions for added variety and such, as well as a few others things. But I will keep your post in mind when I start working on this again, I may have a few ideas on how I could do this with your method, mixed in with custom C# code to make it all work out.

imsobadatnicknames
Posts: 296
Joined: Sun Jun 02, 2019 4:28 pm
Location: Colombia

Re: How Can I Spawn Custom Flats Inside Interior Buildings?

Post by imsobadatnicknames »

Nice! It's always good to have more quest writers
I'm glad you found the explanation useful or at least interesting!

I know you said you're taking a break from this, but I found it interesting to keep thinking about this mod last night so I have my own ideas about how this could work.

Since interkarma confirmed in this post (viewtopic.php?f=12&t=3878) that it's possible to add new quest actions, I think that'd be your safest bet.

Like, let's say we wanna add a spellmaker that appears at taverns using the quest code I posted above. I'm guessing you could add a custom quest action called "spellmaking" or something like that, that when called by a quest opens the spellmaking menu.

Then you could modify the code I posted above to something like:

Code: Select all

Quest: SPELLMAKER
DisplayName: Spellmaker
-- Message panels
QRC:            

Message:  1025
<ce> Do you require my spellmaking services?

QBN:

Place _inn_ local tavern
Clock _end_ 01:00
Person _servicegiver_ group Servicegroup

--	Quest start-up:
	place _servicegiver_ at _inn_
	
_npcclicked_ task:
	clicked npc _servicegiver_
	prompt 1025 yes _service_ no _refuse_
	
_service_ task:
	spellmaking
	clear _npcclicked_ _service_
	
_refuse_ task:
	clear _npcclicked_ _refuse_
	
_end_ task:
	end quest
Then you could simply do the same for every service you want these npcs to provide.

Of course... Idk how hard it'd be to create these custom quest actions bc I don't know shit about actual coding, but I know it's theoretically possible to do it.
Magicono43 wrote: Mon Aug 10, 2020 2:26 am so your examples of "non-conventional" quests are a nice thing to see, where tasks are being done, but there are no defined goal and such besides the execution of said tasks
Also yeah, recently I kinda started having a thing for using the quest system to do encounters that aren't quests :p If you found Populated Buildings itneresting you could check out these:
https://www.nexusmods.com/daggerfallunity/mods/107
https://www.nexusmods.com/daggerfallunity/mods/109 (which I coded last night)

Anyway, can't wait to see what you do with this!
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0

User avatar
Magicono43
Posts: 630
Joined: Tue Nov 06, 2018 7:06 am

Re: How Can I Spawn Custom Flats Inside Interior Buildings?

Post by Magicono43 »

Once again, thanks for the example, i'm not sure when i'll get back to working on this specific mod/idea, but i'll eventually get there. Seeing how useful the built in quest system can be for performing certain tasks, that are somewhat difficult and tedious to do with pure C# code, I will almost definitely be using some form of quests to do this mod, at the very least for the spawning of flat NPC at specific locations inside of towns, etc.

Hope to see some of your other ideas as well working with the questing system, always very interesting to see how people get creative and use it.

imsobadatnicknames
Posts: 296
Joined: Sun Jun 02, 2019 4:28 pm
Location: Colombia

Re: How Can I Spawn Custom Flats Inside Interior Buildings?

Post by imsobadatnicknames »

Heeey dude. Since it doesn't really seem like you're gonna come back to this idea anytime soon, as you're busy with your overhaul project, I hope you don't mind I gave this idea a go, I tried to implement non-guild potion sellers in random taverns: viewtopic.php?f=14&t=4270
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0

User avatar
Magicono43
Posts: 630
Joined: Tue Nov 06, 2018 7:06 am

Re: How Can I Spawn Custom Flats Inside Interior Buildings?

Post by Magicono43 »

imsobadatnicknames wrote: Tue Oct 27, 2020 6:45 pm Heeey dude. Since it doesn't really seem like you're gonna come back to this idea anytime soon, as you're busy with your overhaul project, I hope you don't mind I gave this idea a go, I tried to implement non-guild potion sellers in random taverns: viewtopic.php?f=14&t=4270
Absolutely, I don't have any "dibs" on anything I bring up on here. So if you want to do something like this please feel free, lol. Once again a clever use of the quest system and seems like it would work very well for that particular service as well.

Post Reply