Skip to main content

Large Monster Implementation.

One thing which has been a cornerstone of my development framework so far has been Large Monster Implementation (from this point referred to as LMI). It's something that I've said I wouldn't give up on.

So as it became increasingly likely that LMI wasn't going to work, or was going to have to require two completely different movement and combat systems working in tandem I became a little downhearted.

A giant spider, and look, it really is GIANT!

I had built my level prefabs to include a two square wide door, specifically to allow plus size monsters. Many of the monsters I had already designed had small and large variants. It was a real downer.

Anyway, my original plan was to have two sets of tile data, one for small tiles and one for large. I would keep track of movement in both, and then share data between them. it was horrible complex to try and code, and I just gave up, just trying to work around the issue on other things that I could actually do.

Today I though again about my reasons for using two sets of tile data. Why separate things? A large monster takes up 4 tiles, so we could get the second set of data by checking every group of 4 tiles in the first data set and then checking to see if any of them are occupied. We could do this when building the map, and then update the data sets every time someone moves. But what if we check the tiles only when we need to?

Lets look at an example:

A spider ready to move across our large room.

Right now every walkable tile in the game is stored in a dictionary. We can set whether the tile is walkable, whether it blocks vision and who or what is occupying the tile. We can select a tile by clicking on it and checking who is occupying it. When characters move from tile to tile they clear their presence on the old tile and set it on a new one. Because character moves in this game are upwards of 6 tiles per turn (instead of the traditional 1 tile movement of most rogue likes), I only need to change the occupier reference in the start and end tiles of the movement. The path-finding script takes care of what happens between those tiles.

The pathfinder in fact consists of two parts, the graph builder which gets walkable tiles from the map, and the path-finding algorithm (which is again split in to two parts, a simple Bresenham's line script and an A star algorithm for if more complex movement is required).

Before getting passed to the pathfinder the graph can be built to take in to account the possibility of large monsters. By checking if each square is walkable, and if it's 3 neighbors are also walkable we can check for a 2 square wide path instead of a single width path.

So we check the actual location of the spider and its neighbors using a search array:


add_to_graph = True
search_array = ((0,0)(1,0),(1,1),(0,1))
for xy in search_array:
    check_x = own_x + xy[0]
    check_y = own_y + xy[1]
    tile_key = get_map_key(check_x,check_y)
    if tile_key in walk_dictionary:
         if walk_dictionary['tile_key']['occupier'] != None:
            add_to_graph = False
    else:
        add_to_graph = False

If add_to_graph is True we can add the square to the graph, knowing that it has enough room around it for the spider to walk through.

We keep going, filling up the graph to the extent of the monster's maximum movement range or the distance of the goal. Then we hand off to A* to try to make a route to the goal.


In this case the route is blocked, the actual A* would try a lot more routes than this one, I do have a variant which will find the best square from the closed list and path find to there too to get as close the goal as possible rather than just giving up.

If we remove the blocking square the spider will go all the way to the goal.


We have to do more things to get this to work, for example when moving the spider we have to give it an offset so visually it appears in the center of the 4 squares. We also have to set all the 4 squares as occupied and set the occupier as the spider. When moving to a new position we also have to clear all the occupied squares.

If e do it right clicking on any of the 4 squares will return the spider as the occupier. This will allow the player to select the monster for a combat target, or to shoot at it, or cast a spell on it or loot its corpse or interact with it in any other way without ever knowing that it really only occupies one square.

But... I do have more headaches in store, one of which is the fact that the Bresenham's line script actually runs before the graph builder (to try and save processing time, building a graph can be time consuming) so the Bresenham's line script will also have to be modified when dealing with large monsters. Or we can just skip linechecks for large monsters, baring in mind they are going to be quite few and far between.

Setting aside such problems for now, it seems like the LMI problem may have been partly solved, and the implementation can also be shared by such things as large pieces of furniture

Comments

Popular posts from this blog

Vinland 1936

What have I been up to this month?

Well you can see it in a couple of development blog videos, here, here and here.

Vinland 1936 is a game I've been working on (on and off) for about 3 years. It is somewhat based on the old Nirval interactive game, Blitzkrieg;





I hope you've played it since it is one of the best games ever!!! (IMHO)
Blitzkrieg was a real time tactics game. You didn't build a base, or spawn units. It wasn't about rushing the enemy. You got a small number of troops and vehicles that could be replenished or repaired if you had access to a supply base and the right supply trucks, but couldn't be replaced if lost. Once your vehicles were destroyed and your infantry killed you were finished. You couldn't just churn out some more from your factory and have another go at rushing the enemy guns. This made you invest a lot in each of your units. They really mattered.

It was also procedurally generated. Each mission (except for the historical missions) was…

Reboot / Remake / Restart

Although the roguelike project was going well I had a few issues with some parts of the code, and the sheer size of the project was something I could see stretching away in front of me for years with no guarantee that people would actually want to play it when it's finished.

It's time to try something a little less ambitious.
I'm going full rogueLITE!

Using a lot of the code from the roguelike project, I started making a more limited game.
There will be a single character, combat will be more arcade like, there will still be a chance to upgrade and develop your character's stats, but they represent only a single class and have fixed equipment.

I've got a fun character, an interesting setting and an exciting story lined up. It still utilizes my low poly style, but things are going to be a little more cartoony.

Game play involves mostly chucking bombs at the enemy.

But there's also a lot of platforming, jumping from multiple levels is part of the game. And you ca…

Telling a story; Creating a Compelling Narrative.

Telling a story; Creating a Compelling Narrative. In this blog I will talk about my own recent brush with story telling and go on to talk about how tools from creative wring can help you to better author the narrative in your games, whether they have a traditional linear narrative or a procedurally generated interactive narrative.

Narrative and structure in traditional fiction  last week I started writing a story set in the world I'm developing for my game Vinland: 1936.

I hope the story will help me to flesh out my game world and develop my own expanded universe which will be a good place to set my games in the future.

After about a week of work, on and off I've progressed the story to outline stage. For each character thread I have half a dozen chapters which plot a course through the events of the story. Each thread is told from the perspective of a different character.


Actually I started writing as soon as I had my outline, but I've since gone back and deleted what …