Forgot to submit last night. I spent a couple hours starting to implement an npc for this example quest. It was enlightening. There are still many many npc path and ai bugs that I need to either find nice workarounds for or fix properly. My goal was to have a simple dialog tree that ended with the npc walking off and hanging out in a specified area.
The behavior tree nodes setup for pathing feel much more complicated than I think they need to be, and I am pretty limited in the kinds of behavior I can easily implement. I didn't have a pre-defined behavior handy, and trying to come up with a "hanging out" behavior was taxing my brain. Editing behavior trees is hard, because I always have to remember what all of the nodes mean, which means either better naming or an editor may be in order.
I also still have a weird disconnect between the dialog system and events. I think I have talked about this before, and it's possible I need to redesign the whole thing. To implement this simple situation, I have to:
Last night I basically stopped when I got to that last step. I couldn't really think of The first set of steps took about an hour. Not terrible but not great either. There are some fairly well behaviors that are defined now that make some things easy. Picking up or doing something with an item takes only a few lines (once I remember how to do it). But anything else is a bit confusing. I think an editor would help a lot. But I think I need to redesign how behaviors, conversations, and events work in a wholistic way, because this isn't going to scale. It would be really nice if I could just open a new file, and put all of those things together line by line in a simple way:
"I'm going to go off by myself now"
char1 behavior =
if char1.distance(region(x)) < 500:
char1.movetoward(region(x))
Definitely need to spend some time creating a more cohesive and complete grammar for everything before I can get to something clean like that. But it will help so much in experimenting with such highly experimental gameplay!
I also had a bug with the response interface where the player chooses what to say. After getting fed up with behaviors, I tried to fix this and couldn't narrow down why it wasn't working, so I went to bed frustrated. I hate going to bed frustrated!
Finally made it back to the meetup, which was cool. I didn't do much socializing because I was hot on finishing up some of the code changes I've been working on, but let's just say one of the guys there worked on kerbal space program and I sat in the corner with stars in my eyes glancing over at him every few minutes lol.
Anyway, I am still playing with behavior trees to try and get a balance between flexibility and ease of adding stuff. I was able to finish hooking up the drag action as a behavior, but it still had some bugs in that if you move, the guy chasing you goes to where you triggered the chase, rather than where you are now. I used a previous follow behavior, and added some arguments (and ways to set arguments in the behavior tree) so that the drag_to behavior can call into the follow behavior and attach it to the right character. So the guy chasing you will keep trying to get to you, only initiating the drag when he's actually close enough.
I also added arguments to the event which triggers the drag, enabling characters to chase and drag other offenders besides just the player. Force your "friend" to commit a crime just as the guard comes around the corner, and watch him get taken to the prison :)
Sometimes it's like keeping plates spinning, but while challenging they do look cool while they are spinning. Before the ai gets stuck trying to go around a corner and the plates crash to the ground!
For bonus points I also added a tick event to the event system, so I can set events to happen in the future.
Hooked up a generic event trigger to item interactions. Now I can listen for people doing things with items. I then made an event where trying to take down the tent makes the field guide annoyed and he comes over to stop you. I thought of actually adding in logic that allows the event response prevent the action from happening, so that if you try to take down the tent with the guide around he actually wont let you. But I thought of a better idea - taking down the tent becomes a task (an action that happens over time), and the drag response I've talked about in prior updates will automatically cancel any running tasks on the target of the drag. So what happens, is you start taking down the tent and see the progress bar, but if he reaches you before you finish, the action wont complete as he drags you away kicking and screaming.
Easier to code, and better for gameplay. You can now judge how long unappreciated tasks take and see if you can complete them before you are thwarted.
Events.json to accomplish this behavior:
{"type":"action","action":"dismantle","npc":"erik","repeat":1,"result":[
["drag_to",{"npc":"trask","target":"erik","location":"away_from_tent"}]
]}
The location of the drag has to be pre-set which is kind of annoying, but I will probably have simple enough scenes to just hard code all of the spots you get pushed to. Later on I can have the guards drag you to a jail cell haha.
Sadly, some of the "improvements" to pathing have made the npcs really bad at it again for some reason. I HATE PATHING! No gif, because I have to set up just the right scenario for the npc to get to me in time to prevent me from taking down the tent :/
I added to the conversation about where to set up the camp. If you reject the first campsite, the npc walks to a different location and asks again if it's a good spot to set up camp. It's not the full on voting that it will be, but I'm just doing the basic flow of the mechanics. Every little thing I add contentwise is still requiring quite a bit of extra coding to be done in either the event system, the conversation system, or the ai system. In this case, I had to add a way to trigger an event from the conversation (when you say "No, this is a bad spot to set up camp"), and a way for the event system to hear events triggered FROM conversation. I already had a way for events to create a new conversation - but they were always centered on a specific npc, and in this case, I needed to generate the conversation elsewhere (the location of the new camp). So I added an argument to the "create_conversation" action which will center it on a tagged location from the map editor.
It sounds more complicated than it is :P But I wonder if I have too many systems.
This is probably par for the course for the start of the game, but the goal is that by either act 2 or 3 I will mainly be adding content to the json files and not spending too much time in code.
Hey, I sat down thinking I was just going to twiddle some tickets and ended up adding a bunch of cool things.
I did twiddle some tickets though :)
I added meat you can eat to regain your endurance. The meat uses the tasks interface. You can fail, making it lose you endurance instead :P Not sure if I will keep this, but the main reason I chose to use tasks for it is because it's the best way I have right now for an action to take time, and eating should totally take time.
I added some birds that fly around and don't collide with things. They are basically just flavor. They currently do land on walls which I may change later.
I added a "drop_item" command for npcs so that I can trigger the setting up the camp scene in the act 1 I've been working on. So now, rather than the tents just starting there, the group will have a conversation about the safest place to set up. I can eventually script it so that after there is a consensus, the people who are carrying the tents will go drop them in the right spot. I'm thinking of having the group walk between two or three different potential spots, and then having a vote - where the player will get one vote. It will be split such that the players vote is actually the deciding one :P