Friday, October 14, 2011

Memory leak

Somewhat related to AI bug, I noticed that if I keep playing the game long enough it gets slow.. and  I mean really slow. Usually it runs on 30fps ( limited ) and when using walkmode it almost never goes down to 28 even with 30+ npc and 15+ light sources. However after playing a bit it became so slow that when doing nothing, just letting visual rendering do its stuff, it ran on 30fps but as soon as player moves one square it downed fps to 5 fps or even 1 fps.. and it took several second to recover.

The problem was memory leak in fov stuff of lightsources and npcs. When it started to jam the game was hauling around 1GB of memory and increasing the memory consumption by 30MB/pc move. I solved the problem by using fovs copy method instead of recreating the fov object everytime.. Stupid mistake and it took a while to figure it out but now I know better :)

Sunday, October 9, 2011

AI routine.. bug found..

Hello,


After making good progress in combat and other AI and skill related stuff I noticed disturbing thing in my TimeEngine and AI routine.. It seems current system can't handle instant stuff, it always takes at least one turn to make  stuff happen. It wasn't obvious when I implemented the system and tried it with walking because the AI decision was made on first turn and didn't change after that - thus no delay on NPC brainactivity... Now that I need NPC to make fast decisions based on if player attacks or flees, it takes one round npc to discover that player had fled or on the other side, it takes one extra round for npc to attack.

I need to fix this by making TimeEngine not responsible of calling AI routines but just keeping track how much every NPC gonna get action points based on what player has used. Monsters should do their own AI calling. Im not sure if TimeEngine gonna get more authority but we will see once I start implementing new system.

On the plus side its good that I noticed this bug now.. It would have been pain to fix later on.

Friday, October 7, 2011

Initial combat

Hello,

At the moment initial combat can be done between player and monsters. It only includes one skill, attack, which is at the moment common for both player and monster. In future when I start writing more skills I intend to add several basic attacking skills based on race of the monster. It makes the gameplay more unique when monster attacking you doesn't just do 'hit' but monsters with claws do 'clawing' and 'biting'.

The way taking damage is handled is that when creature performs for example attack skill the damage, crit chance, hit chance and damage type is taking from the 'casters' stats and then send as a object to 'target'.

When target receives that object target first calculates if the skill misses or not the target. First the hit chance of the 'caster' is taken into memory and then from that we minus certain percent of what 'coverage' attribute and dexterity adds to missing chance. If the skill hits the target we check if the damage of the skill is to be critical. This is calculated via caster's critical hit chance, again as with hit, the chance is lowered with 'coverage' and 'dex'. After that we start calculating how much targets armor and resistances lower the actual damage. First damage reduction from armor is calculated and taken from the incoming damage and then damage reduction from type resists is applied to incoming damage.

After those calculations the target takes the damage and object which stores all the results of what happened in those calculations is sent back to attack skill. Reason for this is that in attack skill we do the actual messaging of what happened. It is also possible for skill to add effect(s) on target after the actual usage of the skill therefore its important to get results back from the target to see if target is for example critically hit, missed, or immune.

Of course all this could have been done in the attack skill in the first place but then there might have been a lot of repeating code and for some reason I like to calculate things where they actually take effect even tho this is a bit more complex way than what it needs to be.

I still probably need to add magic effects in the calculations of damage reduction but that's a future work. I am now trying to finish the attack skill fully before continuing onwards.

Oh ye and on a side note I noticed that the game starts to eat quite a lot of CPU power. If you type directions as fast as you can with 20x monster and 10+ lights it takes about 30-40% cpu of my mac book pro. Now if you use walk command it takes the whole 100%. Im not too worried tho since most of the what needs to be calculated on every turn is in place but still, gotta keep eye on that and do something about it if it becomes a problem.

Thursday, October 6, 2011

Abilities

Hey

As I worked on monster AI I noticed it's quite closely tied to combat and other abilities. That said I figured it's time to start working on abilities( skills and spells ). I changed movement of monsters and player to use skill.

Movement skill is a passive skill which takes different amount of action points to perform. The reason why I changed it was that as a skill I am able to modify it more easily via items, spells and that sort of things. I already made a algorithm which takes few of the stats in account when defining how fast( how many actionpoints movement takes ) creature is. It is not much but creature with 50 agility/constitution vs 10 agility/constitution is more nimble and thus requires less effort in moving around.

