Wednesday, October 10, 2007

Range attacks in

The range attack is really just an upgrade of the melee attack. Since the "range check" was already in, the only new mechanism needed was something to check line of sight. Again, there was plenty of resources on the web to understand how to accomplish this.

To determine if a target is in the line of sight, I used Bresenham's line algorithm. All I really wanted to achieve is to make sure there is no obstacles between the attacker and its target.

There's many explanation of this algorithm but what was most helpful for me was this article on Code Project. My function receives coordinates of the attacker and the target as well as an array for "collision coordinates" which are coordinates of props with an elevation higher than 0 (characters are always on elevation 0 while buildings, trees and such have an elevation of 1.). So instead of drawing a pixel, there is a check against the array (which is in fact a generic dictionary). If the current calculated coordinate is found in the array, the function simply returns false, meaning you "can't see" your target. The checks are made at the same time as the line is "drawn" so it doesn't have to calculate it all if a collision is found before it reach the target.


To test this I only needed to create a new prop type (crossbow) part of the range weapon family and create a skill called "Basic range attack" part of the family "Range attack". Just like melee attack, when the skill is used, we make sure the weapon type currently equipped match the skill type. Everything else is just the same code used for melee attack.


This took about 3 hours to code and get it running which is great. Being able to "finish" a system in little time really does help for motivation.

The more it goes, the more I only see some tweaking tasks on my to-do list which mean that after I'm done with the crafting mechanic, I'll probably start to work on the interface. We're getting there and I can't wait to invite some people to help me test this.

Read More......

Monday, September 3, 2007

Demo 2 - Combat, improved prototype interface

I finally decided to put some more time on the interface. Even if it's just a prototype and that I will probably throw away a lot of that code, it just make things a lot easier to explain and more enjoyable.

I used graphics from Lost Garden here. Really nice set that gives a sense of life to these lines of code I'm writing. And since I decided to put an online diary of my project, I figured that putting up something decent is still the best way to show that I'm not just throwing ideas on the web. Ideas are cheap and many people have good ideas.

It's still using only Javascript and animated GIF. I'm using Script.aculo.us for the movement animation. As a reminder, the server-side is ASP.NET web services sending JSON data to the client.

About the demo, I'm showing in this one the combat system. It's quite basic in fact: Target something, use a skill, the server check if the target is compatible with the skill used and a result is produced. The distance between the target and the PC is also checked to make sure the PC is within range of using the skill (different skills can have different range). The same system will be used for any skill (like lockpicking a door for example).

In this demo, Dak (PC) is attacking a NPC. The NPC is currently not replying to attacks but I could have done the same demo with Dak attacking another PC. Some kind of basic intelligence for NPC is something I'm planning but there's still more work to do before that.

There's currently 2 skills implemented: Punch and Basic Weapon Melee Attack. With those 2 skills, I added the system allowing a PC to equip a prop. The prop can be a weapon or anything else allowed to be equipped at the desired slot. There's currently only one slot, the one for the prop the PC have in his hands. More can be easily added. The interface to equip the PC is yet to come.

By default, Dak have no weapon equipped. He's allowed to only use the Punch skill. Once he picks his sword, he's not able to use it anymore but now can use the Basic Weapon Melee Attack.

The next thing I will be working on will be to make sure I can build the inside of a building. The tavern currently existing will be used for this. Currently, the inside of the tavern just look like any other zone with props in it. I'll have to make sure I can put walls in there to have something that looks like this.

After this, well, I'll see. I'm trying to cover only the most familiar systems we see in games while keeping them basic for now (next milestones will be PC to PC trading, basic guild system and some kind of interaction with NPCs). My goal is to have something opening me enough opportunities without going too far in each systems. I'm only building a framework for now so I need to focus on it without falling into systems specific to a game.

Here's the link to the demo : Demo 2

Hope you'll enjoy this new demo. As always, comments are welcome!

Read More......