wtorek, 29 lipca 2014

Saving and bug fixing - part one

Hello everyone!

I spent most of this week trying to find and fix bugs that had left in game code and to implement last engine functions. I'll write about the most important ones.
I also implemented basic game saving / loading, so it should speed up my testing work.

First thing that I managed to finish this week is the map location. It's a little bit different from normal locations. There was a problem with masks and objects, which should hide undiscovered parts of map.

Objects (edges of map and black shapes) are drawn on background surface only once, at location loading, and they are removed from objects list after it. This new surface become a current background, so when masks are drawn (check here), they don't show as discovered parts. In this location masks are triggered only by hero and they are used to hide him when he's walking across unexplored places.

Map location - temple exploring
Left - before  / Right - after

Second thing that I implemented was algorithm for map exploring animation. I changed the original one a little, but final effect should still be the same or very similar:

Map during exploring - Temple
Left - original / Right - ScummVM



I was working on implementation of blackPalette() and setPalette() functions.
They are used when hero changes location and they allow to gradually change color palette from normal to black and vice-versa.

Location no. 1 - Graveyard
Palette blackout


Game saving and loading is working only during the runtime now. You can't load your save-game from a launcher, but it's working similar to original game (you always start from the beginning in it and you have to skip intro animation to load your game). I'll think on updating it later, when everything else will be done.



I aslo made huge update in sounds and midi music part. I get rid of all memory leaks in it and now all sounds (not only hero and mobs voices) are playing correctly. We can hear gravedigger polishing graves or owl sounds for example.

Rest of things that I fixed this week:
- position of texts in wider locations and fix for inventory texts
- hero special animation drawing (still without shadows)
- mob priority list (order of mobs names drawing)
- bear form animation crashes
- pathfinding update
- blocked RMB menu on map mobs

I'm going to work on fixing rest of existing bugs this week and maybe implement rest of ScummVM's Advanced Engine Features.



wtorek, 22 lipca 2014

Pathfinding and hero movement

Hello everyone!

I was working to finish pathfinding part and implement hero movement animation this week.

I made huge clean-up in code and optimized an algorithm so it's not hanging whole game now. I used Visual Studio performance test to find slowest part of code. I also found and fix several bugs in pathfinding part, so it's not causing crashes anymore and there are no memory leaks in it. I can say it's working in 99% now, but it still need some testing. ;)

I updated it to allow mouse-clicking on places where hero can't directly go and to find closest point for destination instead. Pathfinding is also working correctly in wider locations now.

Last function to implement was scanDirection(). It used calculated array of path points to create array of directions for hero animation.

After finishing engine part of pathfinding I updated script part functions - O_RUNHERO, O_MOVEHERO, O_CLEARPATH, O_SETPATH and O_LOADPATH, so hero is walking to objects or mobs before he inspects or talks with them. "Walk to" option in right mouse button menu is also working now.

I made big changes in part of code that I had implemented at the beginning of my project - most in showHero(). It's a function that, among other things, make use of path cords and directions arrays calculated in pathfinding part. It counts hero animation frames and change animation according to current direction. It allows to turn hero during the path and to speed up his movement by skipping some of points on the path.

You can watch my progress on video right here: https://www.youtube.com/watch?v=nDPYoZoO3mI





poniedziałek, 14 lipca 2014

Pathfinding - beginning of implementation

Hello everyone!

Great news, someone may actually play Prince when I finish coding it! ;)
If you understand Polish, you can check articles about my project on websites here:
cdaction.pl, antyweb.pl, polygamia.pl, przygodomania.pl, gram.pl, playingdaily.pl, gry-online.pl, polskathebest.pl, gry.interia.pl, osworld.pl

I finally edited and upload video of first location gameplay that I promised you in my previous post.
You can watch it here: https://www.youtube.com/watch?v=Q5bhHKp8Eh8


