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.

No comments:

Post a Comment