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!