I'm aware of existing bugs in it, like:
- hero talking animation sync (fix to match currently playing voice)
- hero boredom animation timing (shouldn't start randomly in time of dialog)
- hero shouldn't have dagger equipped from the beginning of a game
- gravedigger's last line before his runaway - "O w morde..." is not playing
And gameplay also lacks working pathfinding, so Prince is standing still whole time, but I'd like to tell you about my current progress with fixing it.

I spend this week trying to analyze, code and then fix most of path-making functions.
It was lots of lines to code and it still has some things that I have to fix but right now it looks like this:

Pathfinding - testing
Path drawing #1

Pathfinding - testing
Path drawing #2

If you look closely you can see white dotted lines that are drown temporary to display array of calculated path coordinates. I'm working on part that allows to find a correct, nearest place for destination when you click on place where hero can't go.

Next step will be implementing scanDirections() function, that will allow to create array of directions for hero walk animation during the path and also updating showHero() function to fix some bugs that I mentioned before and allow hero to actually walk the path.



środa, 9 lipca 2014

First playable location

Hello everyone!

Quick update to show you my weekly progress. I was working on script part this week and I have some good news. ;)

After setting an interpreter's debugger, understanding of how game script is working was actually quite easy. Most of script functions are done and are working correctly now. It was about 60 functions to code. Many of them have just 10 - 20 lines of code, but they are doing huge job in the game (like setting frames of background animations and loading special animations).

Some of them was pretty complex though and needed serious thinking - like O_INITDIALOG.
I had to change the way text for dialog-boxes are stored. I was just using array of strings before, but it was to simple and it was blocking script. To fix it I had to stick with concept from original game that uses special characters, hidden inside texts, to know how whole conversation should look like (who is talking, where to make pause while talking etc).

After taking care of script I found lots of bugs. I had to update background animations to allow changing from one to another, make fix for some voice loading and change the way objects (like shovel) are set to visible. I also update some mouse button events again.

Right now I have first fully playable scene - graveyard and I looks so cool ;) I still have to fix map scene to allow to change to another locations correctly, but after some testing I think that basics of other locations should work well too. I have very slow Internet access where I live now, but I'll try to upload game-play of it later at night.

Location 1 - Graveyard
Gravedigger's magic

Location 1 - Graveyard
Summoning Arivald


I'm preparing for pathfinding part right now. I'd like to finish it this week. One of things that I'll have to take care next is saving. It should make testing easier and allow to skip beginning of the game.


wtorek, 1 lipca 2014

LMB outside of inventory, beginning of script part

Hello everyone!

Finally, my exam time is over and I move back from my student apartment in Gdansk to my hometown for next two months. Moving cost a lot of time and effort, but from now I'll have peace and quiet to do serious work with Prince's code ;)
I'm also waiting for results of two last exams and I wish I will pass all of them.

Let's talk about my progress in last days:

At the beginning of a week I was working on handling rest of LMB actions outside of inventory. I manged to finish rest of option frame events (Examine, Pick up, Use, Open/Push, Close/Pull, Talk to). I have to implement pathfinding part before finishing the last one - "Walk to".

After choosing one of these options, it searches in proper mobs/op codes list to check if any special event for selected mob exists. If it exists we store its op code as next for foreground interpreter. If not we just store standard procedure's op code. Something similar happens for "Give item" and "Use item" events outside of inventory (events with item taken out from inventory). Second important step it to set current mob flag to allow proper working of upcoming script's functions.

Next thing that I had to understand this week, was how actually the script part is working. I choosed "Examine" option for testing, set up interpreter's debugger to show only foreground op codes and start fixing my first script functions.

I was able to implement script O_GETMOBTEXT(), which also need big update in setVoice() function. It used to support only one type of voice file for intro part, now it should work for every voice in game.

Last thing that I fixed to finish "Examine" option was small, but was very hard to find out. I had to update loading data for longer texts, when prince is talking more then once, like for graves examining in first location. I also implement O_CHANGEMOB() that is used to set visibility of mob and allow to change from one mob to another, e.g changing "unknown grave" to "Arivald's grave" after first examining.

I also updated checkMob() function and it's displaying names of background animation mobs and objects now. I also checked original code and found part of code that update visibility of static mobs for each location.

Background animation - owl (left) / Object - shovel (right)
Displaying names of mobs


I was also trying to find memory leak problems and I fixed most of them, but part of implemented code still need some clean-up and tweaks.

Right now I'm working on dialog part in script for "Talk to" option. It should allow to get some serious progress and to actually play a game for a while, but it's pretty complex and it requires implementing about 4-5 new script functions, so stay tuned.