Also basic attack( moving towards hostile npc ) is considered as skill. Effect of the attack is defined by what creature is wielding or if it's not wielding anything it checks if it has martial arts trained. Also procent of what the skill is trained up to defines how well creature performs that skill.

I am still in process of adding Effect class into ability class. When that is done Player is able to cast fireblast at enemy and couse aftermath effect which ticks some hps during next few turns. Or spider can use bite skill on player and couse player to get poisoned.


Sunday, October 2, 2011

Monster AI and behavior

Pam!


I have undertaken AI and monster behavior, something I have dreaded for some time now. Mostly 'cos its one of the most complex things to code and it dictates the challenge, fun and feel of the game, at least party of them. Anyway I have decided to go for this FLAG approach on how monsters are set to react to their environment.

First we have FLAG for how monster AI is generally seen. We have PC( pure caster ), NC( non caster ) and  PRM ( preferable caster ). PC generally tries to keep its distance and use spells/ranged attack to attack player. NC tries to get near player and use skills to down player and PRM starts with ranged attacks but at the same times engages player to melee.

Second FLAG is wimpy. It tells monster when its time to wimpy from the battle. This usually takes place on low health to annoy player but I can see some nasty tactics with fast monsters.. Monster with fast legs could try attack player with hit and run tactic when wimpy is set high.

Third FLAG is not yet in effect but I was thinking of something aline of courage. Monsters could decide to attack and retrieve depending how high their courage is. Courage could be raised if monster has friends around or if monster casts some sort of war essemble song. On the otherhand player could have some way of making monsters more afraid of the player thus dropping its morale and making it to flee. Monster parties could take advantage of this..

Thats all I have come up so far but I'll keep posting as I go along..
Got any suggestions, please send a comment =)

Tuesday, September 27, 2011

Dungeon generation

Poks!

As I finally finished GameDirector I was able to continue on more of the content side. This time it was resuming work on dungeon creation and how to actually make player move within those dungeons, aka "stairs".

RoA has basically two types of dungeons; those which are saved and those which are not. Saved ones usually are important places for main storyline, like Astacia. Non-saved dungeons are more or less ways to develop the character and to get to event/storyline places. Hmm.. When said like that it would seem that these non savable dungeons are not important nor interested but that is soooo far from truth. They are as important as the event places since majority of the gameplay happens in these dungeons.

And to point.. I added feature that GameDirector keeps track of entrances of dungeons ( Acts, from earlier post ) and integrates entrances directly into terrain as a feature of terrain, not object. It seems to work perfectly, all data can be saved and retrieved and GameDirector tells the engine what to do next and how.

I added four main dungeon types: scatter, maze, caves and mines. Appearance of those can be further tweak within generation to make them look more random. I am still creating regular dungeon type and single/double room shop generator but those have to wait for now.

Screenshots below are as they are seen without FOV restrictions nor shadowing. When playing the game the dungeons appear, in my opinion, even better but for the sake of showing screenshots I have eliminated FOV and shadow from the game.

So here are the screenshots:

Cave dungeon, Lights are indicators of entrances

Maze dungeon

Still somewhat experimental mine dungeon. I am not 
too happy about it yet but at least it has rooms and 
shafts which connects them :)

Scatter type

Saturday, September 24, 2011

GameDirector

Howdy,

I just finished adding the main features to GameDirector. GameDirector is now in charge of saving and loading the game but also keeping track of what goes on in the different Acts. Acts are the all the different scenarios the player can encounter, basically Act class holds all the information that is needed to reconstruct a scenario player has visited or is going to visit.

When new game is launched all the predefined scenarios ( those that hold important main storyline events, mostly handcrafted map and special NPCs ) are created as Acts and stored into GameDirectors masterlist. Also places which are randomly generated are stored into masterlist but they are not saved by GameDirector unless player is within one at the time of saving.

Now I can finally turn my eye on content side. I  am planing to add one random act, one guild and one more special storyline act before I make my first release. I could release it now as a techdemo but for some reason I don't think that serves really anyone. It is better to release something at least a bit playable.