Clock and agendas
wachibou485
08 Jul 2017, 19:59Hey there!
I was asking myself: is there any way to make a character move by himself following a routine (I use ClockLib) ?
I already modified the 'IsAfter' script from ClockLib so that it can handle entries such as "16:00" (4 pm today) instead of "XX:16:00" (4 pm on day XX).
<function name="IsAfter" parameters="time" type="boolean"><![CDATA[
if (TypeOf(time) = "string") {
l = Split(time, ":")
if (not ListCount(l) = 3) {
if (ListCount(l) = 2) {
hours24 = ToInt(StringListItem(l, 0))
minutes = ToInt(StringListItem(l, 1))
time = (game_clock.days * 24 + hours24) * 60 + minutes
}
else {
msg ("That's not a valid string.")
}
}
days = ToInt(StringListItem(l, 0))
hours24 = ToInt(StringListItem(l, 1))
minutes = ToInt(StringListItem(l, 2))
time = (days * 24 + hours24) * 60 + minutes
}
return (game_clock.time > time)
]]></function>
I create a turnscript, myTurnscript, that moves a NPC at a given hour.
<turnscript name="moveNPC">
<enabled />
<script>
if(IsAfter(16:00)){
MoveObject(NPC, givenRoom)
}
</script>
</turnscript>
Here's my problem: it works fine with one NPC moving once a day.
But with, let's say, 10 NPCs, that moves four times each day, it becomes way too messy.
Is there an easy way to create a library that creates a tab in the object editor where I can put some sort of NPC "agenda"?
Have you any ideas of how to do this?
Thanks!
[EDIT]: I also have special events that don't repeat on daily basis (NPC1 meets NPC2, NPC1 buys special item, etc.). There is about one event per day per character, sometime more.
Also, the player must be able to create events (Player meets NPC1 in two days, etc.) and to override NPCs' routines.

DarkLizerd
08 Jul 2017, 20:12make it a function that is called by each NPC when it is it's time (turn) to move.
Add a parameter to name the NPC to move.
wachibou485
08 Jul 2017, 20:19Yeah, that's an idea.
But my game plays out on over a year, and various stuff happens (about 1 event per NPC per day, sometimes more). If I code 365 days of events for every NPC, the game will become way too messy...

DarkLizerd
08 Jul 2017, 20:29If each NPC does the same thing, at the same time every day, then all you need to do is check the time each day, and not worry about the day of the year...
Just because you set your alarm clock at 8:00 am, does not mean you need to set it every day.
A switch would be the easiest way to track and edit NPC actions.
wachibou485
08 Jul 2017, 20:32Good idea
The Pixie
08 Jul 2017, 21:24ClockLib has this built in. Create event objects for one-off events (though it is limited to 99 days). Use sequences if they keep repeating; they can keep going indefinitely. I designed it primarily to control NPCs.
https://github.com/ThePix/quest/wiki/Clock-Library